./sqliteodbc-0.992/0040755000076400001440000000000012126210177012532 5ustar chwusers./sqliteodbc-0.992/README0100644000076400001440000002564612126210067013422 0ustar chwusersSQLite ODBC Driver ------------------ This is an open source ODBC driver for the wonderful SQLite 2.8.* and SQLite 3.* Database Engine/Library. The driver is usable but may contain bugs. Use it on your own risk. The current source can be downloaded from http://www.ch-werner.de/sqliteodbc/sqliteodbc-*.tar.gz WIN32 binaries (the ODBC driver DLL, install/uninstall programs) are in http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe The binaries were made with SQLite 2.8.17, SQLite 3.7.16.1, MingW cross compiler and tested on Windows NT 4.0 with the query tool of MS Excel 97, with StarOffice 5.2 and OpenOffice 1.1 and 2.x. Execute the sqliteodbc.exe NSIS installer to unpack the necessary files. This installs the SQLite ODBC driver and creates a System DSN. To remove the driver use the start menu entries or the UNINST.EXE program. To create a SQLite data source use the ODBC control panel applet and provide the name of the SQLite database file to be worked on as an absolute pathname including the drive letter, eg as "C:\TEMP\SQLite.DB". The busy (or lock) timeout for the database can be specified in the respective field. If empty a default value of 100000 milliseconds is used. The Win64 installer (sqliteodbc_w64.exe) was made with SQLite 3.7.16.1, MingW cross compiler and only rudimentary tested on Windows Vista 64. Other tests were made on Linux with the "isql" command line tool and the "DataManager" GUI tool of unixODBC 2.1.0. Since October 14th, 2001, the driver supports the data types SQL_INTEGER, SQL_TINYINT, SQL_SMALLINT, SQL_FLOAT, SQL_DOUBLE, SQL_DATE, SQL_TIME, SQL_TIMESTAMP, and SQL_VARCHAR. Since May 25th, 2002, SQL_LONGVARCHAR is available but rather experimental. That type is used for SQLite schema containing text or varchar with a size specifier larger than 255. The data type mapping obtains per-column meta information from the "PRAGMA table_info(...)" SQLite statement. If SELECTs are used which contain columns for which the table qualifier cannot be determined, no meta information for data type mapping is available and therefore the database source data type will be SQL_VARCHAR or SQL_LONGVARCHAR which usually maps to SQL_C_CHAR. Restrictions of data type mapping: - Integer and floating point columns in the database are reported as NULLs when no digit seen in the column, otherwise all digits up to end of string or non-digit are interpreted as the value, i.e. '10blurk' is ten, '0blurk' is zero, but 'blurk' is NULL. - Format for SQL_DATE is YYYY-MM-DD or YYYYMMDD - Format for SQL_TIME is hh:mm:ss or hhmmss - Format for SQL_TIMESTAMP is YYYYMMDDhhmmss[fraction] or YYYY-MM-DD hh:mm:ss[.fraction] or hh:mm:ss[.fraction] YYYY-MM-DD The fractional part is expressed as 1E-09 seconds - The driver puts the ODBC string representations for date/time, (eg for "{ts '2001-10-10 12:58:00'}" the substring within the single quotes) directly into the SQLite column Since November 17th, 2001, configure/libtool is used for the Un*x version which should automatically find the SQLite and unixODBC (or iODBC) header files and libraries. Do the usual $ ./configure && make followed by # make install in order to get /usr/local/lib/libsqliteodbc.so. Of course, you should have installed the unixODBC (or iODBC) development RPMs since the ODBC header files are required for the build of the SQLite ODBC driver. Since May 15th, 2003, (version 0.51), there are two variants of the SQLite 2.x driver for Win32 platforms: the first (sqliteodbc.dll) linked against ISO8859-1 SQLite library exporting ODBC/SQL ANSI functions, and the second (sqliteodbcu.dll) linked against UTF-8 SQLite library exporting ODBC/SQL UNICODE functions. The UNICODE version is experimental and allows to turn off wide character SQL data types by its configuration dialog (checkmark labelled "No WCHAR"). It is known to work on Win32. It may work on UN*X too using newer version of unixODBC. To setup a SQLite data source using unixODBC (www.unixodbc.org): 1. Add the driver to /etc/odbcinst.ini: [SQLite] Description=SQLite ODBC Driver Driver=/usr/local/lib/libsqliteodbc.so Setup=/usr/local/lib/libsqliteodbc.so Threading=2 2. Add a DSN to your private ~/.odbc.ini: [mysqlitedb] Description=My SQLite test database Driver=SQLite Database=/home/johndoe/databases/mytest.db # optional lock timeout in milliseconds Timeout=2000 For iODBC (www.iodbc.org, only versions 3.0.[56] tested) do the following steps: 1. Add the driver to /etc/odbcinst.ini: [ODBC Drivers] ... SQLite=Installed ... [SQLite] Driver=/usr/local/lib/libsqliteodbc.so 2. Add a DSN to your private ~/.odbc.ini: [ODBC Data Sources] ... mysqlitedb=SQLite ... [mysqlitedb] Driver=/usr/local/lib/libsqliteodbc.so Description=My SQLite test database Database=/home/johndoe/databases/mytest.db # optional lock timeout in milliseconds Timeout=2000 Python sample usage with eGenix mx-Extension (see http://www.lemburg.com/files/python/mxODBC.html) $ python >>> import mx.ODBC.unixODBC >>> dbc=mx.ODBC.unixODBC.connect("mysqlitedb") >>> cur=dbc.cursor() >>> cur.execute("create table foo (id int, name string)") 1 >>> cur.execute("insert into foo values(1, 'Me')") 1 >>> cur.execute("insert into foo values(2, 'You')") 1 >>> dbc.commit() >>> cur.execute("select * from foo") >>> print cur.fetchall() [(1, 'Me'), (2, 'You')] >>> print cur.fetchall() [] >>> cur.execute("drop table foo") 1 >>> dbc.commit() Build instructions for MS Visual C++ 6.0: ... for SQLite 2.x.x 1. Extract the source tarball sqliteodbc.tar.gz 2. Extract the official SQLite 2.x.x sources in the sqliteodbc directory which resulted from step 1. Optionally, apply the sqlite-locale-patch-28* which matches your SQLite version 3. Setup your MSVC++ environment, ie PATH/INCLUDE/LIB, then open a command window, cd to the sqliteodbc directory and enter: nmake -f sqliteodbc.mak This compiles the SQLite sources first, creates a link library of the necessary object files, then compiles and links the ODBC driver and the (un)install program. 4. If you'd like to create the UNICODE version of the driver, enter: nmake -f sqliteodbc.mak clean nmake -f sqliteodbc.mak ENCODING=UTF8 ... for SQLite 3.x.x 1. Extract the source tarball sqliteodbc.tar.gz 2. Extract the amalgamation SQLite 3.x.x. sources in the sqliteodbc directory which resulted from step 1. 3. Setup your MSVC++ environment, ie PATH/INCLUDE/LIB, then open a command window, cd to the sqliteodbc directory and enter: nmake -f sqlite3odbc.mak This compiles the amalgamation SQLite3 source and the ODBC driver first, then and links the ODBC driver and the (un)install program. Names of Win32 Driver DLLs: sqliteodbc.dll Driver with ISO8859-1 SQLite2 engine sqliteodbcu.dll Driver with UTF-8/UNICODE SQLite2 engine sqlite3odbc.dll Driver with SQLite3 engine Build instructions for MingW cross compiler for Win32 targets: A script named mingw-cross-build.sh is provided which contains all necessary information. It downloads the required SQLite source tarballs and builds SQLite and the ODBC drivers. The final step is creating an NSIS installer. Build instructions for MingW cross compiler for Win64 targets: A script named mingw64-cross-build.sh is provided which contains all necessary information. It downloads the required SQLite source tarballs and builds SQLite 3 and the ODBC driver. The final step is creating an NSIS installer. Win32 install/remove/shell by RUNDLL32 Each driver DLL provides entry points for ODBC driver installation and removal which can be invoked from RUNDLL32.EXE, eg ### install sqliteodbc.dll C:\> rundll32 [path]sqliteodbc.dll,install [quiet] ### remove sqlite3odbc.dll C:\> rundll32 [path]sqlite3odbc.dll,uninstall [quiet] If [path] is not provided newer Windows OSes tend to favor the sqlite*odbc*dll in system directories over the current directory, thus better provide an absolute path to the DLL of interest. If the word "quiet" appears anywhere after the DLL/function name, no info message boxes pop up (but errors are shown). An (interactive or batch) SQLite shell can be invoked, too, eg ### run SQLite shell on database C:\bla\my.db C:\> rundll32 [path]sqliteodbc.dll,shell C:\bla\my.db ... ### batch run with given SQL C:\> rundll32 [path]sqliteodbc.dll,shell -batch C:\bla\my.db "select * from table" NUL: >out.txt Win64 notes On Win64 (64 bit versions of Vista, Windows 7) both 32 bit and 64 bit drivers can be installed in parallel. The 32 bit drivers are required when using 32 bit applications. In order to manage 32 bit data sources, the 32 bit ODBC admin tool C:\Windows\SysWOW64\odbcad32.exe must be used. DSN-less connection to the driver Using the SQLDriverConnect() API it should be possible to connect to a SQLite database with these strings (Win32 and UN*X) DSN=SQLite Datasource;Database=full-path-to-db;... DSN=SQLite3 Datasource;Database=full-path-to-db;... alternatively Win32: Driver=SQLite ODBC Driver;Database=full-path-to-db;... Driver=SQLite3 ODBC Driver;Database=full-path-to-db;... UN*X (Linux RPM): Driver=SQLITE;Database=full-path-to-db;... Driver=SQLITE3;Database=full-path-to-db;... Build Instructions for Alpha/Tru64 (OSF1 V5.1) and HP/UX (B.11.23 U ia64) Nikola Radovanovic had success with these commands to build all required components: sqlite (3.6.7): ./configure --prefix=$HOME/development --disable-tcl \ CC='cc -pthread' CFLAGS='-DSQLITE_ENABLE_COLUMN_METADATA=1' gmake && gmake install unixODBC (2.2.12): ./configure --prefix=${HOME}/development --disable-gui \ --without-x --enable-iconv=no gmake && gmake install sqliteodbc (>0.79): ./configure --with-sqlite3=${HOME}/development \ --with-odbc=${HOME}/development --prefix=${HOME}/development \ --enable-winterface=no OSF1: gmake && gmake install HP/UX: gmake CFLAGS="+DD64" && gmake install Build Instructions for RPM based systems rpmbuild -tb sqliteodbc-*.tar.gz Build Instructions for Debian based systems tar xzf sqliteodbc-*.tar.gz cd sqliteodbc-* ./configure && make deb Special build to use System.Data.SQLite on Win32/Win64 A variant of the SQLite3 ODBC driver can be build which uses internal dynamic linking to System.Data.SQLite.dll or sqlite3.dll. This feature is turned on when running the mingw*-cross-build.sh scripts with SQLITE_DLLS=2. TODO: - improve documentation 2013-04-01 Christian Werner mailto:chw@ch-werner.de ./sqliteodbc-0.992/VERSION0100644000076400001440000000000612125472735013604 0ustar chwusers0.992 ./sqliteodbc-0.992/ChangeLog0100644000076400001440000006250712126210076014311 0ustar chwusersSQLite ODBC Driver ------------------ Mon Apr 01 2013 version 0.992 released * update to SQLite 3.7.16.1 * enhancements in XPath virtual table module Wed Mar 20 2013 version 0.991 released * update to SQLite 3.7.16 * added experimental libxml2 XPath virtual table module * added Michael Brey's configure fixes * added Zac Vawter's patch for Win32 ExpandEnviromentStrings() on database file names * fixes for Windows 8 64bit (SetWindowLongPtr()) * added experimental SQLite4 driver * fixes in impexp extension module * added manifests to adddsn.exe/inst.exe Fri Dec 14 2012 version 0.99 released * update to SQLite 3.7.15 * added read-only support for embedded SQLite3 databases in zipfile extension, and on Linux r/w support using mremap() system call * fixed missing fclose() in blob_export SQLite function * added proper handling for SQL_DIAG_CURSOR_ROW_COUNT and SQL_DIAG_ROW_COUNT in SQLGetDiagField() * fixed return code for CREATE/DROP stmts in SQLPrepare() and SQLExecDirect() thanks Peter Harvey for reporting * fixed missing SQL_DIAG_DYNAMIC_FUNCTION case in SQLGetDiagField(), thans Peter Harvey for reporting * SQLGetData fixes for JDK1.7 on x86_64 * added UN*X build of ZIP read-only extension module Sat Oct 06 2012 version 0.98 released * update to SQLite 3.7.14.1 * fixes in floating point retrieval for MSVC, thanks Ben van der Merwe for reporting and test * added ZIP read-only extension module (zipfile) * fixes in CSV table extension module * fixes in handling default DSNs for Win32, thanks Zac Vawter for patch Thu Sep 06 2012 version 0.97 released * update to SQLite 3.7.14 * added CSV table extension module (csvtable) * added handling of SQL_DATA_AT_EXEC for parameter binding * increased file name buffers for Win32 * length fixes in Win32 version of SQLDriverConnectW() Sun Jun 24 2012 version 0.96 released * update to SQLite 3.7.13 * allow "PRAGMA" SQL command to return result set * fixed UCS-2 surrogate sequences and UTF-8 translation, thanks KamLeong Lai for fix and testing Sat May 19 2012 version 0.95 released * update to SQLite 3.7.12 * fixed compiler warnings * now build SQLite 2 driver for Win64, too Wed Jan 25 2012 version 0.94 released * update to SQLite 3.7.10 * use new MinGW cross compiler for Win32/Win64 binaries * fixed strtol issues regarding timestamp fractional parts * filter out ODBC escape sequences {oj ...} etc. Tue Nov 15 2011 version 0.93 released * update to SQLite 3.7.9 * fixes regarding SQLULEN in Win64 * added infrastructure for building with SEE * added compile option in SQLite3 driver to perform dynamic linking to SQLite engine internally in order to use System.data.SQLite (EXPERIMENTAL) * SQL_ATTR_METADATA_ID partial support (stmt/conn level) * reverted to SQLSetPos() fix of 0.91 * SQL_ATTR_CURRENT_CATALOG fix, thanks Stanislav Povolotsky Wed Sep 21 2011 version 0.92 released * update to SQLite 3.7.8 * another SQLSetPos() fix * added "Always BIGINT" DSN option * bug fixes in blobtoxy extension module * segfault in SQLite 2 driver fixed, thanks Dave Peticolas Thu Jul 07 2011 version 0.91 released * update to SQLite 3.7.7.1 * updated blobtoxy module interface (xRename was missing) * support URI names in SQLite 3 driver when available * SQLite 3 driver now uses SQLite memory management routines * fixed BIGINT signed/unsigned flag Thu Jun 09 2011 version 0.90 released * update to SQLite 3.7.6.3 * added packaging infrastructure for Debian * update sqlite+tcc module to TCC 0.9.25 * added blob_import/blob_export functions to SQLite 3 driver * fixes in SQLSetPos() * made SQLEndTran() logic simpler, no more automatic rollback * reviewed Win32 installer, SQLite 2 now an optional component Fri Mar 25 2011 version 0.89 released * update to SQLite 3.7.5 * fixes regarding parameter binding (conversions) * added JSON output to impexp extension module * improved Win32 cross build script Thu Dec 30 2010 version 0.88 released * update to SQLite 3.7.4 * added logic to parse date/timestamps in MM/DD/YYYY format * included Matthew Kirkwood's patch for handling SQL_ATTR_PARAMS_PROCESSED_PTR * on Windows use CP_OEMCP transcoding for SQL_C_CHAR data (DSN option, default is on) * further fixes in parameter binding (NULL pointer handling) Thu Sep 02 2010 version 0.87 released * update to SQLite 3.7.2 * various fixes in parameter set handling * again fixes in SQL_TIMESTAMP handling * fixes in buffer length handling in SQLBindParameter() * basic support for SQLTablePrivileges() * support SQL_C_WCHAR for non-wide drivers (POSIX platforms) * use sqlite3_profile() for tracing if available * more fixes when calling internal variadic functions Wed May 26 2010 version 0.86 released * update to SQLite 3.6.23.1 * fixes in handling SQL_TIMESTAMP data regarding fractional part * fixes in SQLForeignKeys() and SQLGetTypeInfo() as suggested by Farid Zidan * SQLGetData() now returns real length instead of SQL_NO_TOTAL when the buffer was too small * added sqlite3_mod_extfunc.dll from www.sqlite.org/contrib * fixed UTF8/UNICODE en/decoding of character range 0x80..0xff * fixed SQLSetConnectAttr(..SQL_AUTOCOMMIT..) handling as suggested by Simon Schubert Tue Jan 12 2010 version 0.85 released * update to SQLite 3.6.22 * added JournalMode DSN option * again fixes in SQLPrimaryKeys() * allow zero length parameter in SQLSetConnectAttr(..SQL_AUTO_COMMIT..) Wed Dec 02 2009 version 0.84 released * update to SQLite 3.6.20 * SQLStatistics() now reports INTEGER PRIMARY KEY as first index * SQL_ATTR_MAX_ROWS for SQLite3 driver * fixed memory leaks in SQLPrimaryKeys() * try to detect last argument of SQLSetStmtOption() needed for newer unixODBC versions Tue May 26 2009 version 0.83 released * update to SQLite 3.6.14.2 * fixed UNICODE string length issues in SQLGetInfoW() et.al. Mon May 11 2009 version 0.82 released * update to SQLite 3.6.14 * in driver connect dialog, disable DSN input field when driver name property is set on begin of dialog * initial Win64 NSIS installer of SQLite3 driver * Win64 version of SQLite3 driver can now be made with MingW-64 cross compiler * eliminated warnings for Win64 build Tue Apr 14 2009 version 0.81 released * update to SQLite 3.6.13 * use sqlite3_table_column_metadata() when available to optimize out "PRAGMA table_info()" * configure now prefers the amalgamation SQLite3 source if it finds sqlite3.c/sqlite3.h using the --with-sqlite3 switch * various hacks to make MS Excel/Query happy * various fixes and enhancements in impexp.c * keep sqlite3_stmt pointers as long as possible between SQLPrepare() and SQLExecute() in order to minimize SQLite API calls * provide current date when retrieving TIME rows as TIMESTAMP * now use amalgamation source sqlite3.c when building SQLite3 drivers * partial implementation of SQLSetPos(), fixes in length handling for deferred parameters, and row-wise parameter array binding to make Database Template Library (DTL) happy * 64 Bit fixes for getrowdata() thanks Nikolas Taylor for fix Tue Jan 27 2009 version 0.80 released * update to SQLite 3.6.10 * Tru64 and HP/UX 64 bit fixes and build notes in README thanks to Nikola Radovanovic * length/indicator fixes for parameter arrays * getrowdata fixes for length/indicator and truncation * added Win32 build option to use sqlite*.dll instead of static linking * initial Win64 support, thanks Nikolas Taylor for help * fixed x86_64 problems in SQLite2 driver * provide ODBC2/ODBC3 column names for metadata w.r.t. SQL_HENV * provide proper SQL_DESC_LENGTH for SQL_BIT * fixes in SQLBindCol regarding SQL_BIND_BY_COLUMN * made SQL_DESC_OCTET_LENGTH/SQL_DESC_TYPE_NAME more consistent w.r.t. wide-char types * fix in iODBC include path in configure.in, thanks Ingo Bormuth for patch * again fixes in SQLGetData for SQL_NO_DATA paths Mon Sep 29 2008 version 0.79 released * update to SQLite 3.6.3 * fixes in SQLGetData for zero-length SQL_C_CHAR and SQL_C_BINARY * fixed off-by-one counting problem for SQL_ATTR_ROW_NUMBER and SQL_ROW_NUMBER, thanks Christian Mueller for initial fix Sun Aug 24 2008 version 0.78 released * update to SQLite 3.6.1 * relaxed fixupsql() parsing to be able to support "CREATE TRIGGER ..." SQL statements in SQLPrepare() et.al. * added XML output format to impexp.c * provide SQLAllocHandle/SQLFreeHandle for iODBC, too, thanks Nick Davis for patch * double free fix in SQLPrimaryKeys(), thanks Ingo Bormuth for reporting * increased some PRECISION fields in SQLGetTypeInfo() * fix in SQLSetConnect(Attr|Option)(..SQL_AUTOCOMMIT..) when a transaction is in progress and autocommit is turned on again, thanks Sam Kanai for reporting Sun Jan 06 2008 version 0.77 released * update to SQLite 3.5.4 * fixed length/offset issues in SQLGetData() when reading data in multiple chunks, thanks Sam Kanai for reporting * fix in parameter binding regarding SQL_C_WCHAR/SQL_NTS buffers, thanks Sam Kanai for reporting * fix regarding SQL_RESET_PARAMS and unbound parameter semantic, thanks Sam Kanai for reporting and providing initial fix * fixes in Win32 rundll32 install/uninstall handlers * more 64bit fixes * fixed wrong typeinfo for time/timestamp * now use sqlite3_bind_*() functions for SQLite3 driver's parameter passing Thu Oct 11 2007 version 0.76 released * update to SQLite 3.5.1 * partly reverted SQLPrimaryKeys() change from version 0.73: report primary keys from PRAGMA table_info or if none found fall back to "*autoindex*" PKs from PRAGMA index_list * minor tweaks in Makefile.in regarding libtool mode parameter and SQLite3 install targets * added handling for SQL_DESC_SCHEMA_NAME in SQLColAttribute() * added handling for SQL_ATTR_CURSOR_SENSITIVITY in SQLSetStmtAttr() * improved SQLTables()/SQLColumns() regarding pattern search * use *printf(3) format %Q instead of '%q' in SQLite 3 driver * if available use newer SQLite3 APIs (sqlite3_prepare_v2() etc) Sat Aug 04 2007 version 0.75 released * update to SQLite 3.4.1 * hack for MS Access' wrong usage of SQLStatistics (reserved error -7748) * minor code cleanup * fixed bug in SQLite2 driver SQLColumns() * reworked start transaction logic w.r.t. meta data functions like SQLTables() * added some additional logic to SQLCancel() and SQLite busy handlers Mon Apr 02 2007 version 0.74 released * SQLColAttribute(s)(): provide proper info for SQL_DESC_NULLABLE/SQL_COLUMN_NULLABLE * SQLPrimaryKeys(): report only real primary keys * fixed SQL_COLUMN_PRECISION/SQL_DESC_PRECISION for integer/double/date/time/timestamp columns * SQLStatistics(): report INTEGER PRIMARY KEY column as index when no other indices available * fixed SQL_COLUMN_TYPE_NAME/SQL_DESC_TYPE_NAME return, should be "VARCHAR" instead of "VARCHAR(100)" * fixed wrong pointer increments for DSN parsing on Win32 * minor fixes in blobtoxy extension module Sun Feb 18 2007 version 0.73 released * update to SQLite 3.3.13 * SQLGetInfo(SQL_OWNER_TERM) now is empty string * fixed bug in Win32 version concerning SQLDriverConnect() * added -L/-l/-I/-i switches to sqlite+tcc.c Sat Feb 10 2007 version 0.72 released * update to SQLite 3.3.12 * added case for SQL_DESC_NUM_PREC_RADIX in SQLColAttribute[s] * Win32 MinGW build: turn on SQLITE_SOUNDEX * UN*X: try libodbcinst.so.1/libiodbcinst.so.2 before libodbcinst.so/libiodbcinst.so for SQLGetPrivateProfileString(), the latter are normally only in development packages * unquote table names for SQLForeignKeys() and pragma foreign_key_list() * added Win32 build of experimental sqlite+tcc module * fixes/additions in configure.in/Makefile.in * minor changes regarding WITHOUT_DRIVERMGR compile-time switch * added new compile-time switches WITHOUT_INSTALLER and WITHOUT_SHELL for Win32 * added blobtoxy and impexp loadable modules, Win32 names are sqlite3_mod_blobtoxy.dll and sqlite3_mod_impexp.dll * added DSN option LoadExt for specification of loadable extensions as comma separated list of pathnames * added Win32 build of FTS1/FTS2 to DLLs sqlite3_mod_fts1.dll and sqlite3_mod_fts2.dll Thu Jan 11 2007 version 0.71 released * update to SQLite 3.3.10 * MingW Win32 build: added shell function in order to run driver DLL as SQLite shell from rundll32 * WIN32 thread safety as suggested by Dmitriy Ivanov: serialize most SQL*() APIs using critical section on ENV struct * implemented SQLGetDiagField(W)(), initial code kindly donated by Arnold Schulz * more tweaks regarding Win32 code page vs. UTF-8 * added patches from Debian 0.70 testing * on Win32 don't assume that database, DSN, and driver names are UTF-8 encoded in SQLite3 driver * fixes in corner cases of SQL query substitution with 0 parameters and SQL patterns (%) * added "ShortNames" DSN option in SQLite 3 driver * allow naming a column (no pattern) in SQLColumns() * UN*X standard behaviour now is not to build drivers with wide char interfaces, this must be turned on explicitely by specifying "--enable-winterface" at configure time * now provide SQL*W functions in Win32 SQLite3 driver, quick and dirty ported from sqliteodbc.c, not optimized for SQLite 3.x wide char APIs Sun Aug 20 2006 version 0.70 released * update to SQLite 3.3.7 * fix for SQLBindCol(,,NULL,,) which must unbind column * added missing SQL_CATALOG_NAME/SQL_COLLATION_SEQ in SQLGetInfo() * added SQLiteODBCInstaller for Win32 as contributed by Gunter Hinrichsen * added install/uninstall functions in Win32 versions in order to allow driver install/remove by rundll32 Sun Jul 23 2006 version 0.69 released * added "NoCreat" DSN option in SQLite3 driver to prevent from implicit creation of empty database files * fixed severe bug in conditional compile for (un)defined HAVE_SQLITE3COLUMNTABLENAME, thanks Tim Tassonis for reporting * detect and handle SQLITE_SCHEMA errors from sqlite3_prepare() Fri Jul 07 2006 version 0.68 released * update to SQLite 3.3.6, 2.8.17 * increased default lock timeout to 100000 milliseconds * use sqlite3_column_table_name when available * improved type mapping/type detect for SQLite3 driver, thanks Rainer Keuchel for ideas/initial coding * fixed buggy memcpy() in getrowdata(), thanks Rainer Keuchel * tweaks in SQLTables() * improved .spec file w.r.t. standard RPM/configure places, * UN*X version: try to use dlopen() for SQLGetPrivateProfileString() in order to become agnostic of unixODBC vs iODBC * fixes in SQLite3 driver regarding percent substitution for queries with no parameters (eg strftime SQL function) * fixes w.r.t. SQL_C_DEFAULT type mapping * fixes in SQLParamData()/SQLPutData() again * minor changes in Win32 dialog handling Mon Apr 03 2006 version 0.67 released * reworked blob handling in SQLite 2+3 drivers, thanks Altan Özgür for testing * added NSIS installer script * Win32 version can now be made with MingW cross compiler * eliminated some more warnings in Win32 DSN config * improved SQLite 3 tracing for DSN option "tracefile" * added shell scripts drvdsninst.sh/drvdsnuninst.sh and Makefile targets drvinst/drvuninst * added configure option --enable/disable-winterface to turn on (= enable, default) or off (= disable) SQLite 2.x SQLITE_UTF8 mapping to SQL*W() functions * fixes in accordance with MSDN KB#294169 Unicode length arguments mainly in SQLColAttribute[s]*W() Sat Feb 25 2006 version 0.66 released * update to SQLite 3.3.4 * added DSN option "LongNames" to switch behaviour regarding column name truncation * eliminated warnings when compiled with GCC 4.x * added handling for Unicode 2 word sequences * added alpha SQL_BINARY support for SQLite 3 driver * fixes regarding SQLParamData/SQLPutData for data-at-execution parameters * GCC 4 related fixes regarding signedness warnings * added mkopc3.c utility to create opcode.[ch] files for newer SQLite 3 (> 3.0.8) sources * added SQL_BIT data type handling * added SQL_BIGINT data type handling for SQLite 3 * fixes in fixupsql() * some defines to deal with newer ODBC headers * fixes w.r.t. va_list handling for sqlite_exec_vprintf, sqlite_vmprintf etc. * update to SQLite 2.8.16 * fixes w.r.t. blob handling in SQLite2 driver * added DSN option "NoTXN" to disable BEGIN/COMMIT/ROLLBACK * added SQL_ATTR_NOSCAN handling * added DSN option for PRAGMA synchronous (SQLite3 only) * minor fixes concerning return code of SQLFetch() and friends w.r.t. non-SELECT statements * added SQL_DESC_COUNT handling as requested by Vadim Zeitlin * added OS/2 port in SQLite2 driver contributed by Lorne Sunley * handle MEMO like TEXT in columns * use BEGIN EXCLUSIVE transaction when SQLite >= 3.0.8 * fixed memory leak in vm_step/s3stmt_step Thu Oct 07 2004 version 0.65 released * first (alpha) version of SQLite3 driver for Win32 * fixes in Win32 resources * minor tweaks in SQLGetInfo() * fixes in length return of SQLGetInfoW() concerning UNICODE data * fixed errors in orientation/offset handling of SQLExtendedFetch/ SQLFetchScroll, thanks Lucky Prianata for testing * added handling of SQL_ATTR_ROW_BIND_OFFSET_PTR for statements * added handling of SQL_ATTR_RETRIEVE_DATA for statements (seems to be needed by ADO) Sun Sep 05 2004 version 0.64 released * added row-wise binding for rowsets * fixed off-by-one error for SQL_FETCH_PRIOR * another bug fix in fixupsql() concerning quotes thanks to Justin Foutts * always fallback to _ROWID_ in SQLSpecialColumns(SQL_BEST_ROWID) even for tables w/o index * update to SQLite 2.8.15 * fixes concerning SQL_COLUMN_LABEL in SQLColumnAttribute(s) Thu Jul 08 2004 version 0.63 released * added tracefile DSN option using sqlite_trace() if available * in drvprepare() make SQL check with all parameters set to NULL * only use *step() for select statements w/o parameters (makes option usable on OpenOffice.org on Linux) * added pre-alpha version for SQLite 3.x * added limited support for paramsets/rowset for OTLv4 * added limited support for named parameters (Oracle-style) * fixed problem in SQLBindParameter argument checking * when using gcc do printf-style format checks on setstat/setstatd * added SQLite functions current_(date|time|datetime)_(local|utc) * include SQLite error codes or -1 in native error field in SQLError() and SQLGetDiagRec() * bug fixes in SQLNativeSql() concerning buffer/length semantics, thanks to N Rajesh * corrected problems in fixupdyncols (select on views) and UN*X version of drvdriverconnect * added SQLite functions hextobin/bintohex when sqlite_(encode|decode)_binary API available * introduced blob handling when sqlite_(encode|decode)_binary available (SQLite 2.8.14 made these APIs public) * update to SQLite 2.8.14 * made SQL_COLUMN_LABEL different from SQL_COLUMN_NAME * fix in configure.in concerning SQLITE_INC/LIBDIR macros, thanks to Stefan Radman Sat May 01 2004 version 0.62 released * don't implement some APIs for unixODBC unicode driver version * fixed unicode length semantics in SQLGetInfoW() et.al. * when SQLITE_UTF8 make SQLDriverConnectW() on UN*X, too * added missing SQL_DESC_TYPE_NAME case in SQLColAttribute(), patch provided by Chris Waters Sat Apr 24 2004 version 0.61 released * fixed getrowdata() to support SQLGetData() with NULL ptr and SQLFetch() to retrieve proper data length, thanks to Joel Reed * fall back to integer primary key columns in SQLPrimaryKeys() and SQLStatistics() when no indices on table found * improved auto increment detection Thu Apr 08 2004 version 0.60 released * improved RPM .spec file * added heuristic to detect auto increment columns (not a 100% solution yet) for better OpenOffice.org support, thanks to Yves Chaufour for OOo testing * added property list function for unixODBC setup dialog * another SQLFreeStmt(...SQL_CLOSE) fix to make OOo work * added implemetation of SQLForeignKeys() * removed worker thread support, use sqlite_compile(), sqlite_step(), sqlite_finalize() instead, DSN option to use that feature is "StepAPI" * minimum required SQLite version is now 2.8.0 Sun Mar 21 2004 version 0.56 released * update to SQLite 2.8.13 * fixes in UTF to unicode conversion * fixes in handling of length indicator in SQLBindParameter() * added SQL_{COLUMN,DESC}_{PRECISION,SCALE} to SQLColAttribute() * some unixODBC tweaks related to SQLError()/SQLGetDiagRec() * corrections in SQLError()/SQLGetDiagRec() handling, * fixed bugs in SQLColAttribute() which crashed OpenOffice.org * added SQL_FETCH_RELATIVE support as requested by Jorge Mason * fix in SQLFreeStmt(...SQL_CLOSE): don't unbind bound columns thanks to Martin Saturka Sat Jan 25 2004 version 0.55 released * update to SQLite 2.8.11 * fixes in error messages * fixed SQL_IDENTIFIER_QUOTE_CHAR to be double-quote, thanks to Mourad Ben Cheikh * minor fixes in functions related to SQLColAttribute(s) * started support of bookmarks * added SQL_DYNAMIC_CURSOR_ATTRIBUTES1 in drvgetinfo(), thanks to Jeff Robbins * changed "numeric" in mapsqltype() to return SQL_DOUBLE, thanks to Cristian Guissani * added add[sys]dsn/rem[sys]dsn utility programs for Win32 as requested by Tom Shafer * fix in ParseAttributes() for proper DSN configuration * don't automatically rollback in drvexecute() * bug fix in UTF8 version for deferred bound parameters thanks to Kimmo Hamalainen Sun Jul 27 2003 version 0.54 released * update to SQLite 2.8.5 * minor fixes in SQLGetDiagRec() * when ODBC V3 turned on report proper error codes (eg HY000) * added partial support of SQL_ATTR_ROW_BIND_TYPE Fri Jul 11 2003 version 0.53 released * update to SQLite 2.8.4 * added missing handling of ODBC V3 data type codes SQL_C_DATE, SQL_C_TIME, SQL_C_TIMESTAMP in some functions. Thanks to Justin at cloudmark dot com Sun Jun 15 2003 version 0.52 released * update to SQLite 2.8.3 * fixed potential crash in dbopen() thanks to Gene Shkolnik * some improvements and hacks for WIN32 ADO * for SQL type "float" report SQL_DOUBLE instead of SQL_FLOAT * WIN32: export more ODBC V2 symbols * fixes in unicode conversions in SQLGetData() and drvbindparam(). Thu May 15 2003 version 0.51 released * added support for SQLITE_UTF8 by SQL*W unicode entries, partially tested on Win32 only! * added ODBC v2/3 handling on SQLAllocHandle etc. * use localeconv() to fixup floating point formatting * eliminated unnecessary odbcver.h and ctl3d.h from *.rc and *.c files, thanks to Roberto Artigas Jr * added ODBC version 3 SQL_TYPE_* features * fixes in configure.in for Solaris, thanks to Gene Shkolnik * fixed bug in drvbindparam() thanks to Alex Clement * switched coroutine handling to use pth_uctx_*() from GNU pth package, configure option --enable-pth Sat Mar 08 2003 version 0.50 released * changed freeresult() behaviour in order to allow SQLBindCol() column bindings before prepare/execute * revision of SQLGetTypeInfo() * minor changes in SQLGetInfo() and SQLGetFunctions() Sat Feb 22 2003 version 0.49 released * update to SQLite 2.8.0 * bug fix in fixupsql() concerning quotes thanks to Alex Clement * bug fix in substparam() for SQL_NTS/SQL_NULL_DATA thanks to Alex Clement * bug fix in drvfetchscroll for wrong column counting for SQL_FETCH_ABSOLUTE, thanks to Gene Shkolnik Thu Jan 02 2003 version 0.48 released * cleanup threading * added mkopc tool for making opcodes.[ch] on Win32 Sat Sep 14 2002 version 0.47 released * fixed NULL pointer derefs in getmd() and mapsqltype() * SQLBindCol() now always binds even if no result available Sat Aug 31 2002 version 0.46 released * experimental: configuration option: use coroutine instead of thread for running select statements * SQLMoreResults() now always returns SQL_NO_DATA * use the new PRAGMA show_datatypes if available * reworked busy handling logic to use sqlite_busy_handler() * now perform sqlite_open() in single function dbopen() * changed all pthread_cond_signal() to pthread_cond_broadcast() Fri Jul 05 2002 version 0.45 released * improved timestamp scanning * return result set with _ROWID_ for SQLSpecialColumns() when no unique column in table * fixes in parameter substitution (SQLSetParam()) * fixed reading data in pieces (SQLGetData()) * added dummy implementations for SQLTablePrivileges(), SQLColumnPrivileges(), SQLProcedures(), SQLForeignKeys(), SQLProcedureColumns() * code cleanup * added support for NULL in parameters using %Q sqlite_..printf() format specifier for SQLite > 2.4.x Sun Jun 16 2002 version 0.44 released * fixed getbool() to return false on empty string * added implementation of SQLParamData(), SQLPutData() * fixed values of NON_UNIQUE field in SQLStatistics(), store empty INDEX_QUALIFIER field in SQLStatistics() * fixes in getrowdata() concerning partial retrieving of result set * when starting an asynchronous query, set number of result rows to -1 * fixes in SQLBindParameters(), for some datatypes the binding was not performed Sun Jun 09 2002 version 0.43 released * replaced all %s in PRAGMAs by '%q' to make SQLPrimaryKeys(), SQLStatistics(), SQLSpecialColumns() work on automatic indexes * added NULLABLE column to result set of SQLSpecialColumns() to support last SQLSpecialColumns() parameter properly * additions in SQLGetInfo() * added implemetation of SQL(Get|Set)ConnectAttr() * improved handling of SQLDriverConnect() for non Win32 OSes * improved handling of arguments in SQLTables() Tue Jun 04 2002 version 0.42 released * now use doxygen for docs * added ChangeLog * added BSD type license ./sqliteodbc-0.992/license.terms0100644000076400001440000000266010145322672015234 0ustar chwusersThis software is copyrighted by Christian Werner and other authors. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ./sqliteodbc-0.992/header.html0100644000076400001440000000040507476331170014655 0ustar chwusers $title ./sqliteodbc-0.992/footer.html0100644000076400001440000000026207476335643014735 0ustar chwusers
Generated on $date by doxygen.
Contact: chw@ch-werner.de
./sqliteodbc-0.992/stylesheet.css0100644000076400001440000000341207476330727015452 0ustar chwusersH1 { text-align: center; } CAPTION { font-weight: bold } A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } A:hover { text-decoration: none; background-color: #f2f2ff } DL.el { margin-left: -1cm } DIV.fragment { width: 100%; border: none; background-color: #eeeeee } DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } TD.md { background-color: #f2f2ff; font-weight: bold; } TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; } TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; } DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold } DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } BODY { background: white } TD.indexkey { background-color: #eeeeff; font-weight: bold; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } TD.indexvalue { background-color: #eeeeff; font-style: italic; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } FONT.keyword { color: #008000 } FONT.keywordtype { color: #604020 } FONT.keywordflow { color: #e08000 } FONT.comment { color: #800000 } FONT.preprocessor { color: #806020 } FONT.stringliteral { color: #002080 } FONT.charliteral { color: #008080 } ./sqliteodbc-0.992/doxygen.conf0100644000076400001440000001003212121325510015040 0ustar chwusers# Doxyfile 1.2.16 PROJECT_NAME = SQLiteODBC PROJECT_NUMBER = OUTPUT_DIRECTORY = . OUTPUT_LANGUAGE = English EXTRACT_ALL = YES EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = INTERNAL_DOCS = YES STRIP_CODE_COMMENTS = YES CASE_SENSE_NAMES = YES SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO VERBATIM_HEADERS = YES SHOW_INCLUDE_FILES = YES JAVADOC_AUTOBRIEF = YES DETAILS_AT_TOP = YES INHERIT_DOCS = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 8 GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES ALIASES = ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = YES QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = INPUT = inst.c adddsn.c sqlite3odbc.h sqlite3odbc.c blobtoxy.c impexp.h impexp.c csvtable.c zipfile.c xpath.c FILE_PATTERNS = RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = . EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_SOURCE_FILES = NO SOURCE_BROWSER = YES INLINE_SOURCES = NO REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = header.html HTML_FOOTER = footer.html HTML_STYLESHEET = stylesheet.css HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO GENERATE_XML = NO GENERATE_AUTOGEN_DEF = NO ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = HAVE_LOCALECONV=1 HAVE_SQLITE3PROFILE=1 EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO CLASS_GRAPH = YES COLLABORATION_GRAPH = YES TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES GRAPHICAL_HIERARCHY = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 GENERATE_LEGEND = YES DOT_CLEANUP = YES SEARCHENGINE = NO CGI_NAME = search.cgi CGI_URL = DOC_URL = DOC_ABSPATH = BIN_ABSPATH = /usr/local/bin/ EXT_DOC_PATHS = ./sqliteodbc-0.992/adddsn.c0100644000076400001440000000550112074001561014126 0ustar chwusers/** * @file adddsn.c * DSN creation utility for Win32. * * $Id: adddsn.c,v 1.8 2013/01/11 12:19:55 chw Exp chw $ * * Copyright (c) 2003-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #ifndef _WIN32 #error "only WIN32 supported" #endif #include #include #include #include #include #include #include #include /** * Handler for ODBC installation error messages. * @param name name of API function for which to show error messages */ static BOOL ProcessErrorMessages(char *name) { WORD err = 1; DWORD code; char errmsg[301]; WORD errlen, errmax = sizeof (errmsg) - 1; int rc; BOOL ret = FALSE; do { errmsg[0] = '\0'; rc = SQLInstallerError(err, &code, errmsg, errmax, &errlen); if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { MessageBox(NULL, errmsg, name, MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); ret = TRUE; } err++; } while (rc != SQL_NO_DATA); return ret; } /** * Main function of DSN utility. * This is the Win32 GUI main entry point. * It (un)installs a DSN. * * Example usage: * * add[sys]dsn "SQLite ODBC Driver" DSN=foobar;Database=C:/FOOBAR * rem[sys]dsn "SQLite ODBC Driver" DSN=foobar */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char tmp[1024], *p, *drv, *cfg, *msg; int i, op; GetModuleFileName(NULL, tmp, sizeof (tmp)); p = tmp; while (*p) { *p = tolower(*p); ++p; } p = strrchr(tmp, '\\'); if (p == NULL) { p = tmp; } op = ODBC_ADD_DSN; msg = "Adding DSN"; if (strstr(p, "rem") != NULL) { msg = "Removing DSN"; op = ODBC_REMOVE_DSN; } if (strstr(p, "sys") != NULL) { if (op == ODBC_REMOVE_DSN) { op = ODBC_REMOVE_SYS_DSN; } else { op = ODBC_ADD_SYS_DSN; } } strncpy(tmp, lpszCmdLine, sizeof (tmp)); /* get driver argument */ i = strspn(tmp, "\""); drv = tmp + i; if (i > 0) { i = strcspn(drv, "\""); drv[i] = '\0'; cfg = drv + i + 1; } else { i = strcspn(drv, " \t"); if (i > 0) { drv[i] = '\0'; cfg = drv + i + 1; } else { cfg = "\0\0"; } } if (strlen(drv) == 0) { MessageBox(NULL, "No driver name given", msg, MB_ICONERROR|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); exit(1); } i = strspn(cfg, " \t;"); cfg += i; i = strlen(cfg); cfg[i + 1] = '\0'; if (i > 0) { p = cfg; do { p = strchr(p, ';'); if (p != NULL) { p[0] = '\0'; p += 1; } } while (p != NULL); } p = cfg; if (SQLConfigDataSource(NULL, (WORD) op, drv, cfg)) { exit(0); } ProcessErrorMessages(msg); exit(1); } ./sqliteodbc-0.992/adddsn.rc0100644000076400001440000000303712064606763014330 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (63) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLiteODBC DSN Manager\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "adddsn\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "adddsn.exe\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqlite.ico" ///////////////////////////////////////////////////////////////////////////// // // Manifest // #ifndef RT_MANIFEST #define RT_MANIFEST 24 #endif #ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #endif CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "adddsn.manifest" ./sqliteodbc-0.992/adddsn.manifest0100644000076400001440000000063712064621500015517 0ustar chwusers ./sqliteodbc-0.992/fixup.c0100644000076400001440000000243710253472103014032 0ustar chwusers/* * Simple string replacement utility * * $Id: fixup.c,v 1.2 2005/06/14 06:07:43 chw Exp chw $ */ #include #include int main(int argc, char **argv) { int i; char line[512]; if (argc < 2 || argc % 2 != 1) { fprintf(stderr, "usage: %s search1 replace1 ..\n", argv[0]); exit(1); } for (i = 1 + 1; i < argc; i += 2) { if (argv[i][0] == '@') { int len, off = 1; FILE *f; if (argv[i][1] == '@') { off++; } f = fopen(argv[i] + off, "r"); if (f == NULL) { fprintf(stderr, "unable to read %s\n", argv[i] + off); exit(1); } line[0] = '\0'; fgets(line, sizeof (line), f); fclose(f); len = strlen(line); if (len) { line[len - 1] = '\0'; } if (off > 1) { int x = 0, y = 0, z = 0; sscanf(line, "%d.%d.%d", &x, &y, &z); sprintf(line, "%d", x * 100000 + y * 1000 + z); } argv[i] = strdup(line); } } while (fgets(line, sizeof (line), stdin) != NULL) { int found = 0; for (i = 1; i < argc; i += 2) { char *p = strstr(line, argv[i]); if (p != NULL) { fwrite(line, p - line, 1, stdout); fputs(argv[i + 1], stdout); p += strlen(argv[i]); fputs(p, stdout); found = 1; break; } } if (!found) { fputs(line, stdout); } } exit(0); } ./sqliteodbc-0.992/mkopc.c0100644000076400001440000000200307601004475014003 0ustar chwusers/* * Make opcodes.[ch] from standard input. */ #include #include int main(int argc, char **argv) { FILE *c_file, *h_file; char line[512]; int count = 0; c_file = fopen("opcodes.c", "w"); h_file = fopen("opcodes.h", "w"); if (c_file == NULL || h_file == NULL) { fprintf(stderr, "unable to open output file(s)\n"); exit(1); } fprintf(c_file, "/* Automatically generated file. Do not edit */\n"); fprintf(c_file, "char *sqliteOpcodeNames[] = { \"???\",\n"); fprintf(h_file, "/* Automatically generated file. Do not edit */\n"); while (fgets(line, sizeof (line), stdin) != NULL) { if (strncmp(line, "case OP_", 7) == 0) { char *p, *q; p = line + 8; q = strchr(p, ':'); if (q == NULL) { continue; } *q = '\0'; fprintf(c_file, " \"%s\",\n", p); fprintf(h_file, "#define %-30s %3d\n", p - 3, ++count); } } fprintf(c_file, "};\n"); fclose(h_file); fclose(c_file); return 0; } ./sqliteodbc-0.992/mkopc3.c0100644000076400001440000001145610377314651014106 0ustar chwusers/* * Make opcodes.[ch] from standard input and parse.h. */ #include #include #include struct tk { struct tk *next, *other; char *name; int val; int nopush; }; static int opsort(const void *a, const void *b) { struct tk *ta = (struct tk *) a; struct tk *tb = (struct tk *) b; return ta->val - tb->val; } static void append(struct tk **head, struct tk *tk) { struct tk *h = *head; tk->next = NULL; if (h != NULL) { while (h->next != NULL) { h = h->next; } h->next = tk; } else { *head = tk; } } static int nopush[10]; int main(int argc, char **argv) { FILE *c_file, *h_file, *p_file, *a_file; char line[512]; char used[1024]; int count = 0, last_val, max_val = -1, nop = 0; struct tk *tk = NULL; struct tk *op = NULL, *opa = NULL; memset(used, 0, sizeof (used)); p_file = fopen("parse.h", "r"); c_file = fopen("opcodes.c", "w"); h_file = fopen("opcodes.h", "w"); if (p_file == NULL) { fprintf(stderr, "unable to open parse.h\n"); exit(1); } if (c_file == NULL || h_file == NULL) { fprintf(stderr, "unable to open output file(s)\n"); exit(1); } while (fgets(line, sizeof (line), p_file) != NULL) { if (strncmp(line, "#define TK_", 11) == 0) { char name[64]; int val; if (sscanf(line, "#define %s%d", name, &val) == 2) { struct tk *tkn = malloc(sizeof (struct tk) + strlen(name) + 1); tkn->next = tk; tkn->other = NULL; tkn->name = (char *) (tkn + 1); tkn->val = val; tkn->nopush = 0; strcpy(tkn->name, name); tk = tkn; if (val > max_val) { max_val = val; } } } } fclose(p_file); a_file = fopen("addopcodes.awk", "r"); if (a_file) { p_file = fopen("parse.h", "a"); while (fgets(line, sizeof (line), a_file) != NULL) { if (strstr(line, "printf") && strstr(line, "#define TK_")) { char *name = NULL, *p; for (p = line, count = 0; p != NULL && count < 3; count++) { p = strchr(p, '"'); if (p) { ++p; } } if (p != NULL) { char *q = strchr(p, '"'); if (q != NULL) { name = p; *q = '\0'; } } if (name != NULL) { struct tk *tkn = malloc(sizeof (struct tk) + strlen(name) + 3 + 1); fprintf(p_file, "#define TK_%-27s %3d\n", name, ++max_val); tkn->next = tk; tkn->other = NULL; tkn->name = (char *) (tkn + 1); tkn->val = max_val; tkn->nopush = 0; strcpy(tkn->name, "TK_"); strcat(tkn->name, name); tk = tkn; } } } fclose(a_file); fclose(p_file); } while (fgets(line, sizeof (line), stdin) != NULL) { if (strncmp(line, "case OP_", 7) == 0) { char *p, *q, *qq; struct tk *opn; p = line + 5; q = strchr(p, ':'); if (q == NULL) { continue; } *q = '\0'; opn = malloc(sizeof (struct tk) + strlen(p) + 1); opn->next = opn->other = NULL; opn->name = (char *) (opn + 1); opn->val = -1; opn->nopush = 0; strcpy(opn->name, p); append(&op, opn); qq = strstr(q + 1, "same as TK_"); if (qq != NULL) { qq = strstr(qq, "TK_"); q = qq + 3; } if (qq != NULL) { struct tk *tkp; for (tkp = tk; tkp != NULL; tkp = tkp->next) { if (memcmp(qq, tkp->name, strlen(tkp->name)) == 0) { opn->other = tkp; opn->val = tkp->val; used[opn->val] = 1; break; } } } qq = strstr(q + 1, "no-push"); if (qq != NULL) { opn->nopush = 1; } } } if (op != NULL) { struct tk *opp; for (opp = op; opp != NULL; opp = opp->next) { if (opp->val < 0) { ++count; while (used[count]) { count++; } opp->val = count; } ++nop; } opa = malloc(sizeof (struct tk) * nop); nop = 0; for (opp = op; opp != NULL; opp = opp->next) { opa[nop++] = *opp; } qsort(opa, nop, sizeof (struct tk), opsort); } fprintf(c_file, "/* Automatically generated file. Do not edit */\n"); fprintf(c_file, "char *sqliteOpcodeNames[] = {\n"); fprintf(h_file, "/* Automatically generated file. Do not edit */\n"); for (count = 0, last_val = -1; count < nop; count++) { while (++last_val < opa[count].val) { fprintf(c_file, " \"???\",\n"); } fprintf(c_file, " \"%s\",\n", opa[count].name + 3); fprintf(h_file, "#define %-30s %3d", opa[count].name, opa[count].val); if (opa[count].other != NULL) { fprintf(h_file, " /* same as %s */", opa[count].other->name); } fprintf(h_file, "\n"); } fprintf(c_file, "};\n"); for (count = 0; count < nop; count++) { if (opa[count].nopush) { int bit = opa[count].val % 16; int off = opa[count].val / 16; nopush[off] |= 1 << bit; } } for (count = 0; count < 10; count++) { fprintf(h_file, "#define NOPUSH_MASK_%d %d\n", count, nopush[count]); } fclose(h_file); fclose(c_file); return 0; } ./sqliteodbc-0.992/sqliteodbc.c0100644000076400001440000140475612113324642015044 0ustar chwusers/** * @file sqliteodbc.c * SQLite ODBC Driver main module. * * $Id: sqliteodbc.c,v 1.205 2013/02/27 06:36:58 chw Exp chw $ * * Copyright (c) 2001-2013 Christian Werner * OS/2 Port Copyright (c) 2004 Lorne R. Sunley * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #include "sqliteodbc.h" #ifdef SQLITE_UTF8 #ifndef WITHOUT_WINTERFACE #define WINTERFACE #define WCHARSUPPORT #endif #endif #ifdef SQLITE_UTF8 #if !defined(_WIN32) && !defined(_WIN64) #if !defined(WCHARSUPPORT) && defined(HAVE_SQLWCHAR) && (HAVE_SQLWCHAR) #define WCHARSUPPORT #endif #endif #endif #if defined(WINTERFACE) #include #endif #if defined(_WIN32) || defined(_WIN64) #include "resource.h" #define ODBC_INI "ODBC.INI" #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO VERSION #endif #else #ifdef __OS2__ #define ODBC_INI "ODBC.INI" #else #define ODBC_INI ".odbc.ini" #endif #endif #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 3))) #define CANT_PASS_VALIST_AS_CHARPTR 1 #endif #ifdef _WIN64 #undef CANT_PASS_VALIST_AS_CHARPTR #define CANT_PASS_VALIST_AS_CHARPTR 1 #endif #ifdef CANT_PASS_VALIST_AS_CHARPTR #define MAX_PARAMS_FOR_VPRINTF 32 #endif #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO "0.0" #endif #ifndef COLATTRIBUTE_LAST_ARG_TYPE #ifdef _WIN64 #define COLATTRIBUTE_LAST_ARG_TYPE SQLLEN * #else #define COLATTRIBUTE_LAST_ARG_TYPE SQLPOINTER #endif #endif #ifndef SETSTMTOPTION_LAST_ARG_TYPE #define SETSTMTOPTION_LAST_ARG_TYPE SQLROWCOUNT #endif #undef min #define min(a, b) ((a) < (b) ? (a) : (b)) #undef max #define max(a, b) ((a) < (b) ? (b) : (a)) #ifndef PTRDIFF_T #define PTRDIFF_T int #endif #define array_size(x) (sizeof (x) / sizeof (x[0])) #define stringify1(s) #s #define stringify(s) stringify1(s) #define verinfo(maj, min, lev) ((maj) << 16 | (min) << 8 | (lev)) /* Column types for static string column descriptions (SQLTables etc.) */ #if defined(WINTERFACE) && !defined(_WIN32) && !defined(_WIN64) #define SCOL_VARCHAR SQL_WVARCHAR #define SCOL_CHAR SQL_WCHAR #else #define SCOL_VARCHAR SQL_VARCHAR #define SCOL_CHAR SQL_CHAR #endif #define ENV_MAGIC 0x53544145 #define DBC_MAGIC 0x53544144 #define DEAD_MAGIC 0xdeadbeef #ifdef MEMORY_DEBUG static void * xmalloc_(int n, char *file, int line) { int nn = n + 4 * sizeof (long); long *p; p = malloc(nn); if (!p) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\tNULL\t%s:%d\n", n, file, line); #endif return NULL; } p[0] = 0xdead1234; nn = nn / sizeof (long) - 1; p[1] = n; p[nn] = 0xdead5678; #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\t%p\t%s:%d\n", n, &p[2], file, line); #endif return (void *) &p[2]; } static void * xrealloc_(void *old, int n, char *file, int line) { int nn = n + 4 * sizeof (long), nnn; long *p, *pp; if (n == 0 || !old) { return xmalloc_(n, file, line); } p = &((long *) old)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", old); abort(); } nnn = p[1] + 4 * sizeof (long); nnn = nnn / sizeof (long) - 1; if (p[nnn] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", old); abort(); } pp = realloc(p, nn); if (!pp) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\tNULL\t%s:%d\n", old, n, file, line); #endif return NULL; } #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\t%p\t%s:%d\n", old, n, &pp[2], file, line); #endif p = pp; p[1] = n; nn = nn / sizeof (long) - 1; p[nn] = 0xdead5678; return (void *) &p[2]; } static void xfree_(void *x, char *file, int line) { long *p; int n; if (!x) { return; } p = &((long *) x)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", x); abort(); } n = p[1] + 4 * sizeof (long); n = n / sizeof (long) - 1; if (p[n] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", x); abort(); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "free\t%p\t\t%s:%d\n", x, file, line); #endif free(p); } static void xfree__(void *x) { xfree_(x, "unknown location", 0); } static char * xstrdup_(const char *str, char *file, int line) { char *p; if (!str) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\tNULL\tNULL\t%s:%d\n", file, line); #endif return NULL; } p = xmalloc_(strlen(str) + 1, file, line); if (p) { strcpy(p, str); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\t%p\t%p\t%s:%d\n", str, p, file, line); #endif return p; } #define xmalloc(x) xmalloc_(x, __FILE__, __LINE__) #define xrealloc(x,y) xrealloc_(x, y, __FILE__, __LINE__) #define xfree(x) xfree_(x, __FILE__, __LINE__) #define xstrdup(x) xstrdup_(x, __FILE__, __LINE__) #else #define xmalloc(x) malloc(x) #define xrealloc(x,y) realloc(x, y) #define xfree(x) free(x) #define xstrdup(x) strdup_(x) #endif #if defined(_WIN32) || defined(_WIN64) #define vsnprintf _vsnprintf #define snprintf _snprintf #define strcasecmp _stricmp #define strncasecmp _strnicmp static HINSTANCE NEAR hModule; /* Saved module handle for resources */ #endif #if defined(_WIN32) || defined(_WIN64) /* * SQLHENV, SQLHDBC, and SQLHSTMT synchronization * is done using a critical section in ENV structure. */ #define HDBC_LOCK(hdbc) \ { \ DBC *d; \ \ if ((hdbc) == SQL_NULL_HDBC) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) (hdbc); \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HDBC_UNLOCK(hdbc) \ if ((hdbc) != SQL_NULL_HDBC) { \ DBC *d; \ \ d = (DBC *) (hdbc); \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #define HSTMT_LOCK(hstmt) \ { \ DBC *d; \ \ if ((hstmt) == SQL_NULL_HSTMT) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HSTMT_UNLOCK(hstmt) \ if ((hstmt) != SQL_NULL_HSTMT) { \ DBC *d; \ \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #else /* * On UN*X assume that we are single-threaded or * the driver manager provides serialization for us. * * In iODBC (3.52.x) serialization can be turned * on using the DSN property "ThreadManager=yes". * * In unixODBC that property is named * "Threading=0-3" and takes one of these values: * * 0 - no protection * 1 - statement level protection * 2 - connection level protection * 3 - environment level protection * * unixODBC 2.2.11 uses environment level protection * by default when it has been built with pthread * support. */ #define HDBC_LOCK(hdbc) #define HDBC_UNLOCK(hdbc) #define HSTMT_LOCK(hdbc) #define HSTMT_UNLOCK(hdbc) #endif /* * tolower() replacement w/o locale */ static const char upper_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char lower_chars[] = "abcdefghijklmnopqrstuvwxyz"; static int TOLOWER(int c) { if (c) { char *p = strchr(upper_chars, c); if (p) { c = lower_chars[p - upper_chars]; } } return c; } /* * isdigit() replacement w/o ctype.h */ static const char digit_chars[] = "0123456789"; #define ISDIGIT(c) \ ((c) && strchr(digit_chars, (c)) != NULL) /* * isspace() replacement w/o ctype.h */ static const char space_chars[] = " \f\n\r\t\v"; #define ISSPACE(c) \ ((c) && strchr(space_chars, (c)) != NULL) /* * Characters in named parameters */ static const char id_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "_0123456789"; #define ISIDCHAR(c) \ ((c) && strchr(id_chars, (c)) != NULL) /* * Forward declarations of static functions. */ static void freedyncols(STMT *s); static void freeresult(STMT *s, int clrcols); static void unbindcols(STMT *s); static SQLRETURN drvexecute(SQLHSTMT stmt, int initial); static SQLRETURN freestmt(HSTMT stmt); static SQLRETURN mkbindcols(STMT *s, int ncols); static SQLRETURN setupparbuf(STMT *s, BINDPARM *p); static SQLRETURN starttran(STMT *s); static SQLRETURN substparam(STMT *s, int pnum, char **outp); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 1 (reserved error -7748) */ static COL *statSpec2P, *statSpec3P; #endif #if (MEMORY_DEBUG < 1) /** * Duplicate string using xmalloc(). * @param str string to be duplicated * @result pointer to new string or NULL */ static char * strdup_(const char *str) { char *p = NULL; if (str) { p = xmalloc(strlen(str) + 1); if (p) { strcpy(p, str); } } return p; } #endif #ifdef WCHARSUPPORT /** * Return length of UNICODE string. * @param str UNICODE string * @result length of string in characters */ static int uc_strlen(SQLWCHAR *str) { int len = 0; if (str) { while (*str) { ++len; ++str; } } return len; } /** * Copy UNICODE string like strncpy(). * @param dest destination area * @param src source area * @param len length of source area in characters * @return pointer to destination area */ static SQLWCHAR * uc_strncpy(SQLWCHAR *dest, SQLWCHAR *src, int len) { int i = 0; while (i < len) { if (!src[i]) { break; } dest[i] = src[i]; ++i; } if (i < len) { dest[i] = 0; } return dest; } /** * Make UNICODE string from UTF8 string into buffer. * @param str UTF8 string to be converted * @param len length in characters of str or -1 * @param uc destination area to receive UNICODE string * @param ucLen byte length of destination area */ static void uc_from_utf_buf(unsigned char *str, int len, SQLWCHAR *uc, int ucLen) { ucLen = ucLen / sizeof (SQLWCHAR); if (!uc || ucLen < 0) { return; } if (len < 0) { len = ucLen * 5; } uc[0] = 0; if (str) { int i = 0; while (i < len && *str && i < ucLen) { unsigned char c = str[0]; if (c < 0x80) { uc[i++] = c; ++str; } else if (c <= 0xc1 || c >= 0xf5) { /* illegal, ignored */ ++str; } else if (c < 0xe0) { if ((str[1] & 0xc0) == 0x80) { unsigned long t = ((c & 0x1f) << 6) | (str[1] & 0x3f); uc[i++] = t; str += 2; } else { uc[i++] = c; ++str; } } else if (c < 0xf0) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80) { unsigned long t = ((c & 0x0f) << 12) | ((str[1] & 0x3f) << 6) | (str[2] & 0x3f); uc[i++] = t; str += 3; } else { uc[i++] = c; ++str; } } else if (c < 0xf8) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80) { unsigned long t = ((c & 0x03) << 18) | ((str[1] & 0x3f) << 12) | ((str[2] & 0x3f) << 6) | (str[3] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 4; } else { uc[i++] = c; ++str; } } else if (c < 0xfc) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80 && (str[4] & 0xc0) == 0x80) { unsigned long t = ((c & 0x01) << 24) | ((str[1] & 0x3f) << 18) | ((str[2] & 0x3f) << 12) | ((str[3] & 0x3f) << 6) | (str[4] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 5; } else { uc[i++] = c; ++str; } } else { /* ignore */ ++str; } } if (i < ucLen) { uc[i] = 0; } } } /** * Make UNICODE string from UTF8 string. * @param str UTF8 string to be converted * @param len length of UTF8 string * @return alloc'ed UNICODE string to be free'd by uc_free() */ static SQLWCHAR * uc_from_utf(unsigned char *str, int len) { SQLWCHAR *uc = NULL; int ucLen; if (str) { if (len == SQL_NTS) { len = strlen((char *) str); } ucLen = sizeof (SQLWCHAR) * (len + 1); uc = xmalloc(ucLen); if (uc) { uc_from_utf_buf(str, len, uc, ucLen); } } return uc; } /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in bytes * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf(SQLWCHAR *str, int len) { int i; char *cp, *ret = NULL; if (!str) { return ret; } if (len == SQL_NTS) { len = uc_strlen(str); } else { len = len / sizeof (SQLWCHAR); } cp = xmalloc(len * 6 + 1); if (!cp) { return ret; } ret = cp; for (i = 0; i < len; i++) { unsigned long c = str[i]; if (sizeof (SQLWCHAR) == 2 * sizeof (char)) { c &= 0xffff; } if (c < 0x80) { *cp++ = c; } else if (c < 0x800) { *cp++ = 0xc0 | ((c >> 6) & 0x1f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x10000) { if (sizeof (SQLWCHAR) == 2 * sizeof (char) && c >= 0xd800 && c <= 0xdbff && i + 1 < len) { unsigned long c2 = str[i + 1] & 0xffff; if (c2 >= 0xdc00 && c2 <= 0xdfff) { c = (((c & 0x3ff) << 10) | (c2 & 0x3ff)) + 0x10000; *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); ++i; continue; } } *cp++ = 0xe0 | ((c >> 12) & 0x0f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x200000) { *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x4000000) { *cp++ = 0xf8 | ((c >> 24) & 0x03); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x80000000) { *cp++ = 0xfc | ((c >> 31) & 0x01); *cp++ = 0x80 | ((c >> 24) & 0x3f); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } } *cp = '\0'; return ret; } #endif #ifdef WINTERFACE /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in characters * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf_c(SQLWCHAR *str, int len) { if (len != SQL_NTS) { len = len * sizeof (SQLWCHAR); } return uc_to_utf(str, len); } #endif #if defined(WINTERFACE) || defined(WCHARSUPPORT) /** * Free converted UTF8 or UNICODE string. */ static void uc_free(void *str) { if (str) { xfree(str); } } #endif #ifdef USE_DLOPEN_FOR_GPPS #include #define SQLGetPrivateProfileString(A,B,C,D,E,F) drvgpps(d,A,B,C,D,E,F) /* * EXPERIMENTAL: SQLGetPrivateProfileString infrastructure using * dlopen(), in theory this makes the driver independent from the * driver manager, i.e. the same driver binary can run with iODBC * and unixODBC. */ static void drvgetgpps(DBC *d) { void *lib; int (*gpps)(); lib = dlopen("libodbcinst.so.1", RTLD_LAZY); if (!lib) { lib = dlopen("libodbcinst.so", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so.2", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so", RTLD_LAZY); } if (lib) { gpps = (int (*)()) dlsym(lib, "SQLGetPrivateProfileString"); if (!gpps) { dlclose(lib); return; } d->instlib = lib; d->gpps = gpps; } } static void drvrelgpps(DBC *d) { if (d->instlib) { dlclose(d->instlib); d->instlib = 0; } } static int drvgpps(DBC *d, char *sect, char *ent, char *def, char *buf, int bufsiz, char *fname) { if (d->gpps) { return d->gpps(sect, ent, def, buf, bufsiz, fname); } strncpy(buf, def, bufsiz); buf[bufsiz - 1] = '\0'; return 1; } #else #include #define drvgetgpps(d) #define drvrelgpps(d) #endif /** * Set error message and SQL state on DBC * @param d database connection pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstatd(DBC *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstatd(DBC *d, int naterr, char *msg, char *st, ...) { va_list ap; if (!d) { return; } d->naterr = naterr; d->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) d->logmsg, sizeof (d->logmsg), msg, ap); va_end(ap); if (count < 0) { d->logmsg[sizeof (d->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(d->sqlstate, st, 5); d->sqlstate[5] = '\0'; } /** * Set error message and SQL state on statement * @param s statement pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstat(STMT *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstat(STMT *s, int naterr, char *msg, char *st, ...) { va_list ap; if (!s) { return; } s->naterr = naterr; s->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) s->logmsg, sizeof (s->logmsg), msg, ap); va_end(ap); if (count < 0) { s->logmsg[sizeof (s->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(s->sqlstate, st, 5); s->sqlstate[5] = '\0'; } /** * Report IM001 (not implemented) SQL error code for HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvunimpldbc(HDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; setstatd(d, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Report IM001 (not implemented) SQL error code for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN drvunimplstmt(HSTMT stmt) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; setstat(s, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Free memory given pointer to memory pointer. * @param x pointer to pointer to memory to be free'd */ static void freep(void *x) { if (x && ((char **) x)[0]) { xfree(((char **) x)[0]); ((char **) x)[0] = NULL; } } /** * Report S1000 (out of memory) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN nomem(STMT *s) { setstat(s, -1, "out of memory", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Report S1000 (not connected) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN noconn(STMT *s) { setstat(s, -1, "not connected", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal locale neutral strtod function. * @param data pointer to string * @param endp pointer for ending character * @result double value */ #if defined(HAVE_SQLITEATOF) && (HAVE_SQLITEATOF) extern double sqliteAtoF(char *data, char **endp); #define ln_strtod(A,B) sqliteAtoF(A,B) #else #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) static double ln_strtod(const char *data, char **endp) { static struct lconv *lc = 0; char buf[128], *p, *end; double value; if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { strncpy(buf, data, sizeof (buf) - 1); buf[sizeof (buf) - 1] = '\0'; p = strchr(buf, '.'); if (p) { *p = lc->decimal_point[0]; } p = buf; } else { p = (char *) data; } value = strtod(p, &end); end = (char *) data + (end - p); if (endp) { *endp = end; } return value; } #else #define ln_strtod(A,B) strtod(A,B) #endif #endif #if !defined(HAVE_SQLITEMPRINTF) || !(HAVE_SQLITEMPRINTF) /** * Internal locale neutral sprintf("%g") function. * @param buf pointer to string * @param value double value */ static void ln_sprintfg(char *buf, double value) { #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) static struct lconv *lc = 0; char *p; sprintf(buf, "%.16g", value); if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { p = strchr(buf, lc->decimal_point[0]); if (p) { *p = '.'; } } #else sprintf(buf, "%.16g", value); #endif } #endif /** * Strip quotes from quoted string in-place. * @param str string */ static char * unquote(char *str) { if (str) { int len = strlen(str); if (len > 1) { if ((str[0] == '\'' && str[len - 1] == '\'') || (str[0] == '"' && str[len - 1] == '"') || (str[0] == '[' && str[len - 1] == ']')) { str[len - 1] = '\0'; strcpy(str, str + 1); } } } return str; } /** * Unescape search pattern for e.g. table name in * catalog functions. Replacements in string are done in-place. * @param str string * @result number of pattern characters in string or 0 */ static int unescpat(char *str) { char *p, *q; int count = 0; p = str; while ((q = strchr(p, '_')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '%')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '\\')) != NULL) { if (q[1] == '\\' || q[1] == '_' || q[1] == '%') { strcpy(q, q + 1); } p = q + 1; } return count; } /** * SQL LIKE string match with optional backslash escape handling. * @param str string * @param pat pattern * @param esc when true, treat literally "\\" as "\", "\%" as "%", "\_" as "_" * @result true when pattern matched */ static int namematch(char *str, char *pat, int esc) { int cp, ch; while (1) { cp = TOLOWER(*pat); if (cp == '\0') { if (*str != '\0') { goto nomatch; } break; } if (*str == '\0' && cp != '%') { goto nomatch; } if (cp == '%') { while (*pat == '%') { ++pat; } cp = TOLOWER(*pat); if (cp == '\0') { break; } while (1) { if (cp != '_' && cp != '\\') { while (*str) { ch = TOLOWER(*str); if (ch == cp) { break; } ++str; } } if (namematch(str, pat, esc)) { goto match; } if (*str == '\0') { goto nomatch; } ch = TOLOWER(*str); ++str; } } if (cp == '_') { pat++; str++; continue; } if (esc && cp == '\\' && (pat[1] == '\\' || pat[1] == '%' || pat[1] == '_')) { ++pat; cp = TOLOWER(*pat); } ch = TOLOWER(*str++); ++pat; if (ch != cp) { goto nomatch; } } match: return 1; nomatch: return 0; } /** * Busy callback for SQLite. * @param udata user data, pointer to DBC * @param table table name or NULL * @param count count of subsequenct calls * @result true of false */ static int busy_handler(void *udata, const char *table, int count) { DBC *d = (DBC *) udata; long t1; int ret = 0; #if !defined(_WIN32) && !defined(_WIN64) struct timeval tv; #ifdef HAVE_NANOSLEEP struct timespec ts; #endif #endif if (d->busyint) { d->busyint = 0; return ret; } if (d->timeout <= 0) { return ret; } if (count <= 1) { #if defined(_WIN32) || defined(_WIN64) d->t0 = GetTickCount(); #else gettimeofday(&tv, NULL); d->t0 = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif } #if defined(_WIN32) || defined(_WIN64) t1 = GetTickCount(); #else gettimeofday(&tv, NULL); t1 = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif if (t1 - d->t0 > d->timeout) { goto done; } #if defined(_WIN32) || defined(_WIN64) Sleep(10); #else #ifdef HAVE_NANOSLEEP ts.tv_sec = 0; ts.tv_nsec = 10000000; do { ret = nanosleep(&ts, &ts); if (ret < 0 && errno != EINTR) { ret = 0; } } while (ret); #else #ifdef HAVE_USLEEP usleep(10000); #else tv.tv_sec = 0; tv.tv_usec = 10000; select(0, NULL, NULL, NULL, &tv); #endif #endif #endif ret = 1; done: return ret; } #ifdef HAVE_ENCDEC static void hextobin_func(sqlite_func *context, int argc, const char **argv); static void bintohex_func(sqlite_func *context, int argc, const char **argv); #endif static void time_func(sqlite_func *context, int argc, const char **argv); /** * Set SQLite options (PRAGMAs) given SQLite handle. * @param x SQLite database handle * @param d DBC pointer * @result SQLite error code * * "full_column_names" is always turned on to get the table * names in column labels. "count_changes" is always turned * on to get the number of affected rows for INSERTs et.al. * "empty_result_callbacks" is always turned on to get * column labels even when no rows are returned. * Starting from SQLite 2.6.0 data types are reported for * callback functions when the "show_datatypes" pragma is * asserted. */ static int setsqliteopts(sqlite *x, DBC *d) { int count = 0, step = 0, rc; while (step < 4) { if (step < 1) { rc = sqlite_exec(x, "PRAGMA full_column_names = on;", NULL, NULL, NULL); } else if (step < 2) { rc = sqlite_exec(x, "PRAGMA count_changes = on;", NULL, NULL, NULL); } else if (step < 3) { rc = sqlite_exec(x, "PRAGMA empty_result_callbacks = on;", NULL, NULL, NULL); } else { rc = sqlite_exec(x, "PRAGMA show_datatypes = on;", NULL, NULL, NULL); } if (rc != SQLITE_OK) { if (rc != SQLITE_BUSY || !busy_handler((void *) d, NULL, ++count)) { return rc; } continue; } count = 0; ++step; } sqlite_busy_handler(x, busy_handler, (void *) d); #if (HAVE_ENCDEC) { char *fname; fname = "hextobin"; sqlite_create_function(x, fname, 1, hextobin_func, 0); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "bintohex"; sqlite_create_function(x, fname, 1, bintohex_func, 0); sqlite_function_type(x, fname, SQLITE_TEXT); } #endif { char *fname; fname = "current_time_local"; sqlite_create_function(x, fname, 0, time_func, (void *) 0); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_time_utc"; sqlite_create_function(x, fname, 0, time_func, (void *) 1); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_date_local"; sqlite_create_function(x, fname, 0, time_func, (void *) 2); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_date_utc"; sqlite_create_function(x, fname, 0, time_func, (void *) 3); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_datetime_local"; sqlite_create_function(x, fname, 0, time_func, (void *) 4); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_datetime_utc"; sqlite_create_function(x, fname, 0, time_func, (void *) 5); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_timestamp_local"; sqlite_create_function(x, fname, 0, time_func, (void *) 4); sqlite_function_type(x, fname, SQLITE_TEXT); fname = "current_timestamp_utc"; sqlite_create_function(x, fname, 0, time_func, (void *) 5); sqlite_function_type(x, fname, SQLITE_TEXT); } return SQLITE_OK; } /** * Free counted array of char pointers. * @param rowp pointer to char pointer array * * The -1-th element of the array holds the array size. * All non-NULL pointers of the array and then the array * itself are free'd. */ static void freerows(char **rowp) { int size, i; if (!rowp) { return; } --rowp; size = (PTRDIFF_T) rowp[0]; for (i = 1; i <= size; i++) { freep(&rowp[i]); } freep(&rowp); } /** * Map SQL field type from string to ODBC integer type code. * @param typename field type string * @param nosign pointer to indicator for unsigned field or NULL * @param ov3 boolean, true for SQL_OV_ODBC3 * @param nowchar boolean, for WINTERFACE don't use WCHAR * @result SQL data type */ static int mapsqltype(const char *typename, int *nosign, int ov3, int nowchar) { char *p, *q; int testsign = 0, result; #ifdef WINTERFACE result = nowchar ? SQL_VARCHAR : SQL_WVARCHAR; #else result = SQL_VARCHAR; #endif if (!typename) { return result; } q = p = xmalloc(strlen(typename) + 1); if (!p) { return result; } strcpy(p, typename); while (*q) { *q = TOLOWER(*q); ++q; } if (strncmp(p, "inter", 5) == 0) { } else if (strncmp(p, "int", 3) == 0 || strncmp(p, "mediumint", 9) == 0) { testsign = 1; result = SQL_INTEGER; } else if (strncmp(p, "numeric", 7) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "tinyint", 7) == 0) { testsign = 1; result = SQL_TINYINT; } else if (strncmp(p, "smallint", 8) == 0) { testsign = 1; result = SQL_SMALLINT; } else if (strncmp(p, "float", 5) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "double", 6) == 0 || strncmp(p, "real", 4) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "timestamp", 9) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "datetime", 8) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "time", 4) == 0) { #ifdef SQL_TYPE_TIME result = ov3 ? SQL_TYPE_TIME : SQL_TIME; #else result = SQL_TIME; #endif } else if (strncmp(p, "date", 4) == 0) { #ifdef SQL_TYPE_DATE result = ov3 ? SQL_TYPE_DATE : SQL_DATE; #else result = SQL_DATE; #endif #ifdef SQL_LONGVARCHAR } else if (strncmp(p, "text", 4) == 0 || strncmp(p, "memo", 4) == 0 || strncmp(p, "longvarchar", 11) == 0) { #ifdef WINTERFACE result = nowchar ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else result = SQL_LONGVARCHAR; #endif #ifdef WINTERFACE } else if (strncmp(p, "wtext", 5) == 0 || strncmp(p, "wvarchar", 8) == 0 || strncmp(p, "longwvarchar", 12) == 0) { result = SQL_WLONGVARCHAR; #endif #endif #if (HAVE_ENCDEC) } else if (strncmp(p, "binary", 6) == 0 || strncmp(p, "varbinary", 9) == 0 || strncmp(p, "bytea", 5) == 0 || strncmp(p, "blob", 4) == 0 || strncmp(p, "tinyblob", 8) == 0 || strncmp(p, "mediumblob", 10) == 0) { result = SQL_VARBINARY; } else if (strncmp(p, "longbinary", 10) == 0 || strncmp(p, "longvarbinary", 13) == 0 || strncmp(p, "longblob", 8) == 0) { result = SQL_LONGVARBINARY; #endif #ifdef SQL_BIT } else if (strncmp(p, "bool", 4) == 0 || strncmp(p, "bit", 3) == 0) { testsign = 0; result = SQL_BIT; #endif } if (nosign) { if (testsign) { *nosign = strstr(p, "unsigned") != NULL; } else { *nosign = 1; } } xfree(p); return result; } /** * Get maximum display size and number of digits after decimal point * from field type specification. * @param typename field type specification * @param sqltype target SQL data type * @param mp pointer to maximum display size or NULL * @param dp pointer to number of digits after decimal point or NULL */ static void getmd(const char *typename, int sqltype, int *mp, int *dp) { int m = 0, d = 0; switch (sqltype) { case SQL_INTEGER: m = 10; d = 9; break; case SQL_TINYINT: m = 4; d = 3; break; case SQL_SMALLINT: m = 6; d = 5; break; case SQL_FLOAT: m = 25; d = 24; break; case SQL_DOUBLE: m = 54; d = 53; break; case SQL_VARCHAR: m = 255; d = 0; break; #ifdef WINTERFACE #ifdef SQL_WVARCHAR case SQL_WVARCHAR: m = 255; d = 0; break; #endif #endif #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: m = 10; d = 0; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: m = 8; d = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: m = 32; d = 3; break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR : m = 65536; d = 0; break; #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: m = 65536; d = 0; break; #endif #endif #if (HAVE_ENCDEC) case SQL_VARBINARY: m = 255; d = 0; break; case SQL_LONGVARBINARY: m = 65536; d = 0; break; #endif #ifdef SQL_BIT case SQL_BIT: m = 1; d = 1; break; #endif } if (m && typename) { int mm, dd; if (sscanf(typename, "%*[^(](%d)", &mm) == 1) { if (sqltype == SQL_TIMESTAMP) { d = mm; } #ifdef SQL_TYPE_TIMESTAMP if (sqltype == SQL_TYPE_TIMESTAMP) { d = mm; } #endif else { m = d = mm; } } else if (sscanf(typename, "%*[^(](%d,%d)", &mm, &dd) == 2) { m = mm; d = dd; } } if (mp) { *mp = m; } if (dp) { *dp = d; } } /** * Map SQL_C_DEFAULT to proper C type. * @param type input C type * @param stype input SQL type * @param nosign 0=signed, 0>unsigned, 0 0) ? SQL_C_ULONG : SQL_C_LONG; break; case SQL_TINYINT: type = (nosign > 0) ? SQL_C_UTINYINT : SQL_C_TINYINT; break; case SQL_SMALLINT: type = (nosign > 0) ? SQL_C_USHORT : SQL_C_SHORT; break; case SQL_FLOAT: type = SQL_C_FLOAT; break; case SQL_DOUBLE: type = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: type = SQL_C_TIMESTAMP; break; case SQL_TIME: type = SQL_C_TIME; break; case SQL_DATE: type = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: type = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: type = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: type = SQL_C_TYPE_DATE; break; #endif #ifdef WINTERFACE case SQL_WVARCHAR: case SQL_WCHAR: #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: #endif type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; break; #endif #if (HAVE_ENCDEC) case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: type = SQL_C_BINARY; break; #endif #ifdef SQL_BIT case SQL_BIT: type = SQL_C_BIT; break; #endif default: #ifdef WINTERFACE type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; #else type = SQL_C_CHAR; #endif break; } } return type; } /** * Fixup query string with optional parameter markers. * @param sql original query string * @param sqlLen length of query string or SQL_NTS * @param nparam output number of parameters * @param isselect output indicator for SELECT (1) or DDL statement (2) * @param errmsg output error message * @param version SQLite version information * @param namepp pointer to parameter names array * @result newly allocated string containing query string for SQLite or NULL */ static char * fixupsql(char *sql, int sqlLen, int *nparam, int *isselect, char **errmsg, int version, char ***namepp) { char *q = sql, *qz = NULL, *p, *inq = NULL, *out; int np = 0, isddl = -1, size; char **npp = NULL, *ncp = NULL; *errmsg = NULL; if (sqlLen != SQL_NTS) { qz = q = xmalloc(sqlLen + 1); if (!qz) { return NULL; } memcpy(q, sql, sqlLen); q[sqlLen] = '\0'; size = sqlLen * 4; } else { size = strlen(sql) * 4; } size += sizeof (char *) - 1; size &= ~(sizeof (char *) - 1); p = xmalloc(2 * size + size * sizeof (char *) / 2); if (!p) { errout: freep(&qz); return NULL; } memset(p, 0, 2 * size + size * sizeof (char *) / 2); out = p; npp = (char **) (out + size); ncp = (char *) npp + size * sizeof (char *) / 2; while (*q) { switch (*q) { case '\'': case '\"': if (q == inq) { inq = NULL; } else if (!inq) { inq = q + 1; while (*inq) { if (*inq == *q) { if (inq[1] == *q) { inq++; } else { break; } } inq++; } } *p++ = *q; break; case '?': if (inq) { *p++ = *q; } else { *p++ = '%'; *p++ = 'Q'; npp[np] = ncp; *ncp = '\0'; ++ncp; np++; } break; case ':': /* ORACLE-style named parameter */ case '@': /* ADO.NET-style named parameter */ if (inq) { *p++ = *q; } else { int n = -1; do { ++q; ++n; } while (*q && ISIDCHAR(*q)); if (n > 0) { *p++ = '%'; *p++ = 'Q'; npp[np] = ncp; memcpy(ncp, q - n, n); ncp[n] = '\0'; ncp += n + 1; np++; } --q; } break; case ';': if (!inq) { if (isddl < 0) { char *qq = out; while (*qq && ISSPACE(*qq)) { ++qq; } if (*qq && *qq != ';') { int i; static const struct { int len; const char *str; } ddlstr[] = { { 6, "attach" }, { 5, "begin" }, { 6, "commit" }, { 6, "create" }, { 6, "detach" }, { 4, "drop" }, { 3, "end" }, { 8, "rollback" }, { 6, "vacuum" } }; size = strlen(qq); for (i = 0; i < array_size(ddlstr); i++) { if (size >= ddlstr[i].len && strncasecmp(qq, ddlstr[i].str, ddlstr[i].len) == 0) { isddl = 1; break; } } if (isddl != 1) { isddl = 0; } } } if (isddl == 0) { char *qq = q; do { ++qq; } while (*qq && ISSPACE(*qq)); if (*qq && *qq != ';') { freep(&out); *errmsg = "only one SQL statement allowed"; goto errout; } } } *p++ = *q; break; case '%': *p++ = '%'; *p++ = '%'; break; case '{': /* * Deal with escape sequences: * {d 'YYYY-MM-DD'}, {t ...}, {ts ...} * {oj ...}, {fn ...} etc. */ if (!inq) { int ojfn = 0; char *inq2 = NULL, *end = q + 1; if (*end != 'd' && *end != 'D' && *end != 't' && *end != 'T') { ojfn = 1; } while (*end) { if (inq2 && *end == *inq2) { inq2 = NULL; } else if (inq2 == NULL && *end == '}') { break; } else if (inq2 == NULL && (*end == '\'' || *end == '"')) { inq2 = end; } ++end; } if (*end == '}') { char *start = q + 1; char *end2 = end - 1; if (ojfn) { while (start < end) { if (ISSPACE(*start)) { break; } ++start; } while (start < end) { *p++ = *start; ++start; } q = end; break; } else { while (start < end2 && *start != '\'') { ++start; } while (end2 > start && *end2 != '\'') { --end2; } if (*start == '\'' && *end2 == '\'') { while (start <= end2) { *p++ = *start; ++start; } q = end; break; } } } } /* FALL THROUGH */ default: *p++ = *q; } ++q; } freep(&qz); *p = '\0'; if (nparam) { *nparam = np; } if (isselect) { if (isddl > 0) { *isselect = 2; } else { int incom = 0; p = out; while (*p) { switch (*p) { case '-': if (!incom && p[1] == '-') { incom = -1; } break; case '\n': if (incom < 0) { incom = 0; } break; case '/': if (incom > 0 && p[-1] == '*') { incom = 0; p++; continue; } else if (!incom && p[1] == '*') { incom = 1; } break; } if (!incom && !ISSPACE(*p)) { break; } ++p; } size = strlen(p); if (size >= 6 && (strncasecmp(p, "select", 6) == 0 || strncasecmp(p, "pragma", 6) == 0)) { *isselect = 1; } else { *isselect = 0; } } } if (namepp) { *namepp = npp; } return out; } /** * Find column given name in string array. * @param cols string array * @param ncols number of strings * @param name column name * @result >= 0 on success, -1 on error */ static int findcol(char **cols, int ncols, char *name) { int i; if (cols) { for (i = 0; i < ncols; i++) { if (strcmp(cols[i], name) == 0) { return i; } } } return -1; } /** * Fixup column information for a running statement. * @param s statement to get fresh column information * @param sqlite SQLite database handle * @param types column types or NULL * * The column labels get the table names stripped * when there's more than one column and all table * names are identical. * * The "dyncols" field of STMT is filled with column * information obtained by SQLite "PRAGMA table_info" * for each column whose table name is known. If the * types are already present as with SQLite 2.5.7 * this information is used instead. */ static void fixupdyncols(STMT *s, sqlite *sqlite, const char **types) { int i, k, pk, nn, t, r, nrows, ncols; char **rowp, *flagp, flags[128]; if (!s->dyncols) { return; } /* fixup labels */ if (!s->longnames) { if (s->dcols > 1) { char *table = s->dyncols[0].table; for (i = 1; table[0] && i < s->dcols; i++) { if (strcmp(s->dyncols[i].table, table)) { break; } } if (i >= s->dcols) { for (i = 0; i < s->dcols; i++) { s->dyncols[i].label = s->dyncols[i].column; } } } else if (s->dcols == 1) { s->dyncols[0].label = s->dyncols[0].column; } } if (types) { for (i = 0; i < s->dcols; i++) { freep(&s->dyncols[i].typename); s->dyncols[i].typename = xstrdup(types[i] ? types[i] : "text"); s->dyncols[i].type = mapsqltype(types[i], &s->dyncols[i].nosign, *s->ov3, s->nowchar[0] || s->nowchar[1]); getmd(types[i], s->dyncols[i].type, &s->dyncols[i].size, &s->dyncols[i].prec); #ifdef SQL_LONGVARCHAR if (s->dyncols[i].type == SQL_VARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (s->dyncols[i].type == SQL_WVARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_WLONGVARCHAR; } #endif #endif #if (HAVE_ENCDEC) if (s->dyncols[i].type == SQL_VARBINARY && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARBINARY; } #endif } } if (s->dcols > array_size(flags)) { flagp = xmalloc(sizeof (flags[0]) * s->dcols); if (flagp == NULL) { return; } } else { flagp = flags; } memset(flagp, 0, sizeof (flags[0]) * s->dcols); for (i = 0; i < s->dcols; i++) { s->dyncols[i].autoinc = SQL_FALSE; s->dyncols[i].notnull = SQL_NULLABLE; } for (i = 0; i < s->dcols; i++) { int ret, lastpk = -1, autoinccount = 0; if (!s->dyncols[i].table[0]) { continue; } if (flagp[i]) { continue; } ret = sqlite_get_table_printf(sqlite, "PRAGMA table_info('%q')", &rowp, &nrows, &ncols, NULL, s->dyncols[i].table); if (ret != SQLITE_OK) { continue; } k = findcol(rowp, ncols, "name"); t = findcol(rowp, ncols, "type"); pk = findcol(rowp, ncols, "pk"); nn = findcol(rowp, ncols, "notnull"); if (k < 0 || t < 0) { goto freet; } for (r = 1; r <= nrows; r++) { int m; for (m = i; m < s->dcols; m++) { if (!flagp[m] && strcmp(s->dyncols[m].column, rowp[r * ncols + k]) == 0 && strcmp(s->dyncols[m].table, s->dyncols[i].table) == 0) { char *typename = rowp[r * ncols + t]; flagp[m] = 1; freep(&s->dyncols[m].typename); s->dyncols[m].typename = xstrdup(typename); s->dyncols[m].type = mapsqltype(typename, &s->dyncols[m].nosign, *s->ov3, s->nowchar[0] || s->nowchar[1]); getmd(typename, s->dyncols[m].type, &s->dyncols[m].size, &s->dyncols[m].prec); #ifdef SQL_LONGVARCHAR if (s->dyncols[m].type == SQL_VARCHAR && s->dyncols[m].size > 255) { s->dyncols[m].type = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (s->dyncols[i].type == SQL_WVARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_WLONGVARCHAR; } #endif #endif #if (HAVE_ENCDEC) if (s->dyncols[i].type == SQL_VARBINARY && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARBINARY; } #endif if (pk >= 0 && strcmp(rowp[r * ncols + pk], "1") == 0) { if (++autoinccount > 1) { if (lastpk >= 0) { s->dyncols[lastpk].autoinc = SQL_FALSE; lastpk = -1; } } else { lastpk = m; if (strlen(typename) == 7 && strncasecmp(typename, "integer", 7) == 0) { s->dyncols[m].autoinc = SQL_TRUE; } } } if (nn >= 0 && rowp[r * ncols + nn][0] != '0') { s->dyncols[m].notnull = SQL_NO_NULLS; } } } } freet: sqlite_free_table(rowp); } if (flagp != flags) { freep(&flagp); } } /** * Return number of month days. * @param year * @param month 1..12 * @result number of month days or 0 */ static int getmdays(int year, int month) { static const int mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int mday; if (month < 1) { return 0; } mday = mdays[(month - 1) % 12]; if (mday == 28 && year % 4 == 0 && (!(year % 100 == 0) || year % 400 == 0)) { mday++; } return mday; } /** * Convert string to ODBC DATE_STRUCT. * @param str string to be converted * @param ds output DATE_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDD' or 'YYYY-MM-DD' or * 'YYYY/MM/DD' or 'MM/DD/YYYY' are converted to a * DATE_STRUCT. */ static int str2date(char *str, DATE_STRUCT *ds) { int i, err = 0; char *p, *q, sepc = '\0'; ds->year = ds->month = ds->day = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && !ISDIGIT(*q)) { ++i; ++q; } if (i >= 8) { char buf[8]; strncpy(buf, p + 0, 4); buf[4] = '\0'; ds->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ds->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; ds->day = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (!sepc) { sepc = *q; } if (*q == '-' || *q == '/' || *q == '\0' || i == 2) { switch (i) { case 0: ds->year = n; break; case 1: ds->month = n; break; case 2: ds->day = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } done: /* final check for overflow */ if (err || ds->month < 1 || ds->month > 12 || ds->day < 1 || ds->day > getmdays(ds->year, ds->month)) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = ds->year; t[1] = ds->month; t[2] = ds->day; ds->year = t[2]; ds->day = t[1]; ds->month = t[0]; if (ds->month >= 1 && ds->month <= 12 && ds->day >= 1 && ds->day <= getmdays(ds->year, ds->month)) { return 0; } } return -1; } return 0; } /** * Convert string to ODBC TIME_STRUCT. * @param str string to be converted * @param ts output TIME_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'HHMMSS' or 'HH:MM:SS' * are converted to a TIME_STRUCT. */ static int str2time(char *str, TIME_STRUCT *ts) { int i, err = 0, ampm = -1; char *p, *q; ts->hour = ts->minute = ts->second = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 6) { char buf[4]; strncpy(buf, p + 0, 2); buf[2] = '\0'; ts->hour = strtol(buf, NULL, 10); strncpy(buf, p + 2, 2); buf[2] = '\0'; ts->minute = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ts->second = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (*q == ':' || *q == '\0' || i == 2) { switch (i) { case 0: ts->hour = n; break; case 1: ts->minute = n; break; case 2: ts->second = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } if (!err) { while (*p) { if ((p[0] == 'p' || p[0] == 'P') && (p[1] == 'm' || p[1] == 'M')) { ampm = 1; } else if ((p[0] == 'a' || p[0] == 'A') && (p[1] == 'm' || p[1] == 'M')) { ampm = 0; } ++p; } if (ampm > 0) { if (ts->hour < 12) { ts->hour += 12; } } else if(ampm == 0) { if (ts->hour == 12) { ts->hour = 0; } } } done: /* final check for overflow */ if (err || ts->hour > 23 || ts->minute > 59 || ts->second > 59) { return -1; } return 0; } /** * Convert string to ODBC TIMESTAMP_STRUCT. * @param str string to be converted * @param tss output TIMESTAMP_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDDhhmmssff' or 'YYYY-MM-DD hh:mm:ss ff' * or 'YYYY/MM/DD hh:mm:ss ff' or 'hh:mm:ss ff YYYY-MM-DD' are * converted to a TIMESTAMP_STRUCT. The ISO8601 formats * YYYY-MM-DDThh:mm:ss[.f]Z * YYYY-MM-DDThh:mm:ss[.f]shh:mm * are also supported. In case a time zone field is present, * the resulting TIMESTAMP_STRUCT is expressed in UTC. */ static int str2timestamp(char *str, TIMESTAMP_STRUCT *tss) { int i, m, n, err = 0, ampm = -1; char *p, *q, in = '\0', sepc = '\0'; tss->year = tss->month = tss->day = 0; tss->hour = tss->minute = tss->second = 0; tss->fraction = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 14) { char buf[16]; strncpy(buf, p + 0, 4); buf[4] = '\0'; tss->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; tss->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; tss->day = strtol(buf, NULL, 10); strncpy(buf, p + 8, 2); buf[2] = '\0'; tss->hour = strtol(buf, NULL, 10); strncpy(buf, p + 10, 2); buf[2] = '\0'; tss->minute = strtol(buf, NULL, 10); strncpy(buf, p + 12, 2); buf[2] = '\0'; tss->second = strtol(buf, NULL, 10); if (i > 14) { m = i - 14; strncpy(buf, p + 14, m); while (m < 9) { buf[m] = '0'; ++m; } buf[m] = '\0'; tss->fraction = strtol(buf, NULL, 10); } m = 7; goto done; } m = i = 0; while ((m & 7) != 7) { q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (m < 1) { err = 1; } goto done; } } if (in == '\0') { switch (*q) { case '-': case '/': if ((m & 1) == 0) { in = *q; i = 0; } break; case ':': if ((m & 2) == 0) { in = *q; i = 0; } break; case ' ': case '.': break; default: in = '\0'; i = 0; break; } } switch (in) { case '-': case '/': if (!sepc) { sepc = in; } switch (i) { case 0: tss->year = n; break; case 1: tss->month = n; break; case 2: tss->day = n; break; } if (++i >= 3) { i = 0; m |= 1; if (!(m & 2)) { m |= 8; } goto skip; } else { ++q; } break; case ':': switch (i) { case 0: tss->hour = n; break; case 1: tss->minute = n; break; case 2: tss->second = n; break; } if (++i >= 3) { i = 0; m |= 2; if (*q == '.') { in = '.'; goto skip2; } if (*q == ' ') { if ((m & 1) == 0) { char *e = NULL; (void) strtol(q + 1, &e, 10); if (e && *e == '-') { goto skip; } } in = '.'; goto skip2; } goto skip; } else { ++q; } break; case '.': if (++i >= 1) { int ndig = q - p; if (p[0] == '+' || p[0] == '-') { ndig--; } while (ndig < 9) { n = n * 10; ++ndig; } tss->fraction = n; m |= 4; i = 0; } default: skip: in = '\0'; skip2: while (*q && !ISDIGIT(*q)) { if ((q[0] == 'a' || q[0] == 'A') && (q[1] == 'm' || q[1] == 'M')) { ampm = 0; ++q; } else if ((q[0] == 'p' || q[0] == 'P') && (q[1] == 'm' || q[1] == 'M')) { ampm = 1; ++q; } ++q; } } p = q; } if ((m & 7) > 1 && (m & 8)) { /* ISO8601 timezone */ if (p > str && ISDIGIT(*p)) { int nn, sign; q = p - 1; if (*q != '+' && *q != '-') { goto done; } sign = (*q == '+') ? -1 : 1; q = NULL; n = strtol(p, &q, 10); if (!q || *q++ != ':' || !ISDIGIT(*q)) { goto done; } p = q; q = NULL; nn = strtol(p, &q, 10); tss->minute += nn * sign; if ((SQLSMALLINT) tss->minute < 0) { tss->hour -= 1; tss->minute += 60; } else if (tss->minute >= 60) { tss->hour += 1; tss->minute -= 60; } tss->hour += n * sign; if ((SQLSMALLINT) tss->hour < 0) { tss->day -= 1; tss->hour += 24; } else if (tss->hour >= 24) { tss->day += 1; tss->hour -= 24; } if ((short) tss->day < 1 || tss->day >= 28) { int mday, pday, pmon; mday = getmdays(tss->year, tss->month); pmon = tss->month - 1; if (pmon < 1) { pmon = 12; } pday = getmdays(tss->year, pmon); if ((SQLSMALLINT) tss->day < 1) { tss->month -= 1; tss->day = pday; } else if (tss->day > mday) { tss->month += 1; tss->day = 1; } if ((SQLSMALLINT) tss->month < 1) { tss->year -= 1; tss->month = 12; } else if (tss->month > 12) { tss->year += 1; tss->month = 1; } } } } done: if ((m & 1) && (tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month))) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = tss->year; t[1] = tss->month; t[2] = tss->day; tss->year = t[2]; tss->day = t[1]; tss->month = t[0]; } } /* Replace missing year/month/day with current date */ if (!err && (m & 1) == 0) { #ifdef _WIN32 SYSTEMTIME t; GetLocalTime(&t); tss->year = t.wYear; tss->month = t.wMonth; tss->day = t.wDay; #else struct timeval tv; struct tm tm; gettimeofday(&tv, NULL); tm = *localtime(&tv.tv_sec); tss->year = tm.tm_year + 1900; tss->month = tm.tm_mon + 1; tss->day = tm.tm_mday; #endif } /* Normalize fraction */ if (tss->fraction < 0) { tss->fraction = 0; } /* Final check for overflow */ if (err || tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month) || tss->hour > 23 || tss->minute > 59 || tss->second > 59) { return -1; } if ((m & 7) > 1) { if (ampm > 0) { if (tss->hour < 12) { tss->hour += 12; } } else if (ampm == 0) { if (tss->hour == 12) { tss->hour = 0; } } } return ((m & 7) < 1) ? -1 : 0; } /** * Get boolean flag from string. * @param string string to be inspected * @result true or false */ static int getbool(char *string) { if (string) { return string[0] && strchr("Yy123456789Tt", string[0]) != NULL; } return 0; } #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) /** * SQLite trace callback * @param arg DBC pointer */ static void dbtrace(void *arg, const char *msg) { DBC *d = (DBC *) arg; if (msg && d->trace) { int len = strlen(msg); if (len > 0) { char *end = "\n"; if (msg[len - 1] != ';') { end = ";\n"; } fprintf(d->trace, "%s%s", msg, end); fflush(d->trace); } } } /** * Trace function for SQLite return codes * @param rc SQLite return code * @param err error string or NULL */ static void dbtracerc(DBC *d, int rc, char *err) { if (rc != SQLITE_OK && d->trace) { fprintf(d->trace, "-- SQLITE ERROR CODE %d", rc); fprintf(d->trace, err ? ": %s\n" : "\n", err); fflush(d->trace); } } #else #define dbtracerc(a,b,c) #endif /** * Open SQLite database file given file name and flags. * @param d DBC pointer * @param name file name * @param dsn data source name * @param sflag STEPAPI flag * @param sflag NoTXN flag * @param busy busy/lock timeout * @result ODBC error code */ static SQLRETURN dbopen(DBC *d, char *name, char *dsn, char *sflag, char *ntflag, char *busy) { char *errp = NULL, *endp = NULL; int tmp, busyto = 100000; #if defined(_WIN32) || defined(_WIN64) char expname[MAX_PATH]; #endif if (d->sqlite) { sqlite_close(d->sqlite); d->sqlite = NULL; } #if defined(_WIN32) || defined(_WIN64) expname[0] = '\0'; tmp = ExpandEnvironmentStrings(name, expname, sizeof (expname)); if (tmp <= sizeof (expname)) { name = expname; } #endif d->sqlite = sqlite_open(name, 0, &errp); if (d->sqlite == NULL) { connfail: setstatd(d, -1, "%s", (*d->ov3) ? "HY000" : "S1000", errp ? errp : "connect failed"); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) if (d->trace) { sqlite_trace(d->sqlite, dbtrace, d); } #endif d->step_enable = getbool(sflag); d->trans_disable = getbool(ntflag); d->curtype = d->step_enable ? SQL_CURSOR_FORWARD_ONLY : SQL_CURSOR_STATIC; tmp = strtol(busy, &endp, 0); if (endp && *endp == '\0' && endp != busy) { busyto = tmp; } if (busyto < 1 || busyto > 1000000) { busyto = 1000000; } d->timeout = busyto; freep(&d->dbname); d->dbname = xstrdup(name); freep(&d->dsn); d->dsn = xstrdup(dsn); if (setsqliteopts(d->sqlite, d) != SQLITE_OK) { sqlite_close(d->sqlite); d->sqlite = NULL; goto connfail; } #if defined(_WIN32) || defined(_WIN64) { char pname[MAX_PATH]; HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()); pname[0] = '\0'; if (h) { HMODULE m = NULL, l = LoadLibrary("psapi.dll"); DWORD need; typedef BOOL (WINAPI *epmfunc)(HANDLE, HMODULE *, DWORD, LPDWORD); typedef BOOL (WINAPI *gmbfunc)(HANDLE, HMODULE, LPSTR, DWORD); epmfunc epm; gmbfunc gmb; if (l) { epm = (epmfunc) GetProcAddress(l, "EnumProcessModules"); gmb = (gmbfunc) GetProcAddress(l, "GetModuleBaseNameA"); if (epm && gmb && epm(h, &m, sizeof (m), &need)) { gmb(h, m, pname, sizeof (pname)); } FreeLibrary(l); } CloseHandle(h); } d->xcelqrx = strncasecmp(pname, "EXCEL", 5) == 0 || strncasecmp(pname, "MSQRY", 5) == 0; if (d->trace && d->xcelqrx) { fprintf(d->trace, "-- enabled EXCEL quirks\n"); fflush(d->trace); } } #endif return SQL_SUCCESS; } /** * Do one VM step gathering one result row * @param s statement pointer * @result ODBC error code */ static int vm_step(STMT *s) { DBC *d = (DBC *) s->dbc; char **rowd = NULL, *errp = NULL; const char **values, **cols; int i, ncols, rc; if (s != d->vm_stmt || !s->vm) { setstat(s, -1, "stale statement", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } rc = sqlite_step(s->vm, &ncols, &values, &cols); if (rc == SQLITE_ROW || rc == SQLITE_DONE) { ++d->vm_rownum; if (d->vm_rownum == 0 && cols && ncols > 0) { int size; char *p; COL *dyncols; for (i = size = 0; i < ncols; i++) { size += 3 + 3 * strlen(cols[i]); } dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); s->ncols = 0; sqlite_finalize(s->vm, NULL); s->vm = NULL; d->vm_stmt = NULL; return nomem(s); } p = (char *) (dyncols + ncols); for (i = 0; i < ncols; i++) { char *q; dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, cols[i]); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(cols[i], '.'); if (q) { dyncols[i].table = p; strncpy(p, cols[i], q - cols[i]); p[q - cols[i]] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { dyncols[i].table = ""; strcpy(p, cols[i]); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; dyncols[i].autoinc = SQL_FALSE; dyncols[i].notnull = SQL_NULLABLE; dyncols[i].typename = NULL; } freedyncols(s); s->ncols = s->dcols = ncols; s->dyncols = s->cols = dyncols; fixupdyncols(s, d->sqlite, cols + ncols); mkbindcols(s, s->ncols); } if (!cols || ncols <= 0) { goto killvm; } if (!values) { if (rc == SQLITE_DONE) { freeresult(s, 0); s->nrows = 0; sqlite_finalize(s->vm, NULL); s->vm = NULL; d->vm_stmt = NULL; return SQL_SUCCESS; } goto killvm; } rowd = xmalloc((1 + 2 * ncols) * sizeof (char *)); if (rowd) { rowd[0] = (char *) ((PTRDIFF_T) (ncols * 2)); ++rowd; for (i = 0; i < ncols; i++) { rowd[i] = NULL; rowd[i + ncols] = xstrdup(values[i]); } for (i = 0; i < ncols; i++) { if (values[i] && !rowd[i + ncols]) { freerows(rowd); rowd = 0; break; } } } if (rowd) { freeresult(s, 0); s->nrows = 1; s->rows = rowd; s->rowfree = freerows; if (rc == SQLITE_DONE) { sqlite_finalize(s->vm, NULL); s->vm = NULL; d->vm_stmt = NULL; } return SQL_SUCCESS; } } killvm: sqlite_finalize(s->vm, &errp); s->vm = NULL; d->vm_stmt = NULL; setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } /** * Stop running VM * @param s statement pointer */ static void vm_end(STMT *s) { DBC *d; if (!s || !s->vm) { return; } d = (DBC *) s->dbc; if (d) { d->busyint = 0; } sqlite_finalize(s->vm, NULL); s->vm = NULL; d->vm_stmt = NULL; } /** * Conditionally stop running VM * @param s statement pointer */ static void vm_end_if(STMT *s) { DBC *d = (DBC *) s->dbc; if (d) { d->busyint = 0; } if (d && d->vm_stmt == s) { vm_end(s); } } /** * Start VM for execution of SELECT statement. * @param s statement pointer * @param params string array of statement parameters * @result ODBC error code */ static SQLRETURN vm_start(STMT *s, char **params) { DBC *d = (DBC *) s->dbc; char *errp = NULL, *sql = NULL; const char *endp; sqlite_vm *vm; int rc; #ifdef CANT_PASS_VALIST_AS_CHARPTR if (params) { sql = sqlite_mprintf((char *) s->query, params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12], params[13], params[14], params[15], params[16], params[17], params[18], params[19], params[20], params[21], params[22], params[23], params[24], params[25], params[26], params[27], params[28], params[29], params[30], params[31]); } else { sql = sqlite_mprintf((char *) s->query); } #else sql = sqlite_vmprintf((char *) s->query, (char *) params); #endif if (!sql) { return nomem(s); } rc = sqlite_compile(d->sqlite, sql, &endp, &vm, &errp); dbtracerc(d, rc, errp); sqlite_freemem(sql); if (rc != SQLITE_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } s->vm = vm; d->vm_stmt = s; d->vm_rownum = -1; return SQL_SUCCESS; } /** * Function not implemented. */ SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt, SQLSMALLINT oper) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSources(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSourcesW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLWCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDrivers(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDriversW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLWCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC dbc, SQLCHAR *connin, SQLSMALLINT conninLen, SQLCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnectW(SQLHDBC dbc, SQLWCHAR *connin, SQLSMALLINT conninLen, SQLWCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif /** * SQLite function "current_time_local" etc. * @param context SQLite function context * @param argc number arguments * @param argv argument vector */ static void time_func(sqlite_func *context, int argc, const char **argv) { char buf[128]; PTRDIFF_T what = (PTRDIFF_T) sqlite_user_data(context); #if defined(_WIN32) || defined(_WIN64) SYSTEMTIME st; if (what & 1) { GetSystemTime(&st); } else { GetLocalTime(&st); } if (what & 4) { sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); } else if (what & 2) { sprintf(buf, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay); } else { sprintf(buf, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond); } #else time_t t; struct tm tm; time(&t); if (what & 1) { #ifdef HAVE_GMTIME_R gmtime_r(&t, &tm); #else tm = *gmtime(&t); #endif } else { #ifdef HAVE_LOCALTIME_R localtime_r(&t, &tm); #else tm = *localtime(&t); #endif } if (what & 4) { sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } else if (what & 2) { sprintf(buf, "%04d-%02d-%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); } else { sprintf(buf, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); } #endif sqlite_set_result_string(context, buf, -1); } #if (HAVE_ENCDEC) static const char hexdigits[] = "0123456789ABCDEFabcdef"; /** * SQLite function "hextobin" * @param context SQLite function context * @param argc number arguments * @param argv argument vector */ static void hextobin_func(sqlite_func *context, int argc, const char **argv) { int i, len; char *bin, *p; if (argc < 1) { return; } if (!argv[0]) { sqlite_set_result_string(context, NULL, 4); return; } len = strlen(argv[0]) / 2; bin = xmalloc(len + 1); if (!bin) { oom: sqlite_set_result_error(context, "out of memory", -1); return; } if (len <= 0) { sqlite_set_result_string(context, bin, 0); freep(&bin); return; } for (i = 0, p = (char *) argv[0]; i < len; i++) { char *x; int v; if (!*p || !(x = strchr(hexdigits, *p))) { goto converr; } v = x - hexdigits; bin[i] = (v >= 16) ? ((v - 6) << 4) : (v << 4); ++p; if (!*p || !(x = strchr(hexdigits, *p))) { converr: freep(&bin); sqlite_set_result_error(context, "conversion error", -1); return; } v = x - hexdigits; bin[i] |= (v >= 16) ? (v - 6) : v; ++p; } i = sqlite_encode_binary((unsigned char *) bin, len, 0); p = xmalloc(i + 1); if (!p) { freep(&bin); goto oom; } i = sqlite_encode_binary((unsigned char *) bin, len, (unsigned char *) p); sqlite_set_result_string(context, p, i); freep(&bin); freep(&p); } /** * SQLite function "bintohex" * @param context SQLite function context * @param argc number arguments * @param argv argument vector */ static void bintohex_func(sqlite_func *context, int argc, const char **argv) { int i, k, len; char *bin, *p; if (argc < 1) { return; } if (!argv[0]) { empty: sqlite_set_result_string(context, "", 0); return; } bin = xmalloc(strlen(argv[0]) + 1); if (!bin) { oom: sqlite_set_result_error(context, "out of memory", -1); return; } len = sqlite_decode_binary((unsigned char *) argv[0], (unsigned char *) bin); if (len < 0) { freep(&bin); sqlite_set_result_error(context, "error decoding binary data", -1); return; } if (len == 0) { goto empty; } p = xmalloc(len * 2 + 1); if (!p) { goto oom; } for (i = 0, k = 0; i < len; i++) { p[k++] = hexdigits[(bin[i] >> 4) & 0x0f]; p[k++] = hexdigits[bin[i] & 0x0f]; } p[k] = '\0'; sqlite_set_result_string(context, p, k); freep(&bin); freep(&p); } /** * Encode hex (char) parameter to SQLite binary string. * @param s STMT pointer * @param p BINDPARM pointer * @result ODBD error code */ static SQLRETURN hextobin(STMT *s, BINDPARM *p) { int i, len = strlen(p->param) / 2; char *bin = xmalloc(len + 1), *pp; if (!bin) { return nomem(s); } if (len <= 0) { bin[0] = '\0'; freep(&p->parbuf); p->parbuf = p->param = bin; p->len = 0; return SQL_SUCCESS; } for (i = 0, pp = (char *) p->param; i < len; i++) { char *x; int v; if (!*pp || !(x = strchr(hexdigits, *pp))) { goto converr; } v = x - hexdigits; bin[i] = (v >= 16) ? ((v - 6) << 4) : (v << 4); ++pp; if (!*pp || !(x = strchr(hexdigits, *pp))) { converr: freep(&bin); setstat(s, -1, "conversion error", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } v = x - hexdigits; bin[i] |= (v >= 16) ? (v - 6) : v; ++pp; } i = sqlite_encode_binary((unsigned char *) bin, len, 0); pp = xmalloc(i + 1); if (!pp) { freep(&bin); return nomem(s); } p->len = sqlite_encode_binary((unsigned char *) bin, len, (unsigned char *) pp); freep(&p->parbuf); p->parbuf = p->param = pp; freep(&bin); return SQL_SUCCESS; } #endif /** * Internal put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ static SQLRETURN drvputdata(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { STMT *s; int i, dlen, done = 0; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->query || s->nparams <= 0) { seqerr: setstat(s, -1, "sequence error", "HY010"); return SQL_ERROR; } for (i = (s->pdcount < 0) ? 0 : s->pdcount; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { int type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); if (len == SQL_NULL_DATA) { freep(&p->parbuf); p->param = NULL; p->len = SQL_NULL_DATA; p->need = -1; } else if (type != SQL_C_CHAR #ifdef WCHARSUPPORT && type != SQL_C_WCHAR #endif #if (HAVE_ENCDEC) && type != SQL_C_BINARY #endif ) { int size = 0; switch (type) { case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif size = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: size = sizeof (SQLSMALLINT); break; case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: size = sizeof (SQLINTEGER); break; case SQL_C_FLOAT: size = sizeof (float); break; case SQL_C_DOUBLE: size = sizeof (double); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: size = sizeof (DATE_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: size = sizeof (TIME_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: size = sizeof (TIMESTAMP_STRUCT); break; } freep(&p->parbuf); p->parbuf = xmalloc(size); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; memcpy(p->param, data, size); p->len = size; p->need = -1; } else if (len == SQL_NTS && ( type == SQL_C_CHAR #ifdef WCHARSUPPORT || type == SQL_C_WCHAR #endif )) { char *dp = data; #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { dp = uc_to_utf(data, len); if (!dp) { return nomem(s); } } #endif dlen = strlen(dp); freep(&p->parbuf); p->parbuf = xmalloc(dlen + 1); if (!p->parbuf) { #ifdef WCHARSUPPORT if (dp != data) { uc_free(dp); } #endif return nomem(s); } p->param = p->parbuf; strcpy(p->param, dp); #ifdef WCHARSUPPORT if (dp != data) { uc_free(dp); } #endif p->len = dlen; p->need = -1; } else if (len < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } else { dlen = min(p->len - p->offs, len); if (!p->param) { setstat(s, -1, "no memory for parameter", "HY013"); return SQL_ERROR; } memcpy((char *) p->param + p->offs, data, dlen); p->offs += dlen; if (p->offs >= p->len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->len); char *np; int nlen; if (!dp) { return nomem(s); } nlen = strlen(dp); np = xmalloc(nlen + 1); if (!np) { uc_free(dp); return nomem(s); } strcpy(np, dp); uc_free(dp); if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = np; p->len = nlen; } else { *((char *) p->param + p->len) = '\0'; } #else #if defined(_WIN32) || defined(_WIN64) if (p->type == SQL_C_WCHAR && (p->stype == SQL_VARCHAR || p->stype == SQL_LONGVARCHAR) && p->len == p->coldef * sizeof (SQLWCHAR)) { /* fix for MS-Access */ p->len = p->coldef; } #endif *((char *) p->param + p->len) = '\0'; #endif #if (HAVE_ENCDEC) if ((p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY) && #ifdef WCHARSUPPORT (type == SQL_C_CHAR || type == SQL_C_WCHAR) #else type == SQL_C_CHAR #endif ) { if (hextobin(s, p) != SQL_SUCCESS) { return SQL_ERROR; } } else if (type == SQL_C_BINARY) { int bsize; unsigned char *bin; bsize = sqlite_encode_binary(p->param, p->len, 0); bin = xmalloc(bsize + 1); if (!bin) { return nomem(s); } p->len = sqlite_encode_binary(p->param, p->len, bin); if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = bin; } #endif p->need = -1; } } done = 1; break; } } if (!done) { goto seqerr; } return SQL_SUCCESS; } /** * Put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvputdata(stmt, data, len); HSTMT_UNLOCK(stmt); return ret; } /** * Clear out parameter bindings, if any. * @param s statement pointer */ static SQLRETURN freeparams(STMT *s) { if (s->bindparms) { int n; for (n = 0; n < s->nbindparms; n++) { freep(&s->bindparms[n].parbuf); memset(&s->bindparms[n], 0, sizeof (BINDPARM)); } } return SQL_SUCCESS; } /** * Substitute parameter for statement. * @param s statement pointer * @param pnum parameter number * @param outp output pointer or NULL * @result ODBC error code * * If no output buffer is given, the function computes and * reports the space needed for the parameter. Otherwise * the parameter is converted to its string representation * in order to be presented to sqlite_exec_vprintf() et.al. */ static SQLRETURN substparam(STMT *s, int pnum, char **outp) { char *outdata = NULL; int type, len, isnull = 0, needalloc = 0; BINDPARM *p; double dval; #if (HAVE_ENCDEC) int chkbin = 1; #endif if (!s->bindparms || pnum < 0 || pnum >= s->nbindparms) { goto error; } p = &s->bindparms[pnum]; type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 4 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && p->type == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif if (p->need > 0) { return setupparbuf(s, p); } p->strbuf[0] = '\0'; if (!p->param || (p->lenp && *p->lenp == SQL_NULL_DATA)) { isnull = 1; goto bind; } #if (HAVE_ENCDEC) if (type == SQL_C_CHAR && (p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY)) { type = SQL_C_BINARY; } #endif switch (type) { case SQL_C_CHAR: #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif #if (HAVE_ENCDEC) case SQL_C_BINARY: #endif break; #ifdef SQL_BIT case SQL_C_BIT: strcpy(p->strbuf, (*((unsigned char *) p->param)) ? "1" : "0"); goto bind; #endif case SQL_C_UTINYINT: sprintf(p->strbuf, "%d", *((unsigned char *) p->param)); goto bind; case SQL_C_TINYINT: case SQL_C_STINYINT: sprintf(p->strbuf, "%d", *((char *) p->param)); goto bind; case SQL_C_USHORT: sprintf(p->strbuf, "%d", *((unsigned short *) p->param)); goto bind; case SQL_C_SHORT: case SQL_C_SSHORT: sprintf(p->strbuf, "%d", *((short *) p->param)); goto bind; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: sprintf(p->strbuf, "%ld", *((long *) p->param)); goto bind; case SQL_C_FLOAT: dval = *((float *) p->param); goto dodouble; case SQL_C_DOUBLE: dval = *((double *) p->param); dodouble: #if defined(HAVE_SQLITEMPRINTF) && (HAVE_SQLITEMPRINTF) { char *buf2 = sqlite_mprintf("%.16g", dval); if (buf2) { strcpy(p->strbuf, buf2); sqlite_freemem(buf2); } else { isnull = 1; } } #else ln_sprintfg(p->strbuf, dval); #endif goto bind; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: sprintf(p->strbuf, "%04d-%02d-%02d", ((DATE_STRUCT *) p->param)->year, ((DATE_STRUCT *) p->param)->month, ((DATE_STRUCT *) p->param)->day); goto bind; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: sprintf(p->strbuf, "%02d:%02d:%02d", ((TIME_STRUCT *) p->param)->hour, ((TIME_STRUCT *) p->param)->minute, ((TIME_STRUCT *) p->param)->second); goto bind; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: len = (int) ((TIMESTAMP_STRUCT *) p->param)->fraction; len /= 1000000; len = len % 1000; if (len < 0) { len = 0; } if (p->coldef && p->coldef <= 16) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:00.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute); } else if (p->coldef && p->coldef <= 19) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second); } else { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.%03d", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second, len); } bind: if (outp) { *outp = isnull ? NULL : p->strbuf; } return SQL_SUCCESS; default: error: setstat(s, -1, "unsupported parameter type", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } if (!p->parbuf && p->lenp) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { if (*p->lenp == SQL_NTS) { p->max = uc_strlen(p->param) * sizeof (SQLWCHAR); } else if (*p->lenp >= 0) { p->max = *p->lenp; } } else #endif if (type == SQL_C_CHAR) { if (*p->lenp == SQL_NTS) { p->len = p->max = strlen(p->param); } else if (*p->lenp >= 0) { p->len = p->max = *p->lenp; needalloc = 1; } } #if (HAVE_ENCDEC) else if (type == SQL_C_BINARY) { p->len = p->max = *p->lenp; } #endif } if (p->need < 0 && p->parbuf == p->param) { outdata = p->param; goto putp; } #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->max); if (!dp) { return nomem(s); } if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; p->len = strlen(p->param); outdata = p->param; } else #endif #if (HAVE_ENCDEC) if (type == SQL_C_BINARY) { int bsize; char *dp; p->len = *p->lenp; if (p->len < 0) { setstat(s, -1, "invalid length reference", "HY009"); return SQL_ERROR; } bsize = sqlite_encode_binary(p->param, p->len, 0); dp = xmalloc(bsize + 1); if (!dp) { return nomem(s); } p->len = sqlite_encode_binary(p->param, p->len, (unsigned char *) dp); if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; chkbin = 0; outdata = p->param; } else #endif if (type == SQL_C_CHAR) { outdata = p->param; if (needalloc) { char *dp; freep(&p->parbuf); dp = xmalloc(p->len + 1); if (!dp) { return nomem(s); } memcpy(dp, p->param, p->len); dp[p->len] = '\0'; p->parbuf = p->param = dp; p->need = -1; outdata = p->param; } } else { outdata = p->param; #if (HAVE_ENCDEC) chkbin = 0; #endif } #if (HAVE_ENCDEC) if (chkbin) { if (p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY) { if (hextobin(s, p) != SQL_SUCCESS) { return SQL_ERROR; } outdata = p->param; } } #endif putp: if (outp) { *outp = outdata; } return SQL_SUCCESS; } /** * Internal bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ static SQLRETURN drvbindparam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLUINTEGER coldef, SQLSMALLINT scale, SQLPOINTER data, SQLINTEGER buflen, SQLLEN *len) { STMT *s; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (pnum == 0) { setstat(s, -1, "invalid parameter", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } if (!data && !len) { setstat(s, -1, "invalid buffer", "HY003"); return SQL_ERROR; } --pnum; if (s->bindparms) { if (pnum >= s->nbindparms) { BINDPARM *newparms; newparms = xrealloc(s->bindparms, (pnum + 1) * sizeof (BINDPARM)); if (!newparms) { outofmem: return nomem(s); } s->bindparms = newparms; memset(&s->bindparms[s->nbindparms], 0, (pnum + 1 - s->nbindparms) * sizeof (BINDPARM)); s->nbindparms = pnum + 1; } } else { int npar = max(10, pnum + 1); s->bindparms = xmalloc(npar * sizeof (BINDPARM)); if (!s->bindparms) { goto outofmem; } memset(s->bindparms, 0, npar * sizeof (BINDPARM)); s->nbindparms = npar; } switch (buftype) { case SQL_C_STINYINT: case SQL_C_UTINYINT: case SQL_C_TINYINT: #ifdef SQL_C_BIT case SQL_C_BIT: #endif buflen = sizeof (char); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: buflen = sizeof (short); break; case SQL_C_SLONG: case SQL_C_ULONG: case SQL_C_LONG: buflen = sizeof (long); break; case SQL_C_FLOAT: buflen = sizeof (float); break; case SQL_C_DOUBLE: buflen = sizeof (double); break; case SQL_C_TIMESTAMP: #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif buflen = sizeof (TIMESTAMP_STRUCT); break; case SQL_C_TIME: #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif buflen = sizeof (TIME_STRUCT); break; case SQL_C_DATE: #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif buflen = sizeof (DATE_STRUCT); break; #ifdef SQL_C_UBIGINT case SQL_C_UBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_SBIGINT case SQL_C_SBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_BIGINT case SQL_C_BIGINT: buflen = sizeof (SQLBIGINT); break; #endif } p = &s->bindparms[pnum]; p->type = buftype; p->stype = ptype; p->coldef = coldef; p->scale = scale; p->max = buflen; p->inc = buflen; p->lenp0 = p->lenp = len; p->offs = 0; p->len = 0; p->param0 = data; freep(&p->parbuf); p->param = p->param0; p->bound = 1; p->need = 0; return SQL_SUCCESS; } /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER data, SQLLEN buflen, SQLLEN *len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, iotype, buftype, ptype, coldef, scale, data, buflen, len); HSTMT_UNLOCK(stmt); return ret; } #ifndef HAVE_IODBC /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param vtype input/output type of parameter * @param ptype * @param lenprec * @param scale * @param val pointer to host variable * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT vtype, SQLSMALLINT ptype, SQLULEN lenprec, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, SQL_PARAM_INPUT, vtype, ptype, lenprec, scale, val, 0, lenp); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Return number of parameters. * @param stmt statement handle * @param nparam output parameter count * @result ODBC error code */ SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT *nparam) { STMT *s; SQLSMALLINT dummy; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!nparam) { nparam = &dummy; } *nparam = s->nparams; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Setup parameter buffer for deferred parameter. * @param s pointer to STMT * @param p pointer to BINDPARM * @result ODBC error code (success indicated by SQL_NEED_DATA) */ static SQLRETURN setupparbuf(STMT *s, BINDPARM *p) { if (!p->parbuf) { if (*p->lenp == SQL_DATA_AT_EXEC) { p->len = p->max; } else { p->len = SQL_LEN_DATA_AT_EXEC(*p->lenp); } if (p->len < 0 && p->len != SQL_NTS && p->len != SQL_NULL_DATA) { setstat(s, -1, "invalid length", "HY009"); return SQL_ERROR; } if (p->len >= 0) { p->parbuf = xmalloc(p->len + 1); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; } else { p->param = NULL; } } return SQL_NEED_DATA; } /** * Retrieve next parameter for sending data to executing query. * @param stmt statement handle * @param pind pointer to output parameter indicator * @result ODBC error code */ SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt, SQLPOINTER *pind) { STMT *s; int i; SQLPOINTER dummy; SQLRETURN ret; BINDPARM *p; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!pind) { pind = &dummy; } if (s->pdcount < s->nparams) { s->pdcount++; } for (i = 0; i < s->pdcount; i++) { p = &s->bindparms[i]; if (p->need > 0) { p->need = -1; } } for (; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { *pind = (SQLPOINTER) p->param0; ret = setupparbuf(s, p); s->pdcount = i; goto done; } } ret = drvexecute(stmt, 0); done: HSTMT_UNLOCK(stmt); return ret; } /** * Return information about parameter. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param dtype output type indicator * @param size output size indicator * @param decdigits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT *dtype, SQLULEN *size, SQLSMALLINT *decdigits, SQLSMALLINT *nullable) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; --pnum; if (pnum >= s->nparams) { setstat(s, -1, "invalid parameter index", (*s->ov3) ? "HY000" : "S1000"); goto done; } if (dtype) { #ifdef SQL_LONGVARCHAR #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else *dtype = SQL_LONGVARCHAR; #endif #else #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_VARCHAR : SQL_WVARCHAR; #else *dtype = SQL_VARCHAR; #endif #endif } if (size) { #ifdef SQL_LONGVARCHAR *size = 65536; #else *size = 255; #endif } if (decdigits) { *decdigits = 0; } if (nullable) { *nullable = SQL_NULLABLE; } ret = SQL_SUCCESS; done: HSTMT_UNLOCK(stmt); return ret; } /** * Set information on parameter. * @param stmt statement handle * @param par parameter number, starting at 1 * @param type type of host variable * @param sqltype * @param coldef * @param scale * @param val pointer to host variable * @param len output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLSetParam(SQLHSTMT stmt, SQLUSMALLINT par, SQLSMALLINT type, SQLSMALLINT sqltype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *nval) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, par, SQL_PARAM_INPUT, type, sqltype, coldef, scale, val, SQL_SETPARAM_VALUE_MAX, nval); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt, SQLULEN rows, SQLULEN *rowp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRecW(SQLHDESC handle, SQLSMALLINT recno, SQLWCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT type, SQLSMALLINT subtype, SQLLEN len, SQLSMALLINT prec, SQLSMALLINT scale, SQLPOINTER data, SQLLEN *strlen, SQLLEN *indicator) { return SQL_ERROR; } /** * Setup empty result set from constant column specification. * @param stmt statement handle * @param colspec column specification array (default, ODBC2) * @param ncols number of columns (default, ODBC2) * @param colspec3 column specification array (ODBC3) * @param ncols3 number of columns (ODBC3) * @param nret returns number of columns * @result ODBC error code */ static SQLRETURN mkresultset(HSTMT stmt, COL *colspec, int ncols, COL *colspec3, int ncols3, int *nret) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } vm_end_if(s); freeresult(s, 0); if (colspec3 && *s->ov3) { s->ncols = ncols3; s->cols = colspec3; } else { s->ncols = ncols; s->cols = colspec; } mkbindcols(s, s->ncols); s->nowchar[1] = 1; s->nrows = 0; s->rowp = -1; s->isselect = -1; if (nret) { *nret = s->ncols; } return SQL_SUCCESS; } /** * Columns for result set of SQLTablePrivileges(). */ static COL tablePrivSpec2[] = { { "SYSTEM", "TABLEPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; static COL tablePrivSpec3[] = { { "SYSTEM", "TABLEPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtableprivileges(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, rc, size, npatt; char *errp = NULL, tname[512]; ret = mkresultset(stmt, tablePrivSpec2, array_size(tablePrivSpec2), tablePrivSpec3, array_size(tablePrivSpec3), NULL); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); ret = starttran(s); if (ret != SQL_SUCCESS) { return ret; } #if defined(_WIN32) || defined(_WIN64) rc = sqlite_get_table_printf(d->sqlite, "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q'", &s->rows, &s->nrows, &ncols, &errp, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname); #else rc = sqlite_get_table_printf(d->sqlite, "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q' " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q'", &s->rows, &s->nrows, &ncols, &errp, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname); #endif if (rc == SQLITE_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = sqlite_free_table; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite_freemem(errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvtableprivileges(stmt, catalog, catalogLen, schema, schemaLen, table, tableLen); HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on tables and/or views (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (catalog) { c = uc_to_utf_c(catalog, catalogLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtableprivileges(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif #endif /** * Columns for result set of SQLColumnPrivileges(). */ static COL colPrivSpec2[] = { { "SYSTEM", "COLPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; static COL colPrivSpec3[] = { { "SYSTEM", "COLPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on columns. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on columns (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #endif /** * Columns for result set of SQLPrimaryKeys(). */ static COL pkeySpec2[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; static COL pkeySpec3[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprimarykeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nrows2 = 0, ncols2 = 0; int namec = -1, uniquec = -1, namec2 = -1, uniquec2 = -1, offs, seq = 1; PTRDIFF_T size; char **rowp = NULL, **rowp2 = NULL, *errp = NULL, tname[512]; sret = mkresultset(stmt, pkeySpec2, array_size(pkeySpec2), pkeySpec3, array_size(pkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowp, &nrows, &ncols, &errp, tname); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } size = 0; if (ncols * nrows > 0) { int typec; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); if (namec >= 0 && uniquec >= 0 && typec >= 0) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { size++; } } } } if (size == 0) { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_list('%q')", &rowp2, &nrows2, &ncols2, &errp, tname); if (ret != SQLITE_OK) { sqlite_free_table(rowp); sqlite_free_table(rowp2); setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } } if (ncols2 * nrows2 > 0) { namec2 = findcol(rowp2, ncols, "name"); uniquec2 = findcol(rowp2, ncols, "unique"); if (namec2 >= 0 && uniquec2 >= 0) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols; char **rowpp; if (*rowp2[i * ncols2 + namec2] != '(' || !strstr(rowp2[i * ncols2 + namec2], " autoindex ")) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp2[i * ncols2 + namec2]); if (ret == SQLITE_OK) { size += nnrows; sqlite_free_table(rowpp); } } } } } if (size == 0) { sqlite_free_table(rowp); sqlite_free_table(rowp2); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite_free_table(rowp); sqlite_free_table(rowp2); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = s->ncols; if (rowp) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { char buf[32]; s->rows[offs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[offs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[offs + 1] = xstrdup(""); #endif s->rows[offs + 2] = xstrdup(tname); s->rows[offs + 3] = xstrdup(rowp[i * ncols + namec]); sprintf(buf, "%d", seq++); s->rows[offs + 4] = xstrdup(buf); offs += s->ncols; } } } if (rowp2) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols; char **rowpp; if (*rowp2[i * ncols2 + namec2] != '(' || !strstr(rowp2[i * ncols2 + namec2], " autoindex ")) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { int k; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp2[i * ncols2 + namec2]); if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 5] = xstrdup(rowp2[i * ncols2 + namec2]); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 4] = xstrdup(buf); } } } offs += nnrows * s->ncols; sqlite_free_table(rowpp); } } } sqlite_free_table(rowp); sqlite_free_table(rowp2); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvprimarykeys(stmt, cat, catLen, schema, schemaLen, table, tableLen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeysW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvprimarykeys(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif /** * Columns for result set of SQLSpecialColumns(). */ static COL scolSpec2[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; static COL scolSpec3[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ static SQLRETURN drvspecialcolumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nnnrows, nnncols, offs; int namec = -1, uniquec = -1, namecc = -1, typecc = -1; int notnullcc = -1, mkrowid = 0; PTRDIFF_T size; char *errp = NULL, tname[512]; char **rowp = NULL, **rowppp = NULL; sret = mkresultset(stmt, scolSpec2, array_size(scolSpec2), scolSpec3, array_size(scolSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); if (id != SQL_BEST_ROWID) { return SQL_SUCCESS; } sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_list('%q')", &rowp, &nrows, &ncols, &errp, tname); if (ret != SQLITE_OK) { doerr: setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } size = 0; /* number result rows */ if (ncols * nrows <= 0) { goto nodata_but_rowid; } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowppp, &nnnrows, &nnncols, &errp, tname); if (ret != SQLITE_OK) { sqlite_free_table(rowp); goto doerr; } if (errp) { sqlite_freemem(errp); errp = NULL; } namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata_but_rowid; } namecc = findcol(rowppp, nnncols, "name"); typecc = findcol(rowppp, nnncols, "type"); notnullcc = findcol(rowppp, nnncols, "notnull"); for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; if (*rowp[i * ncols + uniquec] != '0') { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i * ncols + namec]); if (ret == SQLITE_OK) { size += nnrows; sqlite_free_table(rowpp); } } } nodata_but_rowid: if (size == 0) { size = 1; mkrowid = 1; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite_free_table(rowp); sqlite_free_table(rowppp); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; if (mkrowid) { s->nrows = 0; goto mkrowid; } offs = 0; for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; if (*rowp[i * ncols + uniquec] != '0') { int k; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i * ncols + namec]); if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + m) * s->ncols; s->rows[roffs + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[roffs + 1] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 4] = xstrdup("0"); s->rows[roffs + 7] = xstrdup(stringify(SQL_PC_NOT_PSEUDO)); if (namecc >= 0 && typecc >= 0) { int ii; for (ii = 1; ii <= nnnrows; ii++) { if (strcmp(rowppp[ii * nnncols + namecc], rowpp[m * nncols + k]) == 0) { char *typen = rowppp[ii * nnncols + typecc]; int sqltype, mm, dd, isnullable = 0; char buf[32]; s->rows[roffs + 3] = xstrdup(typen); sqltype = mapsqltype(typen, NULL, *s->ov3, s->nowchar[0]); getmd(typen, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif #if (HAVE_ENCDEC) if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } #endif sprintf(buf, "%d", sqltype); s->rows[roffs + 2] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[roffs + 5] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[roffs + 6] = xstrdup(buf); if (notnullcc >= 0) { char *inp = rowppp[ii * nnncols + notnullcc]; isnullable = inp[0] != '0'; } sprintf(buf, "%d", isnullable); s->rows[roffs + 8] = xstrdup(buf); } } } } } } offs += nnrows; sqlite_free_table(rowpp); } } if (nullable == SQL_NO_NULLS) { for (i = 1; i < s->nrows; i++) { if (s->rows[i * s->ncols + 8][0] == '0') { int m, i1 = i + 1; for (m = 0; m < s->ncols; m++) { freep(&s->rows[i * s->ncols + m]); } size = s->ncols * sizeof (char *) * (s->nrows - i1); if (size > 0) { memmove(s->rows + i * s->ncols, s->rows + i1 * s->ncols, size); memset(s->rows + s->nrows * s->ncols, 0, s->ncols * sizeof (char *)); } s->nrows--; --i; } } } mkrowid: sqlite_free_table(rowp); sqlite_free_table(rowppp); if (s->nrows == 0) { s->rows[s->ncols + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[s->ncols + 1] = xstrdup("_ROWID_"); s->rows[s->ncols + 2] = xstrdup(stringify(SQL_INTEGER)); s->rows[s->ncols + 3] = xstrdup("integer"); s->rows[s->ncols + 4] = xstrdup("0"); s->rows[s->ncols + 5] = xstrdup("10"); s->rows[s->ncols + 6] = xstrdup("9"); s->rows[s->ncols + 7] = xstrdup(stringify(SQL_PC_PSEUDO)); s->rows[s->ncols + 8] = xstrdup(stringify(SQL_FALSE)); s->nrows = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvspecialcolumns(stmt, id, cat, catLen, schema, schemaLen, table, tableLen, scope, nullable); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumnsW(SQLHSTMT stmt, SQLUSMALLINT id, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvspecialcolumns(stmt, id, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, scope, nullable); done: HSTMT_UNLOCK(stmt); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif /** * Columns for result set of SQLForeignKeys(). */ static COL fkeySpec2[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; static COL fkeySpec3[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; /** * Internal retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ static SQLRETURN SQL_API drvforeignkeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, offs, namec, seqc, fromc, toc; PTRDIFF_T size; char **rowp, *errp = NULL, pname[512], fname[512]; sret = mkresultset(stmt, fkeySpec2, array_size(fkeySpec2), fkeySpec3, array_size(fkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } d = (DBC *) s->dbc; if ((!PKtable || PKtable[0] == '\0' || PKtable[0] == '%') && (!FKtable || FKtable[0] == '\0' || FKtable[0] == '%')) { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } size = 0; if (PKtable) { if (PKtableLen == SQL_NTS) { size = sizeof (pname) - 1; } else { size = min(sizeof (pname) - 1, PKtableLen); } strncpy(pname, (char *) PKtable, size); } pname[size] = '\0'; size = 0; if (FKtable) { if (FKtableLen == SQL_NTS) { size = sizeof (fname) - 1; } else { size = min(sizeof (fname) - 1, FKtableLen); } strncpy(fname, (char *) FKtable, size); } fname[size] = '\0'; if (fname[0] != '\0') { int plen; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA foreign_key_list('%q')", &rowp, &nrows, &ncols, &errp, fname); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } if (ncols * nrows <= 0) { nodata: sqlite_free_table(rowp); return SQL_SUCCESS; } size = 0; namec = findcol(rowp, ncols, "table"); seqc = findcol(rowp, ncols, "seq"); fromc = findcol(rowp, ncols, "from"); toc = findcol(rowp, ncols, "to"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { goto nodata; } plen = strlen(pname); for (i = 1; i <= nrows; i++) { char *ptab = unquote(rowp[i * ncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = rowp[i * ncols + namec]; char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowp[i * ncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(fname); s->rows[roffs + 7] = xstrdup(rowp[i * ncols + fromc]); sscanf(rowp[i * ncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } sqlite_free_table(rowp); } else { int nnrows, nncols, plen = strlen(pname); char **rowpp; ret = sqlite_get_table(d->sqlite, "select name from sqlite_master " "where type='table'", &rowp, &nrows, &ncols, &errp); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } if (ncols * nrows <= 0) { goto nodata; } size = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA foreign_key_list('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i]); if (ret != SQLITE_OK || nncols * nnrows <= 0) { sqlite_free_table(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { sqlite_free_table(rowpp); continue; } for (k = 1; k <= nnrows; k++) { char *ptab = unquote(rowpp[k * nncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } sqlite_free_table(rowpp); } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA foreign_key_list('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i]); if (ret != SQLITE_OK || nncols * nnrows <= 0) { sqlite_free_table(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { sqlite_free_table(rowpp); continue; } for (k = 1; k <= nnrows; k++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = unquote(rowpp[k * nncols + namec]); char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowpp[k * nncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(rowp[i]); s->rows[roffs + 7] = xstrdup(rowpp[k * nncols + fromc]); sscanf(rowpp[k * nncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } sqlite_free_table(rowpp); } sqlite_free_table(rowp); } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvforeignkeys(stmt, PKcatalog, PKcatalogLen, PKschema, PKschemaLen, PKtable, PKtableLen, FKcatalog, FKcatalogLen, FKschema, FKschemaLen, FKtable, FKtableLen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about primary/foreign keys (UNICODE version). * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeysW(SQLHSTMT stmt, SQLWCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLWCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLWCHAR *PKtable, SQLSMALLINT PKtableLen, SQLWCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLWCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLWCHAR *FKtable, SQLSMALLINT FKtableLen) { char *pc = NULL, *ps = NULL, *pt = NULL; char *fc = NULL, *fs = NULL, *ft = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (PKcatalog) { pc = uc_to_utf_c(PKcatalog, PKcatalogLen); if (!pc) { ret = nomem((STMT *) stmt); goto done; } } if (PKschema) { ps = uc_to_utf_c(PKschema, PKschemaLen); if (!ps) { ret = nomem((STMT *) stmt); goto done; } } if (PKtable) { pt = uc_to_utf_c(PKtable, PKtableLen); if (!pt) { ret = nomem((STMT *) stmt); goto done; } } if (FKcatalog) { fc = uc_to_utf_c(FKcatalog, FKcatalogLen); if (!fc) { ret = nomem((STMT *) stmt); goto done; } } if (FKschema) { fs = uc_to_utf_c(FKschema, FKschemaLen); if (!fs) { ret = nomem((STMT *) stmt); goto done; } } if (FKtable) { ft = uc_to_utf_c(FKtable, FKtableLen); if (!ft) { ret = nomem((STMT *) stmt); goto done; } } ret = drvforeignkeys(stmt, (SQLCHAR *) pc, SQL_NTS, (SQLCHAR *) ps, SQL_NTS, (SQLCHAR *) pt, SQL_NTS, (SQLCHAR *) fc, SQL_NTS, (SQLCHAR *) fs, SQL_NTS, (SQLCHAR *) ft, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(ft); uc_free(fs); uc_free(fc); uc_free(pt); uc_free(ps); uc_free(pc); return ret; } #endif /** * Start transaction when autocommit off * @param s statement pointer * @result ODBC error code */ static SQLRETURN starttran(STMT *s) { int ret = SQL_SUCCESS, rc; char *errp = NULL; DBC *d = (DBC *) s->dbc; if (!d->autocommit && !d->intrans && !d->trans_disable) { rc = sqlite_exec(d->sqlite, "BEGIN TRANSACTION", NULL, NULL, &errp); dbtracerc(d, rc, errp); if (rc != SQLITE_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); ret = SQL_ERROR; } else { d->intrans = 1; } if (errp) { sqlite_freemem(errp); errp = NULL; } } return ret; } /** * Internal commit or rollback transaction. * @param d database connection pointer * @param comptype type of transaction's end, SQL_COMMIT or SQL_ROLLBACK * @param force force action regardless of DBC's autocommit state * @result ODBC error code */ static SQLRETURN endtran(DBC *d, SQLSMALLINT comptype, int force) { int ret; char *sql, *errp = NULL; if (!d->sqlite) { setstatd(d, -1, "not connected", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if ((!force && d->autocommit) || !d->intrans) { return SQL_SUCCESS; } switch (comptype) { case SQL_COMMIT: sql = "COMMIT TRANSACTION"; goto doit; case SQL_ROLLBACK: sql = "ROLLBACK TRANSACTION"; doit: d->intrans = 0; ret = sqlite_exec(d->sqlite, sql, NULL, NULL, &errp); dbtracerc(d, ret, errp); if (ret != SQLITE_OK) { setstatd(d, ret, "%s", (*d->ov3) ? "HY000" : "S1000", errp ? errp : "transaction failed"); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_SUCCESS; } setstatd(d, -1, "invalid completion type", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ static SQLRETURN drvendtran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { DBC *d; int fail = 0; SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) ENV *e; #endif switch (type) { case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); if (handle == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) handle; ret = endtran(d, comptype, 0); HDBC_UNLOCK((SQLHDBC) handle); return ret; case SQL_HANDLE_ENV: if (handle == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) e = (ENV *) handle; if (e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif d = ((ENV *) handle)->dbcs; while (d) { ret = endtran(d, comptype, 0); if (ret != SQL_SUCCESS) { fail++; } d = d->next; } #if defined(_WIN32) || defined(_WIN64) LeaveCriticalSection(&e->cs); e->owner = 0; #endif return fail ? SQL_ERROR : SQL_SUCCESS; } return SQL_INVALID_HANDLE; } /** * Commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLEndTran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { return drvendtran(type, handle, comptype); } /** * Commit or rollback transaction. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param type SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLTransact(SQLHENV env, SQLHDBC dbc, SQLUSMALLINT type) { if (env != SQL_NULL_HENV) { return drvendtran(SQL_HANDLE_ENV, (SQLHANDLE) env, type); } return drvendtran(SQL_HANDLE_DBC, (SQLHANDLE) dbc, type); } /** * Function not implemented. */ SQLRETURN SQL_API SQLCopyDesc(SQLHDESC source, SQLHDESC target) { return SQL_ERROR; } #ifndef WINTERFACE /** * Translate SQL string. * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSql(SQLHSTMT stmt, SQLCHAR *sqlin, SQLINTEGER sqlinLen, SQLCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = strlen((char *) sqlin); } if (sql) { if (sqlMax > 0) { strncpy((char *) sql, (char *) sqlin, sqlMax - 1); sqlin[sqlMax - 1] = '\0'; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Translate SQL string (UNICODE version). * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSqlW(SQLHSTMT stmt, SQLWCHAR *sqlin, SQLINTEGER sqlinLen, SQLWCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = uc_strlen(sqlin); } if (sql) { if (sqlMax > 0) { uc_strncpy(sql, sqlin, sqlMax - 1); sqlin[sqlMax - 1] = 0; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedures(). */ static COL procSpec2[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; static COL procSpec3[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; #ifndef WINTERFACE /** * Retrieve information about stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProceduresW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedureColumns(). */ static COL procColSpec2[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PRECISION", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "SCALE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL procColSpec3[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_SIZE", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "BUFFER_LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "DECIMAL_DIGITS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NUM_PREC_RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; #ifndef WINTERFACE /** * Retrieve information about columns in result set of stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about columns in result * set of stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumnsW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Get information of HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len, SQLINTEGER *lenp) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_ERROR; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val) { *((SQLINTEGER *) val) = SQL_TRUE; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; case SQL_ATTR_ODBC_VERSION: if (val) { *((SQLINTEGER *) val) = e->ov3 ? SQL_OV_ODBC3 : SQL_OV_ODBC2; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Set information in HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val parameter buffer * @param len length of parameter * @result ODBC error code */ SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_SUCCESS; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val == (SQLPOINTER) SQL_TRUE) { ret = SQL_SUCCESS; } break; case SQL_ATTR_ODBC_VERSION: if (!val) { ret = SQL_ERROR; break; } if (val == (SQLPOINTER) SQL_OV_ODBC2) { e->ov3 = 0; ret = SQL_SUCCESS; } if (val == (SQLPOINTER) SQL_OV_ODBC3) { e->ov3 = 1; ret = SQL_SUCCESS; } break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Internal get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ static SQLRETURN drvgetdiagrec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { DBC *d = NULL; STMT *s = NULL; int len, naterr; char *logmsg, *sqlst; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (sqlstate) { sqlstate[0] = '\0'; } if (msg && buflen > 0) { msg[0] = '\0'; } if (msglen) { *msglen = 0; } if (nativeerr) { *nativeerr = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { ret = SQL_ERROR; goto done; } if (recno > 1) { ret = SQL_NO_DATA; goto done; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (nativeerr) { *nativeerr = naterr; } if (sqlstate) { strcpy((char *) sqlstate, sqlst); } if (msglen) { *msglen = len; } if (len >= buflen) { if (msg && buflen > 0) { strncpy((char *) msg, logmsg, buflen); msg[buflen - 1] = '\0'; logmsg[0] = '\0'; } } else if (msg) { strcpy((char *) msg, logmsg); logmsg[0] = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { return drvgetdiagrec(htype, handle, recno, sqlstate, nativeerr, msg, buflen, msglen); } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Get error message given handle (HENV, HDBC, or HSTMT) * (UNICODE version). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRecW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLWCHAR *sqlstate, SQLINTEGER *nativeerr, SQLWCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { char state[16]; SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagrec(htype, handle, recno, (SQLCHAR *) state, nativeerr, (SQLCHAR *) msg, buflen, &len); if (ret == SQL_SUCCESS) { if (sqlstate) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlstate, 6 * sizeof (SQLWCHAR)); } if (msg) { if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) msg, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(msg, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { msg[0] = 0; } } } else { /* estimated length !!! */ len *= sizeof (SQLWCHAR); } if (msglen) { *msglen = len; } } else if (ret == SQL_NO_DATA) { if (sqlstate) { sqlstate[0] = 0; } if (msg) { if (buflen > 0) { msg[0] = 0; } } if (msglen) { *msglen = 0; } } return ret; } #endif #endif /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ static SQLRETURN drvgetdiagfield(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { DBC *d = NULL; STMT *s = NULL; int len, naterr, strbuf = 1; char *logmsg, *sqlst, *clrmsg = NULL; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (stringlen) { *stringlen = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; d = (DBC *) s->dbc; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { switch (buflen) { case SQL_IS_POINTER: case SQL_IS_UINTEGER: case SQL_IS_INTEGER: case SQL_IS_USMALLINT: case SQL_IS_SMALLINT: strbuf = 0; break; default: ret = SQL_ERROR; goto done; } } if (recno > 1) { ret = SQL_NO_DATA; goto done; } switch (id) { case SQL_DIAG_CLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_SUBCLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == 'H' && sqlst[1] == 'Y') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == '2' || sqlst[0] == '0' || sqlst[0] == '4') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: logmsg = d->dsn ? d->dsn : "No DSN"; break; case SQL_DIAG_SQLSTATE: logmsg = sqlst; break; case SQL_DIAG_MESSAGE_TEXT: if (info) { clrmsg = logmsg; } break; case SQL_DIAG_NUMBER: naterr = 1; /* fall through */ case SQL_DIAG_NATIVE: len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (info) { *((SQLINTEGER *) info) = naterr; } ret = SQL_SUCCESS; goto done; case SQL_DIAG_DYNAMIC_FUNCTION: logmsg = ""; break; case SQL_DIAG_CURSOR_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = (s->isselect == 1 || s->isselect == -1) ? s->nrows : 0; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; case SQL_DIAG_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = s->isselect ? 0 : s->nrows; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; default: ret = SQL_ERROR; goto done; } if (info && buflen > 0) { ((char *) info)[0] = '\0'; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (stringlen) { *stringlen = len; } if (strbuf) { if (len >= buflen) { if (info && buflen > 0) { if (stringlen) { *stringlen = buflen - 1; } strncpy((char *) info, logmsg, buflen); ((char *) info)[buflen - 1] = '\0'; } } else if (info) { strcpy((char *) info, logmsg); } } if (clrmsg) { *clrmsg = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #ifndef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { return drvgetdiagfield(htype, handle, recno, id, info, buflen, stringlen); } #endif #ifdef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagFieldW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagfield(htype, handle, recno, id, info, buflen, &len); if (ret == SQL_SUCCESS) { if (info) { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) info, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(info, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { ((SQLWCHAR *) info)[0] = 0; } } } } else { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: len *= sizeof (SQLWCHAR); break; } } if (stringlen) { *stringlen = len; } } return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { STMT *s = (STMT *) stmt; DBC *d = (DBC *) s->dbc; SQLUINTEGER *uval = (SQLUINTEGER *) val; switch (attr) { case SQL_QUERY_TIMEOUT: *uval = 0; return SQL_SUCCESS; case SQL_ATTR_CURSOR_TYPE: *uval = s->curtype; return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: *uval = (s->curtype != SQL_CURSOR_FORWARD_ONLY) ? SQL_SCROLLABLE : SQL_NONSCROLLABLE; return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *uval = SQL_UNSPECIFIED; return SQL_SUCCESS; #endif case SQL_ATTR_ROW_NUMBER: if (s == d->vm_stmt) { *uval = (d->vm_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (d->vm_rownum + 1); } else { *uval = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: *uval = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *uval = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *uval = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *uval = s->rowset_size; return SQL_SUCCESS; /* Needed for some driver managers, but dummies for now */ case SQL_ATTR_IMP_ROW_DESC: case SQL_ATTR_APP_ROW_DESC: case SQL_ATTR_IMP_PARAM_DESC: case SQL_ATTR_APP_PARAM_DESC: *((SQLHDESC *) val) = (SQLHDESC) DEAD_MAGIC; return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: *((SQLUSMALLINT **) val) = s->row_status; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: *((SQLULEN **) val) = s->row_count; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: { STMT *s = (STMT *) stmt; *(SQLUINTEGER *) val = s->bkmrk ? SQL_UB_ON : SQL_UB_OFF; return SQL_SUCCESS; } case SQL_ATTR_PARAM_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->parm_bind_offs; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLUINTEGER *) val) = SQL_PARAM_BIND_BY_COLUMN; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: *((SQLUSMALLINT **) val) = s->parm_oper; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: *((SQLUSMALLINT **) val) = s->parm_status; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: *((SQLULEN **) val) = s->parm_proc; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: *((SQLUINTEGER *) val) = s->paramset_size; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: *(SQLUINTEGER *) val = s->bind_type; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->bind_offs; return SQL_SUCCESS; case SQL_ATTR_NOSCAN: *((SQLUINTEGER **) val) = SQL_NOSCAN_OFF; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; return SQL_SUCCESS; } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ static SQLRETURN drvsetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { STMT *s = (STMT *) stmt; #if defined(SQL_BIGINT) && defined(__WORDSIZE) && (__WORDSIZE == 64) SQLBIGINT uval; uval = (SQLBIGINT) val; #else SQLULEN uval; uval = (SQLULEN) val; #endif switch (attr) { case SQL_ATTR_CURSOR_TYPE: if (val == (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } if (val != (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY && val != (SQLPOINTER) SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: if (val == (SQLPOINTER) SQL_NONSCROLLABLE) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: if (val != (SQLPOINTER) SQL_ASYNC_ENABLE_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (val != (SQLPOINTER) SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: if (val != (SQLPOINTER) SQL_UNSPECIFIED) { goto e01s02; } return SQL_SUCCESS; #endif case SQL_ATTR_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: if (val != (SQLPOINTER) SQL_RD_ON && val != (SQLPOINTER) SQL_RD_OFF) { goto e01s02; } s->retr_data = uval; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (uval < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (uval > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * uval); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = uval; } return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: s->row_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: s->row_count = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: s->parm_bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: s->parm_bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: s->parm_oper = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: s->parm_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: s->parm_proc = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: if ((PTRDIFF_T) val < 1) { goto e01s02; } s->paramset_size = uval; s->paramset_count = 0; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: s->bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: s->bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: if (val != (SQLPOINTER) SQL_UB_OFF && val != (SQLPOINTER) SQL_UB_ON) { goto e01s02; } s->bkmrk = val == (SQLPOINTER) SQL_UB_ON; return SQL_SUCCESS; case SQL_ATTR_NOSCAN: if (val != (SQLPOINTER) SQL_NOSCAN_OFF) { goto e01s02; } return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: case SQL_ATTR_MAX_LENGTH: if (val != (SQLPOINTER) 1000000000) { goto e01s02; } return SQL_SUCCESS; } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && HAVE_UNIXODBC) || !defined(WINTERFACE) /** * Set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { STMT *s = (STMT *) stmt; DBC *d = (DBC *) s->dbc; SQLUINTEGER *ret = (SQLUINTEGER *) param; switch (opt) { case SQL_QUERY_TIMEOUT: *ret = 0; return SQL_SUCCESS; case SQL_CURSOR_TYPE: *ret = s->curtype; return SQL_SUCCESS; case SQL_ROW_NUMBER: if (s == d->vm_stmt) { *ret = (d->vm_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (d->vm_rownum + 1); } else { *ret = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: *ret = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *ret = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *ret = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *ret = s->rowset_size; return SQL_SUCCESS; case SQL_ATTR_NOSCAN: *ret = SQL_NOSCAN_OFF; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: case SQL_ATTR_MAX_LENGTH: *ret = 1000000000; return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ static SQLRETURN drvsetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLUINTEGER param) { STMT *s = (STMT *) stmt; switch (opt) { case SQL_CURSOR_TYPE: if (param == SQL_CURSOR_FORWARD_ONLY) { s->curtype = param; } else { s->curtype = SQL_CURSOR_STATIC; } if (param != SQL_CURSOR_FORWARD_ONLY && param != SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: if (param != SQL_ASYNC_ENABLE_OFF) { goto e01s02; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (param != SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; case SQL_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_RETRIEVE_DATA: if (param != SQL_RD_ON && param != SQL_RD_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } s->retr_data = (int) param; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (param < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (param > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * param); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = param; } return SQL_SUCCESS; case SQL_ATTR_NOSCAN: if (param != SQL_NOSCAN_OFF) { goto e01s02; } return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: case SQL_ATTR_MAX_LENGTH: if (param != 1000000000) { goto e01s02; } return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #endif /* * Internal set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ static SQLRETURN drvsetpos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { STMT *s = (STMT *) stmt; int rowp; if (op != SQL_POSITION) { return drvunimplstmt(stmt); } rowp = s->rowp + row - 1; if (!s->rows || row <= 0 || rowp < -1 || rowp >= s->nrows) { setstat(s, -1, "row out of range", (*s->ov3) ? "HY107" : "S1107"); return SQL_ERROR; } s->rowp = rowp; return SQL_SUCCESS; } /** * Set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetpos(stmt, row, op, lock); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt, SQLUSMALLINT concur, SQLLEN rowkeyset, SQLUSMALLINT rowset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #define strmak(dst, src, max, lenp) { \ int len = strlen(src); \ int cnt = min(len + 1, max); \ strncpy(dst, src, cnt); \ *lenp = (cnt > len) ? len : cnt; \ } /** * Internal return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ static SQLRETURN drvgetinfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { DBC *d; char dummyc[16]; SQLSMALLINT dummy; #if defined(_WIN32) || defined(_WIN64) char pathbuf[301], *drvname; #else static char drvname[] = #ifdef __OS2__ "SQLLODBC.DLL"; #else "sqliteodbc.so"; #endif #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (valMax) { valMax--; } if (!valLen) { valLen = &dummy; } if (!val) { val = dummyc; valMax = sizeof (dummyc) - 1; } switch (type) { case SQL_MAX_USER_NAME_LEN: *((SQLSMALLINT *) val) = 16; *valLen = sizeof (SQLSMALLINT); break; case SQL_USER_NAME: strmak(val, "", valMax, valLen); break; case SQL_DRIVER_ODBC_VER: #if 0 strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); #else strmak(val, "03.00", valMax, valLen); #endif break; case SQL_ACTIVE_CONNECTIONS: case SQL_ACTIVE_STATEMENTS: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_ASYNC_MODE case SQL_ASYNC_MODE: *((SQLUINTEGER *) val) = SQL_AM_NONE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_TABLE case SQL_CREATE_TABLE: *((SQLUINTEGER *) val) = SQL_CT_CREATE_TABLE | SQL_CT_COLUMN_DEFAULT | SQL_CT_COLUMN_CONSTRAINT | SQL_CT_CONSTRAINT_NON_DEFERRABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_VIEW case SQL_CREATE_VIEW: *((SQLUINTEGER *) val) = SQL_CV_CREATE_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DDL_INDEX case SQL_DDL_INDEX: *((SQLUINTEGER *) val) = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_TABLE case SQL_DROP_TABLE: *((SQLUINTEGER *) val) = SQL_DT_DROP_TABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_VIEW case SQL_DROP_VIEW: *((SQLUINTEGER *) val) = SQL_DV_DROP_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_INDEX_KEYWORDS case SQL_INDEX_KEYWORDS: *((SQLUINTEGER *) val) = SQL_IK_ALL; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DATA_SOURCE_NAME: strmak(val, d->dsn ? d->dsn : "", valMax, valLen); break; case SQL_DRIVER_NAME: #if defined(_WIN32) || defined(_WIN64) GetModuleFileName(hModule, pathbuf, sizeof (pathbuf)); drvname = strrchr(pathbuf, '\\'); if (drvname == NULL) { drvname = strrchr(pathbuf, '/'); } if (drvname == NULL) { drvname = pathbuf; } else { drvname++; } #endif strmak(val, drvname, valMax, valLen); break; case SQL_DRIVER_VER: strmak(val, DRIVER_VER_INFO, valMax, valLen); break; case SQL_FETCH_DIRECTION: *((SQLUINTEGER *) val) = SQL_FD_FETCH_NEXT | SQL_FD_FETCH_FIRST | SQL_FD_FETCH_LAST | SQL_FD_FETCH_PRIOR | SQL_FD_FETCH_ABSOLUTE; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_VER: strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); break; case SQL_ODBC_SAG_CLI_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSCC_NOT_COMPLIANT; *valLen = sizeof (SQLSMALLINT); break; case SQL_STANDARD_CLI_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_SCC_XOPEN_CLI_VERSION1; *valLen = sizeof (SQLUINTEGER); break; case SQL_SERVER_NAME: case SQL_DATABASE_NAME: strmak(val, d->dbname ? d->dbname : "", valMax, valLen); break; case SQL_SEARCH_PATTERN_ESCAPE: strmak(val, "\\", valMax, valLen); break; case SQL_ODBC_SQL_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSC_MINIMUM; *valLen = sizeof (SQLSMALLINT); break; case SQL_ODBC_API_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OAC_LEVEL1; *valLen = sizeof (SQLSMALLINT); break; case SQL_DBMS_NAME: strmak(val, "SQLite", valMax, valLen); break; case SQL_DBMS_VER: strmak(val, SQLITE_VERSION, valMax, valLen); break; case SQL_COLUMN_ALIAS: case SQL_NEED_LONG_DATA_LEN: strmak(val, "Y", valMax, valLen); break; case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: strmak(val, "N", valMax, valLen); break; #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "Y": "N", valMax, valLen); #else strmak(val, "N", valMax, valLen); #endif break; #endif case SQL_DATA_SOURCE_READ_ONLY: strmak(val, "N", valMax, valLen); break; #ifdef SQL_OJ_CAPABILITIES case SQL_OJ_CAPABILITIES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_MAX_IDENTIFIER_LEN case SQL_MAX_IDENTIFIER_LEN: *((SQLUSMALLINT *) val) = 255; *valLen = sizeof (SQLUSMALLINT); break; #endif case SQL_CONCAT_NULL_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CURSOR_COMMIT_BEHAVIOR: case SQL_CURSOR_ROLLBACK_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_PRESERVE; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_CURSOR_SENSITIVITY case SQL_CURSOR_SENSITIVITY: *((SQLUINTEGER *) val) = SQL_UNSPECIFIED; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DEFAULT_TXN_ISOLATION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: strmak(val, "Y", valMax, valLen); break; #endif case SQL_TXN_ISOLATION_OPTION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; case SQL_IDENTIFIER_CASE: *((SQLSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLSMALLINT); break; case SQL_IDENTIFIER_QUOTE_CHAR: strmak(val, "\"", valMax, valLen); break; case SQL_MAX_TABLE_NAME_LEN: case SQL_MAX_COLUMN_NAME_LEN: *((SQLSMALLINT *) val) = 255; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_CURSOR_NAME_LEN: *((SWORD *) val) = 255; *valLen = sizeof (SWORD); break; case SQL_MAX_PROCEDURE_NAME_LEN: *((SQLSMALLINT *) val) = 0; break; case SQL_MAX_QUALIFIER_NAME_LEN: case SQL_MAX_OWNER_NAME_LEN: *((SQLSMALLINT *) val) = 255; break; case SQL_OWNER_TERM: strmak(val, "", valMax, valLen); break; case SQL_PROCEDURE_TERM: strmak(val, "PROCEDURE", valMax, valLen); break; case SQL_QUALIFIER_NAME_SEPARATOR: strmak(val, ".", valMax, valLen); break; case SQL_QUALIFIER_TERM: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "CATALOG" : "", valMax, valLen); #else strmak(val, "", valMax, valLen); #endif break; case SQL_QUALIFIER_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLUINTEGER *) val) = d->xcelqrx ? (SQL_CU_DML_STATEMENTS | SQL_CU_INDEX_DEFINITION | SQL_CU_TABLE_DEFINITION) : 0; #else *((SQLUINTEGER *) val) = 0; #endif *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_CONCURRENCY: *((SQLUINTEGER *) val) = SQL_SCCO_LOCK; *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_OPTIONS: *((SQLUINTEGER *) val) = SQL_SO_STATIC | SQL_SO_FORWARD_ONLY; *valLen = sizeof (SQLUINTEGER); break; case SQL_TABLE_TERM: strmak(val, "TABLE", valMax, valLen); break; case SQL_TXN_CAPABLE: *((SQLSMALLINT *) val) = SQL_TC_ALL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CONVERT_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_SYSTEM_FUNCTIONS: case SQL_NUMERIC_FUNCTIONS: case SQL_STRING_FUNCTIONS: case SQL_TIMEDATE_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BIGINT: case SQL_CONVERT_BIT: case SQL_CONVERT_CHAR: case SQL_CONVERT_DATE: case SQL_CONVERT_DECIMAL: case SQL_CONVERT_DOUBLE: case SQL_CONVERT_FLOAT: case SQL_CONVERT_INTEGER: case SQL_CONVERT_LONGVARCHAR: case SQL_CONVERT_NUMERIC: case SQL_CONVERT_REAL: case SQL_CONVERT_SMALLINT: case SQL_CONVERT_TIME: case SQL_CONVERT_TIMESTAMP: case SQL_CONVERT_TINYINT: case SQL_CONVERT_VARCHAR: *((SQLUINTEGER *) val) = SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_BIGINT | SQL_CVT_DATE | SQL_CVT_TIME | SQL_CVT_TIMESTAMP; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BINARY: case SQL_CONVERT_VARBINARY: case SQL_CONVERT_LONGVARBINARY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_POSITIONED_STATEMENTS: case SQL_LOCK_TYPES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_BOOKMARK_PERSISTENCE: *((SQLUINTEGER *) val) = SQL_BP_SCROLL; *valLen = sizeof (SQLUINTEGER); break; case SQL_UNION: *((SQLUINTEGER *) val) = SQL_U_UNION | SQL_U_UNION_ALL; *valLen = sizeof (SQLUINTEGER); break; case SQL_OWNER_USAGE: case SQL_SUBQUERIES: case SQL_TIMEDATE_ADD_INTERVALS: case SQL_TIMEDATE_DIFF_INTERVALS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUOTED_IDENTIFIER_CASE: *((SQLUSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLUSMALLINT); break; case SQL_POS_OPERATIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ALTER_TABLE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CORRELATION_NAME: *((SQLSMALLINT *) val) = SQL_CN_DIFFERENT; *valLen = sizeof (SQLSMALLINT); break; case SQL_NON_NULLABLE_COLUMNS: *((SQLSMALLINT *) val) = SQL_NNC_NON_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_NULL_COLLATION: *((SQLSMALLINT *) val) = SQL_NC_START; *valLen = sizeof(SQLSMALLINT); break; case SQL_MAX_COLUMNS_IN_GROUP_BY: case SQL_MAX_COLUMNS_IN_ORDER_BY: case SQL_MAX_COLUMNS_IN_SELECT: case SQL_MAX_COLUMNS_IN_TABLE: case SQL_MAX_ROW_SIZE: case SQL_MAX_TABLES_IN_SELECT: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_BINARY_LITERAL_LEN: case SQL_MAX_CHAR_LITERAL_LEN: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_MAX_COLUMNS_IN_INDEX: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_INDEX_SIZE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof(SQLUINTEGER); break; #ifdef SQL_MAX_IDENTIFIER_LENGTH case SQL_MAX_IDENTIFIER_LENGTH: *((SQLUINTEGER *) val) = 255; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_MAX_STATEMENT_LEN: *((SQLUINTEGER *) val) = 16384; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUALIFIER_LOCATION: *((SQLSMALLINT *) val) = SQL_QL_START; *valLen = sizeof (SQLSMALLINT); break; case SQL_GETDATA_EXTENSIONS: *((SQLUINTEGER *) val) = SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER | SQL_GD_BOUND; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_SENSITIVITY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FILE_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLSMALLINT *) val) = d->xcelqrx ? SQL_FILE_CATALOG : SQL_FILE_NOT_SUPPORTED; #else *((SQLSMALLINT *) val) = SQL_FILE_NOT_SUPPORTED; #endif *valLen = sizeof (SQLSMALLINT); break; case SQL_GROUP_BY: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_KEYWORDS: strmak(val, "CREATE,SELECT,DROP,DELETE,UPDATE,INSERT," "INTO,VALUES,TABLE,INDEX,FROM,SET,WHERE,AND,CURRENT,OF", valMax, valLen); break; case SQL_SPECIAL_CHARACTERS: #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif strmak(val, "", valMax, valLen); break; case SQL_BATCH_SUPPORT: case SQL_BATCH_ROW_COUNT: case SQL_PARAM_ARRAY_ROW_COUNTS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE | SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: case SQL_STATIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = SQL_CA2_READ_ONLY_CONCURRENCY | SQL_CA2_LOCK_CONCURRENCY; *valLen = sizeof (SQLUINTEGER); break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: case SQL_KEYSET_CURSOR_ATTRIBUTES2: case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_INTERFACE_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_OIC_CORE; *valLen = sizeof (SQLUINTEGER); break; default: setstatd(d, -1, "unsupported info option %d", (*d->ov3) ? "HYC00" : "S1C00", type); return SQL_ERROR; } return SQL_SUCCESS; } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, valLen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfoW(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; SQLSMALLINT len = 0; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, &len); HDBC_UNLOCK(dbc); if (ret == SQL_SUCCESS) { SQLWCHAR *v = NULL; switch (type) { case SQL_USER_NAME: case SQL_DRIVER_ODBC_VER: case SQL_DATA_SOURCE_NAME: case SQL_DRIVER_NAME: case SQL_DRIVER_VER: case SQL_ODBC_VER: case SQL_SERVER_NAME: case SQL_DATABASE_NAME: case SQL_SEARCH_PATTERN_ESCAPE: case SQL_DBMS_NAME: case SQL_DBMS_VER: case SQL_NEED_LONG_DATA_LEN: case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_COLUMN_ALIAS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: case SQL_DATA_SOURCE_READ_ONLY: #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: #endif case SQL_IDENTIFIER_QUOTE_CHAR: case SQL_OWNER_TERM: case SQL_PROCEDURE_TERM: case SQL_QUALIFIER_NAME_SEPARATOR: case SQL_QUALIFIER_TERM: case SQL_TABLE_TERM: case SQL_KEYWORDS: case SQL_SPECIAL_CHARACTERS: #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #endif #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif if (val) { if (len > 0) { v = uc_from_utf((SQLCHAR *) val, len); if (v) { int vmax = valMax / sizeof (SQLWCHAR); uc_strncpy(val, v, vmax); v[len] = 0; len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (valMax >= sizeof (SQLWCHAR)) { *((SQLWCHAR *)val) = 0; } } } else { len *= sizeof (SQLWCHAR); } break; } if (valLen) { *valLen = len; } } return ret; } #endif /** * Return information about supported ODBC API functions. * @param dbc database connection handle * @param func function code to be retrieved * @param flags output indicator * @result ODBC error code */ SQLRETURN SQL_API SQLGetFunctions(SQLHDBC dbc, SQLUSMALLINT func, SQLUSMALLINT *flags) { int i; SQLUSMALLINT exists[100]; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } for (i = 0; i < array_size(exists); i++) { exists[i] = SQL_FALSE; } exists[SQL_API_SQLALLOCCONNECT] = SQL_TRUE; exists[SQL_API_SQLFETCH] = SQL_TRUE; exists[SQL_API_SQLALLOCENV] = SQL_TRUE; exists[SQL_API_SQLFREECONNECT] = SQL_TRUE; exists[SQL_API_SQLALLOCSTMT] = SQL_TRUE; exists[SQL_API_SQLFREEENV] = SQL_TRUE; exists[SQL_API_SQLBINDCOL] = SQL_TRUE; exists[SQL_API_SQLFREESTMT] = SQL_TRUE; exists[SQL_API_SQLCANCEL] = SQL_TRUE; exists[SQL_API_SQLGETCURSORNAME] = SQL_TRUE; exists[SQL_API_SQLCOLATTRIBUTES] = SQL_TRUE; exists[SQL_API_SQLNUMRESULTCOLS] = SQL_TRUE; exists[SQL_API_SQLCONNECT] = SQL_TRUE; exists[SQL_API_SQLPREPARE] = SQL_TRUE; exists[SQL_API_SQLDESCRIBECOL] = SQL_TRUE; exists[SQL_API_SQLROWCOUNT] = SQL_TRUE; exists[SQL_API_SQLDISCONNECT] = SQL_TRUE; exists[SQL_API_SQLSETCURSORNAME] = SQL_TRUE; exists[SQL_API_SQLERROR] = SQL_TRUE; exists[SQL_API_SQLSETPARAM] = SQL_TRUE; exists[SQL_API_SQLEXECDIRECT] = SQL_TRUE; exists[SQL_API_SQLTRANSACT] = SQL_TRUE; exists[SQL_API_SQLEXECUTE] = SQL_TRUE; exists[SQL_API_SQLBINDPARAMETER] = SQL_TRUE; exists[SQL_API_SQLGETTYPEINFO] = SQL_TRUE; exists[SQL_API_SQLCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLPARAMDATA] = SQL_TRUE; exists[SQL_API_SQLDRIVERCONNECT] = SQL_TRUE; exists[SQL_API_SQLPUTDATA] = SQL_TRUE; exists[SQL_API_SQLGETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLSETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETDATA] = SQL_TRUE; exists[SQL_API_SQLSETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETFUNCTIONS] = SQL_TRUE; exists[SQL_API_SQLSPECIALCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLGETINFO] = SQL_TRUE; exists[SQL_API_SQLSTATISTICS] = SQL_TRUE; exists[SQL_API_SQLGETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLTABLES] = SQL_TRUE; exists[SQL_API_SQLBROWSECONNECT] = SQL_FALSE; exists[SQL_API_SQLNUMPARAMS] = SQL_TRUE; exists[SQL_API_SQLCOLUMNPRIVILEGES] = SQL_FALSE; exists[SQL_API_SQLPARAMOPTIONS] = SQL_FALSE; exists[SQL_API_SQLDATASOURCES] = SQL_TRUE; exists[SQL_API_SQLPRIMARYKEYS] = SQL_TRUE; exists[SQL_API_SQLDESCRIBEPARAM] = SQL_TRUE; exists[SQL_API_SQLPROCEDURECOLUMNS] = SQL_TRUE; exists[SQL_API_SQLDRIVERS] = SQL_FALSE; exists[SQL_API_SQLPROCEDURES] = SQL_TRUE; exists[SQL_API_SQLEXTENDEDFETCH] = SQL_TRUE; exists[SQL_API_SQLSETPOS] = SQL_TRUE; exists[SQL_API_SQLFOREIGNKEYS] = SQL_TRUE; exists[SQL_API_SQLSETSCROLLOPTIONS] = SQL_TRUE; exists[SQL_API_SQLMORERESULTS] = SQL_TRUE; exists[SQL_API_SQLTABLEPRIVILEGES] = SQL_TRUE; exists[SQL_API_SQLNATIVESQL] = SQL_TRUE; if (func == SQL_API_ALL_FUNCTIONS) { memcpy(flags, exists, sizeof (exists)); } else if (func == SQL_API_ODBC3_ALL_FUNCTIONS) { int i; #define SET_EXISTS(x) \ flags[(x) >> 4] |= (1 << ((x) & 0xF)) #define CLR_EXISTS(x) \ flags[(x) >> 4] &= ~(1 << ((x) & 0xF)) memset(flags, 0, sizeof (SQLUSMALLINT) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE); for (i = 0; i < array_size(exists); i++) { if (exists[i]) { flags[i >> 4] |= (1 << (i & 0xF)); } } SET_EXISTS(SQL_API_SQLALLOCHANDLE); SET_EXISTS(SQL_API_SQLFREEHANDLE); SET_EXISTS(SQL_API_SQLGETSTMTATTR); SET_EXISTS(SQL_API_SQLSETSTMTATTR); SET_EXISTS(SQL_API_SQLGETCONNECTATTR); SET_EXISTS(SQL_API_SQLSETCONNECTATTR); SET_EXISTS(SQL_API_SQLGETENVATTR); SET_EXISTS(SQL_API_SQLSETENVATTR); SET_EXISTS(SQL_API_SQLCLOSECURSOR); SET_EXISTS(SQL_API_SQLBINDPARAM); #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ SET_EXISTS(SQL_API_SQLGETDIAGREC); #endif SET_EXISTS(SQL_API_SQLFETCHSCROLL); SET_EXISTS(SQL_API_SQLENDTRAN); } else { if (func < array_size(exists)) { *flags = exists[func]; } else { switch (func) { case SQL_API_SQLALLOCHANDLE: case SQL_API_SQLFREEHANDLE: case SQL_API_SQLGETSTMTATTR: case SQL_API_SQLSETSTMTATTR: case SQL_API_SQLGETCONNECTATTR: case SQL_API_SQLSETCONNECTATTR: case SQL_API_SQLGETENVATTR: case SQL_API_SQLSETENVATTR: case SQL_API_SQLCLOSECURSOR: case SQL_API_SQLBINDPARAM: #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ case SQL_API_SQLGETDIAGREC: #endif case SQL_API_SQLFETCHSCROLL: case SQL_API_SQLENDTRAN: *flags = SQL_TRUE; break; default: *flags = SQL_FALSE; } } } return SQL_SUCCESS; } /** * Internal allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ static SQLRETURN drvallocenv(SQLHENV *env) { ENV *e; if (env == NULL) { return SQL_INVALID_HANDLE; } e = (ENV *) xmalloc(sizeof (ENV)); if (e == NULL) { *env = SQL_NULL_HENV; return SQL_ERROR; } e->magic = ENV_MAGIC; e->ov3 = 0; #if defined(_WIN32) || defined(_WIN64) InitializeCriticalSection(&e->cs); e->owner = 0; #endif e->dbcs = NULL; *env = (SQLHENV) e; return SQL_SUCCESS; } /** * Allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocEnv(SQLHENV *env) { return drvallocenv(env); } /** * Internal free HENV. * @param env environment handle * @result ODBC error code */ static SQLRETURN drvfreeenv(SQLHENV env) { ENV *e; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (e->magic != ENV_MAGIC) { return SQL_SUCCESS; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif if (e->dbcs) { #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return SQL_ERROR; } e->magic = DEAD_MAGIC; #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); DeleteCriticalSection(&e->cs); #endif xfree(e); return SQL_SUCCESS; } /** * Free HENV. * @param env environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeEnv(SQLHENV env) { return drvfreeenv(env); } /** * Internal allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ static SQLRETURN drvallocconnect(SQLHENV env, SQLHDBC *dbc) { DBC *d; ENV *e; const char *verstr; int maj = 0, min = 0, lev = 0; if (dbc == NULL) { return SQL_ERROR; } d = (DBC *) xmalloc(sizeof (DBC)); if (d == NULL) { *dbc = SQL_NULL_HDBC; return SQL_ERROR; } memset(d, 0, sizeof (DBC)); d->curtype = SQL_CURSOR_STATIC; #if (HAVE_LIBVERSION) verstr = sqlite_libversion(); #else verstr = sqlite_version; #endif sscanf(verstr, "%d.%d.%d", &maj, &min, &lev); d->version = verinfo(maj & 0xFF, min & 0xFF, lev & 0xFF); if (d->version < verinfo(2, 8, 0)) { xfree(d); return SQL_ERROR; } d->ov3 = &d->ov3val; e = (ENV *) env; #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); } #endif if (e->magic == ENV_MAGIC) { DBC *n, *p; d->env = e; d->ov3 = &e->ov3; p = NULL; n = e->dbcs; while (n) { p = n; n = n->next; } if (p) { p->next = d; } else { e->dbcs = d; } } #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { e->owner = 0; LeaveCriticalSection(&e->cs); } #endif d->autocommit = 1; d->magic = DBC_MAGIC; *dbc = (SQLHDBC) d; drvgetgpps(d); return SQL_SUCCESS; } /** * Allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC *dbc) { return drvallocconnect(env, dbc); } /** * Internal free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvfreeconnect(SQLHDBC dbc) { DBC *d; ENV *e; SQLRETURN ret = SQL_ERROR; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } e = d->env; if (e && e->magic == ENV_MAGIC) { #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif } else { e = NULL; } if (d->sqlite) { setstatd(d, -1, "not disconnected", (*d->ov3) ? "HY000" : "S1000"); goto done; } while (d->stmt) { freestmt((HSTMT) d->stmt); } if (e && e->magic == ENV_MAGIC) { DBC *n, *p; p = NULL; n = e->dbcs; while (n) { if (n == d) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = d->next; } else { e->dbcs = d->next; } } } drvrelgpps(d); d->magic = DEAD_MAGIC; #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) if (d->trace) { fclose(d->trace); } #endif xfree(d); ret = SQL_SUCCESS; done: #if defined(_WIN32) || defined(_WIN64) if (e) { e->owner = 0; LeaveCriticalSection(&e->cs); } #endif return ret; } /** * Free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeConnect(SQLHDBC dbc) { return drvfreeconnect(dbc); } /** * Internal get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!val) { val = (SQLPOINTER) &dummy; } if (!buflen) { buflen = &dummy; } switch (attr) { case SQL_ATTR_CONNECTION_DEAD: *((SQLINTEGER *) val) = d->sqlite ? SQL_CD_FALSE : SQL_CD_TRUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ACCESS_MODE: *((SQLINTEGER *) val) = SQL_MODE_READ_WRITE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_AUTOCOMMIT: *((SQLINTEGER *) val) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_LOGIN_TIMEOUT: *((SQLINTEGER *) val) = 100; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ODBC_CURSORS: *((SQLINTEGER *) val) = SQL_CUR_USE_DRIVER; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PACKET_SIZE: *((SQLINTEGER *) val) = 16384; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TXN_ISOLATION: *((SQLINTEGER *) val) = SQL_TXN_SERIALIZABLE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TRACEFILE: case SQL_ATTR_CURRENT_CATALOG: case SQL_ATTR_TRANSLATE_LIB: *((SQLCHAR *) val) = 0; *buflen = 0; break; case SQL_ATTR_TRACE: case SQL_ATTR_QUIET_MODE: case SQL_ATTR_TRANSLATE_OPTION: case SQL_ATTR_KEYSET_SIZE: case SQL_ATTR_QUERY_TIMEOUT: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLUINTEGER *) val) = SQL_PARAM_BIND_BY_COLUMN; *buflen = sizeof (SQLUINTEGER); break; case SQL_ATTR_ROW_BIND_TYPE: *((SQLUINTEGER *) val) = SQL_BIND_BY_COLUMN; *buflen = sizeof (SQLUINTEGER); break; case SQL_ATTR_USE_BOOKMARKS: *((SQLINTEGER *) val) = SQL_UB_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ASYNC_ENABLE: *((SQLINTEGER *) val) = SQL_ASYNC_ENABLE_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_NOSCAN: *((SQLINTEGER *) val) = SQL_NOSCAN_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CONCURRENCY: *((SQLINTEGER *) val) = SQL_CONCUR_LOCK; *buflen = sizeof (SQLINTEGER); break; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *((SQLINTEGER *) val) = SQL_UNSPECIFIED; *buflen = sizeof (SQLINTEGER); break; #endif case SQL_ATTR_SIMULATE_CURSOR: *((SQLINTEGER *) val) = SQL_SC_NON_UNIQUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_MAX_ROWS: case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CURSOR_TYPE: *((SQLINTEGER *) val) = d->curtype; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_RETRIEVE_DATA: *((SQLINTEGER *) val) = SQL_RD_ON; *buflen = sizeof (SQLINTEGER); break; default: setstatd(d, -1, "unsupported connect attribute %d", (*d->ov3) ? "HYC00" : "S1C00", (int) attr); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); if (SQL_SUCCEEDED(ret)) { switch (attr) { case SQL_ATTR_TRACEFILE: case SQL_ATTR_CURRENT_CATALOG: case SQL_ATTR_TRANSLATE_LIB: if (val && bufmax >= sizeof (SQLWCHAR)) { *(SQLWCHAR *) val = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ static SQLRETURN drvsetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (attr) { case SQL_AUTOCOMMIT: d->autocommit = val == (SQLPOINTER) SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { vm_end(d->vm_stmt); } return SQL_SUCCESS; default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!param) { param = (SQLPOINTER) &dummy; } switch (opt) { case SQL_ACCESS_MODE: *((SQLINTEGER *) param) = SQL_MODE_READ_WRITE; break; case SQL_AUTOCOMMIT: *((SQLINTEGER *) param) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; break; case SQL_LOGIN_TIMEOUT: *((SQLINTEGER *) param) = 100; break; case SQL_ODBC_CURSORS: *((SQLINTEGER *) param) = SQL_CUR_USE_DRIVER; break; case SQL_PACKET_SIZE: *((SQLINTEGER *) param) = 16384; break; case SQL_TXN_ISOLATION: *((SQLINTEGER *) param) = SQL_TXN_SERIALIZABLE; break; case SQL_OPT_TRACEFILE: case SQL_CURRENT_QUALIFIER: case SQL_TRANSLATE_DLL: *((SQLCHAR *) param) = 0; break; case SQL_OPT_TRACE: case SQL_QUIET_MODE: case SQL_KEYSET_SIZE: case SQL_QUERY_TIMEOUT: case SQL_BIND_TYPE: case SQL_TRANSLATE_OPTION: *((SQLINTEGER *) param) = 0; break; case SQL_USE_BOOKMARKS: *((SQLINTEGER *) param) = SQL_UB_OFF; break; case SQL_ASYNC_ENABLE: *((SQLINTEGER *) param) = SQL_ASYNC_ENABLE_OFF; break; case SQL_NOSCAN: *((SQLINTEGER *) param) = SQL_NOSCAN_OFF; break; case SQL_CONCURRENCY: *((SQLINTEGER *) param) = SQL_CONCUR_LOCK; break; case SQL_SIMULATE_CURSOR: *((SQLINTEGER *) param) = SQL_SC_NON_UNIQUE; break; case SQL_ROWSET_SIZE: case SQL_MAX_ROWS: case SQL_MAX_LENGTH: *((SQLINTEGER *) param) = 1000000000; break; case SQL_CURSOR_TYPE: *((SQLINTEGER *) param) = d->curtype; break; case SQL_RETRIEVE_DATA: *((SQLINTEGER *) param) = SQL_RD_ON; break; default: setstatd(d, -1, "unsupported connect option %d", (*d->ov3) ? "HYC00" : "S1C00", opt); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect option of HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); if (SQL_SUCCEEDED(ret)) { switch (opt) { case SQL_OPT_TRACEFILE: case SQL_CURRENT_QUALIFIER: case SQL_TRANSLATE_DLL: if (param) { *(SQLWCHAR *) param = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ static SQLRETURN drvsetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLUINTEGER param) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (opt) { case SQL_AUTOCOMMIT: d->autocommit = param == SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { vm_end(d->vm_stmt); } break; default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set option on HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64) && !defined(__OS2__)) /** * Handling of SQLConnect() connection attributes * for standalone operation without driver manager. * @param dsn DSN/driver connection string * @param attr attribute string to be retrieved * @param out output buffer * @param outLen length of output buffer * @result true or false */ static int getdsnattr(char *dsn, char *attr, char *out, int outLen) { char *str = dsn, *start; int len = strlen(attr); while (*str) { while (*str && *str == ';') { ++str; } start = str; if ((str = strchr(str, '=')) == NULL) { return 0; } if (str - start == len && strncasecmp(start, attr, len) == 0) { start = ++str; while (*str && *str != ';') { ++str; } len = min(outLen - 1, str - start); strncpy(out, start, len); out[len] = '\0'; return 1; } while (*str && *str != ';') { ++str; } } return 0; } #endif /** * Internal connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvconnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen) { DBC *d; int len; char buf[SQL_MAX_MESSAGE_LENGTH], dbname[SQL_MAX_MESSAGE_LENGTH / 4]; char busy[SQL_MAX_MESSAGE_LENGTH / 4]; char sflag[32], ntflag[32], nwflag[32], lnflag[32]; #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) char tracef[SQL_MAX_MESSAGE_LENGTH]; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->sqlite != NULL) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (dsnLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(sizeof (buf) - 1, dsnLen); } if (dsn != NULL) { strncpy(buf, (char *) dsn, len); } buf[len] = '\0'; if (buf[0] == '\0') { setstatd(d, -1, "invalid DSN", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } busy[0] = '\0'; dbname[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "database", dbname, sizeof (dbname)); if (dbname[0] == '\0') { strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } getdsnattr(buf, "timeout", busy, sizeof (busy)); sflag[0] = '\0'; ntflag[0] = '\0'; nwflag[0] = '\0'; lnflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); getdsnattr(buf, "nowchar", nwflag, sizeof (nwflag)); getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); #else SQLGetPrivateProfileString(buf, "timeout", "100000", busy, sizeof (busy), ODBC_INI); SQLGetPrivateProfileString(buf, "database", "", dbname, sizeof (dbname), ODBC_INI); SQLGetPrivateProfileString(buf, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); SQLGetPrivateProfileString(buf, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); SQLGetPrivateProfileString(buf, "nowchar", "", nwflag, sizeof (nwflag), ODBC_INI); SQLGetPrivateProfileString(buf, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); #endif #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) tracef[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #else SQLGetPrivateProfileString(buf, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); #endif if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } #endif d->nowchar = getbool(nwflag); d->longnames = getbool(lnflag); return dbopen(d, dbname, (char *) dsn, sflag, ntflag, busy); } #ifndef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pass password string or NULL * @param passLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen, SQLCHAR *uid, SQLSMALLINT uidLen, SQLCHAR *pass, SQLSMALLINT passLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvconnect(dbc, dsn, dsnLen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pass password string or NULL * @param passLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnectW(SQLHDBC dbc, SQLWCHAR *dsn, SQLSMALLINT dsnLen, SQLWCHAR *uid, SQLSMALLINT uidLen, SQLWCHAR *pass, SQLSMALLINT passLen) { char *dsna = NULL; SQLRETURN ret; HDBC_LOCK(dbc); if (dsn) { dsna = uc_to_utf_c(dsn, dsnLen); if (!dsna) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } } ret = drvconnect(dbc, (SQLCHAR *) dsna, SQL_NTS); HDBC_UNLOCK(dbc); uc_free(dsna); return ret; } #endif /** * Internal disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvdisconnect(SQLHDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->intrans) { setstatd(d, -1, "incomplete transaction", "25000"); return SQL_ERROR; } if (d->vm_stmt) { vm_end(d->vm_stmt); } if (d->sqlite) { sqlite_close(d->sqlite); d->sqlite = NULL; } freep(&d->dbname); freep(&d->dsn); return SQL_SUCCESS; } /** * Disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLDisconnect(SQLHDBC dbc) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdisconnect(dbc); HDBC_UNLOCK(dbc); return ret; } #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64) && !defined(__OS2__)) /** * Internal standalone (w/o driver manager) database connect. * @param dbc database connection handle * @param hwnd dummy window handle or NULL * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { DBC *d; int len; char buf[SQL_MAX_MESSAGE_LENGTH * 6], dbname[SQL_MAX_MESSAGE_LENGTH]; char dsn[SQL_MAX_MESSAGE_LENGTH / 4], busy[SQL_MAX_MESSAGE_LENGTH / 4]; char sflag[32], ntflag[32], lnflag[32]; #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) char tracef[SQL_MAX_MESSAGE_LENGTH]; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } if (drvcompl != SQL_DRIVER_COMPLETE && drvcompl != SQL_DRIVER_COMPLETE_REQUIRED && drvcompl != SQL_DRIVER_PROMPT && drvcompl != SQL_DRIVER_NOPROMPT) { return SQL_NO_DATA; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (connInLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(connInLen, sizeof (buf) - 1); } if (connIn != NULL) { strncpy(buf, (char *) connIn, len); } buf[len] = '\0'; if (!buf[0]) { setstatd(d, -1, "invalid connect attributes", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } dsn[0] = '\0'; getdsnattr(buf, "DSN", dsn, sizeof (dsn)); /* special case: connIn is sole DSN value without keywords */ if (!dsn[0] && !strchr(buf, ';') && !strchr(buf, '=')) { strncpy(dsn, buf, sizeof (dsn) - 1); dsn[sizeof (dsn) - 1] = '\0'; } busy[0] = '\0'; getdsnattr(buf, "timeout", busy, sizeof (busy)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !busy[0]) { SQLGetPrivateProfileString(dsn, "timeout", "100000", busy, sizeof (busy), ODBC_INI); } #endif dbname[0] = '\0'; getdsnattr(buf, "database", dbname, sizeof (dbname)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !dbname[0]) { SQLGetPrivateProfileString(dsn, "database", "", dbname, sizeof (dbname), ODBC_INI); } #endif sflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !sflag[0]) { SQLGetPrivateProfileString(dsn, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); } #endif ntflag[0] = '\0'; getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !ntflag[0]) { SQLGetPrivateProfileString(dsn, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); } #endif lnflag[0] = '\0'; getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !lnflag[0]) { SQLGetPrivateProfileString(dsn, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); } #endif if (!dbname[0] && !dsn[0]) { strcpy(dsn, "SQLite"); strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) tracef[0] = '\0'; getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !tracef[0]) { SQLGetPrivateProfileString(dsn, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); } #endif #endif if (connOut || connOutLen) { int count; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) "DSN=%s;Database=%s;StepAPI=%s;NoTXN=%s;" "Timeout=%s;LongNames=%s;Tracefile=%s", dsn, dbname, sflag, ntflag, busy, lnflag, tracef #else "DSN=%s;Database=%s;StepAPI=%s;NoTXN=%s;" "Timeout=%s;LongNames=%s", dsn, dbname, sflag, ntflag, busy, lnflag #endif ); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } #endif d->longnames = getbool(lnflag); return dbopen(d, dbname, dsn, sflag, ntflag, busy); } #endif /** * Internal free function for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN freestmt(SQLHSTMT stmt) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; freeresult(s, 1); freep(&s->query); d = (DBC *) s->dbc; if (d && d->magic == DBC_MAGIC) { STMT *p, *n; p = NULL; n = d->stmt; while (n) { if (n == s) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = s->next; } else { d->stmt = s->next; } } } freeparams(s); freep(&s->bindparms); if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); s->rowset_size = 1; s->row_status0 = &s->row_status1; } xfree(s); return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC (driver internal version). * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ static SQLRETURN drvallocstmt(SQLHDBC dbc, SQLHSTMT *stmt) { DBC *d; STMT *s, *sl, *pl; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC || stmt == NULL) { return SQL_INVALID_HANDLE; } s = (STMT *) xmalloc(sizeof (STMT)); if (s == NULL) { *stmt = SQL_NULL_HSTMT; return SQL_ERROR; } *stmt = (SQLHSTMT) s; memset(s, 0, sizeof (STMT)); s->dbc = dbc; s->ov3 = d->ov3; s->nowchar[0] = d->nowchar; s->nowchar[1] = 0; s->longnames = d->longnames; s->curtype = d->curtype; s->row_status0 = &s->row_status1; s->rowset_size = 1; s->retr_data = SQL_RD_ON; s->bind_type = SQL_BIND_BY_COLUMN; s->bind_offs = NULL; s->paramset_size = 1; s->parm_bind_type = SQL_PARAM_BIND_BY_COLUMN; #ifdef _WIN64 sprintf((char *) s->cursorname, "CUR_%I64X", (SQLUBIGINT) *stmt); #else sprintf((char *) s->cursorname, "CUR_%016lX", (long) *stmt); #endif sl = d->stmt; pl = NULL; while (sl) { pl = sl; sl = sl->next; } if (pl) { pl->next = s; } else { d->stmt = s; } return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC. * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocStmt(SQLHDBC dbc, SQLHSTMT *stmt) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvallocstmt(dbc, stmt); HDBC_UNLOCK(dbc); return ret; } /** * Internal function to perform certain kinds of free/close on STMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ static SQLRETURN drvfreestmt(SQLHSTMT stmt, SQLUSMALLINT opt) { STMT *s; SQLRETURN ret = SQL_SUCCESS; SQLHDBC dbc; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_LOCK(stmt); s = (STMT *) stmt; dbc = s->dbc; switch (opt) { case SQL_RESET_PARAMS: freeparams(s); break; case SQL_UNBIND: unbindcols(s); break; case SQL_CLOSE: vm_end_if(s); freeresult(s, 0); break; case SQL_DROP: vm_end_if(s); ret = freestmt(stmt); break; default: setstat(s, -1, "unsupported option", (*s->ov3) ? "HYC00" : "S1C00"); ret = SQL_ERROR; break; } HDBC_UNLOCK(dbc); return ret; } /** * Free HSTMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT opt) { return drvfreestmt(stmt, opt); } /** * Cancel HSTMT closing cursor. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) { if (stmt != SQL_NULL_HSTMT) { DBC *d = (DBC *) ((STMT *) stmt)->dbc; #if defined(_WIN32) || defined(_WIN64) /* interrupt when other thread owns critical section */ int i; for (i = 0; i < 2; i++) { if (d->magic == DBC_MAGIC && d->env && d->env->magic == ENV_MAGIC && d->env->owner != GetCurrentThreadId() && d->env->owner != 0) { d->busyint = 1; sqlite_interrupt(d->sqlite); } Sleep(1); } #else if (d->magic == DBC_MAGIC) { d->busyint = 1; sqlite_interrupt(d->sqlite); } #endif } return drvfreestmt(stmt, SQL_CLOSE); } /** * Internal function to get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ static SQLRETURN drvgetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (lenp && !cursor) { *lenp = strlen((char *) s->cursorname); return SQL_SUCCESS; } if (cursor) { if (buflen > 0) { strncpy((char *) cursor, (char *) s->cursorname, buflen - 1); cursor[buflen - 1] = '\0'; } if (lenp) { *lenp = min(strlen((char *) s->cursorname), buflen - 1); } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetcursorname(stmt, cursor, buflen, lenp); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get cursor name of STMT (UNICODE version). * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvgetcursorname(stmt, (SQLCHAR *) cursor, buflen, &len); if (ret == SQL_SUCCESS) { SQLWCHAR *c = NULL; if (cursor) { c = uc_from_utf((SQLCHAR *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } c[len] = 0; len = uc_strlen(c); if (buflen > 0) { uc_strncpy(cursor, c, buflen - 1); cursor[buflen - 1] = 0; } uc_free(c); } if (lenp) { *lenp = min(len, buflen - 1); } } done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal function to set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ static SQLRETURN drvsetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!cursor || !((cursor[0] >= 'A' && cursor[0] <= 'Z') || (cursor[0] >= 'a' && cursor[0] <= 'z'))) { setstat(s, -1, "invalid cursor name", (*s->ov3) ? "HYC00" : "S1C00"); return SQL_ERROR; } if (len == SQL_NTS) { len = sizeof (s->cursorname) - 1; } else { len = min(sizeof (s->cursorname) - 1, len); } strncpy((char *) s->cursorname, (char *) cursor, len); s->cursorname[len] = '\0'; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetcursorname(stmt, cursor, len); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set cursor name on STMT (UNICODE version). * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT len) { char *c = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cursor) { c = uc_to_utf_c(cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } } ret = drvsetcursorname(stmt, (SQLCHAR *) c, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(c); return ret; } #endif /** * Close open cursor. * @param stmt statement handle * @return ODBC error code */ SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt) { return drvfreestmt(stmt, SQL_CLOSE); } /** * Allocate a HENV, HDBC, or HSTMT handle. * @param type handle type * @param input input handle (HENV, HDBC) * @param output pointer to output handle (HENV, HDBC, HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE input, SQLHANDLE *output) { SQLRETURN ret; switch (type) { case SQL_HANDLE_ENV: ret = drvallocenv((SQLHENV *) output); if (ret == SQL_SUCCESS) { ENV *e = (ENV *) *output; if (e && e->magic == ENV_MAGIC) { e->ov3 = 1; } } return ret; case SQL_HANDLE_DBC: return drvallocconnect((SQLHENV) input, (SQLHDBC *) output); case SQL_HANDLE_STMT: HDBC_LOCK((SQLHDBC) input); ret = drvallocstmt((SQLHDBC) input, (SQLHSTMT *) output); HDBC_UNLOCK((SQLHDBC) input); return ret; } return SQL_ERROR; } /** * Free a HENV, HDBC, or HSTMT handle. * @param type handle type * @param h handle (HENV, HDBC, or HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE h) { switch (type) { case SQL_HANDLE_ENV: return drvfreeenv((SQLHENV) h); case SQL_HANDLE_DBC: return drvfreeconnect((SQLHDBC) h); case SQL_HANDLE_STMT: return drvfreestmt((SQLHSTMT) h, SQL_DROP); } return SQL_ERROR; } /** * Free dynamically allocated column descriptions of STMT. * @param s statement pointer */ static void freedyncols(STMT *s) { if (s->dyncols) { int i; for (i = 0; i < s->dcols; i++) { freep(&s->dyncols[i].typename); } if (s->cols == s->dyncols) { s->cols = NULL; s->ncols = 0; } freep(&s->dyncols); } s->dcols = 0; } /** * Free statement's result. * @param s statement pointer * @param clrcols flag to clear column information * * The result rows are free'd using the rowfree function pointer. * If clrcols is greater than zero, then column bindings and dynamic column * descriptions are free'd. * If clrcols is less than zero, then dynamic column descriptions are free'd. */ static void freeresult(STMT *s, int clrcols) { #if (HAVE_ENCDEC) freep(&s->bincache); freep(&s->hexcache); s->bincell = NULL; #endif if (s->rows) { if (s->rowfree) { s->rowfree(s->rows); s->rowfree = NULL; } s->rows = NULL; } s->nrows = -1; if (clrcols > 0) { freep(&s->bindcols); s->nbindcols = 0; } if (clrcols) { freedyncols(s); s->cols = NULL; s->ncols = 0; s->nowchar[1] = 0; } } /** * Reset bound columns to unbound state. * @param s statement pointer */ static void unbindcols(STMT *s) { int i; s->bkmrkcol.type = -1; s->bkmrkcol.max = 0; s->bkmrkcol.lenp = NULL; s->bkmrkcol.valp = NULL; s->bkmrkcol.index = 0; s->bkmrkcol.offs = 0; for (i = 0; s->bindcols && i < s->nbindcols; i++) { s->bindcols[i].type = -1; s->bindcols[i].max = 0; s->bindcols[i].lenp = NULL; s->bindcols[i].valp = NULL; s->bindcols[i].index = i; s->bindcols[i].offs = 0; } } /** * Reallocate space for bound columns. * @param s statement pointer * @param ncols number of columns * @result ODBC error code */ static SQLRETURN mkbindcols(STMT *s, int ncols) { if (s->bindcols) { if (s->nbindcols < ncols) { int i; BINDCOL *bindcols = xrealloc(s->bindcols, ncols * sizeof (BINDCOL)); if (!bindcols) { return nomem(s); } for (i = s->nbindcols; i < ncols; i++) { bindcols[i].type = -1; bindcols[i].max = 0; bindcols[i].lenp = NULL; bindcols[i].valp = NULL; bindcols[i].index = i; bindcols[i].offs = 0; } s->bindcols = bindcols; s->nbindcols = ncols; } } else if (ncols > 0) { s->bindcols = (BINDCOL *) xmalloc(ncols * sizeof (BINDCOL)); if (!s->bindcols) { return nomem(s); } s->nbindcols = ncols; unbindcols(s); } return SQL_SUCCESS; } /** * Internal function to retrieve row data, used by SQLFetch() and * friends and SQLGetData(). * @param s statement pointer * @param col column number, 0 based * @param otype output data type * @param val output buffer * @param len length of output buffer * @param lenp output length * @param partial flag for partial data retrieval * @result ODBC error code */ static SQLRETURN getrowdata(STMT *s, SQLUSMALLINT col, SQLSMALLINT otype, SQLPOINTER val, SQLLEN len, SQLLEN *lenp, int partial) { char **data, valdummy[16]; SQLLEN dummy; SQLINTEGER *ilenp = NULL; int valnull = 0; int type = otype; SQLRETURN sret = SQL_NO_DATA; if (!lenp) { lenp = &dummy; } /* workaround for JDK 1.7.0 on x86_64 */ if (((SQLINTEGER *) lenp) + 1 == (SQLINTEGER *) val) { ilenp = (SQLINTEGER *) lenp; lenp = &dummy; } if (col >= s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!s->rows) { *lenp = SQL_NULL_DATA; goto done; } if (s->rowp < 0 || s->rowp >= s->nrows) { *lenp = SQL_NULL_DATA; goto done; } if (s->retr_data != SQL_RD_ON) { return SQL_SUCCESS; } type = mapdeftype(type, s->cols[col].type, s->cols[col].nosign ? 1 : 0, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 3 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && otype == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif #if (HAVE_ENCDEC) if (type == SQL_C_CHAR) { switch (s->cols[col].type) { case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: type = SQL_C_BINARY; break; } #ifdef WCHARSUPPORT } else if (type == SQL_C_WCHAR) { switch (s->cols[col].type) { case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: type = SQL_C_BINARY; break; } #endif } #endif data = s->rows + s->ncols + (s->rowp * s->ncols) + col; if (!val) { valnull = 1; val = (SQLPOINTER) valdummy; } if (*data == NULL) { *lenp = SQL_NULL_DATA; switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif *((char *) val) = 0; break; case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((short *) val) = 0; break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = 0; break; case SQL_C_FLOAT: *((float *) val) = 0; break; case SQL_C_DOUBLE: *((double *) val) = 0; break; case SQL_C_BINARY: case SQL_C_CHAR: #ifdef WCHARSUPPORT case SQL_C_WCHAR: if (type == SQL_C_WCHAR) { *((SQLWCHAR *) val) = '\0'; } else { *((char *) val) = '\0'; } #else *((char *) val) = '\0'; #endif break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: memset((DATE_STRUCT *) val, 0, sizeof (DATE_STRUCT)); break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: memset((TIME_STRUCT *) val, 0, sizeof (TIME_STRUCT)); break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: memset((TIMESTAMP_STRUCT *) val, 0, sizeof (TIMESTAMP_STRUCT)); break; default: return SQL_ERROR; } } else { char *endp = NULL; switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: *((char *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (char); } break; #ifdef SQL_BIT case SQL_C_BIT: *((char *) val) = getbool(*data); *lenp = sizeof (char); break; #endif case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((short *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (short); } break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLINTEGER); } break; case SQL_C_FLOAT: *((float *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (float); } break; case SQL_C_DOUBLE: *((double *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (double); } break; case SQL_C_BINARY: #if (HAVE_ENCDEC) { int dlen, offs = 0; char *bin; if (*data == s->bincell && s->bincache) { bin = s->bincache; dlen = s->binlen; } else { freep(&s->bincache); freep(&s->hexcache); s->bincell = NULL; dlen = strlen(*data); bin = xmalloc(dlen + 1); if (!bin) { return nomem(s); } dlen = sqlite_decode_binary((unsigned char *) *data, (unsigned char *) bin); if (dlen < 0) { freep(&bin); setstat(s, -1, "error decoding binary data", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } s->bincache = bin; s->binlen = dlen; s->bincell = *data; } if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { *lenp = 0; if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && !valnull && len) { memcpy(val, bin + offs, min(len, dlen)); } if (valnull || len < 1) { *lenp = dlen; } else { *lenp = min(len, dlen); if (*lenp == len && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } } if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } #endif #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif case SQL_C_CHAR: { int doz, zlen = len - 1; int dlen = strlen(*data); int offs = 0; #ifdef WCHARSUPPORT SQLWCHAR *ucdata = NULL; #endif #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 2 (reserved error -7748) */ if (!valnull && (s->cols == statSpec2P || s->cols == statSpec3P) && type == SQL_C_WCHAR) { if (len > 0 && len <= sizeof (SQLWCHAR)) { ((char *) val)[0] = data[0][0]; memset((char *) val + 1, 0, len - 1); *lenp = 1; sret = SQL_SUCCESS; goto done; } } #endif #ifdef WCHARSUPPORT switch (type) { case SQL_C_CHAR: doz = 1; break; case SQL_C_WCHAR: doz = sizeof (SQLWCHAR); break; default: doz = 0; break; } if (type == SQL_C_WCHAR) { ucdata = uc_from_utf((SQLCHAR *) *data, dlen); if (!ucdata) { return nomem(s); } dlen = uc_strlen(ucdata) * sizeof (SQLWCHAR); } #else doz = type == SQL_C_CHAR ? 1 : 0; #endif if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { #ifdef WCHARSUPPORT uc_free(ucdata); #endif *lenp = 0; if (doz && val) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[0] = 0; } else { ((char *) val)[0] = '\0'; } #else ((char *) val)[0] = '\0'; #endif } if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && !valnull && len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { uc_strncpy(val, ucdata + offs / sizeof (SQLWCHAR), (len - doz) / sizeof (SQLWCHAR)); } else { strncpy(val, *data + offs, len - doz); } #else strncpy(val, *data + offs, len - doz); #endif } if (valnull || len < 1) { *lenp = dlen; } else { *lenp = min(len - doz, dlen); if (*lenp == len - doz && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } else if (*lenp < zlen) { zlen = *lenp; } } if (len && !valnull && doz) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[zlen / sizeof (SQLWCHAR)] = 0; } else { ((char *) val)[zlen] = '\0'; } #else ((char *) val)[zlen] = '\0'; #endif } #ifdef WCHARSUPPORT uc_free(ucdata); #endif if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len - doz; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: if (str2date(*data, (DATE_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (DATE_STRUCT); } break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: if (str2time(*data, (TIME_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIME_STRUCT); } break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: if (str2timestamp(*data, (TIMESTAMP_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIMESTAMP_STRUCT); } switch (s->cols[col].prec) { case 0: ((TIMESTAMP_STRUCT *) val)->fraction = 0; break; case 1: ((TIMESTAMP_STRUCT *) val)->fraction /= 100000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 100000000; break; case 2: ((TIMESTAMP_STRUCT *) val)->fraction /= 10000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 10000000; break; } break; default: return SQL_ERROR; } } sret = SQL_SUCCESS; done: if (ilenp) { *ilenp = *lenp; } return sret; } /** * Internal bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ static SQLRETURN drvbindcol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { STMT *s; int sz = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col < 1) { if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { s->bkmrkcol.type = type; s->bkmrkcol.max = sizeof (SQLINTEGER); s->bkmrkcol.lenp = lenp; s->bkmrkcol.valp = val; s->bkmrkcol.offs = 0; if (lenp) { *lenp = 0; } return SQL_SUCCESS; } setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (mkbindcols(s, col) != SQL_SUCCESS) { return SQL_ERROR; } --col; if (type == SQL_C_DEFAULT) { type = mapdeftype(type, s->cols[col].type, 0, s->nowchar[0] || s->nowchar[1]); } switch (type) { case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: sz = sizeof (SQLINTEGER); break; case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: sz = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: sz = sizeof (short); break; case SQL_C_FLOAT: sz = sizeof (SQLFLOAT); break; case SQL_C_DOUBLE: sz = sizeof (SQLDOUBLE); break; case SQL_C_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; case SQL_C_TIME: sz = sizeof (SQL_TIME_STRUCT); break; case SQL_C_DATE: sz = sizeof (SQL_DATE_STRUCT); break; case SQL_C_CHAR: break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: break; #endif #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: sz = sizeof (SQL_DATE_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: sz = sizeof (SQL_TIME_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; #endif #ifdef SQL_BIT case SQL_C_BIT: sz = sizeof (SQLCHAR); break; #endif #if (HAVE_ENCDEC) case SQL_C_BINARY: break; #endif default: if (val == NULL) { /* fall through, unbinding column */ break; } setstat(s, -1, "invalid type %d", "HY003", type); return SQL_ERROR; } if (val == NULL) { /* unbind column */ s->bindcols[col].type = -1; s->bindcols[col].max = 0; s->bindcols[col].lenp = NULL; s->bindcols[col].valp = NULL; s->bindcols[col].offs = 0; } else { if (sz == 0 && max < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } s->bindcols[col].type = type; s->bindcols[col].max = (sz == 0) ? max : sz; s->bindcols[col].lenp = lenp; s->bindcols[col].valp = val; s->bindcols[col].offs = 0; if (lenp) { *lenp = 0; } } return SQL_SUCCESS; } /** * Bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindcol(stmt, col, type, val, max, lenp); HSTMT_UNLOCK(stmt); return ret; } /** * Columns for result set of SQLTables(). */ static COL tableSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; static COL tableSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, asize, rc, size, npatt; char *errp = NULL, tname[512]; char *where = "(type = 'table' or type = 'view')"; ret = mkresultset(stmt, tableSpec2, array_size(tableSpec2), tableSpec3, array_size(tableSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] == '%') { int size = 3 * asize; s->rows = xmalloc(size * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } memset(s->rows, 0, sizeof (char *) * size); s->ncols = asize; s->rows[s->ncols + 0] = ""; s->rows[s->ncols + 1] = ""; s->rows[s->ncols + 2] = ""; s->rows[s->ncols + 3] = "TABLE"; s->rows[s->ncols + 5] = ""; s->rows[s->ncols + 6] = ""; s->rows[s->ncols + 7] = ""; s->rows[s->ncols + 8] = "VIEW"; #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = free; #endif s->nrows = 2; s->rowp = -1; return SQL_SUCCESS; } if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] != '\0') { char tmp[256], *t; int with_view = 0, with_table = 0; if (typeLen == SQL_NTS) { strncpy(tmp, (char *) type, sizeof (tmp)); tmp[sizeof (tmp) - 1] = '\0'; } else { int len = min(sizeof (tmp) - 1, typeLen); strncpy(tmp, (char *) type, len); tmp[len] = '\0'; } t = tmp; while (*t) { *t = TOLOWER(*t); t++; } t = tmp; unescpat(t); while (t) { if (t[0] == '\'') { ++t; } if (strncmp(t, "table", 5) == 0) { with_table++; } else if (strncmp(t, "view", 4) == 0) { with_view++; } t = strchr(t, ','); if (t) { ++t; } } if (with_view && with_table) { /* where is already preset */ } else if (with_view && !with_table) { where = "type = 'view'"; } else if (!with_view && with_table) { where = "type = 'table'"; } else { return SQL_SUCCESS; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); ret = starttran(s); if (ret != SQL_SUCCESS) { return ret; } #if defined(_WIN32) || defined(_WIN64) rc = sqlite_get_table_printf(d->sqlite, "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s '%q'", &s->rows, &s->nrows, &ncols, &errp, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", where, npatt ? "like" : "=", tname); #else rc = sqlite_get_table_printf(d->sqlite, "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s '%q'", &s->rows, &s->nrows, &ncols, &errp, where, npatt ? "like" : "=", tname); #endif if (rc == SQLITE_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = sqlite_free_table; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite_freemem(errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvtables(stmt, cat, catLen, schema, schemaLen, table, tableLen, type, typeLen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablesW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *type, SQLSMALLINT typeLen) { char *c = NULL, *s = NULL, *t = NULL, *y = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (type) { y = uc_to_utf_c(type, typeLen); if (!y) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtables(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) y, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(y); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif /** * Columns for result set of SQLColumns(). */ static COL colSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "SCALE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL colSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NUM_PREC_RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; /** * Internal retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvcolumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { SQLRETURN sret; STMT *s; DBC *d; int ret, nrows, ncols, asize, i, k, roffs, namec; int tnrows, tncols, npatt; PTRDIFF_T size; char *errp = NULL, tname[512], cname[512], **rowp, **trows; sret = mkresultset(stmt, colSpec2, array_size(colSpec2), colSpec3, array_size(colSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); size = 0; if (col) { if (colLen == SQL_NTS) { size = sizeof (cname) - 1; } else { size = min(sizeof (cname) - 1, colLen); } strncpy(cname, (char *) col, size); } cname[size] = '\0'; if (!strcmp(cname, "%")) { cname[0] = '\0'; } sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } ret = sqlite_get_table_printf(d->sqlite, "select tbl_name from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s '%q'", &trows, &tnrows, &tncols, &errp, npatt ? "like" : "=", tname); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } /* pass 1; compute number of rows of result set */ if (tncols * tnrows <= 0) { sqlite_free_table(trows); return SQL_SUCCESS; } size = 0; for (i = 1; i <= tnrows; i++) { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowp, &nrows, &ncols, &errp, trows[i]); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } if (ncols * nrows > 0) { namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { size++; } } } else { size += nrows; } } sqlite_free_table(rowp); } /* pass 2: fill result set */ if (size <= 0) { sqlite_free_table(trows); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite_free_table(trows); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; roffs = 1; for (i = 1; i <= tnrows; i++) { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowp, &nrows, &ncols, &errp, trows[i]); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } sqlite_free_table(trows); return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } if (ncols * nrows > 0) { int m, mr, nr = nrows; namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { nr = 0; for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { nr++; } } } for (k = 0; k < nr; k++) { m = asize * (roffs + k); s->rows[m + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[m + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[m + 1] = xstrdup(""); #endif s->rows[m + 2] = xstrdup(trows[i]); s->rows[m + 8] = xstrdup("10"); s->rows[m + 9] = xstrdup("0"); s->rows[m + 15] = xstrdup("16384"); } for (k = 0; nr && k < ncols; k++) { if (strcmp(rowp[k], "cid") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char buf[256]; int ir, coln = i; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); sscanf(rowp[m * ncols + k], "%d", &coln); sprintf(buf, "%d", coln + 1); s->rows[ir + 16] = xstrdup(buf); ++mr; } } else if (k == namec) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 3] = xstrdup(rowp[m * ncols + k]); ++mr; } } else if (strcmp(rowp[k], "notnull") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); if (*rowp[m * ncols + k] != '0') { s->rows[ir + 10] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[ir + 10] = xstrdup(stringify(SQL_TRUE)); } s->rows[ir + 17] = xstrdup((*rowp[m * ncols + k] != '0') ? "NO" : "YES"); ++mr; } } else if (strcmp(rowp[k], "dflt_value") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *dflt = rowp[m * ncols + k]; int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 12] = xstrdup(dflt ? dflt : "NULL"); ++mr; } } else if (strcmp(rowp[k], "type") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *typename = rowp[m * ncols + k]; int sqltype, mm, dd, ir; char buf[256]; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 5] = xstrdup(typename); sqltype = mapsqltype(typename, NULL, *s->ov3, s->nowchar[0]); getmd(typename, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif #if (HAVE_ENCDEC) if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } #endif sprintf(buf, "%d", sqltype); s->rows[ir + 4] = xstrdup(buf); s->rows[ir + 13] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[ir + 7] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[ir + 6] = xstrdup(buf); ++mr; } } } roffs += nr; } sqlite_free_table(rowp); } sqlite_free_table(trows); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvcolumns(stmt, cat, catLen, schema, schemaLen, table, tableLen, col, colLen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column information on table (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *col, SQLSMALLINT colLen) { char *c = NULL, *s = NULL, *t = NULL, *k = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (col) { k = uc_to_utf_c(col, colLen); if (!k) { ret = nomem((STMT *) stmt); goto done; } } ret = drvcolumns(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) k, SQL_NTS); done: HSTMT_UNLOCK(stmt); uc_free(k); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif /** * Columns for result set of SQLGetTypeInfo(). */ static COL typeSpec2[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "PRECISION", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MONEY", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_INCREMENT", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 } }; static COL typeSpec3[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "COLUMN_SIZE", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "FIXED_PREC_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_UNIQUE_VALUE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATETIME_SUB", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "NUM_PREC_RADIX", SQL_INTEGER, 4 }, { "SYSTEM", "TYPE", "INTERVAL_PRECISION", SQL_SMALLINT, 2 } }; /** * Internal function to build up data type information as row in result set. * @param s statement pointer * @param row row number * @param asize number of items in a row * @param typename name of type * @param type integer SQL type * @param tind type index */ static void mktypeinfo(STMT *s, int row, int asize, char *typename, int type, int tind) { int offs = row * asize; char *tcode, *crpar = NULL, *quote = NULL, *sign = stringify(SQL_FALSE); static char tcodes[32 * 32]; if (tind <= 0) { tind = row; } tcode = tcodes + tind * 32; sprintf(tcode, "%d", type); s->rows[offs + 0] = typename; s->rows[offs + 1] = tcode; if (asize >= 17) { s->rows[offs + 15] = tcode; s->rows[offs + 16] = "0"; } switch (type) { default: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #ifdef WINTERFACE case SQL_WLONGVARCHAR: #endif crpar = "length"; quote = "'"; sign = NULL; s->rows[offs + 2] = "65536"; break; #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #endif s->rows[offs + 2] = "255"; crpar = "length"; quote = "'"; sign = NULL; break; case SQL_TINYINT: s->rows[offs + 2] = "3"; break; case SQL_SMALLINT: s->rows[offs + 2] = "5"; break; case SQL_INTEGER: s->rows[offs + 2] = "9"; break; case SQL_FLOAT: s->rows[offs + 2] = "7"; break; case SQL_DOUBLE: s->rows[offs + 2] = "15"; break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: s->rows[offs + 2] = "10"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: s->rows[offs + 2] = "8"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 2] = "32"; quote = "'"; sign = NULL; break; #if (HAVE_ENCDEC) case SQL_VARBINARY: sign = NULL; s->rows[offs + 2] = "255"; break; case SQL_LONGVARBINARY: sign = NULL; s->rows[offs + 2] = "65536"; break; #endif #ifdef SQL_BIT case SQL_BIT: sign = NULL; s->rows[offs + 2] = "1"; break; #endif } s->rows[offs + 3] = s->rows[offs + 4] = quote; s->rows[offs + 5] = crpar; s->rows[offs + 6] = stringify(SQL_NULLABLE); s->rows[offs + 7] = stringify(SQL_FALSE); s->rows[offs + 8] = stringify(SQL_SEARCHABLE); s->rows[offs + 9] = sign; s->rows[offs + 10] = stringify(SQL_FALSE); s->rows[offs + 11] = stringify(SQL_FALSE); s->rows[offs + 12] = typename; switch (type) { case SQL_DATE: case SQL_TIME: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "0"; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "3"; break; default: s->rows[offs + 13] = NULL; s->rows[offs + 14] = NULL; break; } } /** * Helper function to sort type information. * Callback for qsort(). * @param a first item to compare * @param b second item to compare * @result ==0, <0, >0 according to data type number */ static int typeinfosort(const void *a, const void *b) { char **pa = (char **) a; char **pb = (char **) b; int na, nb; na = strtol(pa[1], NULL, 0); nb = strtol(pb[1], NULL, 0); return na - nb; } /** * Internal return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ static SQLRETURN drvgettypeinfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; STMT *s; int asize; ret = mkresultset(stmt, typeSpec2, array_size(typeSpec2), typeSpec3, array_size(typeSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; #ifdef WINTERFACE #ifdef SQL_LONGVARCHAR #ifdef SQL_WLONGVARCHAR if (s->nowchar[0]) { s->nrows = (sqltype == SQL_ALL_TYPES) ? 13 : 1; } else { s->nrows = (sqltype == SQL_ALL_TYPES) ? 17 : 1; } #else if (s->nowchar[0]) { s->nrows = (sqltype == SQL_ALL_TYPES) ? 12 : 1; } else { s->nrows = (sqltype == SQL_ALL_TYPES) ? 16 : 1; } #endif #else s->nrows = (sqltype == SQL_ALL_TYPES) ? 15 : 1; #endif #else #ifdef SQL_LONGVARCHAR s->nrows = (sqltype == SQL_ALL_TYPES) ? 13 : 1; #else s->nrows = (sqltype == SQL_ALL_TYPES) ? 12 : 1; #endif #endif #if (HAVE_ENCDEC) if (sqltype == SQL_ALL_TYPES) { s->nrows += 2; } #endif #ifdef SQL_BIT if (sqltype == SQL_ALL_TYPES) { s->nrows += 1; } #endif s->rows = (char **) xmalloc(sizeof (char *) * (s->nrows + 1) * asize); if (!s->rows) { s->nrows = 0; return nomem(s); } #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = free; #endif memset(s->rows, 0, sizeof (char *) * (s->nrows + 1) * asize); if (sqltype == SQL_ALL_TYPES) { int cc = 1; mktypeinfo(s, cc++, asize, "varchar", SQL_VARCHAR, 0); mktypeinfo(s, cc++, asize, "tinyint", SQL_TINYINT, 0); mktypeinfo(s, cc++, asize, "smallint", SQL_SMALLINT, 0); mktypeinfo(s, cc++, asize, "integer", SQL_INTEGER, 0); mktypeinfo(s, cc++, asize, "float", SQL_FLOAT, 0); mktypeinfo(s, cc++, asize, "double", SQL_DOUBLE, 0); #ifdef SQL_TYPE_DATE mktypeinfo(s, cc++, asize, "date", (*s->ov3) ? SQL_TYPE_DATE : SQL_DATE, 0); #else mktypeinfo(s, cc++, asize, "date", SQL_DATE, 0); #endif #ifdef SQL_TYPE_TIME mktypeinfo(s, cc++, asize, "time", (*s->ov3) ? SQL_TYPE_TIME : SQL_TIME, 0); #else mktypeinfo(s, cc++, asize, "time", SQL_TIME, 0); #endif #ifdef SQL_TYPE_TIMESTAMP mktypeinfo(s, cc++, asize, "timestamp", (*s->ov3) ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP, 0); #else mktypeinfo(s, cc++, asize, "timestamp", SQL_TIMESTAMP, 0); #endif mktypeinfo(s, cc++, asize, "char", SQL_CHAR, 0); mktypeinfo(s, cc++, asize, "numeric", SQL_DOUBLE, 0); #ifdef SQL_LONGVARCHAR mktypeinfo(s, cc++, asize, "text", SQL_LONGVARCHAR, 0); mktypeinfo(s, cc++, asize, "longvarchar", SQL_LONGVARCHAR, 0); #else mktypeinfo(s, cc++, asize, "text", SQL_VARCHAR, 0); #endif #ifdef WINTERFACE if (!s->nowchar[0]) { mktypeinfo(s, cc++, asize, "wvarchar", SQL_WVARCHAR, 0); #ifdef SQL_LONGVARCHAR mktypeinfo(s, cc++, asize, "wchar", SQL_WCHAR, 0); mktypeinfo(s, cc++, asize, "wtext", SQL_WLONGVARCHAR, 0); #ifdef SQL_WLONGVARCHAR mktypeinfo(s, cc++, asize, "longwvarchar", SQL_WLONGVARCHAR, 0); #endif #else mktypeinfo(s, cc++, asize, "wvarchar", SQL_WVARCHAR, 0); mktypeinfo(s, cc++, asize, "wchar", SQL_WCHAR, 0); mktypeinfo(s, cc++, asize, "wtext", SQL_WVARCHAR, 0); #endif } #endif #if (HAVE_ENCDEC) mktypeinfo(s, cc++, asize, "varbinary", SQL_VARBINARY, 0); mktypeinfo(s, cc++, asize, "longvarbinary", SQL_LONGVARBINARY, 0); #endif #ifdef SQL_BIT mktypeinfo(s, cc++, asize, "bit", SQL_BIT, 0); #endif qsort(s->rows + asize, s->nrows, sizeof (char *) * asize, typeinfosort); } else { switch (sqltype) { case SQL_CHAR: mktypeinfo(s, 1, asize, "char", SQL_CHAR, 10); break; case SQL_VARCHAR: mktypeinfo(s, 1, asize, "varchar", SQL_VARCHAR, 1); break; case SQL_TINYINT: mktypeinfo(s, 1, asize, "tinyint", SQL_TINYINT, 2); break; case SQL_SMALLINT: mktypeinfo(s, 1, asize, "smallint", SQL_SMALLINT, 3); break; case SQL_INTEGER: mktypeinfo(s, 1, asize, "integer", SQL_INTEGER, 4); break; case SQL_FLOAT: mktypeinfo(s, 1, asize, "float", SQL_FLOAT, 5); break; case SQL_DOUBLE: mktypeinfo(s, 1, asize, "double", SQL_DOUBLE, 6); break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: mktypeinfo(s, 1, asize, "date", SQL_TYPE_DATE, 25); break; #endif case SQL_DATE: mktypeinfo(s, 1, asize, "date", SQL_DATE, 7); break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: mktypeinfo(s, 1, asize, "time", SQL_TYPE_TIME, 26); break; #endif case SQL_TIME: mktypeinfo(s, 1, asize, "time", SQL_TIME, 8); break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TYPE_TIMESTAMP, 27); break; #endif case SQL_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TIMESTAMP, 9); break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: mktypeinfo(s, 1, asize, "longvarchar", SQL_LONGVARCHAR, 12); break; #endif #ifdef WINTERFACE #ifdef SQL_WCHAR case SQL_WCHAR: mktypeinfo(s, 1, asize, "wchar", SQL_WCHAR, 18); break; #endif #ifdef SQL_WVARCHAR case SQL_WVARCHAR: mktypeinfo(s, 1, asize, "wvarchar", SQL_WVARCHAR, 19); break; #endif #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: mktypeinfo(s, 1, asize, "longwvarchar", SQL_WLONGVARCHAR, 20); break; #endif #endif #if (HAVE_ENCDEC) case SQL_VARBINARY: mktypeinfo(s, 1, asize, "varbinary", SQL_VARBINARY, 30); break; case SQL_LONGVARBINARY: mktypeinfo(s, 1, asize, "longvarbinary", SQL_LONGVARBINARY, 31); break; #endif #ifdef SQL_BIT case SQL_BIT: mktypeinfo(s, 1, asize, "bit", SQL_BIT, 29); break; #endif default: s->nrows = 0; } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return data type information (UNICODE version). * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfoW(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLStatistics(). */ static COL statSpec2[] = { { "SYSTEM", "STATISTICS", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "SEQ_IN_INDEX", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "COLLATION", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; static COL statSpec3[] = { { "SYSTEM", "STATISTICS", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "ASC_OR_DESC", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; /** * Internal return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ static SQLRETURN drvstatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { SQLRETURN sret; STMT *s; DBC *d; int i, asize, ret, nrows, ncols, offs, namec, uniquec, addipk = 0; PTRDIFF_T size; char **rowp, *errp = NULL, tname[512]; sret = mkresultset(stmt, statSpec2, array_size(statSpec2), statSpec3, array_size(statSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } /* * Try integer primary key (autoincrement) first */ if (itype == SQL_INDEX_UNIQUE || itype == SQL_INDEX_ALL) { int colid, typec, npk = 0; rowp = 0; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowp, &nrows, &ncols, NULL, tname); if (ret != SQLITE_OK) { goto noipk; } namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); colid = findcol(rowp, ncols, "cid"); if (namec < 0 || uniquec < 0 || typec < 0 || colid < 0) { goto noipk; } for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0' && strlen(rowp[i * ncols + typec]) == 7 && strncasecmp(rowp[i * ncols + typec], "integer", 7) == 0) { npk++; } } if (npk == 1) { addipk = 1; } noipk: sqlite_free_table(rowp); } ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_list('%q')", &rowp, &nrows, &ncols, &errp, tname); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite_freemem(errp); errp = NULL; } size = 0; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata; } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; if (isuniq || itype == SQL_INDEX_ALL) { ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i * ncols + namec]); if (ret == SQLITE_OK) { size += nnrows; sqlite_free_table(rowpp); } } } nodata: if (addipk) { size++; } if (size == 0) { sqlite_free_table(rowp); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; if (addipk) { char **rowpp; int ncols2, nrows2; rowpp = 0; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA table_info('%q')", &rowpp, &nrows2, &ncols2, NULL, tname); if (ret == SQLITE_OK) { int namecc, uniquecc, colid, typec, roffs; namecc = findcol(rowpp, ncols2, "name"); uniquecc = findcol(rowpp, ncols2, "pk"); typec = findcol(rowpp, ncols2, "type"); colid = findcol(rowpp, ncols2, "cid"); if (namecc < 0 || uniquecc < 0 || typec < 0 || colid < 0) { addipk = 0; s->nrows--; goto nodata2; } for (i = 1; i <= nrows2; i++) { if (*rowpp[i * ncols2 + uniquecc] != '0' && strlen(rowpp[i * ncols2 + typec]) == 7 && strncasecmp(rowpp[i * ncols2 + typec], "integer", 7) == 0) { break; } } if (i > nrows) { addipk = 0; s->nrows--; goto nodata2; } roffs = s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); s->rows[roffs + 5] = xstrdup("(autoindex 0)"); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 7] = xstrdup("1"); s->rows[roffs + 8] = xstrdup(rowpp[i * ncols2 + namecc]); s->rows[roffs + 9] = xstrdup("A"); } nodata2: sqlite_free_table(rowpp); } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; if (*rowp[i * ncols + uniquec] != '0' || itype == SQL_INDEX_ALL) { int k; ret = sqlite_get_table_printf(d->sqlite, "PRAGMA index_info('%q')", &rowpp, &nnrows, &nncols, NULL, rowp[i * ncols + namec]); if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; s->rows[roffs + 0] = xstrdup(""); s->rows[roffs + 1] = xstrdup(""); s->rows[roffs + 2] = xstrdup(tname); if (isuniq) { s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[roffs + 3] = xstrdup(stringify(SQL_TRUE)); } s->rows[roffs + 5] = xstrdup(rowp[i * ncols + namec]); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 8] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 9] = xstrdup("A"); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 7] = xstrdup(buf); } } } offs += nnrows; sqlite_free_table(rowpp); } } sqlite_free_table(rowp); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvstatistics(stmt, cat, catLen, schema, schemaLen, table, tableLen, itype, resv); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return statistic information on table indices (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatisticsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvstatistics(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, itype, resv); done: HSTMT_UNLOCK(stmt); uc_free(t); uc_free(s); uc_free(c); return ret; } #endif /** * Retrieve row data after fetch. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN len, SQLLEN *lenp) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { *((long *) val) = s->rowp; if (lenp) { *lenp = sizeof (long); } ret = SQL_SUCCESS; goto done; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); goto done; } --col; ret = getrowdata(s, col, type, val, len, lenp, 1); done: HSTMT_UNLOCK(stmt); return ret; } /** * Internal: fetch and bind from statement's current row * @param s statement pointer * @param rsi rowset index * @result ODBC error code */ static SQLRETURN dofetchbind(STMT *s, int rsi) { int ret, i, withinfo = 0; s->row_status0[rsi] = SQL_ROW_SUCCESS; if (s->bkmrk && s->bkmrkcol.valp) { long *val; if (s->bind_type != SQL_BIND_BY_COLUMN) { val = (long *) ((char *) s->bkmrkcol.valp + s->bind_type * rsi); } else { val = (long *) s->bkmrkcol.valp + rsi; } if (s->bind_offs) { val = (long *) ((char *) val + *s->bind_offs); } *val = s->rowp; if (s->bkmrkcol.lenp) { SQLLEN *ival; if (s->bind_type != SQL_BIND_BY_COLUMN) { ival = (SQLLEN *) ((char *) s->bkmrkcol.lenp + s->bind_type * rsi); } else { ival = &s->bkmrkcol.lenp[rsi]; } if (s->bind_offs) { ival = (SQLLEN *) ((char *) ival + *s->bind_offs); } *ival = sizeof (long); } } ret = SQL_SUCCESS; for (i = 0; s->bindcols && i < s->ncols; i++) { BINDCOL *b = &s->bindcols[i]; SQLPOINTER dp = 0; SQLLEN *lp = 0; b->offs = 0; if (b->valp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { dp = (SQLPOINTER) ((char *) b->valp + s->bind_type * rsi); } else { dp = (SQLPOINTER) ((char *) b->valp + b->max * rsi); } if (s->bind_offs) { dp = (SQLPOINTER) ((char *) dp + *s->bind_offs); } } if (b->lenp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { lp = (SQLLEN *) ((char *) b->lenp + s->bind_type * rsi); } else { lp = b->lenp + rsi; } if (s->bind_offs) { lp = (SQLLEN *) ((char *) lp + *s->bind_offs); } } if (dp || lp) { ret = getrowdata(s, (SQLUSMALLINT) i, b->type, dp, b->max, lp, 0); if (!SQL_SUCCEEDED(ret)) { s->row_status0[rsi] = SQL_ROW_ERROR; break; } if (ret != SQL_SUCCESS) { withinfo = 1; #ifdef SQL_ROW_SUCCESS_WITH_INFO s->row_status0[rsi] = SQL_ROW_SUCCESS_WITH_INFO; #endif } } } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } return ret; } /** * Internal fetch function for SQLFetchScroll() and SQLExtendedFetch(). * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ static SQLRETURN drvfetchscroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLINTEGER offset) { STMT *s; int i, withinfo = 0; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_NOROW; } if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = 0; if (s->row_count) { *s->row_count = s->row_count0; } if (!s->bindcols) { for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_ERROR; } ret = SQL_ERROR; i = 0; goto done2; } if (s->isselect != 1 && s->isselect != -1) { setstat(s, -1, "no result set available", "24000"); ret = SQL_ERROR; i = s->nrows; goto done2; } if (s->curtype == SQL_CURSOR_FORWARD_ONLY && orient != SQL_FETCH_NEXT) { setstat(s, -1, "wrong fetch direction", "01000"); ret = SQL_ERROR; i = 0; goto done2; } ret = SQL_SUCCESS; i = 0; if (((DBC *) (s->dbc))->vm_stmt == s && s->vm) { s->rowp = 0; for (; i < s->rowset_size; i++) { ret = vm_step(s); if (ret != SQL_SUCCESS) { s->row_status0[i] = SQL_ROW_ERROR; break; } if (s->nrows < 1) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } else if (s->rows) { switch (orient) { case SQL_FETCH_NEXT: if (s->nrows < 1) { return SQL_NO_DATA; } if (s->rowp < 0) { s->rowp = -1; } if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } break; case SQL_FETCH_PRIOR: if (s->nrows < 1 || s->rowp <= 0) { s->rowp = -1; return SQL_NO_DATA; } s->rowp -= s->rowset_size + 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } break; case SQL_FETCH_FIRST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = -1; break; case SQL_FETCH_LAST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = s->nrows - s->rowset_size; if (--s->rowp < -1) { s->rowp = -1; } break; case SQL_FETCH_ABSOLUTE: if (offset == 0) { s->rowp = -1; return SQL_NO_DATA; } else if (offset < 0) { if (0 - offset <= s->nrows) { s->rowp = s->nrows + offset - 1; break; } s->rowp = -1; return SQL_NO_DATA; } else if (offset > s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } s->rowp = offset - 1 - 1; break; case SQL_FETCH_RELATIVE: if (offset >= 0) { s->rowp += offset * s->rowset_size - 1; if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } } else { s->rowp += offset * s->rowset_size - 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } } break; case SQL_FETCH_BOOKMARK: if (s->bkmrk) { if (offset < 0 || offset >= s->nrows) { return SQL_NO_DATA; } s->rowp = offset - 1; break; } /* fall through */ default: s->row_status0[0] = SQL_ROW_ERROR; ret = SQL_ERROR; goto done; } for (; i < s->rowset_size; i++) { ++s->rowp; if (s->rowp < 0 || s->rowp >= s->nrows) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } done: if (i == 0) { if (SQL_SUCCEEDED(ret)) { return SQL_NO_DATA; } return ret; } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } done2: if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = i; if (s->row_count) { *s->row_count = s->row_count0; } return ret; } /** * Fetch next result row. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, SQL_FETCH_NEXT, 0); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLLEN offset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, orient, offset); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling and row status. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @param rowcount output number of fetched rows * @param rowstatus array for row stati * @result ODBC error code */ SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT orient, SQLROWOFFSET offset, SQLROWSETSIZE *rowcount, SQLUSMALLINT *rowstatus) { STMT *s; SQLRETURN ret; SQLUSMALLINT *rst; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; /* temporarily turn off SQL_ATTR_ROW_STATUS_PTR */ rst = s->row_status; s->row_status = 0; ret = drvfetchscroll(stmt, orient, offset); s->row_status = rst; if (rowstatus) { memcpy(rowstatus, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } if (rowcount) { *rowcount = s->row_count0; } HSTMT_UNLOCK(stmt); return ret; } /** * Return number of affected rows of HSTMT. * @param stmt statement handle * @param nrows output number of rows * @result ODBC error code */ SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN *nrows) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (nrows) { *nrows = s->isselect ? 0 : s->nrows; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Return number of columns of result set given HSTMT. * @param stmt statement handle * @param ncols output number of columns * @result ODBC error code */ SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *ncols) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (ncols) { *ncols = s->ncols; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Internal describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ static SQLRETURN drvdescribecol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { STMT *s; COL *c; int didname = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { setstat(s, -1, "no columns", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } c = s->cols + col - 1; if (name && nameMax > 0) { strncpy((char *) name, c->column, nameMax); name[nameMax - 1] = '\0'; didname = 1; } if (nameLen) { if (didname) { *nameLen = strlen((char *) name); } else { *nameLen = strlen(c->column); } } if (type) { *type = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (c->type) { case SQL_WCHAR: *type = SQL_CHAR; break; case SQL_WVARCHAR: *type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: *type = SQL_LONGVARCHAR; break; #endif } } #endif } if (size) { *size = c->size; } if (digits) { *digits = 0; } if (nullable) { *nullable = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvdescribecol(stmt, col, name, nameMax, nameLen, type, size, digits, nullable); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Describe column information (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeColW(SQLHSTMT stmt, SQLUSMALLINT col, SQLWCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvdescribecol(stmt, col, (SQLCHAR *) name, (SQLSMALLINT) (nameMax * sizeof (SQLWCHAR)), &len, type, size, digits, nullable); if (ret == SQL_SUCCESS) { if (name) { if (len > 0) { SQLWCHAR *n = NULL; n = uc_from_utf((SQLCHAR *) name, len); if (n) { uc_strncpy(name, n, nameMax); n[len] = 0; len = min(nameMax, uc_strlen(n)); uc_free(n); } else { len = 0; } } if (len <= 0) { len = 0; if (nameMax > 0) { name[0] = 0; } } } else { STMT *s = (STMT *) stmt; COL *c = s->cols + col - 1; len = 0; if (c->column) { len = strlen(c->column); } } if (nameLen) { *nameLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { STMT *s; COL *c; SQLSMALLINT dummy; char *valc = (char *) val; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (!valLen) { valLen = &dummy; } if (id == SQL_COLUMN_COUNT) { if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; } if (id == SQL_COLUMN_TYPE && col == 0) { if (val2) { *val2 = SQL_INTEGER; } *valLen = sizeof (int); return SQL_SUCCESS; } #ifdef SQL_DESC_OCTET_LENGTH if (id == SQL_DESC_OCTET_LENGTH && col == 0) { if (val2) { *val2 = 4; } *valLen = sizeof (int); return SQL_SUCCESS; } #endif if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009": "S1002"); return SQL_ERROR; } c = s->cols + col - 1; switch (id) { case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_COLUMN_TYPE: case SQL_DESC_TYPE: #ifdef WINTERFACE { int type = c->type; if (s->nowchar[0] || s->nowchar[1]) { switch (type) { case SQL_WCHAR: type = SQL_CHAR; break; case SQL_WVARCHAR: type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: type = SQL_LONGVARCHAR; break; } } if (val2) { *val2 = type; } #endif } #else if (val2) { *val2 = c->type; } #endif *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_DISPLAY_SIZE: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UNSIGNED: if (val2) { *val2 = c->nosign ? SQL_TRUE : SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: if (val2) { *val2 = c->scale; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: if (val2) { switch (c->type) { case SQL_SMALLINT: *val2 = 5; break; case SQL_INTEGER: *val2 = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: *val2 = 15; break; case SQL_DATE: *val2 = 0; break; case SQL_TIME: *val2 = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: *val2 = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: *val2 = c->prec; break; } } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_MONEY: if (val2) { *val2 = SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_AUTO_INCREMENT: if (val2) { *val2 = c->autoinc; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_NULLABLE: case SQL_DESC_NULLABLE: if (val2) { *val2 = c->notnull; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SEARCHABLE: if (val2) { *val2 = SQL_SEARCHABLE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_CASE_SENSITIVE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UPDATABLE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_DESC_COUNT: if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: if (val2) { switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: *val2 = 0; break; default: *val2 = 2; } } *valLen = sizeof (int); return SQL_SUCCESS; #endif } setstat(s, -1, "unsupported column attributes %d", "HY091", id); return SQL_ERROR; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvcolattributes(stmt, col, id, val, valMax, valLen, val2); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributesW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattributes(stmt, col, id, val, valMax, &len, val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_COLUMN_LABEL: case SQL_COLUMN_NAME: case SQL_DESC_NAME: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLPOINTER val2) { STMT *s; COL *c; int v = 0; char *valc = (char *) val; SQLSMALLINT dummy; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!valLen) { valLen = &dummy; } c = s->cols + col - 1; switch (id) { case SQL_DESC_COUNT: v = s->ncols; break; case SQL_DESC_CATALOG_NAME: if (valc && valMax > 0) { strncpy(valc, c->db, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->db); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } break; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: v = c->size; break; case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); goto checkLen; case SQL_DESC_SCHEMA_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_DESC_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_DESC_OCTET_LENGTH: v = c->size; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { v *= sizeof (SQLWCHAR); } } #endif break; #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_COLUMN_TABLE_NAME: #endif case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; case SQL_DESC_TYPE: v = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (v) { case SQL_WCHAR: v = SQL_CHAR; break; case SQL_WVARCHAR: v = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: v = SQL_LONGVARCHAR; break; #endif } } #endif break; case SQL_DESC_CONCISE_TYPE: switch (c->type) { case SQL_INTEGER: v = SQL_C_LONG; break; case SQL_TINYINT: v = SQL_C_TINYINT; break; case SQL_SMALLINT: v = SQL_C_SHORT; break; case SQL_FLOAT: v = SQL_C_FLOAT; break; case SQL_DOUBLE: v = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: v = SQL_C_TIMESTAMP; break; case SQL_TIME: v = SQL_C_TIME; break; case SQL_DATE: v = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: v = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: v = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: v = SQL_C_TYPE_DATE; break; #endif #ifdef SQL_BIT case SQL_BIT: v = SQL_C_BIT; break; #endif default: #ifdef WINTERFACE v = (s->nowchar[0] || s->nowchar[1]) ? SQL_C_CHAR : SQL_C_WCHAR; #else v = SQL_C_CHAR; #endif break; } break; case SQL_DESC_UPDATABLE: v = SQL_TRUE; break; case SQL_COLUMN_DISPLAY_SIZE: v = c->size; break; case SQL_COLUMN_UNSIGNED: v = c->nosign ? SQL_TRUE : SQL_FALSE; break; case SQL_COLUMN_SEARCHABLE: v = SQL_SEARCHABLE; break; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: v = c->scale; break; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: switch (c->type) { case SQL_SMALLINT: v = 5; break; case SQL_INTEGER: v = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: v = 15; break; case SQL_DATE: v = 0; break; case SQL_TIME: v = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: v = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: v = c->prec; break; } break; case SQL_COLUMN_MONEY: v = SQL_FALSE; break; case SQL_COLUMN_AUTO_INCREMENT: v = c->autoinc; break; case SQL_DESC_NULLABLE: v = c->notnull; break; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: v = 0; break; default: v = 2; } break; #endif default: setstat(s, -1, "unsupported column attribute %d", "HY091", id); return SQL_ERROR; } if (val2) { *(SQLLEN *) val2 = v; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvcolattribute(stmt, col, id, val, valMax, valLen, (SQLPOINTER) val2); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattribute(stmt, col, id, val, valMax, &len, (SQLPOINTER) val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_DESC_SCHEMA_NAME: case SQL_DESC_CATALOG_NAME: case SQL_COLUMN_LABEL: case SQL_DESC_NAME: case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif case SQL_DESC_TYPE_NAME: if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ static SQLRETURN drverror(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { SQLCHAR dummy0[6]; SQLINTEGER dummy1; SQLSMALLINT dummy2; if (env == SQL_NULL_HENV && dbc == SQL_NULL_HDBC && stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } if (sqlState) { sqlState[0] = '\0'; } else { sqlState = dummy0; } if (!nativeErr) { nativeErr = &dummy1; } *nativeErr = 0; if (!errlen) { errlen = &dummy2; } *errlen = 0; if (errmsg) { if (errmax > 0) { errmsg[0] = '\0'; } } else { errmsg = dummy0; errmax = 0; } if (stmt) { STMT *s = (STMT *) stmt; HSTMT_LOCK(stmt); if (s->logmsg[0] == '\0') { HSTMT_UNLOCK(stmt); goto noerr; } *nativeErr = s->naterr; strcpy((char *) sqlState, s->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) s->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) s->logmsg, errmax - 8); } *errlen = min(strlen((char *) s->logmsg) + 8, errmax); } s->logmsg[0] = '\0'; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } if (dbc) { DBC *d = (DBC *) dbc; HDBC_LOCK(dbc); if (d->magic != DBC_MAGIC || d->logmsg[0] == '\0') { HDBC_UNLOCK(dbc); goto noerr; } *nativeErr = d->naterr; strcpy((char *) sqlState, d->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) d->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) d->logmsg, errmax - 8); } *errlen = min(strlen((char *) d->logmsg) + 8, errmax); } d->logmsg[0] = '\0'; HDBC_UNLOCK(dbc); return SQL_SUCCESS; } noerr: sqlState[0] = '\0'; errmsg[0] = '\0'; *nativeErr = 0; *errlen = 0; return SQL_NO_DATA; } #ifndef WINTERFACE /** * Return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLError(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { return drverror(env, dbc, stmt, sqlState, nativeErr, errmsg, errmax, errlen); } #endif #ifdef WINTERFACE /** * Return last HDBC or HSTMT error message (UNICODE version). * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLErrorW(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLWCHAR *sqlState, SQLINTEGER *nativeErr, SQLWCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { char state[16]; SQLSMALLINT len = 0; SQLRETURN ret; ret = drverror(env, dbc, stmt, (SQLCHAR *) state, nativeErr, (SQLCHAR *) errmsg, errmax, &len); if (ret == SQL_SUCCESS) { if (sqlState) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlState, 6 * sizeof (SQLWCHAR)); } if (errmsg) { if (len > 0) { SQLWCHAR *e = NULL; e = uc_from_utf((SQLCHAR *) errmsg, len); if (e) { if (errmax > 0) { uc_strncpy(errmsg, e, errmax); e[len] = 0; len = min(errmax, uc_strlen(e)); } else { len = uc_strlen(e); } uc_free(e); } else { len = 0; } } if (len <= 0) { len = 0; if (errmax > 0) { errmsg[0] = 0; } } } else { len = 0; } if (errlen) { *errlen = len; } } else if (ret == SQL_NO_DATA) { if (sqlState) { sqlState[0] = 0; } if (errmsg) { if (errmax > 0) { errmsg[0] = 0; } } if (errlen) { *errlen = 0; } } return ret; } #endif /** * Return information for more result sets. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt) { HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_UNLOCK(stmt); return SQL_NO_DATA; } /** * SQLite callback during drvprepare(), used to collect column information. * @param arg user data, actually a statement pointer * @param ncols number of columns * @param values value string array * @param cols column name string array * @result always 1 to abort sqlite_exec() */ static int selcb(void *arg, int ncols, char **values, char **cols) { STMT *s = (STMT *) arg; if (ncols > 0) { int i, size; char *p; COL *dyncols; DBC *d = (DBC *) s->dbc; for (i = size = 0; i < ncols; i++) { size += 3 + 3 * strlen(cols[i]); } dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); s->ncols = 0; return 1; } p = (char *) (dyncols + ncols); for (i = 0; i < ncols; i++) { char *q; dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, cols[i]); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(cols[i], '.'); if (q) { dyncols[i].table = p; strncpy(p, cols[i], q - cols[i]); p[q - cols[i]] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { dyncols[i].table = ""; strcpy(p, cols[i]); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; dyncols[i].autoinc = SQL_FALSE; dyncols[i].notnull = SQL_NULLABLE; dyncols[i].typename = NULL; } freedyncols(s); s->dyncols = s->cols = dyncols; s->dcols = ncols; fixupdyncols(s, d->sqlite, (const char **) cols + ncols); } s->ncols = ncols; return 1; } /** * Internal query preparation used by SQLPrepare() and SQLExecDirect(). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { STMT *s; DBC *d; char *errp = NULL; SQLRETURN sret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = s->dbc; if (!d->sqlite) { goto noconn; } vm_end(s); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } freep(&s->query); s->query = (SQLCHAR *) fixupsql((char *) query, queryLen, &s->nparams, &s->isselect, &errp, d->version, &s->parmnames); if (!s->query) { if (errp) { setstat(s, -1, "%s", (*s->ov3) ? "HY000" : "S1000", errp); return SQL_ERROR; } return nomem(s); } #ifdef CANT_PASS_VALIST_AS_CHARPTR if (s->nparams > MAX_PARAMS_FOR_VPRINTF) { freep(&s->query); setstat(s, -1, "too much parameters in query", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } #endif errp = NULL; freeresult(s, -1); if (s->isselect == 1) { int ret; char **params = NULL; if (s->nparams) { int i, maxp; #ifdef CANT_PASS_VALIST_AS_CHARPTR maxp = MAX_PARAMS_FOR_VPRINTF; #else maxp = s->nparams; #endif params = xmalloc(maxp * sizeof (char *)); if (!params) { return nomem(s); } for (i = 0; i < maxp; i++) { params[i] = NULL; } } #ifdef CANT_PASS_VALIST_AS_CHARPTR if (params) { ret = sqlite_exec_printf(d->sqlite, (char *) s->query, selcb, s, &errp, params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12], params[13], params[14], params[15], params[16], params[17], params[18], params[19], params[20], params[21], params[22], params[23], params[24], params[25], params[26], params[27], params[28], params[29], params[30], params[31]); } else { ret = sqlite_exec_printf(d->sqlite, (char *) s->query, selcb, s, &errp); } #else ret = sqlite_exec_vprintf(d->sqlite, (char *) s->query, selcb, s, &errp, (char *) params); #endif if (ret != SQLITE_ABORT && ret != SQLITE_OK) { dbtracerc(d, ret, errp); freep(¶ms); setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite_freemem(errp); errp = NULL; } return SQL_ERROR; } freep(¶ms); if (errp) { sqlite_freemem(errp); errp = NULL; } } mkbindcols(s, s->ncols); s->paramset_count = 0; return SQL_SUCCESS; } /** * Internal query execution used by SQLExecute() and SQLExecDirect(). * @param stmt statement handle * @param initial false when called from SQLPutData() * @result ODBC error code */ static SQLRETURN drvexecute(SQLHSTMT stmt, int initial) { STMT *s; DBC *d; char *errp = NULL, **params = NULL; int rc, i, ncols; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } if (!s->query) { setstat(s, -1, "no query prepared", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (s->nbindparms < s->nparams) { unbound: setstat(s, -1, "unbound parameters in query", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (!p->bound) { goto unbound; } if (initial) { SQLLEN *lenp = p->lenp; if (lenp && *lenp < 0 && *lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *lenp != SQL_NTS && *lenp != SQL_NULL_DATA && *lenp != SQL_DATA_AT_EXEC) { setstat(s, -1, "invalid length reference", "HY009"); return SQL_ERROR; } if (lenp && (*lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } ret = starttran(s); if (ret != SQL_SUCCESS) { goto cleanup; } again: vm_end(s); if (initial) { /* fixup data-at-execution parameters and alloc'ed blobs */ s->pdcount = -1; for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->need <= 0 && p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } if (s->nparams) { int maxp; #ifdef CANT_PASS_VALIST_AS_CHARPTR maxp = MAX_PARAMS_FOR_VPRINTF; #else maxp = s->nparams; #endif params = xmalloc(maxp * sizeof (char *)); if (!params) { ret = nomem(s); goto cleanup; } for (i = 0; i < maxp; i++) { params[i] = NULL; } for (i = 0; i < s->nparams; i++) { ret = substparam(s, i, ¶ms[i]); if (ret != SQL_SUCCESS) { freep(¶ms); goto cleanup; } } } freeresult(s, 0); if (s->isselect == 1 && !d->intrans && s->curtype == SQL_CURSOR_FORWARD_ONLY && d->step_enable && s->nparams == 0 && d->vm_stmt == NULL) { s->nrows = -1; ret = vm_start(s, params); if (ret == SQL_SUCCESS) { freep(¶ms); goto done2; } } #ifdef CANT_PASS_VALIST_AS_CHARPTR if (params) { rc = sqlite_get_table_printf(d->sqlite, (char *) s->query, &s->rows, &s->nrows, &ncols, &errp, params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12], params[13], params[14], params[15], params[16], params[17], params[18], params[19], params[20], params[21], params[22], params[23], params[24], params[25], params[26], params[27], params[28], params[29], params[30], params[31]); } else { rc = sqlite_get_table_printf(d->sqlite, (char *) s->query, &s->rows, &s->nrows, &ncols, &errp); } #else rc = sqlite_get_table_vprintf(d->sqlite, (char *) s->query, &s->rows, &s->nrows, &ncols, &errp, (char *) params); #endif dbtracerc(d, rc, errp); if (rc != SQLITE_OK) { freep(¶ms); setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); if (errp) { sqlite_freemem(errp); errp = NULL; } ret = SQL_ERROR; goto cleanup; } freep(¶ms); if (errp) { sqlite_freemem(errp); errp = NULL; } s->rowfree = sqlite_free_table; if (ncols == 1 && (s->isselect <= 0 || s->isselect > 1)) { /* * INSERT/UPDATE/DELETE or DDL results are immediately released. */ if (strcmp(s->rows[0], "rows inserted") == 0 || strcmp(s->rows[0], "rows updated") == 0 || strcmp(s->rows[0], "rows deleted") == 0) { int nrows = 0; nrows = strtol(s->rows[1], NULL, 0); freeresult(s, -1); s->nrows = nrows; goto done; } } if (s->ncols != ncols) { int size; char *p; COL *dyncols; for (i = size = 0; i < ncols; i++) { size += 3 + 3 * strlen(s->rows[i]); } if (size == 0) { freeresult(s, -1); goto done; } dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { ret = nomem(s); goto cleanup; } p = (char *) (dyncols + ncols); for (i = 0; i < ncols; i++) { char *q; dyncols[i].db = d->dbname; strcpy(p, s->rows[i]); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(s->rows[i], '.'); if (q) { dyncols[i].table = p; strncpy(p, s->rows[i], q - s->rows[i]); p[q - s->rows[i]] = '\0'; p += strlen(p) + 1; dyncols[i].column = q + 1; } else { dyncols[i].table = ""; dyncols[i].column = s->rows[i]; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65536; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; dyncols[i].autoinc = SQL_FALSE; dyncols[i].notnull = SQL_NULLABLE; dyncols[i].typename = NULL; } freedyncols(s); s->ncols = s->dcols = ncols; s->dyncols = s->cols = dyncols; fixupdyncols(s, d->sqlite, NULL); } done: mkbindcols(s, s->ncols); done2: ret = SQL_SUCCESS; s->rowp = -1; s->paramset_count++; s->paramset_nrows += s->nrows; if (s->paramset_count < s->paramset_size) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->lenp0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->lenp = (SQLLEN *) ((char *) p->lenp0 + s->paramset_count * s->parm_bind_type); } else if (p->lenp0 && p->inc > 0) { p->lenp = p->lenp0 + s->paramset_count; } if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { if (p->param0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->param = (char *) p->param0 + s->paramset_count * s->parm_bind_type; } else if (p->param0 && p->inc > 0) { p->param = (char *) p->param0 + s->paramset_count * p->inc; } } else if (p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } goto again; } cleanup: if (ret != SQL_NEED_DATA) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { p->param = p->param0; } p->lenp = p->lenp0; } s->nrows = s->paramset_nrows; if (s->parm_proc) { *s->parm_proc = s->paramset_count; } s->paramset_count = 0; s->paramset_nrows = 0; } return ret; } #ifndef WINTERFACE /** * Prepare HSTMT. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvprepare(stmt, query, queryLen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Prepare HSTMT (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepareW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Execute query. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvexecute(stmt, 1); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Execute query directly. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvprepare(stmt, query, queryLen); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Execute query directly (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } done: HSTMT_UNLOCK(stmt); return ret; } #endif #if defined(_WIN32) || defined(_WIN64) || defined(__OS2__) #ifndef WITHOUT_DRIVERMGR #if defined(_WIN32) || defined(_WIN64) /* * Windows configuration dialog stuff. */ #include #include #endif #ifdef __OS2__ #define INCL_WIN #define INCL_PM #define INCL_DOSMODULEMGR #define INCL_DOSERRORS #define INCL_WINSTDFILE #include #include #include "resourceos2.h" #endif #define MAXPATHLEN (259+1) /* Max path length */ #define MAXKEYLEN (15+1) /* Max keyword length */ #define MAXDESC (255+1) /* Max description length */ #define MAXDSNAME (32+1) /* Max data source name length */ #define MAXTONAME (32+1) /* Max timeout length */ #define MAXDBNAME MAXPATHLEN /* Attribute key indexes into an array of Attr structs, see below */ #define KEY_DSN 0 #define KEY_DESC 1 #define KEY_DBNAME 2 #define KEY_BUSY 3 #define KEY_DRIVER 4 #define KEY_NOWCHAR 5 #define KEY_STEPAPI 6 #define KEY_NOTXN 7 #define KEY_LONGNAM 8 #define NUMOFKEYS 9 typedef struct { BOOL supplied; char attr[MAXPATHLEN]; } ATTR; typedef struct { SQLHWND parent; #ifdef __OS2__ HMODULE hDLL; #endif LPCSTR driver; ATTR attr[NUMOFKEYS]; char DSN[MAXDSNAME]; BOOL newDSN; BOOL defDSN; } SETUPDLG; static struct { char *key; int ikey; } attrLookup[] = { { "DSN", KEY_DSN }, { "DESC", KEY_DESC }, { "Description", KEY_DESC}, { "Database", KEY_DBNAME }, { "Timeout", KEY_BUSY }, { "Driver", KEY_DRIVER }, { "NoWCHAR", KEY_NOWCHAR }, { "StepAPI", KEY_STEPAPI }, { "NoTXN", KEY_NOTXN }, { "LongNames", KEY_LONGNAM }, { NULL, 0 } }; /** * Setup dialog data from datasource attributes. * @param attribs attribute string * @param setupdlg pointer to dialog data */ static void ParseAttributes(LPCSTR attribs, SETUPDLG *setupdlg) { char *str = (char *) attribs, *start, key[MAXKEYLEN]; int elem, nkey; while (*str) { start = str; if ((str = strchr(str, '=')) == NULL) { return; } elem = -1; nkey = str - start; if (nkey < sizeof (key)) { int i; memcpy(key, start, nkey); key[nkey] = '\0'; for (i = 0; attrLookup[i].key; i++) { if (strcasecmp(attrLookup[i].key, key) == 0) { elem = attrLookup[i].ikey; break; } } } start = ++str; while (*str && *str != ';') { ++str; } if (elem >= 0) { int end = min(str - start, sizeof (setupdlg->attr[elem].attr) - 1); setupdlg->attr[elem].supplied = TRUE; memcpy(setupdlg->attr[elem].attr, start, end); setupdlg->attr[elem].attr[end] = '\0'; } ++str; } } /** * Set datasource attributes in registry. * @param parent handle of parent window * @param setupdlg pointer to dialog data * @result true or false */ static BOOL SetDSNAttributes(HWND parent, SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (setupdlg->newDSN && strlen(dsn) == 0) { return FALSE; } if (!SQLWriteDSNToIni(dsn, setupdlg->driver)) { if (parent) { #if defined(_WIN32) || defined(_WIN64) char buf[MAXPATHLEN], msg[MAXPATHLEN]; LoadString(hModule, IDS_BADDSN, buf, sizeof (buf)); wsprintf(msg, buf, dsn); LoadString(hModule, IDS_MSGTITLE, buf, sizeof (buf)); MessageBox(parent, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #endif #ifdef __OS2__ WinMessageBox(HWND_DESKTOP, parent, "Bad DSN", "Configure Error", 0, MB_ERROR | MB_OK ); #endif } return FALSE; } if (parent || setupdlg->attr[KEY_DESC].supplied) { SQLWritePrivateProfileString(dsn, "Description", setupdlg->attr[KEY_DESC].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_DBNAME].supplied) { SQLWritePrivateProfileString(dsn, "Database", setupdlg->attr[KEY_DBNAME].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_BUSY].supplied) { SQLWritePrivateProfileString(dsn, "Timeout", setupdlg->attr[KEY_BUSY].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOWCHAR].supplied) { SQLWritePrivateProfileString(dsn, "NoWCHAR", setupdlg->attr[KEY_NOWCHAR].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_STEPAPI].supplied) { SQLWritePrivateProfileString(dsn, "StepAPI", setupdlg->attr[KEY_STEPAPI].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOTXN].supplied) { SQLWritePrivateProfileString(dsn, "NoTXN", setupdlg->attr[KEY_NOTXN].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_LONGNAM].supplied) { SQLWritePrivateProfileString(dsn, "LongNames", setupdlg->attr[KEY_LONGNAM].attr, ODBC_INI); } if (setupdlg->attr[KEY_DSN].supplied && strcasecmp(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr)) { SQLRemoveDSNFromIni(setupdlg->DSN); } return TRUE; } /** * Get datasource attributes from registry. * @param setupdlg pointer to dialog data */ static void GetAttributes(SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (!setupdlg->attr[KEY_DESC].supplied) { SQLGetPrivateProfileString(dsn, "Description", "", setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr), ODBC_INI); } if (!setupdlg->attr[KEY_DBNAME].supplied) { SQLGetPrivateProfileString(dsn, "Database", "", setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr), ODBC_INI); } if (!setupdlg->attr[KEY_BUSY].supplied) { SQLGetPrivateProfileString(dsn, "Timeout", "100000", setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOWCHAR].supplied) { SQLGetPrivateProfileString(dsn, "NoWCHAR", "", setupdlg->attr[KEY_NOWCHAR].attr, sizeof (setupdlg->attr[KEY_NOWCHAR].attr), ODBC_INI); } if (!setupdlg->attr[KEY_STEPAPI].supplied) { SQLGetPrivateProfileString(dsn, "StepAPI", "0", setupdlg->attr[KEY_STEPAPI].attr, sizeof (setupdlg->attr[KEY_STEPAPI].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOTXN].supplied) { SQLGetPrivateProfileString(dsn, "NoTXN", "", setupdlg->attr[KEY_NOTXN].attr, sizeof (setupdlg->attr[KEY_NOTXN].attr), ODBC_INI); } if (!setupdlg->attr[KEY_LONGNAM].supplied) { SQLGetPrivateProfileString(dsn, "LongNames", "", setupdlg->attr[KEY_LONGNAM].attr, sizeof (setupdlg->attr[KEY_LONGNAM].attr), ODBC_INI); } } /** * Open file dialog for selection of SQLite database file. * @param hdlg handle of originating dialog window */ static void GetDBFile(HWND hdlg) { #if defined(_WIN32) || defined(_WIN64) #ifdef _WIN64 SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); ofn.lStructSize = sizeof (ofn); ofn.hwndOwner = hdlg; #ifdef _WIN64 ofn.hInstance = (HINSTANCE) GetWindowLongPtr(hdlg, GWLP_HINSTANCE); #else ofn.hInstance = (HINSTANCE) GetWindowLong(hdlg, GWL_HINSTANCE); #endif ofn.lpstrFile = (LPTSTR) setupdlg->attr[KEY_DBNAME].attr; ofn.nMaxFile = MAXPATHLEN; ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_FILEMUSTEXIST; if (GetOpenFileName(&ofn)) { SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); setupdlg->attr[KEY_DBNAME].supplied = TRUE; } #endif #ifdef __OS2__ SETUPDLG *setupdlg = (SETUPDLG *) WinQueryWindowULong(hdlg, QWL_USER); FILEDLG ofn; memset(&ofn, 0, sizeof (ofn)); ofn.cbSize = sizeof (FILEDLG); strcpy(ofn.szFullFile, setupdlg->attr[KEY_DBNAME].attr); ofn.fl = FDS_OPEN_DIALOG | FDS_CENTER; WinFileDlg(hdlg, hdlg, &ofn); if (ofn.lReturn == DID_OK) { strcpy(setupdlg->attr[KEY_DBNAME].attr, ofn.szFullFile); WinSetDlgItemText(hdlg, EF_DATABASE, setupdlg->attr[KEY_DBNAME].attr); setupdlg->attr[KEY_DBNAME].supplied = TRUE; } #endif } #if defined(_WIN32) || defined(_WIN64) /** * Dialog procedure for ConfigDSN(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK ConfigDlgProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg = NULL; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLongPtr(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; GetAttributes(setupdlg); SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_DSNAME: if (GET_WM_COMMAND_CMD(wparam, lparam) == EN_CHANGE) { char item[MAXDSNAME]; EnableWindow(GetDlgItem(hdlg, IDOK), GetDlgItemText(hdlg, IDC_DSNAME, item, sizeof (item))); return TRUE; } break; case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif if (!setupdlg->defDSN) { GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); } GetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); SetDSNAttributes(hdlg, setupdlg); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, wparam); return TRUE; } break; } return FALSE; } #endif #ifdef __OS2__ /** * Dialog procedure for ConfigDSN(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result standard MRESULT */ static MRESULT EXPENTRY ConfigDlgProc(HWND hdlg, ULONG wmsg, MPARAM wparam, MPARAM lparam) { SETUPDLG *setupdlg = NULL; switch (wmsg) { case WM_INITDLG: WinSetWindowULong(hdlg, QWL_USER, (ULONG) lparam); setupdlg = (SETUPDLG *) lparam; GetAttributes(setupdlg); WinSetDlgItemText(hdlg, EF_DSNNAME, setupdlg->attr[KEY_DSN].attr); WinSetDlgItemText(hdlg, EF_DSNDESC, setupdlg->attr[KEY_DESC].attr); WinSetDlgItemText(hdlg, EF_DATABASE, setupdlg->attr[KEY_DBNAME].attr); WinSetDlgItemText(hdlg, EF_TIMEOUT, setupdlg->attr[KEY_BUSY].attr); WinSendDlgItemMsg(hdlg, EF_DSNNAME, EM_SETTEXTLIMIT, MPFROMSHORT(MAXDSNAME - 1), 0L); WinSendDlgItemMsg(hdlg, EF_DSNDESC, EM_SETTEXTLIMIT, MPFROMSHORT(MAXDESC - 1), 0L); WinSendDlgItemMsg(hdlg, EF_DATABASE, EM_SETTEXTLIMIT, MPFROMSHORT(MAXDBNAME - 1), 0L); WinSendDlgItemMsg(hdlg, EF_TIMEOUT, EM_SETTEXTLIMIT, MPFROMSHORT(MAXTONAME - 1), 0L); WinCheckButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr)); WinCheckButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr)); WinCheckButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr)); WinCheckButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr)); if (setupdlg->defDSN) { WinEnableWindow(WinWindowFromID(hdlg, EF_DSNNAME), FALSE); } return 0; case WM_COMMAND: switch (SHORT1FROMMP(wparam)) { case IDC_BROWSE: GetDBFile(hdlg); break; case DID_OK: setupdlg = (SETUPDLG *) WinQueryWindowULong(hdlg, QWL_USER); if (!setupdlg->defDSN) { WinQueryDlgItemText(hdlg, EF_DSNNAME, sizeof (setupdlg->attr[KEY_DSN].attr), setupdlg->attr[KEY_DSN].attr); } WinQueryDlgItemText(hdlg, EF_DSNDESC, sizeof (setupdlg->attr[KEY_DESC].attr), setupdlg->attr[KEY_DESC].attr); WinQueryDlgItemText(hdlg, EF_DATABASE, sizeof (setupdlg->attr[KEY_DBNAME].attr), setupdlg->attr[KEY_DBNAME].attr); WinQueryDlgItemText(hdlg, EF_TIMEOUT, sizeof (setupdlg->attr[KEY_BUSY].attr), setupdlg->attr[KEY_BUSY].attr); if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_NOWCHAR, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_NOWCHAR].attr, "1"); } else { strcpy(setupdlg->attr[KEY_NOWCHAR].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_STEPAPI, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_STEPAPI].attr, "1"); } else { strcpy(setupdlg->attr[KEY_STEPAPI].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_NOTXN, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_NOTXN].attr, "1"); } else { strcpy(setupdlg->attr[KEY_NOTXN].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_LONGNAM, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_LONGNAM].attr, "1"); } else { strcpy(setupdlg->attr[KEY_LONGNAM].attr, "0"); } SetDSNAttributes(hdlg, setupdlg); WinDismissDlg(hdlg, DID_OK); return 0; case DID_CANCEL: WinDismissDlg(hdlg, DID_OK); return 0; } break; } return WinDefDlgProc(hdlg, wmsg, wparam, lparam); } #endif /** * ODBC INSTAPI procedure for DSN configuration. * @param hwnd parent window handle * @param request type of request * @param driver driver name * @param attribs attribute string of DSN * @result true or false */ BOOL INSTAPI ConfigDSN(HWND hwnd, WORD request, LPCSTR driver, LPCSTR attribs) { BOOL success; SETUPDLG *setupdlg; setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return FALSE; } memset(setupdlg, 0, sizeof (SETUPDLG)); if (attribs) { ParseAttributes(attribs, setupdlg); } if (setupdlg->attr[KEY_DSN].supplied) { strcpy(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr); } else { setupdlg->DSN[0] = '\0'; } if (request == ODBC_REMOVE_DSN) { if (!setupdlg->attr[KEY_DSN].supplied) { success = FALSE; } else { success = SQLRemoveDSNFromIni(setupdlg->attr[KEY_DSN].attr); } } else { #if defined(_WIN32) || defined(_WIN64) setupdlg->parent = hwnd; #endif #ifdef __OS2__ setupdlg->parent = (SQLHWND) hwnd; #endif setupdlg->driver = driver; setupdlg->newDSN = request == ODBC_ADD_DSN; setupdlg->defDSN = strcasecmp(setupdlg->attr[KEY_DSN].attr, "Default") == 0; if (hwnd) { #if defined(_WIN32) || defined(_WIN64) success = DialogBoxParam(hModule, MAKEINTRESOURCE(CONFIGDSN), hwnd, (DLGPROC) ConfigDlgProc, (LPARAM) setupdlg) == IDOK; #endif #ifdef __OS2__ HMODULE hDLL; DosQueryModuleHandle("SQLLODBC.DLL", &hDLL); setupdlg->hDLL = hDLL; success = WinDlgBox(HWND_DESKTOP, hwnd, ConfigDlgProc, hDLL, DLG_SQLITEODBCCONFIGURATION, setupdlg); success = (success == DID_OK) ? TRUE : FALSE; #endif } else if (setupdlg->attr[KEY_DSN].supplied) { success = SetDSNAttributes(hwnd, setupdlg); } else { success = FALSE; } } xfree(setupdlg); return success; } #if defined(_WIN32) || defined(_WIN64) /** * Dialog procedure for SQLDriverConnect(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK DriverConnectProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLongPtr(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wparam, lparam) == IDOK); return TRUE; } } return FALSE; } #endif #ifdef __OS2__ /** * Dialog procedure for SQLDriverConnect(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result standard MRESULT */ static MRESULT EXPENTRY DriverConnectProc(HWND hdlg, ULONG wmsg, MPARAM wparam, MPARAM lparam) { SETUPDLG *setupdlg; switch (wmsg) { case WM_INITDLG: WinSetWindowULong(hdlg, QWL_USER, (ULONG) lparam); setupdlg = (SETUPDLG *) lparam; WinSetDlgItemText(hdlg, EF_DSNNAME, setupdlg->attr[KEY_DSN].attr); WinSetDlgItemText(hdlg, EF_DSNDESC, setupdlg->attr[KEY_DESC].attr); WinSetDlgItemText(hdlg, EF_DATABASE, setupdlg->attr[KEY_DBNAME].attr); WinSetDlgItemText(hdlg, EF_TIMEOUT, setupdlg->attr[KEY_BUSY].attr); WinCheckButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr)); WinCheckButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr)); WinCheckButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr)); WinCheckButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr)); return 0; case WM_COMMAND: switch (SHORT1FROMMP(wparam)) { case IDC_BROWSE: GetDBFile(hdlg); return 0; case DID_OK: setupdlg = (SETUPDLG *) WinQueryWindowULong(hdlg, QWL_USER); WinQueryDlgItemText(hdlg, EF_DSNNAME, sizeof (setupdlg->attr[KEY_DSN].attr), setupdlg->attr[KEY_DSN].attr); WinQueryDlgItemText(hdlg, EF_DATABASE, sizeof (setupdlg->attr[KEY_DBNAME].attr), setupdlg->attr[KEY_DBNAME].attr); WinQueryDlgItemText(hdlg, EF_TIMEOUT, sizeof (setupdlg->attr[KEY_BUSY].attr), setupdlg->attr[KEY_BUSY].attr); if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_NOWCHAR, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_NOWCHAR].attr, "1"); } else { strcpy(setupdlg->attr[KEY_NOWCHAR].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_STEPAPI, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_STEPAPI].attr, "1"); } else { strcpy(setupdlg->attr[KEY_STEPAPI].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_NOTXN, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_NOTXN].attr, "1"); } else { strcpy(setupdlg->attr[KEY_NOTXN].attr, "0"); } if ((ULONG)WinSendDlgItemMsg(hdlg, IDC_LONGNAM, BM_QUERYCHECK, 0, 0) == 1) { strcpy(setupdlg->attr[KEY_LONGNAM].attr, "1"); } else { strcpy(setupdlg->attr[KEY_LONGNAM].attr, "0"); } WinDismissDlg(hdlg, DID_OK); return 0; case DID_CANCEL: WinDismissDlg(hdlg, DID_CANCEL); return 0; } } return WinDefDlgProc(hdlg, wmsg, wparam, lparam); } #endif /** * Internal connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { BOOL maybeprompt, prompt = FALSE, defaultdsn = FALSE; DBC *d; SETUPDLG *setupdlg; SQLRETURN ret; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return SQL_ERROR; } memset(setupdlg, 0, sizeof (SETUPDLG)); maybeprompt = drvcompl == SQL_DRIVER_COMPLETE || drvcompl == SQL_DRIVER_COMPLETE_REQUIRED; if (connIn == NULL || !connInLen || (connInLen == SQL_NTS && !connIn[0])) { prompt = TRUE; } else { ParseAttributes((LPCSTR) connIn, setupdlg); if (!setupdlg->attr[KEY_DSN].attr[0] && drvcompl == SQL_DRIVER_COMPLETE_REQUIRED) { strcpy(setupdlg->attr[KEY_DSN].attr, "DEFAULT"); defaultdsn = TRUE; } GetAttributes(setupdlg); if (drvcompl == SQL_DRIVER_PROMPT || (maybeprompt && !setupdlg->attr[KEY_DBNAME].attr[0])) { prompt = TRUE; } } retry: if (prompt) { short dlgret; setupdlg->defDSN = setupdlg->attr[KEY_DRIVER].attr[0] != '\0'; #if defined(_WIN32) || defined(_WIN64) dlgret = DialogBoxParam(hModule, MAKEINTRESOURCE(DRIVERCONNECT), hwnd, (DLGPROC) DriverConnectProc, (LPARAM) setupdlg); #endif #ifdef __OS2__ HMODULE hDLL; DosQueryModuleHandle("SQLLODBC.DLL", &hDLL); setupdlg->hDLL = hDLL; dlgret = WinDlgBox(HWND_DESKTOP, (HWND) hwnd, DriverConnectProc, hDLL, DLG_SQLITEODBCCONFIGURATION, setupdlg); #endif if (!dlgret || dlgret == -1) { xfree(setupdlg); return SQL_NO_DATA; } } if (connOut || connOutLen) { char buf[SQL_MAX_MESSAGE_LENGTH * 4]; int len, count; char dsn_0 = (setupdlg->attr[KEY_DSN].attr[0] && !defaultdsn) ? setupdlg->attr[KEY_DSN].attr[0] : '\0'; char drv_0 = setupdlg->attr[KEY_DRIVER].attr[0]; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), "%s%s%s%s%s%sDatabase=%s;StepAPI=%s;" "NoTXN=%s;Timeout=%s;NoWCHAR=%s;LongNames=%s", dsn_0 ? "DSN=" : "", dsn_0 ? setupdlg->attr[KEY_DSN].attr : "", dsn_0 ? ";" : "", drv_0 ? "Driver=" : "", drv_0 ? setupdlg->attr[KEY_DRIVER].attr : "", drv_0 ? ";" : "", setupdlg->attr[KEY_DBNAME].attr, setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_BUSY].attr, setupdlg->attr[KEY_NOWCHAR].attr, setupdlg->attr[KEY_LONGNAM].attr); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } #if defined(HAVE_SQLITETRACE) && (HAVE_SQLITETRACE) if (setupdlg->attr[KEY_DSN].attr[0]) { char tracef[SQL_MAX_MESSAGE_LENGTH]; tracef[0] = '\0'; SQLGetPrivateProfileString(setupdlg->attr[KEY_DSN].attr, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } } #endif d->nowchar = getbool(setupdlg->attr[KEY_NOWCHAR].attr); d->longnames = getbool(setupdlg->attr[KEY_LONGNAM].attr); ret = dbopen(d, setupdlg->attr[KEY_DBNAME].attr, setupdlg->attr[KEY_DSN].attr, setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_BUSY].attr); if (ret != SQL_SUCCESS) { if (maybeprompt && !prompt) { prompt = TRUE; goto retry; } xfree(setupdlg); return ret; } xfree(setupdlg); return SQL_SUCCESS; } #endif /* WITHOUT_DRIVERMGR */ #endif /* _WIN32 || _WIN64 || __OS2__ */ #ifndef WINTERFACE /** * Connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdriverconnect(dbc, hwnd, connIn, connInLen, connOut, connOutMax, connOutLen, drvcompl); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect using a driver connection string (UNICODE version). * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnectW(SQLHDBC dbc, SQLHWND hwnd, SQLWCHAR *connIn, SQLSMALLINT connInLen, SQLWCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; char *ci = NULL; SQLSMALLINT len = 0; HDBC_LOCK(dbc); if (connIn) { if (connInLen == SQL_NTS) { connInLen = -1; } ci = uc_to_utf_c(connIn, connInLen); if (!ci) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); HDBC_UNLOCK(dbc); return SQL_ERROR; } } ret = drvdriverconnect(dbc, hwnd, (SQLCHAR *) ci, SQL_NTS, (SQLCHAR *) connOut, connOutMax, &len, drvcompl); HDBC_UNLOCK(dbc); uc_free(ci); if (ret == SQL_SUCCESS) { SQLWCHAR *co = NULL; if (connOut) { if (len > 0) { co = uc_from_utf((SQLCHAR *) connOut, len); if (co) { uc_strncpy(connOut, co, connOutMax / sizeof (SQLWCHAR)); len = min(connOutMax / sizeof (SQLWCHAR), uc_strlen(co)); uc_free(co); } else { len = 0; } } if (len <= 0) { len = 0; connOut[0] = 0; } } else { len = 0; } if (connOutLen) { *connOutLen = len; } } return ret; } #endif #if defined(_WIN32) || defined(_WIN64) /** * DLL initializer for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ BOOL APIENTRY LibMain(HANDLE hinst, DWORD reason, LPVOID reserved) { static int initialized = 0; switch (reason) { case DLL_PROCESS_ATTACH: if (!initialized++) { hModule = hinst; #ifdef WINTERFACE /* MS Access hack part 1 (reserved error -7748) */ statSpec2P = statSpec2; statSpec3P = statSpec3; #endif } break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: --initialized; break; case DLL_THREAD_DETACH: break; default: break; } return TRUE; } /** * DLL entry point for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ int __stdcall DllMain(HANDLE hinst, DWORD reason, LPVOID reserved) { return LibMain(hinst, reason, reserved); } #ifndef WITHOUT_INSTALLER /** * Handler for driver installer/uninstaller error messages. * @param name name of API function for which to show error messages * @result true when error message retrieved */ static BOOL InUnError(char *name) { WORD err = 1; DWORD code; char errmsg[301]; WORD errlen, errmax = sizeof (errmsg) - 1; int sqlret; BOOL ret = FALSE; do { errmsg[0] = '\0'; sqlret = SQLInstallerError(err, &code, errmsg, errmax, &errlen); if (SQL_SUCCEEDED(sqlret)) { MessageBox(NULL, errmsg, name, MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ret = TRUE; } err++; } while (sqlret != SQL_NO_DATA); return ret; } /** * Built in driver installer/uninstaller. * @param remove true for uninstall * @param cmdline command line string of rundll32 */ static BOOL InUn(int remove, char *cmdline) { #ifdef WINTERFACE static char *drivername = "SQLite ODBC (UTF-8) Driver"; static char *dsname = "SQLite3 UTF-8 Datasource"; #else static char *drivername = "SQLite3 ODBC Driver"; static char *dsname = "SQLite Datasource"; #endif char *dllname, *p; char dllbuf[301], path[301], driver[300], attr[300], inst[400]; WORD pathmax = sizeof (path) - 1, pathlen; DWORD usecnt, mincnt; int quiet = 0; dllbuf[0] = '\0'; GetModuleFileName(hModule, dllbuf, sizeof (dllbuf)); p = strrchr(dllbuf, '\\'); dllname = p ? (p + 1) : dllbuf; quiet = cmdline && strstr(cmdline, "quiet"); if (SQLInstallDriverManager(path, pathmax, &pathlen)) { sprintf(driver, "%s;Driver=%s;Setup=%s;", drivername, dllname, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } usecnt = 0; path[0] = '\0'; SQLInstallDriverEx(driver, NULL, path, pathmax, NULL, ODBC_INSTALL_INQUIRY, &usecnt); pathlen = strlen(path); while (pathlen > 0 && path[pathlen - 1] == '\\') { --pathlen; path[pathlen] = '\0'; } sprintf(driver, "%s;Driver=%s\\%s;Setup=%s\\%s;", drivername, path, dllname, path, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } sprintf(inst, "%s\\%s", path, dllname); if (!remove && usecnt > 0) { /* first install try: copy over driver dll, keeping DSNs */ if (GetFileAttributesA(dllbuf) != INVALID_FILE_ATTRIBUTES && CopyFile(dllbuf, inst, 0)) { if (!quiet) { char buf[512]; sprintf(buf, "%s replaced.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } return TRUE; } } mincnt = remove ? 1 : 0; while (usecnt != mincnt) { if (!SQLRemoveDriver(driver, TRUE, &usecnt)) { break; } } if (remove) { if (usecnt && !SQLRemoveDriver(driver, TRUE, &usecnt)) { InUnError("SQLRemoveDriver"); return FALSE; } if (!usecnt) { char buf[512]; DeleteFile(inst); if (!quiet) { sprintf(buf, "%s uninstalled.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); return TRUE; } if (GetFileAttributesA(dllbuf) == INVALID_FILE_ATTRIBUTES) { return FALSE; } if (strcmp(dllbuf, inst) != 0 && !CopyFile(dllbuf, inst, 0)) { char buf[512]; sprintf(buf, "Copy %s to %s failed.", dllbuf, inst); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); return FALSE; } if (!SQLInstallDriverEx(driver, path, path, pathmax, &pathlen, ODBC_INSTALL_COMPLETE, &usecnt)) { InUnError("SQLInstallDriverEx"); return FALSE; } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, drivername, attr)) { InUnError("SQLConfigDataSource"); return FALSE; } if (!quiet) { char buf[512]; sprintf(buf, "%s installed.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } else { InUnError("SQLInstallDriverManager"); return FALSE; } return TRUE; } /** * RunDLL32 entry point for driver installation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK install(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(0, lpszCmdLine); } /** * RunDLL32 entry point for driver uninstallation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK uninstall(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(1, lpszCmdLine); } #endif /* WITHOUT_INSTALLER */ #ifndef WITHOUT_SHELL /** * Setup argv vector from string * @param argcp pointer to argc * @param argvp pointer to argv * @param cmdline command line string * @param argv0 0th element for argv or NULL, must be static */ static void setargv(int *argcp, char ***argvp, char *cmdline, char *argv0) { char *p, *arg, *argspace, **argv; int argc, size, inquote, copy, slashes; size = 2 + (argv0 ? 1 : 0); for (p = cmdline; *p != '\0'; p++) { if (ISSPACE(*p)) { size++; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } } } argspace = malloc(size * sizeof (char *) + strlen(cmdline) + 1); argv = (char **) argspace; argspace += size * sizeof (char *); size--; argc = 0; if (argv0) { argv[argc++] = argv0; } p = cmdline; for (; argc < size; argc++) { argv[argc] = arg = argspace; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if (inquote && p[1] == '"') { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if (*p == '\0' || (!inquote && ISSPACE(*p))) { break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argspace = arg + 1; } argv[argc] = 0; *argcp = argc; *argvp = argv; } /** * RunDLL32 entry point for SQLite shell * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK shell(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int argc, needcon = 0; char **argv; extern int sqlite_main(int, char **); static const char *name = "SQLite Shell"; DWORD ftype0, ftype1, ftype2; ftype0 = GetFileType(GetStdHandle(STD_INPUT_HANDLE)); ftype1 = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); ftype2 = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); if (ftype0 != FILE_TYPE_DISK && ftype0 != FILE_TYPE_CHAR && ftype0 != FILE_TYPE_PIPE) { fclose(stdin); ++needcon; ftype0 = FILE_TYPE_UNKNOWN; } if (ftype1 != FILE_TYPE_DISK && ftype1 != FILE_TYPE_CHAR && ftype1 != FILE_TYPE_PIPE) { fclose(stdout); ++needcon; ftype1 = FILE_TYPE_UNKNOWN; } if (ftype2 != FILE_TYPE_DISK && ftype2 != FILE_TYPE_CHAR && ftype2 != FILE_TYPE_PIPE) { fclose(stderr); ++needcon; ftype2 = FILE_TYPE_UNKNOWN; } if (needcon > 0) { AllocConsole(); SetConsoleTitle(name); } if (ftype0 == FILE_TYPE_UNKNOWN) { freopen("CONIN$", "r", stdin); } if (ftype1 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stdout); } if (ftype2 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stderr); } setargv(&argc, &argv, lpszCmdLine, (char *) name); sqlite_main(argc, argv); } #endif /* WITHOUT_SHELL */ #endif /* _WIN32 || _WIN64 */ #if defined(HAVE_ODBCINSTEXT_H) && (HAVE_ODBCINSTEXT_H) /* * unixODBC property page for this driver, * may or may not work depending on unixODBC version. */ #include int ODBCINSTGetProperties(HODBCINSTPROPERTY prop) { static const char *instYN[] = { "No", "Yes", NULL }; prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_FILENAME; strncpy(prop->szName, "Database", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strncpy(prop->szName, "Timeout", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "100000", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "StepAPI", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #ifdef WINTERFACE prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "NoWCHAR", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #endif prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "LongNames", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); return 1; } #endif /* HAVE_ODBCINSTEXT_H */ ./sqliteodbc-0.992/sqliteodbc.h0100644000076400001440000002157712074001655015046 0ustar chwusers#ifndef _SQLITEODBC_H #define _SQLITEODBC_H /** * @mainpage * @section readme README * @verbinclude README * @section changelog ChangeLog * @verbinclude ChangeLog * @section copying License Terms * @verbinclude license.terms */ /** * @file sqliteodbc.h * Header file for SQLite ODBC driver. * * $Id: sqliteodbc.h,v 1.59 2013/01/11 12:20:56 chw Exp chw $ * * Copyright (c) 2001-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #ifdef __OS2__ #define INCL_WIN #define INCL_PM #define INCL_DOSMODULEMGR #define INCL_DOSERRORS #define INCL_WINSTDFILE #define ALLREADY_HAVE_OS2_TYPES #define DONT_TD_VOID #include #include #define ODBCVER 0x0300 #include "resourceos2.h" #endif #if defined(_WIN32) || defined(_WIN64) #include #if defined(HAVE_SQLITETRACE) && HAVE_SQLITETRACE #include #endif #else #include #include #include #include #include #endif #include #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) #include #endif #include #include #include #include #include #include #include "sqlite.h" #ifdef HAVE_IODBC #include #endif #if defined(HAVE_UNIXODBC) || defined(_WIN32) || defined(_WIN64) #include #endif #ifndef SQL_API #define SQL_API #endif #ifndef HAVE_SQLLEN #define SQLLEN SQLINTEGER #endif #define SQLLEN_PTR SQLLEN * #ifndef HAVE_SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef HAVE_SQLROWCOUNT #define SQLROWCOUNT SQLUINTEGER #endif #ifndef HAVE_SQLSETPOSIROW #define SQLSETPOSIROW SQLUSMALLINT #endif #ifndef HAVE_SQLROWOFFSET #define SQLROWOFFSET SQLLEN #endif #ifndef HAVE_SQLROWSETSIZE #define SQLROWSETSIZE SQLULEN #endif struct dbc; struct stmt; /** * @typedef ENV * @struct ENV * Driver internal structure for environment (HENV). */ typedef struct { int magic; /**< Magic cookie */ int ov3; /**< True for SQL_OV_ODBC3 */ #if defined(_WIN32) || defined(_WIN64) CRITICAL_SECTION cs; /**< For serializing most APIs */ DWORD owner; /**< Current owner of CS or 0 */ #endif struct dbc *dbcs; /**< Pointer to first DBC */ } ENV; /** * @typedef DBC * @struct dbc * Driver internal structure for database connection (HDBC). */ typedef struct dbc { int magic; /**< Magic cookie */ ENV *env; /**< Pointer to environment */ struct dbc *next; /**< Pointer to next DBC */ sqlite *sqlite; /**< SQLITE database handle */ int version; /**< SQLITE version number */ char *dbname; /**< SQLITE database name */ char *dsn; /**< ODBC data source name */ int timeout; /**< Lock timeout value */ long t0; /**< Start time for SQLITE busy handler */ int busyint; /**< Interrupt busy handler from SQLCancel() */ int *ov3; /**< True for SQL_OV_ODBC3 */ int ov3val; /**< True for SQL_OV_ODBC3 */ int autocommit; /**< Auto commit state */ int intrans; /**< True when transaction started */ struct stmt *stmt; /**< STMT list of this DBC */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar; /**< Don't try to use WCHAR */ int longnames; /**< Don't shorten column names */ int curtype; /**< Default cursor type */ int step_enable; /**< True for sqlite_compile/step/finalize */ int trans_disable; /**< True for no transaction support */ struct stmt *vm_stmt; /**< Current STMT executing VM */ int vm_rownum; /**< Current row number */ #if defined(HAVE_SQLITETRACE) && HAVE_SQLITETRACE FILE *trace; /**< sqlite_trace() file pointer or NULL */ #endif #ifdef USE_DLOPEN_FOR_GPPS void *instlib; int (*gpps)(); #endif #if defined(_WIN32) || defined(_WIN64) int xcelqrx; #endif } DBC; /** * @typedef COL * @struct COL * Internal structure to describe a column in a result set. */ typedef struct { char *db; /**< Database name */ char *table; /**< Table name */ char *column; /**< Column name */ int type; /**< Data type of column */ int size; /**< Size of column */ int index; /**< Index of column in result */ int nosign; /**< Unsigned type */ int scale; /**< Scale of column */ int prec; /**< Precision of column */ int autoinc; /**< AUTO_INCREMENT column */ int notnull; /**< NOT NULL constraint on column */ char *typename; /**< Column type name or NULL */ char *label; /**< Column label or NULL */ } COL; /** * @typedef BINDCOL * @struct BINDCOL * Internal structure for bound column (SQLBindCol). */ typedef struct { SQLSMALLINT type; /**< ODBC type */ SQLINTEGER max; /**< Max. size of value buffer */ SQLLEN *lenp; /**< Value return, actual size of value buffer */ SQLPOINTER valp; /**< Value buffer */ int index; /**< Index of column in result */ int offs; /**< Byte offset for SQLGetData() */ } BINDCOL; /** * @typedef BINDPARM * @struct BINDPARM * Internal structure for bound parameter (SQLBindParameter). */ typedef struct { int type, stype; /**< ODBC and SQL types */ int coldef, scale; /**< from SQLBindParameter() */ SQLLEN max; /**< Max. size size of parameter buffer */ SQLLEN *lenp; /**< Actual size of parameter buffer */ SQLLEN *lenp0; /**< Actual size of parameter buffer, initial value */ void *param; /**< Parameter buffer */ void *param0; /**< Parameter buffer, initial value */ int inc; /**< Increment for paramset size > 1 */ int need; /**< True when SQL_LEN_DATA_AT_EXEC */ int bound; /**< True when SQLBindParameter() called */ int offs, len; /**< Offset/length for SQLParamData()/SQLPutData() */ void *parbuf; /**< Buffer for SQL_LEN_DATA_AT_EXEC etc. */ char strbuf[64]; /**< String buffer for scalar data */ } BINDPARM; /** * @typedef STMT * @struct stmt * Driver internal structure representing SQL statement (HSTMT). */ typedef struct stmt { struct stmt *next; /**< Linkage for STMT list in DBC */ HDBC dbc; /**< Pointer to DBC */ SQLCHAR cursorname[32]; /**< Cursor name */ SQLCHAR *query; /**< Current query, raw string */ char **parmnames; /**< Parameter names from current query */ int *ov3; /**< True for SQL_OV_ODBC3 */ int isselect; /**< > 0 if query is a SELECT statement */ int ncols; /**< Number of result columns */ COL *cols; /**< Result column array */ COL *dyncols; /**< Column array, but malloc()ed */ int dcols; /**< Number of entries in dyncols */ int bkmrk; /**< True when bookmarks used */ BINDCOL bkmrkcol; /**< Bookmark bound column */ BINDCOL *bindcols; /**< Array of bound columns */ int nbindcols; /**< Number of entries in bindcols */ int nbindparms; /**< Number bound parameters */ BINDPARM *bindparms; /**< Array of bound parameters */ int nparams; /**< Number of parameters in query */ int pdcount; /**< SQLParamData() counter */ int nrows; /**< Number of result rows */ int rowp; /**< Current result row */ char **rows; /**< 2-dim array, result set */ void (*rowfree)(); /**< Free function for rows */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar[2]; /**< Don't try to use WCHAR */ int longnames; /**< Don't shorten column names */ SQLULEN retr_data; /**< SQL_ATTR_RETRIEVE_DATA */ SQLULEN rowset_size; /**< Size of rowset */ SQLUSMALLINT *row_status; /**< Row status pointer */ SQLUSMALLINT *row_status0; /**< Internal status array */ SQLUSMALLINT row_status1; /**< Internal status array for 1 row rowsets */ SQLULEN *row_count; /**< Row count pointer */ SQLULEN row_count0; /**< Row count */ SQLULEN paramset_size; /**< SQL_ATTR_PARAMSET_SIZE */ SQLULEN paramset_count; /**< Internal for paramset */ SQLUINTEGER paramset_nrows; /**< Row count for paramset handling */ SQLULEN bind_type; /**< SQL_ATTR_ROW_BIND_TYPE */ SQLULEN *bind_offs; /**< SQL_ATTR_ROW_BIND_OFFSET_PTR */ /* Dummies to make ADO happy */ SQLULEN *parm_bind_offs; /**< SQL_ATTR_PARAM_BIND_OFFSET_PTR */ SQLUSMALLINT *parm_oper; /**< SQL_ATTR_PARAM_OPERATION_PTR */ SQLUSMALLINT *parm_status; /**< SQL_ATTR_PARAMS_STATUS_PTR */ SQLULEN *parm_proc; /**< SQL_ATTR_PARAMS_PROCESSED_PTR */ SQLULEN parm_bind_type; /**< SQL_ATTR_PARAM_BIND_TYPE */ int curtype; /**< Cursor type */ sqlite_vm *vm; /**< SQLite VM or NULL */ #if HAVE_ENCDEC char *bincell; /**< Undecoded string */ char *bincache; /**< Cached decoded binary data */ int binlen; /**< Length of decoded binary data */ char *hexcache; /**< Cached decoded binary in hex */ #endif } STMT; #endif ./sqliteodbc-0.992/sqliteodbc.rc0100644000076400001440000001126412074001102015176 0ustar chwusers#include #include #include "resource.h" #include "sqlite.h" #ifndef SQLITE_VERSION #define SQLITE_VERSION "?.?.?" #endif ///////////////////////////////////////////////////////////////////////////// // // Dialog // DRIVERCONNECT DIALOG DISCARDABLE 65, 43, 287, 111 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU #ifdef SQLITE_UTF8 CAPTION "SQLite ODBC (UTF-8) Driver Connect" #else CAPTION "SQLite ODBC Driver Connect" #endif FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,50,50,15 CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 225,50,45,15 #ifdef SQLITE_UTF8 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,65,50,15 #endif CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,65,95,15 DEFPUSHBUTTON "OK",IDOK,175,90,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,90,40,14 CTEXT "Enter options for connect",1003,95,5,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP END CONFIGDSN DIALOG DISCARDABLE 65, 43, 287, 111 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU #ifdef SQLITE_UTF8 CAPTION "SQLite ODBC (UTF-8) DSN Configuration" #else CAPTION "SQLite ODBC DSN Configuration" #endif FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,50,50,15 CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 225,50,45,15 #ifdef SQLITE_UTF8 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,65,50,15 #endif CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,65,95,15 DEFPUSHBUTTON "OK",IDOK,175,90,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,90,40,14 CTEXT "Enter options for connect",1003,95,5,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP END ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" #ifdef SQLITE_UTF8 VALUE "FileDescription", "SQLite ODBC (UTF-8) Driver\0" #else VALUE "FileDescription", "SQLite ODBC Driver\0" #endif VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "SQLITEODBC\0" VALUE "LegalCopyright", "Copyright İ 2001-2013 \0" VALUE "LegalTrademarks", "\0" #ifdef SQLITE_UTF8 VALUE "OriginalFilename", "SQLITEODBCU.DLL\0" #else VALUE "OriginalFilename", "SQLITEODBC.DLL\0" #endif VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN #ifdef SQLITE_UTF8 IDS_MSGTITLE "SQLite ODBC (UTF-8) Setup" #else IDS_MSGTITLE "SQLite ODBC Setup" #endif IDS_BADDSN "%s cannot be used as a data source name." END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/sqliteodbc.mak0100644000076400001440000000447610470050460015362 0ustar chwusers# VC++ 6 Makefile CC= cl LN= link RC= rc !IF "$(DEBUG)" == "1" LDEBUG= /DEBUG CDEBUG= -Zi !ELSE LDEBUG= /RELEASE !ENDIF !IF "$(ENCODING)" == "" ENCODING= ISO8859 !ENDIF CFLAGS= -I. -Isqlite -Gs -GX -D_WIN32 -D_DLL -nologo $(CDEBUG) \ -DHAVE_ENCDEC=1 -DHAVE_LIBVERSION=1 -DHAVE_SQLITEATOF=1 \ -DHAVE_SQLITEMPRINTF=1 CFLAGSEXE= -I. -Gs -GX -D_WIN32 -nologo $(CDEBUG) DLLLFLAGS= /NODEFAULTLIB $(LDEBUG) /NOLOGO /MACHINE:IX86 \ /SUBSYSTEM:WINDOWS /DLL DLLLIBS= msvcrt.lib odbccp32.lib kernel32.lib \ user32.lib comdlg32.lib sqlite\libsqlite.lib !IF "$(ENCODING)" == "UTF8" DRVDLL= sqliteodbcu.dll !ELSE DRVDLL= sqliteodbc.dll !ENDIF OBJECTS= sqliteodbc.obj .c.obj: $(CC) $(CFLAGS) /c $< all: $(DRVDLL) inst.exe uninst.exe adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe SQLiteODBCInstaller.exe clean: del *.obj del *.res del *.exp del *.ilk del *.pdb del *.res del resource.h del *.exe cd sqlite nmake -f ..\sqlite.mak clean cd .. uninst.exe: inst.exe copy inst.exe uninst.exe inst.exe: inst.c $(CC) $(CFLAGSEXE) inst.c odbc32.lib odbccp32.lib \ kernel32.lib user32.lib remdsn.exe: adddsn.exe copy adddsn.exe remdsn.exe adddsn.exe: adddsn.c $(CC) $(CFLAGSEXE) adddsn.c odbc32.lib odbccp32.lib \ kernel32.lib user32.lib remsysdsn.exe: adddsn.exe copy adddsn.exe remsysdsn.exe addsysdsn.exe: adddsn.exe copy adddsn.exe addsysdsn.exe fixup.exe: fixup.c $(CC) $(CFLAGSEXE) fixup.c mkopc.exe: mkopc.c $(CC) $(CFLAGSEXE) mkopc.c SQLiteODBCInstaller.exe: SQLiteODBCInstaller.c $(CC) $(CFLAGSEXE) SQLiteODBCInstaller.c \ kernel32.lib user32.lib sqliteodbc.c: resource.h sqliteodbc.res: sqliteodbc.rc resource.h $(RC) -I. -Isqlite -fo sqliteodbc.res -r sqliteodbc.rc sqliteodbc.dll: sqlite\libsqlite.lib $(OBJECTS) sqliteodbc.res $(LN) $(DLLLFLAGS) $(OBJECTS) sqliteodbc.res \ -def:sqliteodbc.def -out:$@ $(DLLLIBS) sqliteodbcu.dll: sqlite\libsqlite.lib $(OBJECTS) sqliteodbc.res $(LN) $(DLLLFLAGS) $(OBJECTS) sqliteodbc.res \ -def:sqliteodbcu.def -out:$@ $(DLLLIBS) VERSION_C: VERSION .\fixup < VERSION > VERSION_C . , resource.h: resource.h.in VERSION_C fixup.exe .\fixup < resource.h.in > resource.h \ --VERS-- @VERSION \ --VERS_C-- @VERSION_C sqlite\libsqlite.lib: fixup.exe mkopc.exe cd sqlite nmake -f ..\sqlite.mak ENCODING=$(ENCODING) cd .. ./sqliteodbc-0.992/sqliteodbc.def0100644000076400001440000000222410466721303015343 0ustar chwusersLIBRARY SQLITEODBC DESCRIPTION 'SQLite ODBC Driver ' SEGMENTS DLL_TEXT PRELOAD INIT_TEXT PRELOAD HEAPSIZE 1024 EXPORTS SQLBulkOperations SQLDataSources SQLDrivers SQLBrowseConnect SQLPutData SQLBindParameter SQLBindParam SQLNumParams SQLParamData SQLDescribeParam SQLSetParam SQLParamOptions SQLTablePrivileges SQLColumnPrivileges SQLPrimaryKeys SQLSpecialColumns SQLForeignKeys SQLEndTran SQLTransact SQLNativeSql SQLProcedures SQLProcedureColumns SQLGetEnvAttr SQLSetEnvAttr SQLGetDiagRec SQLGetDiagField SQLGetStmtOption SQLSetStmtOption SQLSetPos SQLSetScrollOptions SQLGetInfo SQLGetFunctions SQLGetConnectAttr SQLSetConnectAttr SQLGetConnectOption SQLSetConnectOption SQLConnect SQLDisconnect SQLDriverConnect SQLCancel SQLGetCursorName SQLSetCursorName SQLCloseCursor SQLBindCol SQLTables SQLColumns SQLGetTypeInfo SQLStatistics SQLGetData SQLFetch SQLFetchScroll SQLExtendedFetch SQLRowCount SQLNumResultCols SQLDescribeCol SQLColAttributes SQLColAttribute SQLError SQLMoreResults SQLPrepare SQLExecute SQLExecDirect SQLAllocHandle SQLFreeHandle SQLGetStmtAttr SQLSetStmtAttr SQLAllocStmt SQLFreeStmt SQLAllocConnect SQLFreeConnect ConfigDSN install uninstall ./sqliteodbc-0.992/sqliteodbcu.def0100644000076400001440000000234210466721346015540 0ustar chwusersLIBRARY SQLITEODBCU DESCRIPTION 'SQLite ODBC (UTF-8) Driver ' SEGMENTS DLL_TEXT PRELOAD INIT_TEXT PRELOAD HEAPSIZE 1024 EXPORTS SQLBulkOperations SQLDataSourcesW SQLDriversW SQLBrowseConnectW SQLPutData SQLBindParameter SQLBindParam SQLNumParams SQLParamData SQLDescribeParam SQLSetParam SQLParamOptions SQLTablePrivilegesW SQLColumnPrivilegesW SQLPrimaryKeysW SQLSpecialColumnsW SQLForeignKeysW SQLEndTran SQLTransact SQLNativeSqlW SQLProceduresW SQLProcedureColumnsW SQLGetEnvAttr SQLSetEnvAttr SQLGetDiagRecW SQLGetDiagFieldW SQLGetStmtOptionW SQLSetStmtOptionW SQLGetStmtOption SQLSetStmtOption SQLSetPos SQLSetScrollOptions SQLGetInfoW SQLGetFunctions SQLGetConnectAttrW SQLSetConnectAttrW SQLGetConnectOptionW SQLSetConnectOptionW SQLConnectW SQLDisconnect SQLDriverConnectW SQLCancel SQLGetCursorNameW SQLSetCursorNameW SQLCloseCursor SQLBindCol SQLTablesW SQLColumnsW SQLGetTypeInfoW SQLStatisticsW SQLGetData SQLFetch SQLFetchScroll SQLExtendedFetch SQLRowCount SQLNumResultCols SQLDescribeColW SQLColAttributesW SQLColAttributeW SQLErrorW SQLMoreResults SQLPrepareW SQLExecute SQLExecDirectW SQLAllocHandle SQLFreeHandle SQLGetStmtAttrW SQLSetStmtAttrW SQLAllocStmt SQLFreeStmt SQLAllocConnect SQLFreeConnect ConfigDSN install uninstall ./sqliteodbc-0.992/sqlite3odbc.c0100644000076400001440000160052012113324641015111 0ustar chwusers/** * @file sqlite3odbc.c * SQLite3 ODBC Driver main module. * * $Id: sqlite3odbc.c,v 1.153 2013/02/27 06:36:58 chw Exp chw $ * * Copyright (c) 2004-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #if defined(SQLITE_HAS_CODEC) && defined(SQLITE_API) #undef WITH_SQLITE_DLLS #undef SQLITE_DYNLOAD #include "sqlite3.c" #endif #if defined(WITH_SQLITE_DLLS) && (WITH_SQLITE_DLLS > 1) #define SQLITE_DYNLOAD 1 #endif #include "sqlite3odbc.h" #ifdef SQLITE_DYNLOAD #undef MEMORY_DEBUG #if defined(_WIN32) || defined(_WIN64) static void dls_init(void); static void dls_fini(void); #else void dls_init(void); void dls_fini(void); #endif static struct dl_sqlite3_funcs { void (*activate_see)(const char *p0); int (*bind_blob)(sqlite3_stmt *p0, int p1, const void *p2, int p3, void (*p4)(void *)); int (*bind_double)(sqlite3_stmt *p0, int p1, double p2); int (*bind_int)(sqlite3_stmt *p0, int p1, int p2); int (*bind_int64)(sqlite3_stmt *p0, int p1, sqlite_int64 p2); int (*bind_null)(sqlite3_stmt *p0, int p1); int (*bind_parameter_count)(sqlite3_stmt *p0); int (*bind_text)(sqlite3_stmt *p0, int p1, const char *p2, int p3, void (*p4)(void *)); int (*busy_handler)(sqlite3 *p0, int (*p2)(void *, int), void *p3); int (*changes)(sqlite3 *p0); int (*close)(sqlite3 *p0); const void * (*column_blob)(sqlite3_stmt *p0, int p1); int (*column_bytes)(sqlite3_stmt *p0, int p1); int (*column_count)(sqlite3_stmt *p0); const char * (*column_database_name)(sqlite3_stmt *p0, int p1); const char * (*column_decltype)(sqlite3_stmt *p0, int p1); double (*column_double)(sqlite3_stmt *p0, int p1); const char * (*column_name)(sqlite3_stmt *p0, int p1); const char * (*column_origin_name)(sqlite3_stmt *p0, int p1); const char * (*column_table_name)(sqlite3_stmt *p0, int p1); const unsigned char * (*column_text)(sqlite3_stmt *p0, int p1); int (*column_type)(sqlite3_stmt *p0, int p1); int (*create_function)(sqlite3 *p0, const char *p1, int p2, int p3, void *p4, void (*p5)(sqlite3_context *, int, sqlite3_value **), void (*p6)(sqlite3_context *, int, sqlite3_value **), void (*p7)(sqlite3_context *)); int (*enable_load_extension)(sqlite3 *p0, int p1); int (*errcode)(sqlite3 *p0); const char * (*errmsg)(sqlite3 *p0); int (*exec)(sqlite3 *p0, const char *p1, int (*p2)(void *, int, char **, char **), void *p3, char **p4); int (*finalize)(sqlite3_stmt *p0); void (*free)(void *p0); void (*free_table)(char **p0); int (*get_table)(sqlite3 *p0, const char *p1, char ***p2, int *p3, int *p4, char **p5); void (*interrupt)(sqlite3 *p0); int (*key)(sqlite3 *p0, const void *p1, int p2); const char * (*libversion)(void); int (*load_extension)(sqlite3 *p0, const char *p1, const char *p2, char **p3); void * (*malloc)(int p0); char * (*mprintf)(const char *p0, ...); int (*open)(const char *p0, sqlite3 **p1); int (*open16)(const void *p0, sqlite3 **p1); int (*open_v2)(const char *p0, sqlite3 **p1, int p2, const char *p3); int (*prepare)(sqlite3 *p0, const char *p1, int p2, sqlite3_stmt **p3, const char **p4); int (*prepare_v2)(sqlite3 *p0, const char *p1, int p2, sqlite3_stmt **p3, const char **p4); void * (*profile)(sqlite3 *p0, void (*p1)(void *, const char *, sqlite3_uint64), void *p2); void * (*realloc)(void *p0, int p1); int (*rekey)(sqlite3 *p0, const void *p1, int p2); int (*reset)(sqlite3_stmt *p0); void (*result_blob)(sqlite3_context *p0, const void *p1, int p2, void (*p3)(void *)); void (*result_error)(sqlite3_context *p0, const char *p1, int p2); void (*result_int)(sqlite3_context *p0, int p1); void (*result_null)(sqlite3_context *p0); int (*step)(sqlite3_stmt *p0); int (*xstrnicmp)(const char *p0, const char *p1, int p2); int (*table_column_metadata)(sqlite3 *p0, const char *p1, const char *p2, const char *p3, char const **p4, char const **p5, int *p6, int *p7, int *p8); void * (*trace)(sqlite3 *p0, void (*p1)(void *, const char *), void *p2); void * (*user_data)(sqlite3_context *p0); const void * (*value_blob)(sqlite3_value *p0); int (*value_bytes)(sqlite3_value *p0); const unsigned char * (*value_text)(sqlite3_value *p0); int (*value_type)(sqlite3_value *p0); } dls_funcs; #define sqlite3_activate_see dls_funcs.activate_see #define sqlite3_bind_blob dls_funcs.bind_blob #define sqlite3_bind_double dls_funcs.bind_double #define sqlite3_bind_int dls_funcs.bind_int #define sqlite3_bind_int64 dls_funcs.bind_int64 #define sqlite3_bind_null dls_funcs.bind_null #define sqlite3_bind_parameter_count dls_funcs.bind_parameter_count #define sqlite3_bind_text dls_funcs.bind_text #define sqlite3_busy_handler dls_funcs.busy_handler #define sqlite3_changes dls_funcs.changes #define sqlite3_close dls_funcs.close #define sqlite3_column_blob dls_funcs.column_blob #define sqlite3_column_bytes dls_funcs.column_bytes #define sqlite3_column_count dls_funcs.column_count #define sqlite3_column_database_name dls_funcs.column_database_name #define sqlite3_column_decltype dls_funcs.column_decltype #define sqlite3_column_double dls_funcs.column_double #define sqlite3_column_name dls_funcs.column_name #define sqlite3_column_origin_name dls_funcs.column_origin_name #define sqlite3_column_table_name dls_funcs.column_table_name #define sqlite3_column_text dls_funcs.column_text #define sqlite3_column_type dls_funcs.column_type #define sqlite3_create_function dls_funcs.create_function #define sqlite3_enable_load_extension dls_funcs.enable_load_extension #define sqlite3_errcode dls_funcs.errcode #define sqlite3_errmsg dls_funcs.errmsg #define sqlite3_exec dls_funcs.exec #define sqlite3_finalize dls_funcs.finalize #define sqlite3_free dls_funcs.free #define sqlite3_free_table dls_funcs.free_table #define sqlite3_get_table dls_funcs.get_table #define sqlite3_interrupt dls_funcs.interrupt #define sqlite3_key dls_funcs.key #define sqlite3_libversion dls_funcs.libversion #define sqlite3_load_extension dls_funcs.load_extension #define sqlite3_malloc dls_funcs.malloc #define sqlite3_mprintf dls_funcs.mprintf #define sqlite3_open dls_funcs.open #define sqlite3_open16 dls_funcs.open16 #define sqlite3_open_v2 dls_funcs.open_v2 #define sqlite3_prepare dls_funcs.prepare #define sqlite3_prepare_v2 dls_funcs.prepare_v2 #define sqlite3_profile dls_funcs.profile #define sqlite3_realloc dls_funcs.realloc #define sqlite3_rekey dls_funcs.rekey #define sqlite3_reset dls_funcs.reset #define sqlite3_result_blob dls_funcs.result_blob #define sqlite3_result_error dls_funcs.result_error #define sqlite3_result_int dls_funcs.result_int #define sqlite3_result_null dls_funcs.result_null #define sqlite3_step dls_funcs.step #define sqlite3_strnicmp dls_funcs.xstrnicmp #define sqlite3_table_column_metadata dls_funcs.table_column_metadata #define sqlite3_trace dls_funcs.trace #define sqlite3_user_data dls_funcs.user_data #define sqlite3_value_blob dls_funcs.value_blob #define sqlite3_value_bytes dls_funcs.value_bytes #define sqlite3_value_text dls_funcs.value_text #define sqlite3_value_type dls_funcs.value_type #endif #ifndef WITHOUT_WINTERFACE #define WINTERFACE #define WCHARSUPPORT #endif #if !defined(_WIN32) && !defined(_WIN64) #if !defined(WCHARSUPPORT) && defined(HAVE_SQLWCHAR) && (HAVE_SQLWCHAR) #define WCHARSUPPORT #endif #endif #if defined(WINTERFACE) #include #endif #if defined(_WIN32) || defined(_WIN64) #include "resource3.h" #define ODBC_INI "ODBC.INI" #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO VERSION #endif #else #define ODBC_INI ".odbc.ini" #endif #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO "0.0" #endif #ifndef COLATTRIBUTE_LAST_ARG_TYPE #ifdef _WIN64 #define COLATTRIBUTE_LAST_ARG_TYPE SQLLEN * #else #define COLATTRIBUTE_LAST_ARG_TYPE SQLPOINTER #endif #endif #ifndef SETSTMTOPTION_LAST_ARG_TYPE #define SETSTMTOPTION_LAST_ARG_TYPE SQLROWCOUNT #endif #undef min #define min(a, b) ((a) < (b) ? (a) : (b)) #undef max #define max(a, b) ((a) < (b) ? (b) : (a)) #ifndef PTRDIFF_T #define PTRDIFF_T int #endif #define array_size(x) (sizeof (x) / sizeof (x[0])) #define stringify1(s) #s #define stringify(s) stringify1(s) #define verinfo(maj, min, lev) ((maj) << 16 | (min) << 8 | (lev)) /* Column types for static string column descriptions (SQLTables etc.) */ #if defined(WINTERFACE) && !defined(_WIN32) && !defined(_WIN64) #define SCOL_VARCHAR SQL_WVARCHAR #define SCOL_CHAR SQL_WCHAR #else #define SCOL_VARCHAR SQL_VARCHAR #define SCOL_CHAR SQL_CHAR #endif #define ENV_MAGIC 0x53544145 #define DBC_MAGIC 0x53544144 #define DEAD_MAGIC 0xdeadbeef static const char *xdigits = "0123456789ABCDEFabcdef"; #ifdef MEMORY_DEBUG static void * xmalloc_(int n, char *file, int line) { int nn = n + 4 * sizeof (long); long *p; p = malloc(nn); if (!p) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\tNULL\t%s:%d\n", n, file, line); #endif return NULL; } p[0] = 0xdead1234; nn = nn / sizeof (long) - 1; p[1] = n; p[nn] = 0xdead5678; #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\t%p\t%s:%d\n", n, &p[2], file, line); #endif return (void *) &p[2]; } static void * xrealloc_(void *old, int n, char *file, int line) { int nn = n + 4 * sizeof (long), nnn; long *p, *pp; if (n == 0 || !old) { return xmalloc_(n, file, line); } p = &((long *) old)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", old); abort(); } nnn = p[1] + 4 * sizeof (long); nnn = nnn / sizeof (long) - 1; if (p[nnn] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", old); abort(); } pp = realloc(p, nn); if (!pp) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\tNULL\t%s:%d\n", old, n, file, line); #endif return NULL; } #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\t%p\t%s:%d\n", old, n, &pp[2], file, line); #endif p = pp; p[1] = n; nn = nn / sizeof (long) - 1; p[nn] = 0xdead5678; return (void *) &p[2]; } static void xfree_(void *x, char *file, int line) { long *p; int n; if (!x) { return; } p = &((long *) x)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", x); abort(); } n = p[1] + 4 * sizeof (long); n = n / sizeof (long) - 1; if (p[n] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", x); abort(); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "free\t%p\t\t%s:%d\n", x, file, line); #endif free(p); } static void xfree__(void *x) { xfree_(x, "unknown location", 0); } static char * xstrdup_(const char *str, char *file, int line) { char *p; if (!str) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\tNULL\tNULL\t%s:%d\n", file, line); #endif return NULL; } p = xmalloc_(strlen(str) + 1, file, line); if (p) { strcpy(p, str); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\t%p\t%p\t%s:%d\n", str, p, file, line); #endif return p; } #define xmalloc(x) xmalloc_(x, __FILE__, __LINE__) #define xrealloc(x,y) xrealloc_(x, y, __FILE__, __LINE__) #define xfree(x) xfree_(x, __FILE__, __LINE__) #define xstrdup(x) xstrdup_(x, __FILE__, __LINE__) #else #define xmalloc(x) sqlite3_malloc(x) #define xrealloc(x,y) sqlite3_realloc(x, y) #define xfree(x) sqlite3_free(x) #define xstrdup(x) strdup_(x) #endif #if defined(_WIN32) || defined(_WIN64) #define vsnprintf _vsnprintf #define snprintf _snprintf #define strcasecmp _stricmp #define strncasecmp _strnicmp static HINSTANCE NEAR hModule; /* Saved module handle for resources */ #endif #ifdef HAVE_SQLITE3STRNICMP #undef strncasecmp #define strncasecmp(A,B,C) sqlite3_strnicmp(A,B,C) #undef strcasecmp #define strcasecmp(A,B) strcasecmp_(A,B) #if defined(__GNUC__) && (__GNUC__ >= 2) static int strcasecmp_(const char *a, const char *b) __attribute__((__unused__)); #endif static int strcasecmp_(const char *a, const char *b) { int c = strlen(a), d = strlen(b); if (c > d) { return strncasecmp(a, b, c); } return strncasecmp(a, b, d); } #endif #if defined(_WIN32) || defined(_WIN64) /* * SQLHENV, SQLHDBC, and SQLHSTMT synchronization * is done using a critical section in ENV structure. */ #define HDBC_LOCK(hdbc) \ { \ DBC *d; \ \ if ((hdbc) == SQL_NULL_HDBC) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) (hdbc); \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HDBC_UNLOCK(hdbc) \ if ((hdbc) != SQL_NULL_HDBC) { \ DBC *d; \ \ d = (DBC *) (hdbc); \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #define HSTMT_LOCK(hstmt) \ { \ DBC *d; \ \ if ((hstmt) == SQL_NULL_HSTMT) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HSTMT_UNLOCK(hstmt) \ if ((hstmt) != SQL_NULL_HSTMT) { \ DBC *d; \ \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #else /* * On UN*X assume that we are single-threaded or * the driver manager provides serialization for us. * * In iODBC (3.52.x) serialization can be turned * on using the DSN property "ThreadManager=yes". * * In unixODBC that property is named * "Threading=0-3" and takes one of these values: * * 0 - no protection * 1 - statement level protection * 2 - connection level protection * 3 - environment level protection * * unixODBC 2.2.11 uses environment level protection * by default when it has been built with pthread * support. */ #define HDBC_LOCK(hdbc) #define HDBC_UNLOCK(hdbc) #define HSTMT_LOCK(hdbc) #define HSTMT_UNLOCK(hdbc) #endif #if defined(ENABLE_NVFS) && (ENABLE_NVFS) extern void nvfs_init(void); extern const char *nvfs_makevfs(const char *); #endif /* * tolower() replacement w/o locale */ static const char upper_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char lower_chars[] = "abcdefghijklmnopqrstuvwxyz"; static int TOLOWER(int c) { if (c) { char *p = strchr(upper_chars, c); if (p) { c = lower_chars[p - upper_chars]; } } return c; } /* * isdigit() replacement w/o ctype.h */ static const char digit_chars[] = "0123456789"; #define ISDIGIT(c) \ ((c) && strchr(digit_chars, (c)) != NULL) /* * isspace() replacement w/o ctype.h */ static const char space_chars[] = " \f\n\r\t\v"; #define ISSPACE(c) \ ((c) && strchr(space_chars, (c)) != NULL) /* * Forward declarations of static functions. */ static void dbtraceapi(DBC *d, char *fn, const char *sql); static void freedyncols(STMT *s); static void freeresult(STMT *s, int clrcols); static void freerows(char **rowp); static void unbindcols(STMT *s); static void s3stmt_drop(STMT *s); static SQLRETURN drvexecute(SQLHSTMT stmt, int initial); static SQLRETURN freestmt(HSTMT stmt); static SQLRETURN mkbindcols(STMT *s, int ncols); static SQLRETURN setupdyncols(STMT *s, sqlite3_stmt *s3stmt, int *ncolsp); static SQLRETURN setupparbuf(STMT *s, BINDPARM *p); static SQLRETURN starttran(STMT *s); static SQLRETURN setupparam(STMT *s, char *sql, int pnum); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 1 (reserved error -7748) */ static COL *statSpec2P, *statSpec3P; #endif #if (MEMORY_DEBUG < 1) /** * Duplicate string using xmalloc(). * @param str string to be duplicated * @result pointer to new string or NULL */ static char * strdup_(const char *str) { char *p = NULL; if (str) { p = xmalloc(strlen(str) + 1); if (p) { strcpy(p, str); } } return p; } #endif #ifdef WCHARSUPPORT /** * Return length of UNICODE string. * @param str UNICODE string * @result length of string in characters */ static int uc_strlen(SQLWCHAR *str) { int len = 0; if (str) { while (*str) { ++len; ++str; } } return len; } /** * Copy UNICODE string like strncpy(). * @param dest destination area * @param src source area * @param len length of source area in characters * @return pointer to destination area */ static SQLWCHAR * uc_strncpy(SQLWCHAR *dest, SQLWCHAR *src, int len) { int i = 0; while (i < len) { if (!src[i]) { break; } dest[i] = src[i]; ++i; } if (i < len) { dest[i] = 0; } return dest; } /** * Make UNICODE string from UTF8 string into buffer. * @param str UTF8 string to be converted * @param len length in characters of str or -1 * @param uc destination area to receive UNICODE string * @param ucLen byte length of destination area */ static void uc_from_utf_buf(unsigned char *str, int len, SQLWCHAR *uc, int ucLen) { ucLen = ucLen / sizeof (SQLWCHAR); if (!uc || ucLen < 0) { return; } if (len < 0) { len = ucLen * 5; } uc[0] = 0; if (str) { int i = 0; while (i < len && *str && i < ucLen) { unsigned char c = str[0]; if (c < 0x80) { uc[i++] = c; ++str; } else if (c <= 0xc1 || c >= 0xf5) { /* illegal, ignored */ ++str; } else if (c < 0xe0) { if ((str[1] & 0xc0) == 0x80) { unsigned long t = ((c & 0x1f) << 6) | (str[1] & 0x3f); uc[i++] = t; str += 2; } else { uc[i++] = c; ++str; } } else if (c < 0xf0) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80) { unsigned long t = ((c & 0x0f) << 12) | ((str[1] & 0x3f) << 6) | (str[2] & 0x3f); uc[i++] = t; str += 3; } else { uc[i++] = c; ++str; } } else if (c < 0xf8) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80) { unsigned long t = ((c & 0x03) << 18) | ((str[1] & 0x3f) << 12) | ((str[2] & 0x3f) << 6) | (str[3] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 4; } else { uc[i++] = c; ++str; } } else if (c < 0xfc) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80 && (str[4] & 0xc0) == 0x80) { unsigned long t = ((c & 0x01) << 24) | ((str[1] & 0x3f) << 18) | ((str[2] & 0x3f) << 12) | ((str[3] & 0x3f) << 6) | (str[4] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 5; } else { uc[i++] = c; ++str; } } else { /* ignore */ ++str; } } if (i < ucLen) { uc[i] = 0; } } } /** * Make UNICODE string from UTF8 string. * @param str UTF8 string to be converted * @param len length of UTF8 string * @return alloc'ed UNICODE string to be free'd by uc_free() */ static SQLWCHAR * uc_from_utf(unsigned char *str, int len) { SQLWCHAR *uc = NULL; int ucLen; if (str) { if (len == SQL_NTS) { len = strlen((char *) str); } ucLen = sizeof (SQLWCHAR) * (len + 1); uc = xmalloc(ucLen); if (uc) { uc_from_utf_buf(str, len, uc, ucLen); } } return uc; } /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in bytes * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf(SQLWCHAR *str, int len) { int i; char *cp, *ret = NULL; if (!str) { return ret; } if (len == SQL_NTS) { len = uc_strlen(str); } else { len = len / sizeof (SQLWCHAR); } cp = xmalloc(len * 6 + 1); if (!cp) { return ret; } ret = cp; for (i = 0; i < len; i++) { unsigned long c = str[i]; if (sizeof (SQLWCHAR) == 2 * sizeof (char)) { c &= 0xffff; } if (c < 0x80) { *cp++ = c; } else if (c < 0x800) { *cp++ = 0xc0 | ((c >> 6) & 0x1f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x10000) { if (sizeof (SQLWCHAR) == 2 * sizeof (char) && c >= 0xd800 && c <= 0xdbff && i + 1 < len) { unsigned long c2 = str[i + 1] & 0xffff; if (c2 >= 0xdc00 && c2 <= 0xdfff) { c = (((c & 0x3ff) << 10) | (c2 & 0x3ff)) + 0x10000; *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); ++i; continue; } } *cp++ = 0xe0 | ((c >> 12) & 0x0f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x200000) { *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x4000000) { *cp++ = 0xf8 | ((c >> 24) & 0x03); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x80000000) { *cp++ = 0xfc | ((c >> 31) & 0x01); *cp++ = 0x80 | ((c >> 24) & 0x3f); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } } *cp = '\0'; return ret; } #endif #ifdef WINTERFACE /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in characters * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf_c(SQLWCHAR *str, int len) { if (len != SQL_NTS) { len = len * sizeof (SQLWCHAR); } return uc_to_utf(str, len); } #endif #if defined(WCHARSUPPORT) || defined(_WIN32) || defined(_WIN64) /** * Free converted UTF8 or UNICODE string. * @param str string to be free'd */ static void uc_free(void *str) { if (str) { xfree(str); } } #endif #if defined(_WIN32) || defined(_WIN64) /** * Convert multibyte, current code page string to UTF8 string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * wmb_to_utf(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(cp, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(cp, 0, str, len, wstr, nchar); wstr[nchar] = 0; str = xmalloc((nchar + 1) * 7); if (!str) { xfree(wstr); return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, nchar * 7, 0, 0); str[nchar] = '\0'; xfree(wstr); return str; } #ifndef WINTERFACE /** * Convert multibyte, current code page string to UTF8 string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * wmb_to_utf_c(char *str, int len) { if (len == SQL_NTS) { len = strlen(str); } return wmb_to_utf(str, len); } #endif /** * Convert UTF8 string to multibyte, current code page string, * @param str UTF8 string to be converted * @param len length of UTF8 string * @return alloc'ed multibyte string to be free'd by uc_free() */ static char * utf_to_wmb(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(CP_UTF8, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(CP_UTF8, 0, str, len, wstr, nchar); wstr[nchar] = 0; str = xmalloc((nchar + 1) * 7); if (!str) { xfree(wstr); return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(cp, 0, wstr, -1, str, nchar * 7, 0, 0); str[nchar] = '\0'; xfree(wstr); return str; } #ifdef WINTERFACE /** * Convert multibyte, current code page string to UNICODE string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UNICODE string to be free'd by uc_free() */ static WCHAR * wmb_to_uc(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(cp, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(cp, 0, str, len, wstr, nchar); wstr[nchar] = 0; return wstr; } /** * Convert UNICODE string to multibyte, current code page string, * @param str UNICODE string to be converted * @param len length of UNICODE string * @return alloc'ed multibyte string to be free'd by uc_free() */ static char * uc_to_wmb(WCHAR *wstr, int len) { char *str; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = WideCharToMultiByte(cp, 0, wstr, len, NULL, 0, 0, 0); str = xmalloc((nchar + 1) * 2); if (!str) { return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(cp, 0, wstr, len, str, nchar * 2, 0, 0); str[nchar] = '\0'; return str; } #endif /* WINTERFACE */ #endif /* _WIN32 || _WIN64 */ #ifdef USE_DLOPEN_FOR_GPPS #include #define SQLGetPrivateProfileString(A,B,C,D,E,F) drvgpps(d,A,B,C,D,E,F) /* * EXPERIMENTAL: SQLGetPrivateProfileString infrastructure using * dlopen(), in theory this makes the driver independent from the * driver manager, i.e. the same driver binary can run with iODBC * and unixODBC. */ static void drvgetgpps(DBC *d) { void *lib; int (*gpps)(); lib = dlopen("libodbcinst.so.1", RTLD_LAZY); if (!lib) { lib = dlopen("libodbcinst.so", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so.2", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so", RTLD_LAZY); } if (lib) { gpps = (int (*)()) dlsym(lib, "SQLGetPrivateProfileString"); if (!gpps) { dlclose(lib); return; } d->instlib = lib; d->gpps = gpps; } } static void drvrelgpps(DBC *d) { if (d->instlib) { dlclose(d->instlib); d->instlib = 0; } } static int drvgpps(DBC *d, char *sect, char *ent, char *def, char *buf, int bufsiz, char *fname) { if (d->gpps) { return d->gpps(sect, ent, def, buf, bufsiz, fname); } strncpy(buf, def, bufsiz); buf[bufsiz - 1] = '\0'; return 1; } #else #include #define drvgetgpps(d) #define drvrelgpps(d) #endif /* * Internal function to bind SQLite3 parameters. */ static void s3bind(DBC *d, sqlite3_stmt *stmt, int nparams, BINDPARM *p) { int i; if (stmt && p && nparams > 0) { for (i = 0; i < nparams; i++, p++) { switch (p->s3type) { default: case SQLITE_NULL: sqlite3_bind_null(stmt, i + 1); if (d->trace) { fprintf(d->trace, "-- parameter %d: NULL\n", i + 1); fflush(d->trace); } break; case SQLITE_TEXT: sqlite3_bind_text(stmt, i + 1, p->s3val, p->s3size, SQLITE_STATIC); if (d->trace) { fprintf(d->trace, "-- parameter %d: '%*s'\n", i + 1, p->s3size, (char *) p->s3val); fflush(d->trace); } break; case SQLITE_BLOB: sqlite3_bind_blob(stmt, i + 1, p->s3val, p->s3size, SQLITE_STATIC); if (d->trace) { fprintf(d->trace, "-- parameter %d: [BLOB]'\n", i + 1); fflush(d->trace); } break; case SQLITE_FLOAT: sqlite3_bind_double(stmt, i + 1, p->s3dval); if (d->trace) { fprintf(d->trace, "-- parameter %d: %g\n", i + 1, p->s3dval); fflush(d->trace); } break; case SQLITE_INTEGER: if (p->s3size > sizeof (int)) { sqlite3_bind_int64(stmt, i + 1, p->s3lival); if (d->trace) { fprintf(d->trace, #ifdef _WIN32 "-- parameter %d: %I64d\n", #else "-- parameter %d: %lld\n", #endif i + 1, p->s3lival); fflush(d->trace); } } else { sqlite3_bind_int(stmt, i + 1, p->s3ival); if (d->trace) { fprintf(d->trace, "-- parameter %d: %d\n", i + 1, p->s3ival); fflush(d->trace); } } break; } } } } /** * @typedef TBLRES * @struct tblres * Internal structure for managing driver's * sqlite3_get_table() implementation. */ typedef struct tblres { char **resarr; /**< result array */ char *errmsg; /**< error message or NULL */ sqlite3_stmt *stmt; /**< SQLite3 statement pointer */ STMT *s; /**< Driver statement pointer */ int nalloc; /**< alloc'ed size of result array */ int nrow; /**< number of rows in result array */ int ncol; /**< number of columns in result array */ PTRDIFF_T ndata; /**< index into result array */ int rc; /**< SQLite return code */ } TBLRES; /* * Driver's version of sqlite3_get_table() and friends which are * capable of dealing with blobs. */ static int drvgettable_row(TBLRES *t, int ncol, int rc) { int need; int i; char *p; if (t->nrow == 0 && rc == SQLITE_ROW) { need = ncol * 2; } else { need = ncol; } if (t->ndata + need >= t->nalloc) { char **resnew; int nalloc = t->nalloc * 2 + need + 1; resnew = xrealloc(t->resarr, sizeof (char *) * nalloc); if (!resnew) { nomem: t->rc = SQLITE_NOMEM; return 1; } t->nalloc = nalloc; t->resarr = resnew; } /* column names when first row */ if (t->nrow == 0) { t->ncol = ncol; for (i = 0; i < ncol; i++) { p = (char *) sqlite3_column_name(t->stmt, i); if (p) { char *q = xmalloc(strlen(p) + 1); if (!q) { goto nomem; } strcpy(q, p); p = q; } t->resarr[t->ndata++] = p; } if (t->s && t->s->guessed_types) { int ncol2 = ncol; setupdyncols(t->s, t->stmt, &ncol2); t->s->guessed_types = 0; t->s->ncols = ncol; } } else if (t->ncol != ncol) { t->errmsg = sqlite3_mprintf("drvgettable() called with two or" " more incompatible queries"); t->rc = SQLITE_ERROR; return 1; } /* copy row data */ if (rc == SQLITE_ROW) { for (i = 0; i < ncol; i++) { int coltype = sqlite3_column_type(t->stmt, i); p = NULL; if (coltype == SQLITE_BLOB) { int k, nbytes = sqlite3_column_bytes(t->stmt, i); char *qp; unsigned const char *bp; bp = sqlite3_column_blob(t->stmt, i); qp = xmalloc(nbytes * 2 + 4); if (!qp) { goto nomem; } p = qp; *qp++ = 'X'; *qp++ = '\''; for (k = 0; k < nbytes; k++) { *qp++ = xdigits[(bp[k] >> 4)]; *qp++ = xdigits[(bp[k] & 0xF)]; } *qp++ = '\''; *qp = '\0'; #ifdef _MSC_VER } else if (coltype == SQLITE_FLOAT) { static struct lconv *lc = 0; double val = sqlite3_column_double(t->stmt, i); char buffer[128]; /* * This avoids floating point rounding * and formatting problems of some SQLite * versions in conjunction with MSVC 2010. */ snprintf(buffer, sizeof (buffer), "%.15g", val); if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { p = strchr(buffer, lc->decimal_point[0]); if (p) { *p = '.'; } } p = xstrdup(buffer); if (!p) { goto nomem; } #endif } else if (coltype != SQLITE_NULL) { p = xstrdup((char *) sqlite3_column_text(t->stmt, i)); if (!p) { goto nomem; } } t->resarr[t->ndata++] = p; } t->nrow++; } return 0; } static int drvgettable(STMT *s, const char *sql, char ***resp, int *nrowp, int *ncolp, char **errp, int nparam, BINDPARM *p) { DBC *d = (DBC *) s->dbc; int rc = SQLITE_OK, keep = sql == NULL; TBLRES tres; const char *sqlleft = 0; int nretry = 0, haveerr = 0; if (!resp) { return SQLITE_ERROR; } *resp = NULL; if (nrowp) { *nrowp = 0; } if (ncolp) { *ncolp = 0; } tres.errmsg = NULL; tres.nrow = 0; tres.ncol = 0; tres.ndata = 1; tres.nalloc = 20; tres.rc = SQLITE_OK; tres.resarr = xmalloc(sizeof (char *) * tres.nalloc); tres.stmt = NULL; tres.s = s; if (!tres.resarr) { return SQLITE_NOMEM; } tres.resarr[0] = 0; if (sql == NULL) { tres.stmt = s->s3stmt; if (tres.stmt == NULL) { return SQLITE_NOMEM; } goto retrieve; } while (sql && *sql && (rc == SQLITE_OK || (rc == SQLITE_SCHEMA && (++nretry) < 2))) { int ncol; tres.stmt = NULL; #if defined(HAVE_SQLITE3PREPAREV2) && (HAVE_SQLITE3PREPAREV2) dbtraceapi(d, "sqlite3_prepare_v2", sql); rc = sqlite3_prepare_v2(d->sqlite, sql, -1, &tres.stmt, &sqlleft); #else dbtraceapi(d, "sqlite3_prepare", sql); rc = sqlite3_prepare(d->sqlite, sql, -1, &tres.stmt, &sqlleft); #endif if (rc != SQLITE_OK) { if (tres.stmt) { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(tres.stmt); tres.stmt = NULL; } continue; } if (!tres.stmt) { /* this happens for a comment or white-space */ sql = sqlleft; continue; } retrieve: if (sqlite3_bind_parameter_count(tres.stmt) != nparam) { if (errp) { *errp = sqlite3_mprintf("%s", "parameter marker count incorrect"); } haveerr = 1; rc = SQLITE_ERROR; goto tbldone; } s3bind(d, tres.stmt, nparam, p); ncol = sqlite3_column_count(tres.stmt); while (1) { if (s->max_rows && tres.nrow >= s->max_rows) { rc = SQLITE_OK; break; } rc = sqlite3_step(tres.stmt); if (rc == SQLITE_ROW || rc == SQLITE_DONE) { if (drvgettable_row(&tres, ncol, rc)) { rc = SQLITE_ABORT; goto tbldone; } } if (rc != SQLITE_ROW) { if (keep) { dbtraceapi(d, "sqlite3_reset", 0); rc = sqlite3_reset(tres.stmt); s->s3stmt_noreset = 1; } else { dbtraceapi(d, "sqlite3_finalize", 0); rc = sqlite3_finalize(tres.stmt); } tres.stmt = 0; if (rc != SQLITE_SCHEMA) { nretry = 0; sql = sqlleft; while (sql && ISSPACE(*sql)) { sql++; } } if (rc == SQLITE_DONE) { rc = SQLITE_OK; } break; } } } tbldone: if (tres.stmt) { if (keep) { if (!s->s3stmt_noreset) { dbtraceapi(d, "sqlite3_reset", 0); sqlite3_reset(tres.stmt); s->s3stmt_noreset = 1; } } else { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(tres.stmt); } } if (haveerr) { /* message already in *errp if any */ } else if (rc != SQLITE_OK && rc == sqlite3_errcode(d->sqlite) && errp) { *errp = sqlite3_mprintf("%s", sqlite3_errmsg(d->sqlite)); } else if (errp) { *errp = NULL; } if (tres.resarr) { tres.resarr[0] = (char *) (tres.ndata - 1); } if (rc == SQLITE_ABORT) { freerows(&tres.resarr[1]); if (tres.errmsg) { if (errp) { if (*errp) { sqlite3_free(*errp); } *errp = tres.errmsg; } else { sqlite3_free(tres.errmsg); } } return tres.rc; } sqlite3_free(tres.errmsg); if (rc != SQLITE_OK) { freerows(&tres.resarr[1]); return rc; } *resp = &tres.resarr[1]; if (ncolp) { *ncolp = tres.ncol; } if (nrowp) { *nrowp = tres.nrow; } return rc; } /** * Set error message and SQL state on DBC * @param d database connection pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstatd(DBC *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstatd(DBC *d, int naterr, char *msg, char *st, ...) { va_list ap; if (!d) { return; } d->naterr = naterr; d->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) d->logmsg, sizeof (d->logmsg), msg, ap); va_end(ap); if (count < 0) { d->logmsg[sizeof (d->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(d->sqlstate, st, 5); d->sqlstate[5] = '\0'; } /** * Set error message and SQL state on statement * @param s statement pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstat(STMT *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstat(STMT *s, int naterr, char *msg, char *st, ...) { va_list ap; if (!s) { return; } s->naterr = naterr; s->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) s->logmsg, sizeof (s->logmsg), msg, ap); va_end(ap); if (count < 0) { s->logmsg[sizeof (s->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(s->sqlstate, st, 5); s->sqlstate[5] = '\0'; } /** * Report IM001 (not implemented) SQL error code for HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvunimpldbc(HDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; setstatd(d, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Report IM001 (not implemented) SQL error code for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN drvunimplstmt(HSTMT stmt) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; setstat(s, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Free memory given pointer to memory pointer. * @param x pointer to pointer to memory to be free'd */ static void freep(void *x) { if (x && ((char **) x)[0]) { xfree(((char **) x)[0]); ((char **) x)[0] = NULL; } } /** * Report S1000 (out of memory) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN nomem(STMT *s) { setstat(s, -1, "out of memory", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Report S1000 (not connected) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN noconn(STMT *s) { setstat(s, -1, "not connected", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal locale neutral strtod function. * @param data pointer to string * @param endp pointer for ending character * @result double value */ #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) static double ln_strtod(const char *data, char **endp) { static struct lconv *lc = 0; char buf[128], *p, *end; double value; if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { strncpy(buf, data, sizeof (buf) - 1); buf[sizeof (buf) - 1] = '\0'; p = strchr(buf, '.'); if (p) { *p = lc->decimal_point[0]; } p = buf; } else { p = (char *) data; } value = strtod(p, &end); end = (char *) data + (end - p); if (endp) { *endp = end; } return value; } #else #define ln_strtod(A,B) strtod(A,B) #endif /** * Strip quotes from quoted string in-place. * @param str string */ static char * unquote(char *str) { if (str) { int len = strlen(str); if (len > 1) { if ((str[0] == '\'' && str[len - 1] == '\'') || (str[0] == '"' && str[len - 1] == '"') || (str[0] == '[' && str[len - 1] == ']')) { str[len - 1] = '\0'; strcpy(str, str + 1); } } } return str; } /** * Unescape search pattern for e.g. table name in * catalog functions. Replacements in string are done in-place. * @param str string * @result number of pattern characters in string or 0 */ static int unescpat(char *str) { char *p, *q; int count = 0; p = str; while ((q = strchr(p, '_')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '%')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '\\')) != NULL) { if (q[1] == '\\' || q[1] == '_' || q[1] == '%') { strcpy(q, q + 1); } p = q + 1; } return count; } /** * SQL LIKE string match with optional backslash escape handling. * @param str string * @param pat pattern * @param esc when true, treat literally "\\" as "\", "\%" as "%", "\_" as "_" * @result true when pattern matched */ static int namematch(char *str, char *pat, int esc) { int cp, ch; while (1) { cp = TOLOWER(*pat); if (cp == '\0') { if (*str != '\0') { goto nomatch; } break; } if (*str == '\0' && cp != '%') { goto nomatch; } if (cp == '%') { while (*pat == '%') { ++pat; } cp = TOLOWER(*pat); if (cp == '\0') { break; } while (1) { if (cp != '_' && cp != '\\') { while (*str) { ch = TOLOWER(*str); if (ch == cp) { break; } ++str; } } if (namematch(str, pat, esc)) { goto match; } if (*str == '\0') { goto nomatch; } ch = TOLOWER(*str); ++str; } } if (cp == '_') { pat++; str++; continue; } if (esc && cp == '\\' && (pat[1] == '\\' || pat[1] == '%' || pat[1] == '_')) { ++pat; cp = TOLOWER(*pat); } ch = TOLOWER(*str++); ++pat; if (ch != cp) { goto nomatch; } } match: return 1; nomatch: return 0; } /** * Busy callback for SQLite. * @param udata user data, pointer to DBC * @param count count of subsequenct calls * @result true or false */ static int busy_handler(void *udata, int count) { DBC *d = (DBC *) udata; long t1; int ret = 0; #if !defined(_WIN32) && !defined(_WIN64) struct timeval tv; #ifdef HAVE_NANOSLEEP struct timespec ts; #endif #endif if (d->busyint) { d->busyint = 0; return ret; } if (d->timeout <= 0) { return ret; } if (count <= 1) { #if defined(_WIN32) || defined(_WIN64) d->t0 = GetTickCount(); #else gettimeofday(&tv, NULL); d->t0 = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif } #if defined(_WIN32) || defined(_WIN64) t1 = GetTickCount(); #else gettimeofday(&tv, NULL); t1 = tv.tv_sec * 1000 + tv.tv_usec / 1000; #endif if (t1 - d->t0 > d->timeout) { goto done; } #if defined(_WIN32) || defined(_WIN64) Sleep(10); #else #ifdef HAVE_NANOSLEEP ts.tv_sec = 0; ts.tv_nsec = 10000000; do { ret = nanosleep(&ts, &ts); if (ret < 0 && errno != EINTR) { ret = 0; } } while (ret); #else #ifdef HAVE_USLEEP usleep(10000); #else tv.tv_sec = 0; tv.tv_usec = 10000; select(0, NULL, NULL, NULL, &tv); #endif #endif #endif ret = 1; done: return ret; } /** * Set SQLite options (PRAGMAs) given SQLite handle. * @param x SQLite database handle * @param d DBC pointer * @result SQLite error code * * SQLite < 3.3.x and not shortnames DSN option: * "full_column_names" is always turned on and "short_column_names" * is always turned off, to get the table names in column labels. */ static int setsqliteopts(sqlite3 *x, DBC *d) { int count = 0, step = 0, max, rc = SQLITE_ERROR; #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) max = d->longnames ? 3 : 1; #else max = 3; #endif if (d->shortnames) { max = 3; } while (step < max) { if (step < 1) { rc = sqlite3_exec(x, "PRAGMA empty_result_callbacks = on;", NULL, NULL, NULL); if (rc == SQLITE_OK) { rc = sqlite3_exec(x, d->fksupport ? "PRAGMA foreign_keys = on;" : "PRAGMA foreign_keys = off;", NULL, NULL, NULL); } } else if (step < 2) { rc = sqlite3_exec(x, d->shortnames ? "PRAGMA full_column_names = off;" : "PRAGMA full_column_names = on;", NULL, NULL, NULL); } else if (step < 3) { rc = sqlite3_exec(x, d->shortnames ? "PRAGMA short_column_names = on;" : "PRAGMA short_column_names = off;", NULL, NULL, NULL); } if (rc != SQLITE_OK) { if (rc != SQLITE_BUSY || !busy_handler((void *) d, ++count)) { return rc; } continue; } count = 0; ++step; } sqlite3_busy_handler(x, busy_handler, (void *) d); return SQLITE_OK; } /** * Free counted array of char pointers. * @param rowp pointer to char pointer array * * The -1-th element of the array holds the array size. * All non-NULL pointers of the array and then the array * itself are free'd. */ static void freerows(char **rowp) { PTRDIFF_T size, i; if (!rowp) { return; } --rowp; size = (PTRDIFF_T) rowp[0]; for (i = 1; i <= size; i++) { freep(&rowp[i]); } freep(&rowp); } /** * Map SQL field type from string to ODBC integer type code. * @param typename field type string * @param nosign pointer to indicator for unsigned field or NULL * @param ov3 boolean, true for SQL_OV_ODBC3 * @param nowchar boolean, for WINTERFACE don't use WCHAR * @param dobigint boolean, force SQL_BIGINT on INTEGER columns * @result SQL data type */ static int mapsqltype(const char *typename, int *nosign, int ov3, int nowchar, int dobigint) { char *p, *q; int testsign = 0, result; #ifdef WINTERFACE result = nowchar ? SQL_VARCHAR : SQL_WVARCHAR; #else result = SQL_VARCHAR; #endif if (!typename) { return result; } q = p = xmalloc(strlen(typename) + 1); if (!p) { return result; } strcpy(p, typename); while (*q) { *q = TOLOWER(*q); ++q; } if (strncmp(p, "inter", 5) == 0) { } else if (strncmp(p, "int", 3) == 0 || strncmp(p, "mediumint", 9) == 0) { testsign = 1; result = SQL_INTEGER; } else if (strncmp(p, "numeric", 7) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "tinyint", 7) == 0) { testsign = 1; result = SQL_TINYINT; } else if (strncmp(p, "smallint", 8) == 0) { testsign = 1; result = SQL_SMALLINT; } else if (strncmp(p, "float", 5) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "double", 6) == 0 || strncmp(p, "real", 4) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "timestamp", 9) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "datetime", 8) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "time", 4) == 0) { #ifdef SQL_TYPE_TIME result = ov3 ? SQL_TYPE_TIME : SQL_TIME; #else result = SQL_TIME; #endif } else if (strncmp(p, "date", 4) == 0) { #ifdef SQL_TYPE_DATE result = ov3 ? SQL_TYPE_DATE : SQL_DATE; #else result = SQL_DATE; #endif #ifdef SQL_LONGVARCHAR } else if (strncmp(p, "text", 4) == 0 || strncmp(p, "memo", 4) == 0 || strncmp(p, "longvarchar", 11) == 0) { #ifdef WINTERFACE result = nowchar ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else result = SQL_LONGVARCHAR; #endif #ifdef WINTERFACE } else if (strncmp(p, "wtext", 5) == 0 || strncmp(p, "wvarchar", 8) == 0 || strncmp(p, "longwvarchar", 12) == 0) { result = SQL_WLONGVARCHAR; #endif #endif #ifdef SQL_BIT } else if (strncmp(p, "bool", 4) == 0 || strncmp(p, "bit", 3) == 0) { result = SQL_BIT; #endif #ifdef SQL_BIGINT } else if (strncmp(p, "bigint", 6) == 0) { testsign = 1; result = SQL_BIGINT; #endif } else if (strncmp(p, "blob", 4) == 0) { result = SQL_BINARY; } else if (strncmp(p, "varbinary", 9) == 0) { result = SQL_VARBINARY; } else if (strncmp(p, "longvarbinary", 13) == 0) { result = SQL_LONGVARBINARY; } if (nosign) { if (testsign) { *nosign = strstr(p, "unsigned") != NULL; } else { *nosign = 1; } } #ifdef SQL_BIGINT if (dobigint && result == SQL_INTEGER) { result = SQL_BIGINT; } #endif xfree(p); return result; } /** * Get maximum display size and number of digits after decimal point * from field type specification. * @param typename field type specification * @param sqltype target SQL data type * @param mp pointer to maximum display size or NULL * @param dp pointer to number of digits after decimal point or NULL */ static void getmd(const char *typename, int sqltype, int *mp, int *dp) { int m = 0, d = 0; switch (sqltype) { case SQL_INTEGER: m = 10; d = 9; break; case SQL_TINYINT: m = 4; d = 3; break; case SQL_SMALLINT: m = 6; d = 5; break; case SQL_FLOAT: m = 25; d = 24; break; case SQL_DOUBLE: m = 54; d = 53; break; case SQL_VARCHAR: m = 255; d = 0; break; #ifdef WINTERFACE #ifdef SQL_WVARCHAR case SQL_WVARCHAR: m = 255; d = 0; break; #endif #endif #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: m = 10; d = 0; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: m = 8; d = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: m = 32; d = 3; break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR : m = 65536; d = 0; break; #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: m = 65536; d = 0; break; #endif #endif case SQL_VARBINARY: m = 255; d = 0; break; case SQL_LONGVARBINARY: m = 65536; d = 0; break; #ifdef SQL_BIGINT case SQL_BIGINT: m = 20; d = 19; break; #endif #ifdef SQL_BIT case SQL_BIT: m = 1; d = 1; break; #endif } if (m && typename) { int mm, dd; if (sscanf(typename, "%*[^(](%d)", &mm) == 1) { if (sqltype == SQL_TIMESTAMP) { d = mm; } #ifdef SQL_TYPE_TIMESTAMP else if (sqltype == SQL_TYPE_TIMESTAMP) { d = mm; } #endif else { m = d = mm; } } else if (sscanf(typename, "%*[^(](%d,%d)", &mm, &dd) == 2) { m = mm; d = dd; } } if (mp) { *mp = m; } if (dp) { *dp = d; } } /** * Map SQL_C_DEFAULT to proper C type. * @param type input C type * @param stype input SQL type * @param nosign 0=signed, 0>unsigned, 0 0) ? SQL_C_ULONG : SQL_C_LONG; break; case SQL_TINYINT: type = (nosign > 0) ? SQL_C_UTINYINT : SQL_C_TINYINT; break; case SQL_SMALLINT: type = (nosign > 0) ? SQL_C_USHORT : SQL_C_SHORT; break; case SQL_FLOAT: type = SQL_C_FLOAT; break; case SQL_DOUBLE: type = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: type = SQL_C_TIMESTAMP; break; case SQL_TIME: type = SQL_C_TIME; break; case SQL_DATE: type = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: type = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: type = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: type = SQL_C_TYPE_DATE; break; #endif #ifdef WINTERFACE case SQL_WVARCHAR: case SQL_WCHAR: #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: #endif type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; break; #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: type = SQL_C_BINARY; break; #ifdef SQL_BIT case SQL_BIT: type = SQL_C_BIT; break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: type = SQL_C_CHAR; break; #endif default: #ifdef WINTERFACE type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; #else type = SQL_C_CHAR; #endif break; } } return type; } /** * Fixup query string with optional parameter markers. * @param sql original query string * @param sqlLen length of query string or SQL_NTS * @param nparam output number of parameters * @param isselect output indicator for SELECT (1) or DDL statement (2) * @param errmsg output error message * @result newly allocated string containing query string for SQLite or NULL */ static char * fixupsql(char *sql, int sqlLen, int *nparam, int *isselect, char **errmsg) { char *q = sql, *qz = NULL, *p, *inq = NULL, *out; int np = 0, isddl = -1, size; *errmsg = NULL; if (sqlLen != SQL_NTS) { qz = q = xmalloc(sqlLen + 1); if (!qz) { return NULL; } memcpy(q, sql, sqlLen); q[sqlLen] = '\0'; size = sqlLen * 4; } else { size = strlen(sql) * 4; } size += sizeof (char *) - 1; size &= ~(sizeof (char *) - 1); p = xmalloc(size); if (!p) { errout: freep(&qz); return NULL; } memset(p, 0, size); out = p; while (*q) { switch (*q) { case '\'': case '\"': if (q == inq) { inq = NULL; } else if (!inq) { inq = q + 1; while (*inq) { if (*inq == *q) { if (inq[1] == *q) { inq++; } else { break; } } inq++; } } *p++ = *q; break; case '?': *p++ = *q; if (!inq) { np++; } break; case ';': if (!inq) { if (isddl < 0) { char *qq = out; while (*qq && ISSPACE(*qq)) { ++qq; } if (*qq && *qq != ';') { int i; static const struct { int len; const char *str; } ddlstr[] = { { 5, "alter" }, { 7, "analyze" }, { 6, "attach" }, { 5, "begin" }, { 6, "commit" }, { 6, "create" }, { 6, "detach" }, { 4, "drop" }, { 3, "end" }, { 7, "reindex" }, { 7, "release" }, { 8, "rollback" }, { 9, "savepoint" }, { 6, "vacuum" } }; size = strlen(qq); for (i = 0; i < array_size(ddlstr); i++) { if (size >= ddlstr[i].len && strncasecmp(qq, ddlstr[i].str, ddlstr[i].len) == 0) { isddl = 1; break; } } if (isddl != 1) { isddl = 0; } } } if (isddl == 0) { char *qq = q; do { ++qq; } while (*qq && ISSPACE(*qq)); if (*qq && *qq != ';') { freep(&out); *errmsg = "only one SQL statement allowed"; goto errout; } } } *p++ = *q; break; case '{': /* * Deal with escape sequences: * {d 'YYYY-MM-DD'}, {t ...}, {ts ...} * {oj ...}, {fn ...} etc. */ if (!inq) { int ojfn = 0; char *inq2 = NULL, *end = q + 1; if (*end != 'd' && *end != 'D' && *end != 't' && *end != 'T') { ojfn = 1; } while (*end) { if (inq2 && *end == *inq2) { inq2 = NULL; } else if (inq2 == NULL && *end == '}') { break; } else if (inq2 == NULL && (*end == '\'' || *end == '"')) { inq2 = end; } ++end; } if (*end == '}') { char *start = q + 1; char *end2 = end - 1; if (ojfn) { while (start < end) { if (ISSPACE(*start)) { break; } ++start; } while (start < end) { *p++ = *start; ++start; } q = end; break; } else { while (start < end2 && *start != '\'') { ++start; } while (end2 > start && *end2 != '\'') { --end2; } if (*start == '\'' && *end2 == '\'') { while (start <= end2) { *p++ = *start; ++start; } q = end; break; } } } } /* FALL THROUGH */ default: *p++ = *q; } ++q; } freep(&qz); *p = '\0'; if (nparam) { *nparam = np; } if (isselect) { if (isddl > 0) { *isselect = 2; } else { int incom = 0; p = out; while (*p) { switch (*p) { case '-': if (!incom && p[1] == '-') { incom = -1; } break; case '\n': if (incom < 0) { incom = 0; } break; case '/': if (incom > 0 && p[-1] == '*') { incom = 0; p++; continue; } else if (!incom && p[1] == '*') { incom = 1; } break; } if (!incom && !ISSPACE(*p)) { break; } p++; } size = strlen(p); if (size >= 6 && (strncasecmp(p, "select", 6) == 0 || strncasecmp(p, "pragma", 6) == 0)) { *isselect = 1; } else { *isselect = 0; } } } return out; } /** * Find column given name in string array. * @param cols string array * @param ncols number of strings * @param name column name * @result >= 0 on success, -1 on error */ static int findcol(char **cols, int ncols, char *name) { int i; if (cols) { for (i = 0; i < ncols; i++) { if (strcmp(cols[i], name) == 0) { return i; } } } return -1; } /** * Fixup column information for a running statement. * @param s statement to get fresh column information * @param d DBC pointer * * The column labels get the table names stripped * when there's more than one column and all table * names are identical. * * The "dyncols" field of STMT is filled with column * information obtained by SQLite "PRAGMA table_info" * for each column whose table name is known. If the * types are already present as with SQLite 2.5.7 * this information is used instead. */ static void fixupdyncols(STMT *s, DBC *d) { int i; #if !defined(HAVE_SQLITE3TABLECOLUMNMETADATA) || !(HAVE_SQLITE3TABLECOLUMNMETADATA) int k, pk, nn, t, r, nrows, ncols; char **rowp, *flagp, flags[128]; #endif if (!s->dyncols) { return; } /* fixup labels */ if (!s->longnames) { if (s->dcols > 1) { char *table = s->dyncols[0].table; for (i = 1; table[0] && i < s->dcols; i++) { if (strcmp(s->dyncols[i].table, table)) { break; } } if (i >= s->dcols) { for (i = 0; i < s->dcols; i++) { s->dyncols[i].label = s->dyncols[i].column; } } } else if (s->dcols == 1) { s->dyncols[0].label = s->dyncols[0].column; } } for (i = 0; i < s->dcols; i++) { s->dyncols[i].type = mapsqltype(s->dyncols[i].typename, &s->dyncols[i].nosign, *s->ov3, s->nowchar[0] || s->nowchar[1], s->dobigint); getmd(s->dyncols[i].typename, s->dyncols[i].type, &s->dyncols[i].size, &s->dyncols[i].prec); #ifdef SQL_LONGVARCHAR if (s->dyncols[i].type == SQL_VARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (s->dyncols[i].type == SQL_WVARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_WLONGVARCHAR; } #endif #endif if (s->dyncols[i].type == SQL_VARBINARY && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARBINARY; } } #if !defined(HAVE_SQLITE3TABLECOLUMNMETADATA) || !(HAVE_SQLITE3TABLECOLUMNMETADATA) if (s->dcols > array_size(flags)) { flagp = xmalloc(sizeof (flags[0]) * s->dcols); if (flagp == NULL) { return; } } else { flagp = flags; } memset(flagp, 0, sizeof (flags[0]) * s->dcols); for (i = 0; i < s->dcols; i++) { s->dyncols[i].autoinc = SQL_FALSE; s->dyncols[i].notnull = SQL_NULLABLE; } for (i = 0; i < s->dcols; i++) { int ret, lastpk = -1, autoinccount = 0; char *sql; if (!s->dyncols[i].table[0]) { continue; } if (flagp[i]) { continue; } sql = sqlite3_mprintf("PRAGMA table_info(%Q)", s->dyncols[i].table); if (!sql) { continue; } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, NULL); sqlite3_free(sql); if (ret != SQLITE_OK) { continue; } k = findcol(rowp, ncols, "name"); t = findcol(rowp, ncols, "type"); pk = findcol(rowp, ncols, "pk"); nn = findcol(rowp, ncols, "notnull"); if (k < 0 || t < 0) { goto freet; } for (r = 1; r <= nrows; r++) { int m; for (m = i; m < s->dcols; m++) { char *colname = s->dyncols[m].column; if (s->longnames) { char *dotp = strchr(colname, '.'); if (dotp) { colname = dotp + 1; } } if (!flagp[m] && strcmp(colname, rowp[r * ncols + k]) == 0 && strcmp(s->dyncols[m].table, s->dyncols[i].table) == 0) { char *typename = rowp[r * ncols + t]; flagp[m] = 1; freep(&s->dyncols[m].typename); s->dyncols[m].typename = xstrdup(typename); s->dyncols[m].type = mapsqltype(typename, &s->dyncols[m].nosign, *s->ov3, s->nowchar[0] || s->nowchar[1], s->dobigint); getmd(typename, s->dyncols[m].type, &s->dyncols[m].size, &s->dyncols[m].prec); #ifdef SQL_LONGVARCHAR if (s->dyncols[m].type == SQL_VARCHAR && s->dyncols[m].size > 255) { s->dyncols[m].type = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (s->dyncols[i].type == SQL_WVARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_WLONGVARCHAR; } #endif #endif if (s->dyncols[i].type == SQL_VARBINARY && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARBINARY; } if (pk >= 0 && strcmp(rowp[r * ncols + pk], "1") == 0) { if (++autoinccount > 1) { if (lastpk >= 0) { s->dyncols[lastpk].autoinc = SQL_FALSE; lastpk = -1; } } else { lastpk = m; if (strlen(typename) == 7 && strncasecmp(typename, "integer", 7) == 0) { s->dyncols[m].autoinc = SQL_TRUE; } } } if (nn >= 0 && rowp[r * ncols + nn][0] != '0') { s->dyncols[m].notnull = SQL_NO_NULLS; } } } } freet: sqlite3_free_table(rowp); } if (flagp != flags) { freep(&flagp); } #endif } /** * Return number of month days. * @param year * @param month 1..12 * @result number of month days or 0 */ static int getmdays(int year, int month) { static const int mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int mday; if (month < 1) { return 0; } mday = mdays[(month - 1) % 12]; if (mday == 28 && year % 4 == 0 && (!(year % 100 == 0) || year % 400 == 0)) { mday++; } return mday; } /** * Convert string to ODBC DATE_STRUCT. * @param str string to be converted * @param ds output DATE_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDD' or 'YYYY-MM-DD' or * 'YYYY/MM/DD' or 'MM/DD/YYYY' are converted to a * DATE_STRUCT. */ static int str2date(char *str, DATE_STRUCT *ds) { int i, err = 0; char *p, *q, sepc = '\0'; ds->year = ds->month = ds->day = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && !ISDIGIT(*q)) { ++i; ++q; } if (i >= 8) { char buf[8]; strncpy(buf, p + 0, 4); buf[4] = '\0'; ds->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ds->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; ds->day = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (!sepc) { sepc = *q; } if (*q == '-' || *q == '/' || *q == '\0' || i == 2) { switch (i) { case 0: ds->year = n; break; case 1: ds->month = n; break; case 2: ds->day = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } done: /* final check for overflow */ if (err || ds->month < 1 || ds->month > 12 || ds->day < 1 || ds->day > getmdays(ds->year, ds->month)) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = ds->year; t[1] = ds->month; t[2] = ds->day; ds->year = t[2]; ds->day = t[1]; ds->month = t[0]; if (ds->month >= 1 && ds->month <= 12 && (ds->day >= 1 || ds->day <= getmdays(ds->year, ds->month))) { return 0; } } return -1; } return 0; } /** * Convert string to ODBC TIME_STRUCT. * @param str string to be converted * @param ts output TIME_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'HHMMSS' or 'HH:MM:SS' * are converted to a TIME_STRUCT. */ static int str2time(char *str, TIME_STRUCT *ts) { int i, err = 0, ampm = -1; char *p, *q; ts->hour = ts->minute = ts->second = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 6) { char buf[4]; strncpy(buf, p + 0, 2); buf[2] = '\0'; ts->hour = strtol(buf, NULL, 10); strncpy(buf, p + 2, 2); buf[2] = '\0'; ts->minute = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ts->second = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (*q == ':' || *q == '\0' || i == 2) { switch (i) { case 0: ts->hour = n; break; case 1: ts->minute = n; break; case 2: ts->second = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } if (!err) { while (*p) { if ((p[0] == 'p' || p[0] == 'P') && (p[1] == 'm' || p[1] == 'M')) { ampm = 1; } else if ((p[0] == 'a' || p[0] == 'A') && (p[1] == 'm' || p[1] == 'M')) { ampm = 0; } ++p; } if (ampm > 0) { if (ts->hour < 12) { ts->hour += 12; } } else if (ampm == 0) { if (ts->hour == 12) { ts->hour = 0; } } } done: /* final check for overflow */ if (err || ts->hour > 23 || ts->minute > 59 || ts->second > 59) { return -1; } return 0; } /** * Convert string to ODBC TIMESTAMP_STRUCT. * @param str string to be converted * @param tss output TIMESTAMP_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDDhhmmssff' or 'YYYY-MM-DD hh:mm:ss ff' * or 'YYYY/MM/DD hh:mm:ss ff' or 'hh:mm:ss ff YYYY-MM-DD' are * converted to a TIMESTAMP_STRUCT. The ISO8601 formats * YYYY-MM-DDThh:mm:ss[.f]Z * YYYY-MM-DDThh:mm:ss[.f]shh:mm * are also supported. In case a time zone field is present, * the resulting TIMESTAMP_STRUCT is expressed in UTC. */ static int str2timestamp(char *str, TIMESTAMP_STRUCT *tss) { int i, m, n, err = 0, ampm = -1; char *p, *q, in = '\0', sepc = '\0'; tss->year = tss->month = tss->day = 0; tss->hour = tss->minute = tss->second = 0; tss->fraction = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 14) { char buf[16]; strncpy(buf, p + 0, 4); buf[4] = '\0'; tss->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; tss->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; tss->day = strtol(buf, NULL, 10); strncpy(buf, p + 8, 2); buf[2] = '\0'; tss->hour = strtol(buf, NULL, 10); strncpy(buf, p + 10, 2); buf[2] = '\0'; tss->minute = strtol(buf, NULL, 10); strncpy(buf, p + 12, 2); buf[2] = '\0'; tss->second = strtol(buf, NULL, 10); if (i > 14) { m = i - 14; strncpy(buf, p + 14, m); while (m < 9) { buf[m] = '0'; ++m; } buf[m] = '\0'; tss->fraction = strtol(buf, NULL, 10); } m = 7; goto done; } m = i = 0; while ((m & 7) != 7) { q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (m < 1) { err = 1; } goto done; } } if (in == '\0') { switch (*q) { case '-': case '/': if ((m & 1) == 0) { in = *q; i = 0; } break; case ':': if ((m & 2) == 0) { in = *q; i = 0; } break; case ' ': case '.': break; default: in = '\0'; i = 0; break; } } switch (in) { case '-': case '/': if (!sepc) { sepc = in; } switch (i) { case 0: tss->year = n; break; case 1: tss->month = n; break; case 2: tss->day = n; break; } if (++i >= 3) { i = 0; m |= 1; if (!(m & 2)) { m |= 8; } goto skip; } else { ++q; } break; case ':': switch (i) { case 0: tss->hour = n; break; case 1: tss->minute = n; break; case 2: tss->second = n; break; } if (++i >= 3) { i = 0; m |= 2; if (*q == '.') { in = '.'; goto skip2; } if (*q == ' ') { if ((m & 1) == 0) { char *e = NULL; (void) strtol(q + 1, &e, 10); if (e && *e == '-') { goto skip; } } in = '.'; goto skip2; } goto skip; } else { ++q; } break; case '.': if (++i >= 1) { int ndig = q - p; if (p[0] == '+' || p[0] == '-') { ndig--; } while (ndig < 9) { n = n * 10; ++ndig; } tss->fraction = n; m |= 4; i = 0; } default: skip: in = '\0'; skip2: while (*q && !ISDIGIT(*q)) { if ((q[0] == 'a' || q[0] == 'A') && (q[1] == 'm' || q[1] == 'M')) { ampm = 0; ++q; } else if ((q[0] == 'p' || q[0] == 'P') && (q[1] == 'm' || q[1] == 'M')) { ampm = 1; ++q; } ++q; } } p = q; } if ((m & 7) > 1 && (m & 8)) { /* ISO8601 timezone */ if (p > str && ISDIGIT(*p)) { int nn, sign; q = p - 1; if (*q != '+' && *q != '-') { goto done; } sign = (*q == '+') ? -1 : 1; q = NULL; n = strtol(p, &q, 10); if (!q || *q++ != ':' || !ISDIGIT(*q)) { goto done; } p = q; q = NULL; nn = strtol(p, &q, 10); tss->minute += nn * sign; if ((SQLSMALLINT) tss->minute < 0) { tss->hour -= 1; tss->minute += 60; } else if (tss->minute >= 60) { tss->hour += 1; tss->minute -= 60; } tss->hour += n * sign; if ((SQLSMALLINT) tss->hour < 0) { tss->day -= 1; tss->hour += 24; } else if (tss->hour >= 24) { tss->day += 1; tss->hour -= 24; } if ((short) tss->day < 1 || tss->day >= 28) { int mday, pday, pmon; mday = getmdays(tss->year, tss->month); pmon = tss->month - 1; if (pmon < 1) { pmon = 12; } pday = getmdays(tss->year, pmon); if ((SQLSMALLINT) tss->day < 1) { tss->month -= 1; tss->day = pday; } else if (tss->day > mday) { tss->month += 1; tss->day = 1; } if ((SQLSMALLINT) tss->month < 1) { tss->year -= 1; tss->month = 12; } else if (tss->month > 12) { tss->year += 1; tss->month = 1; } } } } done: if ((m & 1) && (tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month))) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = tss->year; t[1] = tss->month; t[2] = tss->day; tss->year = t[2]; tss->day = t[1]; tss->month = t[0]; } } /* Replace missing year/month/day with current date */ if (!err && (m & 1) == 0) { #ifdef _WIN32 SYSTEMTIME t; GetLocalTime(&t); tss->year = t.wYear; tss->month = t.wMonth; tss->day = t.wDay; #else struct timeval tv; struct tm tm; gettimeofday(&tv, NULL); tm = *localtime(&tv.tv_sec); tss->year = tm.tm_year + 1900; tss->month = tm.tm_mon + 1; tss->day = tm.tm_mday; #endif } /* Normalize fraction */ if (tss->fraction < 0) { tss->fraction = 0; } /* Final check for overflow */ if (err || tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month) || tss->hour > 23 || tss->minute > 59 || tss->second > 59) { return -1; } if ((m & 7) > 1) { if (ampm > 0) { if (tss->hour < 12) { tss->hour += 12; } } else if (ampm == 0) { if (tss->hour == 12) { tss->hour = 0; } } } return ((m & 7) < 1) ? -1 : 0; } /** * Get boolean flag from string. * @param string string to be inspected * @result true or false */ static int getbool(char *string) { if (string) { return string[0] && strchr("Yy123456789Tt", string[0]) != NULL; } return 0; } /** * SQLite function to import a BLOB from a file * @param ctx function context * @param nargs number arguments * @param args arguments */ static void blob_import(sqlite3_context *ctx, int nargs, sqlite3_value **args) { #if 0 DBC *d = (DBC *) sqlite3_user_data(ctx); #endif char *filename = 0; if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } if (filename) { #ifdef _WIN32 char *wname = utf_to_wmb(filename, -1); FILE *f; #else FILE *f = fopen(filename, "r"); #endif char *p; long n, nn; #ifdef _WIN32 if (wname) { f = fopen(wname, "rb"); } else { sqlite3_result_error(ctx, "out of memory", -1); return; } uc_free(wname); #endif if (f) { if (fseek(f, 0, SEEK_END) == 0) { n = ftell(f); if (fseek(f, 0, SEEK_SET) == 0) { p = sqlite3_malloc(n); if (p) { nn = fread(p, 1, n, f); if (nn != n) { sqlite3_result_error(ctx, "read error", -1); sqlite3_free(p); } else { sqlite3_result_blob(ctx, p, n, sqlite3_free); } } else { sqlite3_result_error(ctx, "out of memory", -1); } } else { sqlite3_result_error(ctx, "seek error", -1); } } else { sqlite3_result_error(ctx, "seek error", -1); } fclose(f); } else { sqlite3_result_error(ctx, "cannot open file", -1); } } else { sqlite3_result_error(ctx, "no filename given", -1); } } /** * SQLite function to export a BLOB to a file * @param ctx function context * @param nargs number arguments * @param args arguments */ static void blob_export(sqlite3_context *ctx, int nargs, sqlite3_value **args) { #if 0 DBC *d = (DBC *) sqlite3_user_data(ctx); #endif char *filename = 0; char *p = 0; int n = 0; if (nargs > 0) { p = (char *) sqlite3_value_blob(args[0]); n = sqlite3_value_bytes(args[0]); } if (nargs > 1) { if (sqlite3_value_type(args[1]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[1]); } } if (p) { if (filename) { #ifdef _WIN32 char *wname = utf_to_wmb(filename, -1); FILE *f; #else FILE *f = fopen(filename, "w"); #endif int nn; #ifdef _WIN32 if (wname) { f = fopen(wname, "wb"); } else { sqlite3_result_error(ctx, "out of memory", -1); return; } uc_free(wname); #endif if (f) { nn = fwrite(p, 1, n, f); fclose(f); if (nn != n) { sqlite3_result_error(ctx, "write error", -1); } else { sqlite3_result_int(ctx, nn); } } else { sqlite3_result_error(ctx, "cannot open file", -1); } } else { sqlite3_result_error(ctx, "no filename given", -1); } } else { sqlite3_result_null(ctx); } } /** * SQLite trace or profile callback * @param arg DBC pointer * @param msg log message, SQL text * @param et elapsed time */ static void #if defined(HAVE_SQLITE3PROFILE) && (HAVE_SQLITE3PROFILE) dbtrace(void *arg, const char *msg, sqlite_uint64 et) #else dbtrace(void *arg, const char *msg) #endif { DBC *d = (DBC *) arg; if (msg && d->trace) { int len = strlen(msg); #if defined(HAVE_SQLITE3PROFILE) && (HAVE_SQLITE3PROFILE) unsigned long s, f; #endif if (len > 0) { char *end = "\n"; if (msg[len - 1] != ';') { end = ";\n"; } fprintf(d->trace, "%s%s", msg, end); #if defined(HAVE_SQLITE3PROFILE) && (HAVE_SQLITE3PROFILE) s = et / 1000000000LL; f = et % 1000000000LL; fprintf(d->trace, "-- took %lu.%09lu seconds\n", s, f); #endif fflush(d->trace); } } } /** * Trace function for SQLite API calls * @param d pointer to database connection handle * @param fn SQLite function name * @param sql SQL string */ static void dbtraceapi(DBC *d, char *fn, const char *sql) { if (fn && d->trace) { if (sql) { fprintf(d->trace, "-- %s: %s\n", fn, sql); } else { fprintf(d->trace, "-- %s\n", fn); } fflush(d->trace); } } /** * Trace function for SQLite return codes * @param d pointer to database connection handle * @param rc SQLite return code * @param err error string or NULL */ static void dbtracerc(DBC *d, int rc, char *err) { if (rc != SQLITE_OK && d->trace) { fprintf(d->trace, "-- SQLITE ERROR CODE %d", rc); fprintf(d->trace, err ? ": %s\n" : "\n", err); fflush(d->trace); } } /** * Open SQLite database file given file name and flags. * @param d DBC pointer * @param name file name * @param isu true/false: file name is UTF8 encoded * @param dsn data source name * @param sflag STEPAPI flag * @param spflag SyncPragma string * @param ntflag NoTransaction string * @param jmode JournalMode string * @param busy busy/lock timeout * @result ODBC error code */ static SQLRETURN dbopen(DBC *d, char *name, int isu, char *dsn, char *sflag, char *spflag, char *ntflag, char *jmode, char *busy) { char *endp = NULL; int rc, tmp, busyto = 100000; #if defined(HAVE_SQLITE3VFS) && (HAVE_SQLITE3VFS) int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; char *uname = name; const char *vfs_name = NULL; #endif if (d->sqlite) { if (d->trace) { fprintf(d->trace, "-- sqlite3_close (deferred): '%s'\n", d->dbname); fflush(d->trace); } sqlite3_close(d->sqlite); d->sqlite = NULL; } #if defined(HAVE_SQLITE3VFS) && (HAVE_SQLITE3VFS) if (d->nocreat) { flags &= ~ SQLITE_OPEN_CREATE; } #if defined(_WIN32) || defined(_WIN64) if (!isu) { char expname[MAX_PATH]; expname[0] = '\0'; rc = ExpandEnvironmentStrings(name, expname, sizeof (expname)); if (rc <= sizeof (expname)) { uname = wmb_to_utf(expname, rc - 1); } else { uname = wmb_to_utf(name, -1); } if (!uname) { rc = SQLITE_NOMEM; setstatd(d, rc, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } } #endif #if defined(ENABLE_NVFS) && (ENABLE_NVFS) vfs_name = nvfs_makevfs(uname); #endif #ifdef SQLITE_OPEN_URI flags |= SQLITE_OPEN_URI; #endif rc = sqlite3_open_v2(uname, &d->sqlite, flags, vfs_name); #if defined(WINTERFACE) || defined(_WIN32) || defined(_WIN64) if (uname != name) { uc_free(uname); } #endif #else #if defined(_WIN32) || defined(_WIN64) if (d->nocreat) { char *cname = NULL; if (isu) { cname = utf_to_wmb(name, -1); } if (GetFileAttributesA(cname ? cname : name) == INVALID_FILE_ATTRIBUTES) { uc_free(cname); rc = SQLITE_CANTOPEN; setstatd(d, rc, "cannot open database", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } uc_free(cname); } #else if (d->nocreat && access(name, 004) < 0) { rc = SQLITE_CANTOPEN; setstatd(d, rc, "cannot open database", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } #endif #if defined(_WIN32) || defined(_WIN64) if (!isu) { WCHAR *wname = wmb_to_uc(name, -1); if (!wname) { rc = SQLITE_NOMEM; setstatd(d, rc, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } rc = sqlite3_open16(wname, &d->sqlite); uc_free(wname); } else #endif rc = sqlite3_open(name, &d->sqlite); #endif /* !HAVE_SQLITE3VFS */ if (rc != SQLITE_OK) { connfail: setstatd(d, rc, "connect failed", (*d->ov3) ? "HY000" : "S1000"); if (d->sqlite) { sqlite3_close(d->sqlite); d->sqlite = NULL; } return SQL_ERROR; } #if defined(SQLITE_DYNLOAD) || defined(SQLITE_HAS_CODEC) if (d->pwd) { sqlite3_key(d->sqlite, d->pwd, d->pwdLen); } #endif d->pwd = NULL; d->pwdLen = 0; if (d->trace) { #if defined(HAVE_SQLITE3PROFILE) && (HAVE_SQLITE3PROFILE) sqlite3_profile(d->sqlite, dbtrace, d); #else sqlite3_trace(d->sqlite, dbtrace, d); #endif } d->step_enable = getbool(sflag); d->trans_disable = getbool(ntflag); d->curtype = d->step_enable ? SQL_CURSOR_FORWARD_ONLY : SQL_CURSOR_STATIC; tmp = strtol(busy, &endp, 0); if (endp && *endp == '\0' && endp != busy) { busyto = tmp; } if (busyto < 1 || busyto > 1000000) { busyto = 1000000; } d->timeout = busyto; freep(&d->dbname); d->dbname = xstrdup(name); freep(&d->dsn); d->dsn = xstrdup(dsn); if ((rc = setsqliteopts(d->sqlite, d)) != SQLITE_OK) { if (d->trace) { fprintf(d->trace, "-- sqlite3_close: '%s'\n", d->dbname); fflush(d->trace); } sqlite3_close(d->sqlite); d->sqlite = NULL; goto connfail; } if (!spflag || spflag[0] == '\0') { spflag = "NORMAL"; } if (spflag[0] != '\0') { char syncp[128]; sprintf(syncp, "PRAGMA synchronous = %8.8s;", spflag); sqlite3_exec(d->sqlite, syncp, NULL, NULL, NULL); } if (jmode[0] != '\0') { char jourp[128]; sprintf(jourp, "PRAGMA journal_mode = %16.16s;", jmode); sqlite3_exec(d->sqlite, jourp, NULL, NULL, NULL); } if (d->trace) { fprintf(d->trace, "-- sqlite3_open: '%s'\n", d->dbname); fflush(d->trace); } #if defined(_WIN32) || defined(_WIN64) { char pname[MAX_PATH]; HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()); pname[0] = '\0'; if (h) { HMODULE m = NULL, l = LoadLibrary("psapi.dll"); DWORD need; typedef BOOL (WINAPI *epmfunc)(HANDLE, HMODULE *, DWORD, LPDWORD); typedef BOOL (WINAPI *gmbfunc)(HANDLE, HMODULE, LPSTR, DWORD); epmfunc epm; gmbfunc gmb; if (l) { epm = (epmfunc) GetProcAddress(l, "EnumProcessModules"); gmb = (gmbfunc) GetProcAddress(l, "GetModuleBaseNameA"); if (epm && gmb && epm(h, &m, sizeof (m), &need)) { gmb(h, m, pname, sizeof (pname)); } FreeLibrary(l); } CloseHandle(h); } d->xcelqrx = strncasecmp(pname, "EXCEL", 5) == 0 || strncasecmp(pname, "MSQRY", 5) == 0; if (d->trace && d->xcelqrx) { fprintf(d->trace, "-- enabled EXCEL quirks\n"); fflush(d->trace); } } #endif sqlite3_create_function(d->sqlite, "blob_import", 1, SQLITE_UTF8, d, blob_import, 0, 0); sqlite3_create_function(d->sqlite, "blob_export", 2, SQLITE_UTF8, d, blob_export, 0, 0); return SQL_SUCCESS; } /** * Load SQLite extension modules, if any * @param d DBC pointer * @param exts string, comma separated extension names */ static void dbloadext(DBC *d, char *exts) { #if defined(HAVE_SQLITE3LOADEXTENSION) && (HAVE_SQLITE3LOADEXTENSION) char *p; char path[SQL_MAX_MESSAGE_LENGTH]; int plen = 0; if (!d->sqlite) { return; } sqlite3_enable_load_extension(d->sqlite, 1); #if defined(_WIN32) || defined(_WIN64) GetModuleFileName(hModule, path, sizeof (path)); p = strrchr(path, '\\'); plen = p ? ((p + 1) - path) : 0; #endif do { p = strchr(exts, ','); if (p) { strncpy(path + plen, exts, p - exts); path[plen + (p - exts)] = '\0'; } else { strcpy(path + plen, exts); } if (exts[0]) { char *errmsg = NULL; int rc; #if defined(_WIN32) || defined(_WIN64) char *q; q = path + plen; if (!(q[0] && ((q[1] == ':' && (q[2] == '\\' || q[2] == '/')) || q[0] == '\\' || q[0] == '/' || q[0] == '.'))) { q = path; } rc = sqlite3_load_extension(d->sqlite, q, 0, &errmsg); #else rc = sqlite3_load_extension(d->sqlite, path, 0, &errmsg); #endif if (rc != SQLITE_OK) { #if defined(_WIN32) || defined(_WIN64) char buf[512], msg[512]; LoadString(hModule, IDS_EXTERR, buf, sizeof (buf)); wsprintf(msg, buf, q, errmsg ? errmsg : "no error info available"); LoadString(hModule, IDS_EXTTITLE, buf, sizeof (buf)); MessageBox(NULL, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #else fprintf(stderr, "extension '%s' did not load%s%s\n", path, errmsg ? ": " : "", errmsg ? errmsg : ""); #endif } } if (p) { exts = p + 1; } } while (p); #endif /* HAVE_SQLITE3LOADEXTENSION */ } /** * Find out column type * @param s3stmt SQLite statement pointer * @param col column number * @param d DBC pointer (for tracing only) * @param guessed_types flag array * @result type name as string */ static char * s3stmt_coltype(sqlite3_stmt *s3stmt, int col, DBC *d, int *guessed_types) { char *typename = (char *) sqlite3_column_decltype(s3stmt, col); char guess[64]; guess[0] = '\0'; if (!typename) { int coltype = sqlite3_column_type(s3stmt, col); if (guessed_types) { guessed_types[0]++; } if (d->trace) { sprintf(guess, " (guessed from %d)", coltype); } switch (coltype) { case SQLITE_INTEGER: typename = "integer"; break; case SQLITE_FLOAT: typename = "double"; break; default: case SQLITE_TEXT: typename = "varchar"; break; case SQLITE_BLOB: typename = "blob"; break; #if 0 case SQLITE_NULL: typename = "null"; break; #endif } } if (d->trace) { fprintf(d->trace, "-- column %d type%s: '%s'\n", col + 1, guess, typename); fflush(d->trace); } return typename; } #if defined(HAVE_SQLITE3TABLECOLUMNMETADATA) && (HAVE_SQLITE3TABLECOLUMNMETADATA) /** * Add meta data for column * @param s3stmt SQLite statement pointer * @param col column number * @param d DBC pointer (for tracing only) * @param ci pointer to COL */ static void s3stmt_addmeta(sqlite3_stmt *s3stmt, int col, DBC *d, COL *ci) { int nn = 0, pk = 0, ai = 0; const char *dn, *tn, *cn, *dummy1, *dummy2; dn = sqlite3_column_database_name(s3stmt, col); tn = sqlite3_column_table_name(s3stmt, col); cn = sqlite3_column_origin_name(s3stmt, col); sqlite3_table_column_metadata(d->sqlite, dn, tn, cn, &dummy1, &dummy2, &nn, &pk, &ai); ci->autoinc = ai ? SQL_TRUE: SQL_FALSE; ci->notnull = nn ? SQL_NO_NULLS : SQL_NULLABLE; if (d->trace) { fprintf(d->trace, "-- column %d %s\n", col + 1, nn ? "notnull" : "nullable"); if (ai) { fprintf(d->trace, "-- column %d autoincrement\n", col + 1); } fflush(d->trace); } } #endif /** * Do one sqlite statement step gathering one result row * @param s statement pointer * @result ODBC error code */ static int s3stmt_step(STMT *s) { DBC *d = (DBC *) s->dbc; char **rowd = NULL; const char *errp = NULL; int i, ncols, rc; if (s != d->cur_s3stmt || !s->s3stmt) { setstat(s, -1, "stale statement", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } rc = sqlite3_step(s->s3stmt); if (rc == SQLITE_ROW || rc == SQLITE_DONE) { ++s->s3stmt_rownum; ncols = sqlite3_column_count(s->s3stmt); if (d->s3stmt_needmeta && s->s3stmt_rownum == 0 && ncols > 0) { PTRDIFF_T size; char *p; COL *dyncols; const char *colname, *typename; #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) char *tblname; #endif for (i = size = 0; i < ncols; i++) { colname = sqlite3_column_name(s->s3stmt, i); size += 3 + 3 * strlen(colname); } #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) tblname = (char *) size; for (i = 0; i < ncols; i++) { p = (char *) sqlite3_column_table_name(s->s3stmt, i); size += 2 + (p ? strlen(p) : 0); } #endif dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); s->ncols = 0; dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s->s3stmt); s->s3stmt = NULL; d->cur_s3stmt = NULL; return nomem(s); } p = (char *) (dyncols + ncols); #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) tblname = p + (PTRDIFF_T) tblname; #endif for (i = 0; i < ncols; i++) { char *q; colname = sqlite3_column_name(s->s3stmt, i); if (d->trace) { fprintf(d->trace, "-- column %d name: '%s'\n", i + 1, colname); fflush(d->trace); } #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) q = (char *) sqlite3_column_table_name(s->s3stmt, i); strcpy(tblname, q ? q : ""); if (d->trace) { fprintf(d->trace, "-- table %d name: '%s'\n", i + 1, tblname); fflush(d->trace); } dyncols[i].table = tblname; tblname += strlen(tblname) + 1; #endif typename = s3stmt_coltype(s->s3stmt, i, d, 0); dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, colname); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(colname, '.'); if (q) { char *q2 = strchr(q + 1, '.'); /* SQLite 3.3.4 produces view.table.column sometimes */ if (q2) { q = q2; } } if (q) { #if !defined(HAVE_SQLITE3COLUMNTABLENAME) || !(HAVE_SQLITE3COLUMNTABLENAME) dyncols[i].table = p; #endif strncpy(p, colname, q - colname); p[q - colname] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { #if !defined(HAVE_SQLITE3COLUMNTABLENAME) || !(HAVE_SQLITE3COLUMNTABLENAME) dyncols[i].table = ""; #endif strcpy(p, colname); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; #if defined(HAVE_SQLITE3TABLECOLUMNMETADATA) && (HAVE_SQLITE3TABLECOLUMNMETADATA) s3stmt_addmeta(s->s3stmt, i, d, &dyncols[i]); #else dyncols[i].autoinc = SQL_FALSE; dyncols[i].notnull = SQL_NULLABLE; #endif dyncols[i].typename = xstrdup(typename); } freedyncols(s); s->ncols = s->dcols = ncols; s->dyncols = s->cols = dyncols; fixupdyncols(s, d); mkbindcols(s, s->ncols); d->s3stmt_needmeta = 0; } if (ncols <= 0) { goto killstmt; } if (rc == SQLITE_DONE) { freeresult(s, 0); s->nrows = 0; dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s->s3stmt); s->s3stmt = NULL; d->cur_s3stmt = NULL; return SQL_SUCCESS; } rowd = xmalloc((1 + 2 * ncols) * sizeof (char *)); if (rowd) { const unsigned char *value; rowd[0] = (char *) ((PTRDIFF_T) (ncols * 2)); ++rowd; for (i = 0; i < ncols; i++) { int coltype = sqlite3_column_type(s->s3stmt, i); rowd[i] = rowd[i + ncols] = NULL; if (coltype == SQLITE_BLOB) { int k, nbytes = sqlite3_column_bytes(s->s3stmt, i); char *qp; unsigned const char *bp; bp = sqlite3_column_blob(s->s3stmt, i); qp = xmalloc(nbytes * 2 + 4); if (qp) { rowd[i + ncols] = qp; *qp++ = 'X'; *qp++ = '\''; for (k = 0; k < nbytes; k++) { *qp++ = xdigits[(bp[k] >> 4)]; *qp++ = xdigits[(bp[k] & 0xF)]; } *qp++ = '\''; *qp = '\0'; } #ifdef _MSC_VER } else if (coltype == SQLITE_FLOAT) { static struct lconv *lc = 0; double d = sqlite3_column_double(s->s3stmt, i); char *p, buffer[128]; /* * This avoids floating point rounding * and formatting problems of some SQLite * versions in conjunction with MSVC 2010. */ snprintf(buffer, sizeof (buffer), "%.15g", d); if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { p = strchr(buffer, lc->decimal_point[0]); if (p) { *p = '.'; } } rowd[i + ncols] = xstrdup(buffer); #endif } else if (coltype != SQLITE_NULL) { value = sqlite3_column_text(s->s3stmt, i); rowd[i + ncols] = xstrdup((char *) value); } } for (i = 0; i < ncols; i++) { int coltype = sqlite3_column_type(s->s3stmt, i); value = NULL; if (coltype == SQLITE_BLOB) { value = sqlite3_column_blob(s->s3stmt, i); } else if (coltype != SQLITE_NULL) { value = sqlite3_column_text(s->s3stmt, i); } if (value && !rowd[i + ncols]) { freerows(rowd); rowd = 0; break; } } } if (rowd) { freeresult(s, 0); s->nrows = 1; s->rows = rowd; s->rowfree = freerows; if (rc == SQLITE_DONE) { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s->s3stmt); s->s3stmt = NULL; d->cur_s3stmt = NULL; } return SQL_SUCCESS; } } killstmt: dbtraceapi(d, "sqlite3_reset", 0); rc = sqlite3_reset(s->s3stmt); s->s3stmt_noreset = 1; errp = sqlite3_errmsg(d->sqlite); if (d->cur_s3stmt == s) { d->cur_s3stmt = NULL; } setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); return SQL_ERROR; } /** * Stop running sqlite statement * @param s statement pointer */ static void s3stmt_end(STMT *s) { DBC *d; if (!s || !s->s3stmt) { return; } d = (DBC *) s->dbc; if (d) { d->busyint = 0; } if (!s->s3stmt_noreset) { dbtraceapi(d, "sqlite3_reset", 0); sqlite3_reset(s->s3stmt); s->s3stmt_noreset = 1; s->s3stmt_rownum = -1; } if (d->cur_s3stmt == s) { d->cur_s3stmt = NULL; } } /** * Conditionally stop running sqlite statement * @param s statement pointer */ static void s3stmt_end_if(STMT *s) { DBC *d = (DBC *) s->dbc; if (d) { d->busyint = 0; } if (d && d->cur_s3stmt == s) { s3stmt_end(s); } } /** * Drop running sqlite statement in STMT * @param s statement pointer */ static void s3stmt_drop(STMT *s) { if (s->s3stmt) { DBC *d = (DBC *) s->dbc; if (d) { dbtraceapi(d, "sqlite3_finalize", 0); } sqlite3_finalize(s->s3stmt); s->s3stmt = NULL; s->s3stmt_rownum = 0; } } /** * Start sqlite statement for execution of SELECT statement. * @param s statement pointer * @result ODBC error code */ static SQLRETURN s3stmt_start(STMT *s) { DBC *d = (DBC *) s->dbc; const char *endp; sqlite3_stmt *s3stmt = NULL; int rc, nretry = 0; d->s3stmt_needmeta = 0; if (!s->s3stmt) { #if defined(HAVE_SQLITE3PREPAREV2) && (HAVE_SQLITE3PREPAREV2) dbtraceapi(d, "sqlite3_prepare_v2", (char *) s->query); #else dbtraceapi(d, "sqlite3_prepare", (char *) s->query); #endif do { s3stmt = NULL; #if defined(HAVE_SQLITE3PREPAREV2) && (HAVE_SQLITE3PREPAREV2) rc = sqlite3_prepare_v2(d->sqlite, (char *) s->query, -1, &s3stmt, &endp); #else rc = sqlite3_prepare(d->sqlite, (char *) s->query, -1, &s3stmt, &endp); #endif if (rc != SQLITE_OK) { if (s3stmt) { sqlite3_finalize(s3stmt); s3stmt = NULL; } } } while (rc == SQLITE_SCHEMA && (++nretry) < 2); dbtracerc(d, rc, NULL); if (rc != SQLITE_OK) { if (s3stmt) { dbtraceapi(d, "sqlite3_finalize", NULL); sqlite3_finalize(s3stmt); } setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", sqlite3_errmsg(d->sqlite), rc); return SQL_ERROR; } if (sqlite3_bind_parameter_count(s3stmt) != s->nparams) { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s3stmt); setstat(s, SQLITE_ERROR, "parameter marker count incorrect", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } s->s3stmt = s3stmt; s->s3stmt_noreset = 1; d->s3stmt_needmeta = 1; } d->cur_s3stmt = s; s->s3stmt_rownum = -1; s3bind(d, s->s3stmt, s->nparams, s->bindparms); return SQL_SUCCESS; } /** * Function not implemented. */ SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt, SQLSMALLINT oper) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSources(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSourcesW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLWCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDrivers(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDriversW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLWCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC dbc, SQLCHAR *connin, SQLSMALLINT conninLen, SQLCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnectW(SQLHDBC dbc, SQLWCHAR *connin, SQLSMALLINT conninLen, SQLWCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ static SQLRETURN drvputdata(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { STMT *s; int i, dlen, done = 0; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->query || s->nparams <= 0) { seqerr: setstat(s, -1, "sequence error", "HY010"); return SQL_ERROR; } for (i = (s->pdcount < 0) ? 0 : s->pdcount; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { int type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); if (len == SQL_NULL_DATA) { freep(&p->parbuf); p->param = NULL; p->len = SQL_NULL_DATA; p->need = -1; } else if (type != SQL_C_CHAR #ifdef WCHARSUPPORT && type != SQL_C_WCHAR #endif && type != SQL_C_BINARY) { int size = 0; switch (type) { case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif size = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: size = sizeof (SQLSMALLINT); break; case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: size = sizeof (SQLINTEGER); break; #ifdef SQL_BIGINT case SQL_C_UBIGINT: case SQL_C_SBIGINT: size = sizeof (SQLBIGINT); break; #endif case SQL_C_FLOAT: size = sizeof (float); break; case SQL_C_DOUBLE: size = sizeof (double); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: size = sizeof (DATE_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: size = sizeof (TIME_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: size = sizeof (TIMESTAMP_STRUCT); break; } freep(&p->parbuf); p->parbuf = xmalloc(size); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; memcpy(p->param, data, size); p->len = size; p->need = -1; } else if (len == SQL_NTS && ( type == SQL_C_CHAR #ifdef WCHARSUPPORT || type == SQL_C_WCHAR #endif )) { char *dp = data; #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { dp = uc_to_utf(data, len); if (!dp) { return nomem(s); } } #endif #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { dp = wmb_to_utf(data, strlen (data)); if (!dp) { return nomem(s); } } #endif dlen = strlen(dp); freep(&p->parbuf); p->parbuf = xmalloc(dlen + 1); if (!p->parbuf) { if (dp != data) { uc_free(dp); } return nomem(s); } p->param = p->parbuf; strcpy(p->param, dp); if (dp != data) { uc_free(dp); } p->len = dlen; p->need = -1; } else if (len < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } else { dlen = min(p->len - p->offs, len); if (!p->param) { setstat(s, -1, "no memory for parameter", "HY013"); return SQL_ERROR; } memcpy((char *) p->param + p->offs, data, dlen); p->offs += dlen; if (p->offs >= p->len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->len); char *np; int nlen; if (!dp) { return nomem(s); } nlen = strlen(dp); np = xmalloc(nlen + 1); if (!np) { uc_free(dp); return nomem(s); } strcpy(np, dp); uc_free(dp); if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = np; p->len = nlen; } else { *((char *) p->param + p->len) = '\0'; } p->need = (type == SQL_C_CHAR || type == SQL_C_WCHAR) ? -1 : 0; #else *((char *) p->param + p->len) = '\0'; p->need = (type == SQL_C_CHAR) ? -1 : 0; #endif #if defined(_WIN32) || defined(_WIN64) if (type == SQL_C_CHAR && *s->oemcp && !(p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY)) { char *dp = wmb_to_utf(p->param, p->len); if (!dp) { return nomem(s); } if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->len = strlen(dp); } if (p->type == SQL_C_WCHAR && (p->stype == SQL_VARCHAR || p->stype == SQL_LONGVARCHAR) && p->len == p->coldef * sizeof (SQLWCHAR)) { /* fix for MS-Access */ p->len = p->coldef; } #endif } } done = 1; break; } } if (!done) { goto seqerr; } return SQL_SUCCESS; } /** * Put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvputdata(stmt, data, len); HSTMT_UNLOCK(stmt); return ret; } /** * Clear out parameter bindings, if any. * @param s statement pointer */ static SQLRETURN freeparams(STMT *s) { if (s->bindparms) { int n; for (n = 0; n < s->nbindparms; n++) { freep(&s->bindparms[n].parbuf); memset(&s->bindparms[n], 0, sizeof (BINDPARM)); } } return SQL_SUCCESS; } /** * Setup SQLite3 parameter for statement parameter. * @param s statement pointer * @param sql sql string * @param pnum parameter number * @result ODBC error code * * The parameter is converted within BINDPARM in order to * be presented to sqlite3_bind_*() functions. */ static SQLRETURN setupparam(STMT *s, char *sql, int pnum) { int type, len = 0, needalloc = 0; BINDPARM *p; if (!s->bindparms || pnum < 0 || pnum >= s->nbindparms) { goto error; } p = &s->bindparms[pnum]; type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 4 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && p->type == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif if (p->need > 0) { return setupparbuf(s, p); } p->strbuf[0] = '\0'; if (!p->param || (p->lenp && *p->lenp == SQL_NULL_DATA)) { p->s3type = SQLITE_NULL; p->s3size = 0; return SQL_SUCCESS; } if (type == SQL_C_CHAR && (p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY)) { type = SQL_C_BINARY; } switch (type) { case SQL_C_BINARY: p->s3type = SQLITE_BLOB; p->s3size = p->len; p->s3val = p->param; if (p->need < 0) { break; } if (!p->lenp) { len = p->len; } else if (*p->lenp == SQL_DATA_AT_EXEC) { len = p->len; } else { len = *p->lenp; if (len <= SQL_LEN_DATA_AT_EXEC_OFFSET) { len = SQL_LEN_DATA_AT_EXEC(len); } } if (len < 0) { setstat(s, -1, "invalid length", "HY009"); return SQL_ERROR; } p->len = len; p->max = p->len; p->need = -1; p->s3size = len; break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif case SQL_C_CHAR: p->s3type = SQLITE_TEXT; p->s3size = -1; p->s3val = p->param; if (!p->parbuf && p->lenp) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { if (*p->lenp == SQL_NTS) { p->max = uc_strlen(p->param) * sizeof (SQLWCHAR); } else if (*p->lenp >= 0) { p->max = *p->lenp; } } else #endif if (type == SQL_C_CHAR) { if (*p->lenp == SQL_NTS) { p->len = p->max = strlen(p->param); #if defined(_WIN32) || defined(_WIN64) needalloc = 1; #endif } else if (*p->lenp >= 0) { p->len = p->max = *p->lenp; needalloc = 1; } } } if (p->need < 0 && p->parbuf == p->param) { break; } #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->max); if (!dp) { return nomem(s); } if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; p->len = strlen(p->param); p->s3val = p->param; p->s3size = p->len; } else #endif if (type == SQL_C_CHAR) { p->s3val = p->param; if (needalloc) { char *dp; #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { dp = wmb_to_utf(p->param, p->len); } else { dp = xmalloc(p->len + 1); } #else dp = xmalloc(p->len + 1); #endif if (!dp) { return nomem(s); } #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { p->len = strlen(dp); } else { memcpy(dp, p->param, p->len); dp[p->len] = '\0'; } #else memcpy(dp, p->param, p->len); dp[p->len] = '\0'; #endif if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; p->s3val = p->param; p->s3size = p->len; } } break; case SQL_C_UTINYINT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLCHAR *) p->param); break; case SQL_C_TINYINT: case SQL_C_STINYINT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLCHAR *) p->param); break; case SQL_C_USHORT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLUSMALLINT *) p->param); break; case SQL_C_SHORT: case SQL_C_SSHORT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLSMALLINT *) p->param); break; case SQL_C_ULONG: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLUINTEGER *) p->param); break; case SQL_C_LONG: case SQL_C_SLONG: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = *((SQLINTEGER *) p->param); break; #ifdef SQL_BIT case SQL_C_BIT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (int); p->s3ival = (*((SQLCHAR *) p->param)) ? 1 : 0; break; #endif #ifdef SQL_BIGINT case SQL_C_SBIGINT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (sqlite_int64); p->s3lival = *((sqlite_int64 *) p->param); break; case SQL_C_UBIGINT: p->s3type = SQLITE_INTEGER; p->s3size = sizeof (sqlite_int64); p->s3lival = *((sqlite_uint64 *) p->param); break; #endif case SQL_C_FLOAT: p->s3type = SQLITE_FLOAT; p->s3size = sizeof (double); p->s3dval = *((float *) p->param); break; case SQL_C_DOUBLE: p->s3type = SQLITE_FLOAT; p->s3size = sizeof (double); p->s3dval = *((double *) p->param); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: sprintf(p->strbuf, "%04d-%02d-%02d", ((DATE_STRUCT *) p->param)->year, ((DATE_STRUCT *) p->param)->month, ((DATE_STRUCT *) p->param)->day); p->s3type = SQLITE_TEXT; p->s3size = -1; p->s3val = p->strbuf; break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: sprintf(p->strbuf, "%02d:%02d:%02d", ((TIME_STRUCT *) p->param)->hour, ((TIME_STRUCT *) p->param)->minute, ((TIME_STRUCT *) p->param)->second); p->s3type = SQLITE_TEXT; p->s3size = -1; p->s3val = p->strbuf; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: len = (int) ((TIMESTAMP_STRUCT *) p->param)->fraction; len /= 1000000; len = len % 1000; if (len < 0) { len = 0; } if (p->coldef && p->coldef <= 16) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:00.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute); } else if (p->coldef && p->coldef <= 19) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second); } else { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.%03d", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second, len); } p->s3type = SQLITE_TEXT; p->s3size = -1; p->s3val = p->strbuf; break; default: error: setstat(s, -1, "unsupported parameter type", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } return SQL_SUCCESS; } /** * Internal bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ static SQLRETURN drvbindparam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLUINTEGER coldef, SQLSMALLINT scale, SQLPOINTER data, SQLINTEGER buflen, SQLLEN *len) { STMT *s; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (pnum == 0) { setstat(s, -1, "invalid parameter", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } if (!data && !len) { setstat(s, -1, "invalid buffer", "HY003"); return SQL_ERROR; } --pnum; if (s->bindparms) { if (pnum >= s->nbindparms) { BINDPARM *newparms; newparms = xrealloc(s->bindparms, (pnum + 1) * sizeof (BINDPARM)); if (!newparms) { outofmem: return nomem(s); } s->bindparms = newparms; memset(&s->bindparms[s->nbindparms], 0, (pnum + 1 - s->nbindparms) * sizeof (BINDPARM)); s->nbindparms = pnum + 1; } } else { int npar = max(10, pnum + 1); s->bindparms = xmalloc(npar * sizeof (BINDPARM)); if (!s->bindparms) { goto outofmem; } memset(s->bindparms, 0, npar * sizeof (BINDPARM)); s->nbindparms = npar; } switch (buftype) { case SQL_C_STINYINT: case SQL_C_UTINYINT: case SQL_C_TINYINT: #ifdef SQL_C_BIT case SQL_C_BIT: #endif buflen = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: buflen = sizeof (SQLSMALLINT); break; case SQL_C_SLONG: case SQL_C_ULONG: case SQL_C_LONG: buflen = sizeof (SQLINTEGER); break; case SQL_C_FLOAT: buflen = sizeof (float); break; case SQL_C_DOUBLE: buflen = sizeof (double); break; case SQL_C_TIMESTAMP: #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif buflen = sizeof (TIMESTAMP_STRUCT); break; case SQL_C_TIME: #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif buflen = sizeof (TIME_STRUCT); break; case SQL_C_DATE: #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif buflen = sizeof (DATE_STRUCT); break; #ifdef SQL_C_UBIGINT case SQL_C_UBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_SBIGINT case SQL_C_SBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_BIGINT case SQL_C_BIGINT: buflen = sizeof (SQLBIGINT); break; #endif } p = &s->bindparms[pnum]; p->type = buftype; p->stype = ptype; p->coldef = coldef; p->scale = scale; p->max = buflen; p->inc = buflen; p->lenp = p->lenp0 = len; p->offs = 0; p->len = 0; p->param0 = data; freep(&p->parbuf); p->param = p->param0; p->bound = 1; p->need = 0; return SQL_SUCCESS; } /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER data, SQLLEN buflen, SQLLEN *len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, iotype, buftype, ptype, coldef, scale, data, buflen, len); HSTMT_UNLOCK(stmt); return ret; } #ifndef HAVE_IODBC /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param vtype input/output type of parameter * @param ptype * @param lenprec * @param scale * @param val pointer to host variable * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT vtype, SQLSMALLINT ptype, SQLULEN lenprec, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, SQL_PARAM_INPUT, vtype, ptype, lenprec, scale, val, 0, lenp); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Return number of parameters. * @param stmt statement handle * @param nparam output parameter count * @result ODBC error code */ SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT *nparam) { STMT *s; SQLSMALLINT dummy; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!nparam) { nparam = &dummy; } *nparam = s->nparams; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Setup parameter buffer for deferred parameter. * @param s pointer to STMT * @param p pointer to BINDPARM * @result ODBC error code (success indicated by SQL_NEED_DATA) */ static SQLRETURN setupparbuf(STMT *s, BINDPARM *p) { if (!p->parbuf) { if (*p->lenp == SQL_DATA_AT_EXEC) { p->len = p->max; } else { p->len = SQL_LEN_DATA_AT_EXEC(*p->lenp); } if (p->len < 0 && p->len != SQL_NTS && p->len != SQL_NULL_DATA) { setstat(s, -1, "invalid length", "HY009"); return SQL_ERROR; } if (p->len >= 0) { p->parbuf = xmalloc(p->len + 2); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; } else { p->param = NULL; } } return SQL_NEED_DATA; } /** * Retrieve next parameter for sending data to executing query. * @param stmt statement handle * @param pind pointer to output parameter indicator * @result ODBC error code */ SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt, SQLPOINTER *pind) { STMT *s; int i; SQLPOINTER dummy; SQLRETURN ret; BINDPARM *p; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!pind) { pind = &dummy; } if (s->pdcount < s->nparams) { s->pdcount++; } for (i = 0; i < s->pdcount; i++) { p = &s->bindparms[i]; if (p->need > 0) { int type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); p->need = (type == SQL_C_CHAR || type == SQL_C_WCHAR) ? -1 : 0; } } for (; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { *pind = (SQLPOINTER) p->param0; ret = setupparbuf(s, p); s->pdcount = i; goto done; } } ret = drvexecute(stmt, 0); done: HSTMT_UNLOCK(stmt); return ret; } /** * Return information about parameter. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param dtype output type indicator * @param size output size indicator * @param decdigits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT *dtype, SQLULEN *size, SQLSMALLINT *decdigits, SQLSMALLINT *nullable) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; --pnum; if (pnum >= s->nparams) { setstat(s, -1, "invalid parameter index", (*s->ov3) ? "HY000" : "S1000"); goto done; } if (dtype) { #ifdef SQL_LONGVARCHAR #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else *dtype = SQL_LONGVARCHAR; #endif #else #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_VARCHAR : SQL_WVARCHAR; #else *dtype = SQL_VARCHAR; #endif #endif } if (size) { #ifdef SQL_LONGVARCHAR *size = 65536; #else *size = 255; #endif } if (decdigits) { *decdigits = 0; } if (nullable) { *nullable = SQL_NULLABLE; } ret = SQL_SUCCESS; done: HSTMT_UNLOCK(stmt); return ret; } /** * Set information on parameter. * @param stmt statement handle * @param par parameter number, starting at 1 * @param type type of host variable * @param sqltype * @param coldef * @param scale * @param val pointer to host variable * @param nval output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLSetParam(SQLHSTMT stmt, SQLUSMALLINT par, SQLSMALLINT type, SQLSMALLINT sqltype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *nval) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, par, SQL_PARAM_INPUT, type, sqltype, coldef, scale, val, SQL_SETPARAM_VALUE_MAX, nval); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt, SQLULEN rows, SQLULEN *rowp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRecW(SQLHDESC handle, SQLSMALLINT recno, SQLWCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT type, SQLSMALLINT subtype, SQLLEN len, SQLSMALLINT prec, SQLSMALLINT scale, SQLPOINTER data, SQLLEN *strlen, SQLLEN *indicator) { return SQL_ERROR; } /** * Setup empty result set from constant column specification. * @param stmt statement handle * @param colspec column specification array (default, ODBC2) * @param ncols number of columns (default, ODBC2) * @param colspec3 column specification array (ODBC3) * @param ncols3 number of columns (ODBC3) * @param nret returns number of columns * @result ODBC error code */ static SQLRETURN mkresultset(HSTMT stmt, COL *colspec, int ncols, COL *colspec3, int ncols3, int *nret) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } s3stmt_end_if(s); freeresult(s, 0); if (colspec3 && *s->ov3) { s->ncols = ncols3; s->cols = colspec3; } else { s->ncols = ncols; s->cols = colspec; } mkbindcols(s, s->ncols); s->nowchar[1] = 1; s->nrows = 0; s->rowp = -1; s->isselect = -1; if (nret) { *nret = s->ncols; } return SQL_SUCCESS; } /** * Columns for result set of SQLTablePrivileges(). */ static COL tablePrivSpec2[] = { { "SYSTEM", "TABLEPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; static COL tablePrivSpec3[] = { { "SYSTEM", "TABLEPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtableprivileges(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, rc, size, npatt; char *errp = NULL, *sql, tname[512]; ret = mkresultset(stmt, tablePrivSpec2, array_size(tablePrivSpec2), tablePrivSpec3, array_size(tablePrivSpec3), NULL); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); #if defined(_WIN32) || defined(_WIN64) sql = sqlite3_mprintf("select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname); #else sql = sqlite3_mprintf("select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname); #endif if (!sql) { return nomem(s); } ret = starttran(s); if (ret != SQL_SUCCESS) { sqlite3_free(sql); return ret; } dbtraceapi(d, "sqlite3_get_table", sql); rc = sqlite3_get_table(d->sqlite, sql, &s->rows, &s->nrows, &ncols, &errp); sqlite3_free(sql); if (rc == SQLITE_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = sqlite3_free_table; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite3_free(errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvtableprivileges(stmt, catalog, catalogLen, schema, schemaLen, table, tableLen); goto done2; } if (catalog) { c = wmb_to_utf_c((char *) catalog, catalogLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtableprivileges(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); #else ret = drvtableprivileges(stmt, catalog, catalogLen, schema, schemaLen, table, tableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on tables and/or views (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (catalog) { c = uc_to_utf_c(catalog, catalogLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtableprivileges(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif #endif /** * Columns for result set of SQLColumnPrivileges(). */ static COL colPrivSpec2[] = { { "SYSTEM", "COLPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; static COL colPrivSpec3[] = { { "SYSTEM", "COLPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on columns. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on columns (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #endif /** * Columns for result set of SQLPrimaryKeys(). */ static COL pkeySpec2[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; static COL pkeySpec3[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprimarykeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nrows2 = 0, ncols2 = 0; int namec = -1, uniquec = -1, namec2 = -1, uniquec2 = -1, offs, seq = 1; PTRDIFF_T size; char **rowp = NULL, **rowp2 = NULL, *errp = NULL, *sql, tname[512]; sret = mkresultset(stmt, pkeySpec2, array_size(pkeySpec2), pkeySpec3, array_size(pkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sql = sqlite3_mprintf("PRAGMA table_info(%Q)", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite3_free(sql); return sret; } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } size = 0; if (ncols * nrows > 0) { int typec; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); if (namec >= 0 && uniquec >= 0 && typec >= 0) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { size++; } } } } if (size == 0) { sql = sqlite3_mprintf("PRAGMA index_list(%Q)", tname); if (!sql) { sqlite3_free_table(rowp); return nomem(s); } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp2, &nrows2, &ncols2, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { sqlite3_free_table(rowp); sqlite3_free_table(rowp2); setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } } if (ncols2 * nrows2 > 0) { namec2 = findcol(rowp2, ncols2, "name"); uniquec2 = findcol(rowp2, ncols2, "unique"); if (namec2 >= 0 && uniquec2 >= 0) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols, nlen = 0; char **rowpp; if (rowp2[i * ncols2 + namec2]) { nlen = strlen(rowp2[i * ncols2 + namec2]); } if (nlen < 17 || strncmp(rowp2[i * ncols2 + namec2], "sqlite_autoindex_", 17)) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp2[i * ncols2 + namec2]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret == SQLITE_OK) { size += nnrows; sqlite3_free_table(rowpp); } } } } } if (size == 0) { sqlite3_free_table(rowp); sqlite3_free_table(rowp2); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite3_free_table(rowp); sqlite3_free_table(rowp2); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = s->ncols; if (rowp) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { char buf[32]; s->rows[offs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[offs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[offs + 1] = xstrdup(""); #endif s->rows[offs + 2] = xstrdup(tname); s->rows[offs + 3] = xstrdup(rowp[i * ncols + namec]); sprintf(buf, "%d", seq++); s->rows[offs + 4] = xstrdup(buf); offs += s->ncols; } } } if (rowp2) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols, nlen = 0; char **rowpp; if (rowp2[i * ncols2 + namec2]) { nlen = strlen(rowp2[i * ncols2 + namec2]); } if (nlen < 17 || strncmp(rowp2[i * ncols2 + namec2], "sqlite_autoindex_", 17)) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { int k; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp2[i * ncols2 + namec2]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 5] = xstrdup(rowp2[i * ncols2 + namec2]); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 4] = xstrdup(buf); } } } offs += nnrows * s->ncols; sqlite3_free_table(rowpp); } } } sqlite3_free_table(rowp); sqlite3_free_table(rowp2); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprimarykeys(stmt, cat, catLen, schema, schemaLen, table, tableLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvprimarykeys(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); #else ret = drvprimarykeys(stmt, cat, catLen, schema, schemaLen, table, tableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeysW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvprimarykeys(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLSpecialColumns(). */ static COL scolSpec2[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; static COL scolSpec3[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ static SQLRETURN drvspecialcolumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nnnrows, nnncols, offs; PTRDIFF_T size; int namec = -1, uniquec = -1, namecc = -1, typecc = -1; int notnullcc = -1, mkrowid = 0; char *errp = NULL, *sql, tname[512]; char **rowp = NULL, **rowppp = NULL; sret = mkresultset(stmt, scolSpec2, array_size(scolSpec2), scolSpec3, array_size(scolSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); if (id != SQL_BEST_ROWID) { return SQL_SUCCESS; } sql = sqlite3_mprintf("PRAGMA index_list(%Q)", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite3_free(sql); return sret; } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { doerr: setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } size = 0; /* number result rows */ if (ncols * nrows <= 0) { goto nodata_but_rowid; } sql = sqlite3_mprintf("PRAGMA table_info(%Q)", tname); if (!sql) { return nomem(s); } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowppp, &nnnrows, &nnncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { sqlite3_free_table(rowp); goto doerr; } if (errp) { sqlite3_free(errp); errp = NULL; } namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata_but_rowid; } namecc = findcol(rowppp, nnncols, "name"); typecc = findcol(rowppp, nnncols, "type"); notnullcc = findcol(rowppp, nnncols, "notnull"); for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = NULL; if (*rowp[i * ncols + uniquec] != '0') { ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret == SQLITE_OK) { size += nnrows; sqlite3_free_table(rowpp); } } } nodata_but_rowid: if (size == 0) { size = 1; mkrowid = 1; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite3_free_table(rowp); sqlite3_free_table(rowppp); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; if (mkrowid) { s->nrows = 0; goto mkrowid; } offs = 0; for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = NULL; if (*rowp[i * ncols + uniquec] != '0') { int k; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + m) * s->ncols; s->rows[roffs + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[roffs + 1] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 4] = xstrdup("0"); s->rows[roffs + 7] = xstrdup(stringify(SQL_PC_NOT_PSEUDO)); if (namecc >= 0 && typecc >= 0) { int ii; for (ii = 1; ii <= nnnrows; ii++) { if (strcmp(rowppp[ii * nnncols + namecc], rowpp[m * nncols + k]) == 0) { char *typen = rowppp[ii * nnncols + typecc]; int sqltype, mm, dd, isnullable = 0; char buf[32]; s->rows[roffs + 3] = xstrdup(typen); sqltype = mapsqltype(typen, NULL, *s->ov3, s->nowchar[0], s->dobigint); getmd(typen, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } sprintf(buf, "%d", sqltype); s->rows[roffs + 2] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[roffs + 5] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[roffs + 6] = xstrdup(buf); if (notnullcc >= 0) { char *inp = rowppp[ii * nnncols + notnullcc]; isnullable = inp[0] != '0'; } sprintf(buf, "%d", isnullable); s->rows[roffs + 8] = xstrdup(buf); } } } } } } offs += nnrows; sqlite3_free_table(rowpp); } } if (nullable == SQL_NO_NULLS) { for (i = 1; i < s->nrows; i++) { if (s->rows[i * s->ncols + 8][0] == '0') { int m, i1 = i + 1; for (m = 0; m < s->ncols; m++) { freep(&s->rows[i * s->ncols + m]); } size = s->ncols * sizeof (char *) * (s->nrows - i1); if (size > 0) { memmove(s->rows + i * s->ncols, s->rows + i1 * s->ncols, size); memset(s->rows + s->nrows * s->ncols, 0, s->ncols * sizeof (char *)); } s->nrows--; --i; } } } mkrowid: sqlite3_free_table(rowp); sqlite3_free_table(rowppp); if (s->nrows == 0) { s->rows[s->ncols + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[s->ncols + 1] = xstrdup("_ROWID_"); s->rows[s->ncols + 2] = xstrdup(stringify(SQL_INTEGER)); s->rows[s->ncols + 3] = xstrdup("integer"); s->rows[s->ncols + 4] = xstrdup("0"); s->rows[s->ncols + 5] = xstrdup("10"); s->rows[s->ncols + 6] = xstrdup("9"); s->rows[s->ncols + 7] = xstrdup(stringify(SQL_PC_PSEUDO)); s->rows[s->ncols + 8] = xstrdup(stringify(SQL_FALSE)); s->nrows = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvspecialcolumns(stmt, id, cat, catLen, schema, schemaLen, table, tableLen, scope, nullable); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvspecialcolumns(stmt, id, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, scope, nullable); #else ret = drvspecialcolumns(stmt, id, cat, catLen, schema, schemaLen, table, tableLen, scope, nullable); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumnsW(SQLHSTMT stmt, SQLUSMALLINT id, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvspecialcolumns(stmt, id, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, scope, nullable); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLForeignKeys(). */ static COL fkeySpec2[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; static COL fkeySpec3[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; /** * Internal retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ static SQLRETURN SQL_API drvforeignkeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, offs, namec, seqc, fromc, toc; int onu, ond; PTRDIFF_T size; char **rowp, *errp = NULL, *sql, pname[512], fname[512]; sret = mkresultset(stmt, fkeySpec2, array_size(fkeySpec2), fkeySpec3, array_size(fkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } d = (DBC *) s->dbc; if ((!PKtable || PKtable[0] == '\0' || PKtable[0] == '%') && (!FKtable || FKtable[0] == '\0' || FKtable[0] == '%')) { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } size = 0; if (PKtable) { if (PKtableLen == SQL_NTS) { size = sizeof (pname) - 1; } else { size = min(sizeof (pname) - 1, PKtableLen); } strncpy(pname, (char *) PKtable, size); } pname[size] = '\0'; size = 0; if (FKtable) { if (FKtableLen == SQL_NTS) { size = sizeof (fname) - 1; } else { size = min(sizeof (fname) - 1, FKtableLen); } strncpy(fname, (char *) FKtable, size); } fname[size] = '\0'; if (fname[0] != '\0') { int plen; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA foreign_key_list(%Q)", fname); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); } if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } if (ncols * nrows <= 0) { nodata: sqlite3_free_table(rowp); return SQL_SUCCESS; } size = 0; namec = findcol(rowp, ncols, "table"); seqc = findcol(rowp, ncols, "seq"); fromc = findcol(rowp, ncols, "from"); toc = findcol(rowp, ncols, "to"); onu = findcol(rowp, ncols, "on_update"); ond = findcol(rowp, ncols, "on_delete"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { goto nodata; } plen = strlen(pname); for (i = 1; i <= nrows; i++) { char *ptab = unquote(rowp[i * ncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = rowp[i * ncols + namec]; char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowp[i * ncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(fname); s->rows[roffs + 7] = xstrdup(rowp[i * ncols + fromc]); sscanf(rowp[i * ncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); if (onu < 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowp[i * ncols + onu], "SET NULL") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowp[i * ncols + onu], "SET DEFAULT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowp[i * ncols + onu], "CASCADE") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowp[i * ncols + onu], "RESTRICT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } } if (ond < 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowp[i * ncols + ond], "SET NULL") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowp[i * ncols + ond], "SET DEFAULT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowp[i * ncols + ond], "CASCADE") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowp[i * ncols + ond], "RESTRICT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } } s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } sqlite3_free_table(rowp); } else { int nnrows, nncols, plen = strlen(pname); char **rowpp; sql = "select name from sqlite_master where type='table'"; dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } if (ncols * nrows <= 0) { goto nodata; } size = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } rowpp = NULL; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA foreign_key_list(%Q)", rowp[i]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret != SQLITE_OK || nncols * nnrows <= 0) { sqlite3_free_table(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { sqlite3_free_table(rowpp); continue; } for (k = 1; k <= nnrows; k++) { char *ptab = unquote(rowpp[k * nncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } sqlite3_free_table(rowpp); } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } rowpp = NULL; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA foreign_key_list(%Q)", rowp[i]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret != SQLITE_OK || nncols * nnrows <= 0) { sqlite3_free_table(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); onu = findcol(rowpp, nncols, "on_update"); ond = findcol(rowpp, nncols, "on_delete"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { sqlite3_free_table(rowpp); continue; } for (k = 1; k <= nnrows; k++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = unquote(rowpp[k * nncols + namec]); char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowpp[k * nncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(rowp[i]); s->rows[roffs + 7] = xstrdup(rowpp[k * nncols + fromc]); sscanf(rowpp[k * nncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); if (onu < 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowpp[k * nncols + onu], "SET NULL") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowpp[k * nncols + onu], "SET DEFAULT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowpp[k * nncols + onu], "CASCADE") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowpp[k * nncols + onu], "RESTRICT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } } if (ond < 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowpp[k * nncols + ond], "SET NULL") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowpp[k * nncols + ond], "SET DEFAULT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowpp[k * nncols + ond], "CASCADE") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowpp[k * nncols + ond], "RESTRICT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } } s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } sqlite3_free_table(rowpp); } sqlite3_free_table(rowp); } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { #if defined(_WIN32) || defined(_WIN64) char *pc = NULL, *ps = NULL, *pt = NULL; char *fc = NULL, *fs = NULL, *ft = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvforeignkeys(stmt, PKcatalog, PKcatalogLen, PKschema, PKschemaLen, PKtable, PKtableLen, FKcatalog, FKcatalogLen, FKschema, FKschemaLen, FKtable, FKtableLen); goto done2; } if (PKcatalog) { pc = wmb_to_utf_c((char *) PKcatalog, PKcatalogLen); if (!pc) { ret = nomem((STMT *) stmt); goto done; } } if (PKschema) { ps = wmb_to_utf_c((char *) PKschema, PKschemaLen); if (!ps) { ret = nomem((STMT *) stmt); goto done; } } if (PKtable) { pt = wmb_to_utf_c((char *) PKtable, PKtableLen); if (!pt) { ret = nomem((STMT *) stmt); goto done; } } if (FKcatalog) { fc = wmb_to_utf_c((char *) FKcatalog, FKcatalogLen); if (!fc) { ret = nomem((STMT *) stmt); goto done; } } if (FKschema) { fs = wmb_to_utf_c((char *) FKschema, FKschemaLen); if (!fs) { ret = nomem((STMT *) stmt); goto done; } } if (FKtable) { ft = wmb_to_utf_c((char *) FKtable, FKtableLen); if (!ft) { ret = nomem((STMT *) stmt); goto done; } } ret = drvforeignkeys(stmt, (SQLCHAR *) pc, SQL_NTS, (SQLCHAR *) ps, SQL_NTS, (SQLCHAR *) pt, SQL_NTS, (SQLCHAR *) fc, SQL_NTS, (SQLCHAR *) fs, SQL_NTS, (SQLCHAR *) ft, SQL_NTS); #else ret = drvforeignkeys(stmt, PKcatalog, PKcatalogLen, PKschema, PKschemaLen, PKtable, PKtableLen, FKcatalog, FKcatalogLen, FKschema, FKschemaLen, FKtable, FKtableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(ft); uc_free(fs); uc_free(fc); uc_free(pt); uc_free(ps); uc_free(pc); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about primary/foreign keys (UNICODE version). * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeysW(SQLHSTMT stmt, SQLWCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLWCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLWCHAR *PKtable, SQLSMALLINT PKtableLen, SQLWCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLWCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLWCHAR *FKtable, SQLSMALLINT FKtableLen) { char *pc = NULL, *ps = NULL, *pt = NULL; char *fc = NULL, *fs = NULL, *ft = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (PKcatalog) { pc = uc_to_utf_c(PKcatalog, PKcatalogLen); if (!pc) { ret = nomem((STMT *) stmt); goto done; } } if (PKschema) { ps = uc_to_utf_c(PKschema, PKschemaLen); if (!ps) { ret = nomem((STMT *) stmt); goto done; } } if (PKtable) { pt = uc_to_utf_c(PKtable, PKtableLen); if (!pt) { ret = nomem((STMT *) stmt); goto done; } } if (FKcatalog) { fc = uc_to_utf_c(FKcatalog, FKcatalogLen); if (!fc) { ret = nomem((STMT *) stmt); goto done; } } if (FKschema) { fs = uc_to_utf_c(FKschema, FKschemaLen); if (!fs) { ret = nomem((STMT *) stmt); goto done; } } if (FKtable) { ft = uc_to_utf_c(FKtable, FKtableLen); if (!ft) { ret = nomem((STMT *) stmt); goto done; } } ret = drvforeignkeys(stmt, (SQLCHAR *) pc, SQL_NTS, (SQLCHAR *) ps, SQL_NTS, (SQLCHAR *) pt, SQL_NTS, (SQLCHAR *) fc, SQL_NTS, (SQLCHAR *) fs, SQL_NTS, (SQLCHAR *) ft, SQL_NTS); done: uc_free(ft); uc_free(fs); uc_free(fc); uc_free(pt); uc_free(ps); uc_free(pc); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Start transaction when autocommit off * @param s statement pointer * @result ODBC error code */ static SQLRETURN starttran(STMT *s) { int ret = SQL_SUCCESS, rc, busy_count = 0; char *errp = NULL; DBC *d = (DBC *) s->dbc; if (!d->autocommit && !d->intrans && !d->trans_disable) { begin_again: rc = sqlite3_exec(d->sqlite, "BEGIN TRANSACTION", NULL, NULL, &errp); if (rc == SQLITE_BUSY) { if (busy_handler((void *) d, ++busy_count)) { if (errp) { sqlite3_free(errp); errp = NULL; } goto begin_again; } } dbtracerc(d, rc, errp); if (rc != SQLITE_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); ret = SQL_ERROR; } else { d->intrans = 1; } if (errp) { sqlite3_free(errp); errp = NULL; } } return ret; } /** * Internal commit or rollback transaction. * @param d database connection pointer * @param comptype type of transaction's end, SQL_COMMIT or SQL_ROLLBACK * @param force force action regardless of DBC's autocommit state * @result ODBC error code */ static SQLRETURN endtran(DBC *d, SQLSMALLINT comptype, int force) { int ret, busy_count = 0; char *sql, *errp = NULL; if (!d->sqlite) { setstatd(d, -1, "not connected", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if ((!force && d->autocommit) || !d->intrans) { return SQL_SUCCESS; } switch (comptype) { case SQL_COMMIT: sql = "COMMIT TRANSACTION"; goto doit; case SQL_ROLLBACK: sql = "ROLLBACK TRANSACTION"; doit: ret = sqlite3_exec(d->sqlite, sql, NULL, NULL, &errp); dbtracerc(d, ret, errp); if (ret == SQLITE_BUSY && busy_count < 10) { if (busy_handler((void *) d, ++busy_count)) { if (errp) { sqlite3_free(errp); errp = NULL; } goto doit; } } d->intrans = 0; if (ret != SQLITE_OK) { setstatd(d, ret, "%s", (*d->ov3) ? "HY000" : "S1000", errp ? errp : "transaction failed"); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_SUCCESS; } setstatd(d, -1, "invalid completion type", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ static SQLRETURN drvendtran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { DBC *d; int fail = 0; SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) ENV *e; #endif switch (type) { case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); if (handle == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) handle; ret = endtran(d, comptype, 0); HDBC_UNLOCK((SQLHDBC) handle); return ret; case SQL_HANDLE_ENV: if (handle == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) e = (ENV *) handle; if (e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif d = ((ENV *) handle)->dbcs; while (d) { ret = endtran(d, comptype, 0); if (ret != SQL_SUCCESS) { fail++; } d = d->next; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return fail ? SQL_ERROR : SQL_SUCCESS; } return SQL_INVALID_HANDLE; } /** * Commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLEndTran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { return drvendtran(type, handle, comptype); } /** * Commit or rollback transaction. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param type SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLTransact(SQLHENV env, SQLHDBC dbc, SQLUSMALLINT type) { if (env != SQL_NULL_HENV) { return drvendtran(SQL_HANDLE_ENV, (SQLHANDLE) env, type); } return drvendtran(SQL_HANDLE_DBC, (SQLHANDLE) dbc, type); } /** * Function not implemented. */ SQLRETURN SQL_API SQLCopyDesc(SQLHDESC source, SQLHDESC target) { return SQL_ERROR; } #ifndef WINTERFACE /** * Translate SQL string. * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSql(SQLHSTMT stmt, SQLCHAR *sqlin, SQLINTEGER sqlinLen, SQLCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = strlen((char *) sqlin); } if (sql) { if (sqlMax > 0) { strncpy((char *) sql, (char *) sqlin, sqlMax - 1); sqlin[sqlMax - 1] = '\0'; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Translate SQL string (UNICODE version). * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSqlW(SQLHSTMT stmt, SQLWCHAR *sqlin, SQLINTEGER sqlinLen, SQLWCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = uc_strlen(sqlin); } if (sql) { if (sqlMax > 0) { uc_strncpy(sql, sqlin, sqlMax - 1); sqlin[sqlMax - 1] = 0; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedures(). */ static COL procSpec2[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; static COL procSpec3[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; #ifndef WINTERFACE /** * Retrieve information about stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProceduresW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedureColumns(). */ static COL procColSpec2[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PRECISION", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "SCALE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL procColSpec3[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_SIZE", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "BUFFER_LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "DECIMAL_DIGITS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NUM_PREC_RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; #ifndef WINTERFACE /** * Retrieve information about columns in result set of stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about columns in result * set of stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumnsW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Get information of HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len, SQLINTEGER *lenp) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_ERROR; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val) { *((SQLINTEGER *) val) = SQL_TRUE; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; case SQL_ATTR_ODBC_VERSION: if (val) { *((SQLINTEGER *) val) = e->ov3 ? SQL_OV_ODBC3 : SQL_OV_ODBC2; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Set information in HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val parameter buffer * @param len length of parameter * @result ODBC error code */ SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_SUCCESS; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val == (SQLPOINTER) SQL_TRUE) { ret = SQL_SUCCESS; } break; case SQL_ATTR_ODBC_VERSION: if (!val) { break; } if (val == (SQLPOINTER) SQL_OV_ODBC2) { e->ov3 = 0; ret = SQL_SUCCESS; } if (val == (SQLPOINTER) SQL_OV_ODBC3) { e->ov3 = 1; ret = SQL_SUCCESS; } break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Internal get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ static SQLRETURN drvgetdiagrec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { DBC *d = NULL; STMT *s = NULL; int len, naterr; char *logmsg, *sqlst; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (sqlstate) { sqlstate[0] = '\0'; } if (msg && buflen > 0) { msg[0] = '\0'; } if (msglen) { *msglen = 0; } if (nativeerr) { *nativeerr = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { goto done; } if (recno > 1) { ret = SQL_NO_DATA; goto done; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (nativeerr) { *nativeerr = naterr; } if (sqlstate) { strcpy((char *) sqlstate, sqlst); } if (msglen) { *msglen = len; } if (len >= buflen) { if (msg && buflen > 0) { strncpy((char *) msg, logmsg, buflen); msg[buflen - 1] = '\0'; logmsg[0] = '\0'; } } else if (msg) { strcpy((char *) msg, logmsg); logmsg[0] = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { return drvgetdiagrec(htype, handle, recno, sqlstate, nativeerr, msg, buflen, msglen); } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Get error message given handle (HENV, HDBC, or HSTMT) * (UNICODE version). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRecW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLWCHAR *sqlstate, SQLINTEGER *nativeerr, SQLWCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { char state[16]; SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagrec(htype, handle, recno, (SQLCHAR *) state, nativeerr, (SQLCHAR *) msg, buflen, &len); if (ret == SQL_SUCCESS) { if (sqlstate) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlstate, 6 * sizeof (SQLWCHAR)); } if (msg) { if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) msg, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(msg, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { msg[0] = 0; } } } else { /* estimated length !!! */ len *= sizeof (SQLWCHAR); } if (msglen) { *msglen = len; } } else if (ret == SQL_NO_DATA) { if (sqlstate) { sqlstate[0] = 0; } if (msg) { if (buflen > 0) { msg[0] = 0; } } if (msglen) { *msglen = 0; } } return ret; } #endif #endif /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ static SQLRETURN drvgetdiagfield(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { DBC *d = NULL; STMT *s = NULL; int len, naterr, strbuf = 1; char *logmsg, *sqlst, *clrmsg = NULL; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (stringlen) { *stringlen = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; d = (DBC *) s->dbc; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { switch (buflen) { case SQL_IS_POINTER: case SQL_IS_UINTEGER: case SQL_IS_INTEGER: case SQL_IS_USMALLINT: case SQL_IS_SMALLINT: strbuf = 0; break; default: ret = SQL_ERROR; goto done; } } if (recno > 1) { ret = SQL_NO_DATA; goto done; } switch (id) { case SQL_DIAG_CLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_SUBCLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == 'H' && sqlst[1] == 'Y') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == '2' || sqlst[0] == '0' || sqlst[0] == '4') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: logmsg = d->dsn ? d->dsn : "No DSN"; break; case SQL_DIAG_SQLSTATE: logmsg = sqlst; break; case SQL_DIAG_MESSAGE_TEXT: if (info) { clrmsg = logmsg; } break; case SQL_DIAG_NUMBER: naterr = 1; /* fall through */ case SQL_DIAG_NATIVE: len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (info) { *((SQLINTEGER *) info) = naterr; } ret = SQL_SUCCESS; goto done; case SQL_DIAG_DYNAMIC_FUNCTION: logmsg = ""; break; case SQL_DIAG_CURSOR_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = (s->isselect == 1 || s->isselect == -1) ? s->nrows : 0; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; case SQL_DIAG_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = s->isselect ? 0 : s->nrows; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; default: goto done; } if (info && buflen > 0) { ((char *) info)[0] = '\0'; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (stringlen) { *stringlen = len; } if (strbuf) { if (len >= buflen) { if (info && buflen > 0) { if (stringlen) { *stringlen = buflen - 1; } strncpy((char *) info, logmsg, buflen); ((char *) info)[buflen - 1] = '\0'; } } else if (info) { strcpy((char *) info, logmsg); } } if (clrmsg) { *clrmsg = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #ifndef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { return drvgetdiagfield(htype, handle, recno, id, info, buflen, stringlen); } #endif #ifdef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagFieldW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagfield(htype, handle, recno, id, info, buflen, &len); if (ret == SQL_SUCCESS) { if (info) { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) info, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(info, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { ((SQLWCHAR *) info)[0] = 0; } } } } else { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: len *= sizeof (SQLWCHAR); break; } } if (stringlen) { *stringlen = len; } } return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { STMT *s = (STMT *) stmt; SQLULEN *uval = (SQLULEN *) val; switch (attr) { case SQL_QUERY_TIMEOUT: *uval = 0; return SQL_SUCCESS; case SQL_ATTR_CURSOR_TYPE: *uval = s->curtype; return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: *uval = (s->curtype != SQL_CURSOR_FORWARD_ONLY) ? SQL_SCROLLABLE : SQL_NONSCROLLABLE; return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *uval = SQL_UNSPECIFIED; return SQL_SUCCESS; #endif case SQL_ATTR_ROW_NUMBER: if (s->s3stmt) { *uval = (s->s3stmt_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->s3stmt_rownum + 1); } else { *uval = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: *uval = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *uval = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *uval = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *uval = s->rowset_size; return SQL_SUCCESS; /* Needed for some driver managers, but dummies for now */ case SQL_ATTR_IMP_ROW_DESC: case SQL_ATTR_APP_ROW_DESC: case SQL_ATTR_IMP_PARAM_DESC: case SQL_ATTR_APP_PARAM_DESC: *((SQLHDESC *) val) = (SQLHDESC) DEAD_MAGIC; return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: *((SQLUSMALLINT **) val) = s->row_status; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: *((SQLULEN **) val) = s->row_count; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: { STMT *s = (STMT *) stmt; *(SQLUINTEGER *) val = s->bkmrk ? SQL_UB_ON : SQL_UB_OFF; return SQL_SUCCESS; } case SQL_ATTR_PARAM_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->parm_bind_offs; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLULEN *) val) = s->parm_bind_type; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: *((SQLUSMALLINT **) val) = s->parm_oper; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: *((SQLUSMALLINT **) val) = s->parm_status; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: *((SQLULEN **) val) = s->parm_proc; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: *((SQLULEN *) val) = s->paramset_size; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: *(SQLULEN *) val = s->bind_type; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->bind_offs; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: *((SQLULEN *) val) = s->max_rows; case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: *((SQLULEN *) val) = SQL_FALSE; return SQL_SUCCESS; #endif } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ static SQLRETURN drvsetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { STMT *s = (STMT *) stmt; #if defined(SQL_BIGINT) && defined(__WORDSIZE) && (__WORDSIZE == 64) SQLBIGINT uval; uval = (SQLBIGINT) val; #else SQLULEN uval; uval = (SQLULEN) val; #endif switch (attr) { case SQL_ATTR_CURSOR_TYPE: if (val == (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } if (val != (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY && val != (SQLPOINTER) SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: if (val == (SQLPOINTER) SQL_NONSCROLLABLE) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: if (val != (SQLPOINTER) SQL_ASYNC_ENABLE_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (val != (SQLPOINTER) SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: if (val != (SQLPOINTER) SQL_UNSPECIFIED) { goto e01s02; } return SQL_SUCCESS; #endif case SQL_ATTR_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: if (val != (SQLPOINTER) SQL_RD_ON && val != (SQLPOINTER) SQL_RD_OFF) { goto e01s02; } s->retr_data = uval; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (uval < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (uval > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * uval); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = uval; } return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: s->row_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: s->row_count = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: s->parm_bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: s->parm_bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: s->parm_oper = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: s->parm_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: s->parm_proc = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: if (uval < 1) { goto e01s02; } s->paramset_size = uval; s->paramset_count = 0; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: s->bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: s->bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: if (val != (SQLPOINTER) SQL_UB_OFF && val != (SQLPOINTER) SQL_UB_ON) { goto e01s02; } s->bkmrk = val == (SQLPOINTER) SQL_UB_ON; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: s->max_rows = uval; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: if (val != (SQLPOINTER) 1000000000) { goto e01s02; } return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: if (val != (SQLPOINTER) SQL_FALSE) { goto e01s02; } return SQL_SUCCESS; #endif } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { STMT *s = (STMT *) stmt; SQLUINTEGER *ret = (SQLUINTEGER *) param; switch (opt) { case SQL_QUERY_TIMEOUT: *ret = 0; return SQL_SUCCESS; case SQL_CURSOR_TYPE: *ret = s->curtype; return SQL_SUCCESS; case SQL_ROW_NUMBER: if (s->s3stmt) { *ret = (s->s3stmt_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->s3stmt_rownum + 1); } else { *ret = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: *ret = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *ret = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *ret = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *ret = s->rowset_size; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: *ret = s->max_rows; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: *ret = 1000000000; return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ static SQLRETURN drvsetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLUINTEGER param) { STMT *s = (STMT *) stmt; switch (opt) { case SQL_CURSOR_TYPE: if (param == SQL_CURSOR_FORWARD_ONLY) { s->curtype = param; } else { s->curtype = SQL_CURSOR_STATIC; } if (param != SQL_CURSOR_FORWARD_ONLY && param != SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: if (param != SQL_ASYNC_ENABLE_OFF) { goto e01s02; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (param != SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; case SQL_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_RETRIEVE_DATA: if (param != SQL_RD_ON && param != SQL_RD_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } s->retr_data = (int) param; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (param < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (param > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * param); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = param; } return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: s->max_rows = param; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: if (param != 1000000000) { goto e01s02; } return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ static SQLRETURN drvsetpos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { STMT *s = (STMT *) stmt; int rowp; if (op != SQL_POSITION) { return drvunimplstmt(stmt); } rowp = s->rowp + row - 1; if (!s->rows || row <= 0 || rowp < -1 || rowp >= s->nrows) { setstat(s, -1, "row out of range", (*s->ov3) ? "HY107" : "S1107"); return SQL_ERROR; } s->rowp = rowp; return SQL_SUCCESS; } /** * Set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetpos(stmt, row, op, lock); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt, SQLUSMALLINT concur, SQLLEN rowkeyset, SQLUSMALLINT rowset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #define strmak(dst, src, max, lenp) { \ int len = strlen(src); \ int cnt = min(len + 1, max); \ strncpy(dst, src, cnt); \ *lenp = (cnt > len) ? len : cnt; \ } /** * Internal return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ static SQLRETURN drvgetinfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { DBC *d; char dummyc[16]; SQLSMALLINT dummy; #if defined(_WIN32) || defined(_WIN64) char pathbuf[301], *drvname; #else static char drvname[] = "sqlite3odbc.so"; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (valMax) { valMax--; } if (!valLen) { valLen = &dummy; } if (!val) { val = dummyc; valMax = sizeof (dummyc) - 1; } switch (type) { case SQL_MAX_USER_NAME_LEN: *((SQLSMALLINT *) val) = 16; *valLen = sizeof (SQLSMALLINT); break; case SQL_USER_NAME: strmak(val, "", valMax, valLen); break; case SQL_DRIVER_ODBC_VER: #if 0 strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); #else strmak(val, "03.00", valMax, valLen); #endif break; case SQL_ACTIVE_CONNECTIONS: case SQL_ACTIVE_STATEMENTS: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_ASYNC_MODE case SQL_ASYNC_MODE: *((SQLUINTEGER *) val) = SQL_AM_NONE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_TABLE case SQL_CREATE_TABLE: *((SQLUINTEGER *) val) = SQL_CT_CREATE_TABLE | SQL_CT_COLUMN_DEFAULT | SQL_CT_COLUMN_CONSTRAINT | SQL_CT_CONSTRAINT_NON_DEFERRABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_VIEW case SQL_CREATE_VIEW: *((SQLUINTEGER *) val) = SQL_CV_CREATE_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DDL_INDEX case SQL_DDL_INDEX: *((SQLUINTEGER *) val) = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_TABLE case SQL_DROP_TABLE: *((SQLUINTEGER *) val) = SQL_DT_DROP_TABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_VIEW case SQL_DROP_VIEW: *((SQLUINTEGER *) val) = SQL_DV_DROP_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_INDEX_KEYWORDS case SQL_INDEX_KEYWORDS: *((SQLUINTEGER *) val) = SQL_IK_ALL; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DATA_SOURCE_NAME: strmak(val, d->dsn ? d->dsn : "", valMax, valLen); break; case SQL_DRIVER_NAME: #if defined(_WIN32) || defined(_WIN64) GetModuleFileName(hModule, pathbuf, sizeof (pathbuf)); drvname = strrchr(pathbuf, '\\'); if (drvname == NULL) { drvname = strrchr(pathbuf, '/'); } if (drvname == NULL) { drvname = pathbuf; } else { drvname++; } #endif strmak(val, drvname, valMax, valLen); break; case SQL_DRIVER_VER: strmak(val, DRIVER_VER_INFO, valMax, valLen); break; case SQL_FETCH_DIRECTION: *((SQLUINTEGER *) val) = SQL_FD_FETCH_NEXT | SQL_FD_FETCH_FIRST | SQL_FD_FETCH_LAST | SQL_FD_FETCH_PRIOR | SQL_FD_FETCH_ABSOLUTE; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_VER: strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); break; case SQL_ODBC_SAG_CLI_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSCC_NOT_COMPLIANT; *valLen = sizeof (SQLSMALLINT); break; case SQL_STANDARD_CLI_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_SCC_XOPEN_CLI_VERSION1; *valLen = sizeof (SQLUINTEGER); break; case SQL_SERVER_NAME: case SQL_DATABASE_NAME: strmak(val, d->dbname ? d->dbname : "", valMax, valLen); break; case SQL_SEARCH_PATTERN_ESCAPE: strmak(val, "\\", valMax, valLen); break; case SQL_ODBC_SQL_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSC_MINIMUM; *valLen = sizeof (SQLSMALLINT); break; case SQL_ODBC_API_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OAC_LEVEL1; *valLen = sizeof (SQLSMALLINT); break; case SQL_DBMS_NAME: strmak(val, "SQLite", valMax, valLen); break; case SQL_DBMS_VER: strmak(val, SQLITE_VERSION, valMax, valLen); break; case SQL_COLUMN_ALIAS: case SQL_NEED_LONG_DATA_LEN: strmak(val, "Y", valMax, valLen); break; case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: strmak(val, "N", valMax, valLen); break; #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "Y" : "N", valMax, valLen); #else strmak(val, "N", valMax, valLen); #endif break; #endif case SQL_DATA_SOURCE_READ_ONLY: strmak(val, "N", valMax, valLen); break; #ifdef SQL_OJ_CAPABILITIES case SQL_OJ_CAPABILITIES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_MAX_IDENTIFIER_LEN case SQL_MAX_IDENTIFIER_LEN: *((SQLUSMALLINT *) val) = 255; *valLen = sizeof (SQLUSMALLINT); break; #endif case SQL_CONCAT_NULL_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CURSOR_COMMIT_BEHAVIOR: case SQL_CURSOR_ROLLBACK_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_PRESERVE; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_CURSOR_SENSITIVITY case SQL_CURSOR_SENSITIVITY: *((SQLUINTEGER *) val) = SQL_UNSPECIFIED; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DEFAULT_TXN_ISOLATION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: strmak(val, "Y", valMax, valLen); break; #endif case SQL_TXN_ISOLATION_OPTION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; case SQL_IDENTIFIER_CASE: *((SQLSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLSMALLINT); break; case SQL_IDENTIFIER_QUOTE_CHAR: strmak(val, "\"", valMax, valLen); break; case SQL_MAX_TABLE_NAME_LEN: case SQL_MAX_COLUMN_NAME_LEN: *((SQLSMALLINT *) val) = 255; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_CURSOR_NAME_LEN: *((SQLSMALLINT *) val) = 255; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_PROCEDURE_NAME_LEN: *((SQLSMALLINT *) val) = 0; break; case SQL_MAX_QUALIFIER_NAME_LEN: case SQL_MAX_OWNER_NAME_LEN: *((SQLSMALLINT *) val) = 255; break; case SQL_OWNER_TERM: strmak(val, "", valMax, valLen); break; case SQL_PROCEDURE_TERM: strmak(val, "PROCEDURE", valMax, valLen); break; case SQL_QUALIFIER_NAME_SEPARATOR: strmak(val, ".", valMax, valLen); break; case SQL_QUALIFIER_TERM: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "catalog" : "", valMax, valLen); #else strmak(val, "", valMax, valLen); #endif break; case SQL_QUALIFIER_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLUINTEGER *) val) = d->xcelqrx ? (SQL_CU_DML_STATEMENTS | SQL_CU_INDEX_DEFINITION | SQL_CU_TABLE_DEFINITION) : 0; #else *((SQLUINTEGER *) val) = 0; #endif *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_CONCURRENCY: *((SQLUINTEGER *) val) = SQL_SCCO_LOCK; *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_OPTIONS: *((SQLUINTEGER *) val) = SQL_SO_STATIC | SQL_SO_FORWARD_ONLY; *valLen = sizeof (SQLUINTEGER); break; case SQL_TABLE_TERM: strmak(val, "TABLE", valMax, valLen); break; case SQL_TXN_CAPABLE: *((SQLSMALLINT *) val) = SQL_TC_ALL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CONVERT_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_SYSTEM_FUNCTIONS: case SQL_NUMERIC_FUNCTIONS: case SQL_STRING_FUNCTIONS: case SQL_TIMEDATE_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BIGINT: case SQL_CONVERT_BIT: case SQL_CONVERT_CHAR: case SQL_CONVERT_DATE: case SQL_CONVERT_DECIMAL: case SQL_CONVERT_DOUBLE: case SQL_CONVERT_FLOAT: case SQL_CONVERT_INTEGER: case SQL_CONVERT_LONGVARCHAR: case SQL_CONVERT_NUMERIC: case SQL_CONVERT_REAL: case SQL_CONVERT_SMALLINT: case SQL_CONVERT_TIME: case SQL_CONVERT_TIMESTAMP: case SQL_CONVERT_TINYINT: case SQL_CONVERT_VARCHAR: *((SQLUINTEGER *) val) = SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_BIGINT | SQL_CVT_DATE | SQL_CVT_TIME | SQL_CVT_TIMESTAMP; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BINARY: case SQL_CONVERT_VARBINARY: case SQL_CONVERT_LONGVARBINARY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_POSITIONED_STATEMENTS: case SQL_LOCK_TYPES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_BOOKMARK_PERSISTENCE: *((SQLUINTEGER *) val) = SQL_BP_SCROLL; *valLen = sizeof (SQLUINTEGER); break; case SQL_UNION: *((SQLUINTEGER *) val) = SQL_U_UNION | SQL_U_UNION_ALL; *valLen = sizeof (SQLUINTEGER); break; case SQL_OWNER_USAGE: case SQL_SUBQUERIES: case SQL_TIMEDATE_ADD_INTERVALS: case SQL_TIMEDATE_DIFF_INTERVALS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUOTED_IDENTIFIER_CASE: *((SQLUSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLUSMALLINT); break; case SQL_POS_OPERATIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ALTER_TABLE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CORRELATION_NAME: *((SQLSMALLINT *) val) = SQL_CN_DIFFERENT; *valLen = sizeof (SQLSMALLINT); break; case SQL_NON_NULLABLE_COLUMNS: *((SQLSMALLINT *) val) = SQL_NNC_NON_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_NULL_COLLATION: *((SQLSMALLINT *) val) = SQL_NC_START; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_COLUMNS_IN_GROUP_BY: case SQL_MAX_COLUMNS_IN_ORDER_BY: case SQL_MAX_COLUMNS_IN_SELECT: case SQL_MAX_COLUMNS_IN_TABLE: case SQL_MAX_ROW_SIZE: case SQL_MAX_TABLES_IN_SELECT: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_BINARY_LITERAL_LEN: case SQL_MAX_CHAR_LITERAL_LEN: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_MAX_COLUMNS_IN_INDEX: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_INDEX_SIZE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; #ifdef SQL_MAX_IDENTIFIER_LENGTH case SQL_MAX_IDENTIFIER_LENGTH: *((SQLUINTEGER *) val) = 255; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_MAX_STATEMENT_LEN: *((SQLUINTEGER *) val) = 16384; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUALIFIER_LOCATION: *((SQLSMALLINT *) val) = SQL_QL_START; *valLen = sizeof (SQLSMALLINT); break; case SQL_GETDATA_EXTENSIONS: *((SQLUINTEGER *) val) = SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER | SQL_GD_BOUND; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_SENSITIVITY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FILE_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLSMALLINT *) val) = d->xcelqrx ? SQL_FILE_CATALOG : SQL_FILE_NOT_SUPPORTED; #else *((SQLSMALLINT *) val) = SQL_FILE_NOT_SUPPORTED; #endif *valLen = sizeof (SQLSMALLINT); break; case SQL_GROUP_BY: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_KEYWORDS: strmak(val, "CREATE,SELECT,DROP,DELETE,UPDATE,INSERT," "INTO,VALUES,TABLE,INDEX,FROM,SET,WHERE,AND,CURRENT,OF", valMax, valLen); break; case SQL_SPECIAL_CHARACTERS: #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif strmak(val, "", valMax, valLen); break; case SQL_BATCH_SUPPORT: case SQL_BATCH_ROW_COUNT: case SQL_PARAM_ARRAY_ROW_COUNTS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE | SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: case SQL_STATIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = SQL_CA2_READ_ONLY_CONCURRENCY | SQL_CA2_LOCK_CONCURRENCY; *valLen = sizeof (SQLUINTEGER); break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: case SQL_KEYSET_CURSOR_ATTRIBUTES2: case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_INTERFACE_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_OIC_CORE; *valLen = sizeof (SQLUINTEGER); break; default: setstatd(d, -1, "unsupported info option %d", (*d->ov3) ? "HYC00" : "S1C00", type); return SQL_ERROR; } return SQL_SUCCESS; } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, valLen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfoW(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; SQLSMALLINT len = 0; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, &len); HDBC_UNLOCK(dbc); if (ret == SQL_SUCCESS) { SQLWCHAR *v = NULL; switch (type) { case SQL_USER_NAME: case SQL_DRIVER_ODBC_VER: case SQL_DATA_SOURCE_NAME: case SQL_DRIVER_NAME: case SQL_DRIVER_VER: case SQL_ODBC_VER: case SQL_SERVER_NAME: case SQL_DATABASE_NAME: case SQL_SEARCH_PATTERN_ESCAPE: case SQL_DBMS_NAME: case SQL_DBMS_VER: case SQL_NEED_LONG_DATA_LEN: case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_COLUMN_ALIAS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: case SQL_DATA_SOURCE_READ_ONLY: #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: #endif case SQL_IDENTIFIER_QUOTE_CHAR: case SQL_OWNER_TERM: case SQL_PROCEDURE_TERM: case SQL_QUALIFIER_NAME_SEPARATOR: case SQL_QUALIFIER_TERM: case SQL_TABLE_TERM: case SQL_KEYWORDS: case SQL_SPECIAL_CHARACTERS: #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #endif #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif if (val) { if (len > 0) { v = uc_from_utf((SQLCHAR *) val, len); if (v) { int vmax = valMax / sizeof (SQLWCHAR); uc_strncpy(val, v, vmax); v[len] = 0; len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (valMax >= sizeof (SQLWCHAR)) { *((SQLWCHAR *)val) = 0; } } } else { len *= sizeof (SQLWCHAR); } break; } if (valLen) { *valLen = len; } } return ret; } #endif /** * Return information about supported ODBC API functions. * @param dbc database connection handle * @param func function code to be retrieved * @param flags output indicator * @result ODBC error code */ SQLRETURN SQL_API SQLGetFunctions(SQLHDBC dbc, SQLUSMALLINT func, SQLUSMALLINT *flags) { int i; SQLUSMALLINT exists[100]; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } for (i = 0; i < array_size(exists); i++) { exists[i] = SQL_FALSE; } exists[SQL_API_SQLALLOCCONNECT] = SQL_TRUE; exists[SQL_API_SQLFETCH] = SQL_TRUE; exists[SQL_API_SQLALLOCENV] = SQL_TRUE; exists[SQL_API_SQLFREECONNECT] = SQL_TRUE; exists[SQL_API_SQLALLOCSTMT] = SQL_TRUE; exists[SQL_API_SQLFREEENV] = SQL_TRUE; exists[SQL_API_SQLBINDCOL] = SQL_TRUE; exists[SQL_API_SQLFREESTMT] = SQL_TRUE; exists[SQL_API_SQLCANCEL] = SQL_TRUE; exists[SQL_API_SQLGETCURSORNAME] = SQL_TRUE; exists[SQL_API_SQLCOLATTRIBUTES] = SQL_TRUE; exists[SQL_API_SQLNUMRESULTCOLS] = SQL_TRUE; exists[SQL_API_SQLCONNECT] = SQL_TRUE; exists[SQL_API_SQLPREPARE] = SQL_TRUE; exists[SQL_API_SQLDESCRIBECOL] = SQL_TRUE; exists[SQL_API_SQLROWCOUNT] = SQL_TRUE; exists[SQL_API_SQLDISCONNECT] = SQL_TRUE; exists[SQL_API_SQLSETCURSORNAME] = SQL_FALSE; exists[SQL_API_SQLERROR] = SQL_TRUE; exists[SQL_API_SQLSETPARAM] = SQL_TRUE; exists[SQL_API_SQLEXECDIRECT] = SQL_TRUE; exists[SQL_API_SQLTRANSACT] = SQL_TRUE; exists[SQL_API_SQLEXECUTE] = SQL_TRUE; exists[SQL_API_SQLBINDPARAMETER] = SQL_TRUE; exists[SQL_API_SQLGETTYPEINFO] = SQL_TRUE; exists[SQL_API_SQLCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLPARAMDATA] = SQL_TRUE; exists[SQL_API_SQLDRIVERCONNECT] = SQL_TRUE; exists[SQL_API_SQLPUTDATA] = SQL_TRUE; exists[SQL_API_SQLGETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLSETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETDATA] = SQL_TRUE; exists[SQL_API_SQLSETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETFUNCTIONS] = SQL_TRUE; exists[SQL_API_SQLSPECIALCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLGETINFO] = SQL_TRUE; exists[SQL_API_SQLSTATISTICS] = SQL_TRUE; exists[SQL_API_SQLGETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLTABLES] = SQL_TRUE; exists[SQL_API_SQLBROWSECONNECT] = SQL_FALSE; exists[SQL_API_SQLNUMPARAMS] = SQL_TRUE; exists[SQL_API_SQLCOLUMNPRIVILEGES] = SQL_FALSE; exists[SQL_API_SQLPARAMOPTIONS] = SQL_FALSE; exists[SQL_API_SQLDATASOURCES] = SQL_TRUE; exists[SQL_API_SQLPRIMARYKEYS] = SQL_TRUE; exists[SQL_API_SQLDESCRIBEPARAM] = SQL_TRUE; exists[SQL_API_SQLPROCEDURECOLUMNS] = SQL_TRUE; exists[SQL_API_SQLDRIVERS] = SQL_FALSE; exists[SQL_API_SQLPROCEDURES] = SQL_TRUE; exists[SQL_API_SQLEXTENDEDFETCH] = SQL_TRUE; exists[SQL_API_SQLSETPOS] = SQL_TRUE; exists[SQL_API_SQLFOREIGNKEYS] = SQL_TRUE; exists[SQL_API_SQLSETSCROLLOPTIONS] = SQL_TRUE; exists[SQL_API_SQLMORERESULTS] = SQL_TRUE; exists[SQL_API_SQLTABLEPRIVILEGES] = SQL_TRUE; exists[SQL_API_SQLNATIVESQL] = SQL_TRUE; if (func == SQL_API_ALL_FUNCTIONS) { memcpy(flags, exists, sizeof (exists)); } else if (func == SQL_API_ODBC3_ALL_FUNCTIONS) { int i; #define SET_EXISTS(x) \ flags[(x) >> 4] |= (1 << ((x) & 0xF)) #define CLR_EXISTS(x) \ flags[(x) >> 4] &= ~(1 << ((x) & 0xF)) memset(flags, 0, sizeof (SQLUSMALLINT) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE); for (i = 0; i < array_size(exists); i++) { if (exists[i]) { flags[i >> 4] |= (1 << (i & 0xF)); } } SET_EXISTS(SQL_API_SQLALLOCHANDLE); SET_EXISTS(SQL_API_SQLFREEHANDLE); SET_EXISTS(SQL_API_SQLGETSTMTATTR); SET_EXISTS(SQL_API_SQLSETSTMTATTR); SET_EXISTS(SQL_API_SQLGETCONNECTATTR); SET_EXISTS(SQL_API_SQLSETCONNECTATTR); SET_EXISTS(SQL_API_SQLGETENVATTR); SET_EXISTS(SQL_API_SQLSETENVATTR); SET_EXISTS(SQL_API_SQLCLOSECURSOR); SET_EXISTS(SQL_API_SQLBINDPARAM); #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ SET_EXISTS(SQL_API_SQLGETDIAGREC); #endif SET_EXISTS(SQL_API_SQLGETDIAGFIELD); SET_EXISTS(SQL_API_SQLFETCHSCROLL); SET_EXISTS(SQL_API_SQLENDTRAN); } else { if (func < array_size(exists)) { *flags = exists[func]; } else { switch (func) { case SQL_API_SQLALLOCHANDLE: case SQL_API_SQLFREEHANDLE: case SQL_API_SQLGETSTMTATTR: case SQL_API_SQLSETSTMTATTR: case SQL_API_SQLGETCONNECTATTR: case SQL_API_SQLSETCONNECTATTR: case SQL_API_SQLGETENVATTR: case SQL_API_SQLSETENVATTR: case SQL_API_SQLCLOSECURSOR: case SQL_API_SQLBINDPARAM: #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ case SQL_API_SQLGETDIAGREC: #endif case SQL_API_SQLGETDIAGFIELD: case SQL_API_SQLFETCHSCROLL: case SQL_API_SQLENDTRAN: *flags = SQL_TRUE; break; default: *flags = SQL_FALSE; } } } return SQL_SUCCESS; } /** * Internal allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ static SQLRETURN drvallocenv(SQLHENV *env) { ENV *e; if (env == NULL) { return SQL_INVALID_HANDLE; } e = (ENV *) xmalloc(sizeof (ENV)); if (e == NULL) { *env = SQL_NULL_HENV; return SQL_ERROR; } e->magic = ENV_MAGIC; e->ov3 = 0; #if defined(_WIN32) || defined(_WIN64) InitializeCriticalSection(&e->cs); e->owner = 0; #else #if defined(ENABLE_NVFS) && (ENABLE_NVFS) nvfs_init(); #endif #endif e->dbcs = NULL; *env = (SQLHENV) e; return SQL_SUCCESS; } /** * Allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocEnv(SQLHENV *env) { return drvallocenv(env); } /** * Internal free HENV. * @param env environment handle * @result ODBC error code */ static SQLRETURN drvfreeenv(SQLHENV env) { ENV *e; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (e->magic != ENV_MAGIC) { return SQL_SUCCESS; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif if (e->dbcs) { #if defined(_WIN32) || defined(_WIN64) LeaveCriticalSection(&e->cs); e->owner = 0; #endif return SQL_ERROR; } e->magic = DEAD_MAGIC; #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); DeleteCriticalSection(&e->cs); #endif xfree(e); return SQL_SUCCESS; } /** * Free HENV. * @param env environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeEnv(SQLHENV env) { return drvfreeenv(env); } /** * Internal allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ static SQLRETURN drvallocconnect(SQLHENV env, SQLHDBC *dbc) { DBC *d; ENV *e; const char *verstr; int maj = 0, min = 0, lev = 0; if (dbc == NULL) { return SQL_ERROR; } d = (DBC *) xmalloc(sizeof (DBC)); if (d == NULL) { *dbc = SQL_NULL_HDBC; return SQL_ERROR; } memset(d, 0, sizeof (DBC)); d->curtype = SQL_CURSOR_STATIC; d->ov3 = &d->ov3val; verstr = sqlite3_libversion(); sscanf(verstr, "%d.%d.%d", &maj, &min, &lev); d->version = verinfo(maj & 0xFF, min & 0xFF, lev & 0xFF); e = (ENV *) env; #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); } #endif if (e->magic == ENV_MAGIC) { DBC *n, *p; d->env = e; d->ov3 = &e->ov3; p = NULL; n = e->dbcs; while (n) { p = n; n = n->next; } if (p) { p->next = d; } else { e->dbcs = d; } } #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { e->owner = 0; LeaveCriticalSection(&e->cs); } d->oemcp = 1; #endif d->autocommit = 1; d->magic = DBC_MAGIC; *dbc = (SQLHDBC) d; drvgetgpps(d); return SQL_SUCCESS; } /** * Allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC *dbc) { return drvallocconnect(env, dbc); } /** * Internal free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvfreeconnect(SQLHDBC dbc) { DBC *d; ENV *e; SQLRETURN ret = SQL_ERROR; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } e = d->env; if (e && e->magic == ENV_MAGIC) { #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif } else { e = NULL; } if (d->sqlite) { setstatd(d, -1, "not disconnected", (*d->ov3) ? "HY000" : "S1000"); goto done; } while (d->stmt) { freestmt((HSTMT) d->stmt); } if (e && e->magic == ENV_MAGIC) { DBC *n, *p; p = NULL; n = e->dbcs; while (n) { if (n == d) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = d->next; } else { e->dbcs = d->next; } } } drvrelgpps(d); d->magic = DEAD_MAGIC; if (d->trace) { fclose(d->trace); } xfree(d); ret = SQL_SUCCESS; done: #if defined(_WIN32) || defined(_WIN64) if (e) { e->owner = 0; LeaveCriticalSection(&e->cs); } #endif return ret; } /** * Free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeConnect(SQLHDBC dbc) { return drvfreeconnect(dbc); } /** * Internal get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!val) { val = (SQLPOINTER) &dummy; } if (!buflen) { buflen = &dummy; } switch (attr) { case SQL_ATTR_CONNECTION_DEAD: *((SQLINTEGER *) val) = d->sqlite ? SQL_CD_FALSE : SQL_CD_TRUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ACCESS_MODE: *((SQLINTEGER *) val) = SQL_MODE_READ_WRITE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_AUTOCOMMIT: *((SQLINTEGER *) val) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_LOGIN_TIMEOUT: *((SQLINTEGER *) val) = 100; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ODBC_CURSORS: *((SQLINTEGER *) val) = SQL_CUR_USE_DRIVER; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PACKET_SIZE: *((SQLINTEGER *) val) = 16384; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TXN_ISOLATION: *((SQLINTEGER *) val) = SQL_TXN_SERIALIZABLE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TRACEFILE: case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_CURRENT_CATALOG: *((SQLCHAR *) val) = 0; *buflen = 0; break; case SQL_ATTR_TRACE: case SQL_ATTR_QUIET_MODE: case SQL_ATTR_TRANSLATE_OPTION: case SQL_ATTR_KEYSET_SIZE: case SQL_ATTR_QUERY_TIMEOUT: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLULEN *) val) = SQL_PARAM_BIND_BY_COLUMN; *buflen = sizeof (SQLUINTEGER); break; case SQL_ATTR_ROW_BIND_TYPE: *((SQLULEN *) val) = SQL_BIND_BY_COLUMN; *buflen = sizeof (SQLULEN); break; case SQL_ATTR_USE_BOOKMARKS: *((SQLINTEGER *) val) = SQL_UB_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ASYNC_ENABLE: *((SQLINTEGER *) val) = SQL_ASYNC_ENABLE_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_NOSCAN: *((SQLINTEGER *) val) = SQL_NOSCAN_ON; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CONCURRENCY: *((SQLINTEGER *) val) = SQL_CONCUR_LOCK; *buflen = sizeof (SQLINTEGER); break; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *((SQLINTEGER *) val) = SQL_UNSPECIFIED; *buflen = sizeof (SQLINTEGER); break; #endif case SQL_ATTR_SIMULATE_CURSOR: *((SQLINTEGER *) val) = SQL_SC_NON_UNIQUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_MAX_ROWS: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CURSOR_TYPE: *((SQLINTEGER *) val) = d->curtype; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_RETRIEVE_DATA: *((SQLINTEGER *) val) = SQL_RD_ON; *buflen = sizeof (SQLINTEGER); break; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: *((SQLULEN *) val) = SQL_FALSE; return SQL_SUCCESS; #endif default: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); setstatd(d, -1, "unsupported connect attribute %d", (*d->ov3) ? "HYC00" : "S1C00", (int) attr); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); if (SQL_SUCCEEDED(ret)) { switch (attr) { case SQL_ATTR_TRACEFILE: case SQL_ATTR_CURRENT_CATALOG: case SQL_ATTR_TRANSLATE_LIB: if (val && bufmax >= sizeof (SQLWCHAR)) { *(SQLWCHAR *) val = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ static SQLRETURN drvsetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (attr) { case SQL_AUTOCOMMIT: d->autocommit = val == (SQLPOINTER) SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { s3stmt_end(d->cur_s3stmt); } return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: if (val == (SQLPOINTER) SQL_FALSE) { return SQL_SUCCESS; } /* fall through */ #endif default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!param) { param = (SQLPOINTER) &dummy; } switch (opt) { case SQL_ACCESS_MODE: *((SQLINTEGER *) param) = SQL_MODE_READ_WRITE; break; case SQL_AUTOCOMMIT: *((SQLINTEGER *) param) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; break; case SQL_LOGIN_TIMEOUT: *((SQLINTEGER *) param) = 100; break; case SQL_ODBC_CURSORS: *((SQLINTEGER *) param) = SQL_CUR_USE_DRIVER; break; case SQL_PACKET_SIZE: *((SQLINTEGER *) param) = 16384; break; case SQL_TXN_ISOLATION: *((SQLINTEGER *) param) = SQL_TXN_SERIALIZABLE; break; case SQL_OPT_TRACE: case SQL_OPT_TRACEFILE: case SQL_QUIET_MODE: case SQL_TRANSLATE_DLL: case SQL_TRANSLATE_OPTION: case SQL_KEYSET_SIZE: case SQL_QUERY_TIMEOUT: case SQL_BIND_TYPE: case SQL_CURRENT_QUALIFIER: *((SQLINTEGER *) param) = 0; break; case SQL_USE_BOOKMARKS: *((SQLINTEGER *) param) = SQL_UB_OFF; break; case SQL_ASYNC_ENABLE: *((SQLINTEGER *) param) = SQL_ASYNC_ENABLE_OFF; break; case SQL_NOSCAN: *((SQLINTEGER *) param) = SQL_NOSCAN_ON; break; case SQL_CONCURRENCY: *((SQLINTEGER *) param) = SQL_CONCUR_LOCK; break; case SQL_SIMULATE_CURSOR: *((SQLINTEGER *) param) = SQL_SC_NON_UNIQUE; break; case SQL_MAX_ROWS: *((SQLINTEGER *) param) = 0; break; case SQL_ROWSET_SIZE: case SQL_MAX_LENGTH: *((SQLINTEGER *) param) = 1000000000; break; case SQL_CURSOR_TYPE: *((SQLINTEGER *) param) = d->curtype; break; case SQL_RETRIEVE_DATA: *((SQLINTEGER *) param) = SQL_RD_ON; break; default: *((SQLINTEGER *) param) = 0; setstatd(d, -1, "unsupported connect option %d", (*d->ov3) ? "HYC00" : "S1C00", opt); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect option of HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); if (SQL_SUCCEEDED(ret)) { switch (opt) { case SQL_OPT_TRACEFILE: case SQL_CURRENT_QUALIFIER: case SQL_TRANSLATE_DLL: if (param) { *(SQLWCHAR *) param = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ static SQLRETURN drvsetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLUINTEGER param) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (opt) { case SQL_AUTOCOMMIT: d->autocommit = param == SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { s3stmt_end(d->cur_s3stmt); } break; default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set option on HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64)) /** * Handling of SQLConnect() connection attributes * for standalone operation without driver manager. * @param dsn DSN/driver connection string * @param attr attribute string to be retrieved * @param out output buffer * @param outLen length of output buffer * @result true or false */ static int getdsnattr(char *dsn, char *attr, char *out, int outLen) { char *str = dsn, *start; int len = strlen(attr); while (*str) { while (*str && *str == ';') { ++str; } start = str; if ((str = strchr(str, '=')) == NULL) { return 0; } if (str - start == len && strncasecmp(start, attr, len) == 0) { start = ++str; while (*str && *str != ';') { ++str; } len = min(outLen - 1, str - start); strncpy(out, start, len); out[len] = '\0'; return 1; } while (*str && *str != ';') { ++str; } } return 0; } #endif /** * Internal connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param pwd password or NULL * @param pwdLen length of password or SQL_NTS * @param isu true/false: file name is UTF8 encoded * @result ODBC error code */ static SQLRETURN drvconnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen, char *pwd, int pwdLen, int isu) { DBC *d; int len; SQLRETURN ret; char buf[SQL_MAX_MESSAGE_LENGTH], dbname[SQL_MAX_MESSAGE_LENGTH / 4]; char busy[SQL_MAX_MESSAGE_LENGTH / 4], tracef[SQL_MAX_MESSAGE_LENGTH]; char loadext[SQL_MAX_MESSAGE_LENGTH]; char sflag[32], spflag[32], ntflag[32], nwflag[32], biflag[32]; char snflag[32], lnflag[32], ncflag[32], fkflag[32], jmode[32]; #if defined(_WIN32) || defined(_WIN64) char oemcp[32]; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->sqlite != NULL) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (dsnLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(sizeof (buf) - 1, dsnLen); } if (dsn != NULL) { strncpy(buf, (char *) dsn, len); } buf[len] = '\0'; if (buf[0] == '\0') { setstatd(d, -1, "invalid DSN", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } #if defined(_WIN32) || defined(_WIN64) /* * When DSN is in UTF it must be converted to ANSI * here for ANSI SQLGetPrivateProfileString() */ if (isu) { char *cdsn = utf_to_wmb(buf, len); if (!cdsn) { setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } strcpy(buf, cdsn); uc_free(cdsn); } #endif busy[0] = '\0'; dbname[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "database", dbname, sizeof (dbname)); if (dbname[0] == '\0') { strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } getdsnattr(buf, "timeout", busy, sizeof (busy)); sflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); spflag[0] = '\0'; getdsnattr(buf, "syncpragma", spflag, sizeof (spflag)); ntflag[0] = '\0'; getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); nwflag[0] = '\0'; getdsnattr(buf, "nowchar", nwflag, sizeof (nwflag)); snflag[0] = '\0'; getdsnattr(buf, "shortnames", snflag, sizeof (snflag)); lnflag[0] = '\0'; getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); ncflag[0] = '\0'; getdsnattr(buf, "nocreat", ncflag, sizeof (ncflag)); fkflag[0] = '\0'; getdsnattr(buf, "fksupport", fkflag, sizeof (fkflag)); loadext[0] = '\0'; getdsnattr(buf, "loadext", loadext, sizeof (loadext)); jmode[0] = '\0'; getdsnattr(buf, "journalmode", jmode, sizeof (jmode)); #if defined(_WIN32) || defined(_WIN64) oemcp[0] = '\0'; getdsnattr(buf, "oemcp", oemcp, sizeof (oemcp)); #endif biflag[0] = '\0'; getdsnattr(buf, "bigint", biflag, sizeof (biflag)); #else SQLGetPrivateProfileString(buf, "timeout", "100000", busy, sizeof (busy), ODBC_INI); SQLGetPrivateProfileString(buf, "database", "", dbname, sizeof (dbname), ODBC_INI); #if defined(_WIN32) || defined(_WIN64) /* database name read from registry is not UTF8 !!! */ isu = 0; #endif SQLGetPrivateProfileString(buf, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); SQLGetPrivateProfileString(buf, "syncpragma", "NORMAL", spflag, sizeof (spflag), ODBC_INI); SQLGetPrivateProfileString(buf, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); SQLGetPrivateProfileString(buf, "nowchar", "", nwflag, sizeof (nwflag), ODBC_INI); SQLGetPrivateProfileString(buf, "shortnames", "", snflag, sizeof (snflag), ODBC_INI); SQLGetPrivateProfileString(buf, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); SQLGetPrivateProfileString(buf, "nocreat", "", ncflag, sizeof (ncflag), ODBC_INI); SQLGetPrivateProfileString(buf, "fksupport", "", fkflag, sizeof (fkflag), ODBC_INI); SQLGetPrivateProfileString(buf, "loadext", "", loadext, sizeof (loadext), ODBC_INI); SQLGetPrivateProfileString(buf, "journalmode", "", jmode, sizeof (jmode), ODBC_INI); #if defined(_WIN32) || defined(_WIN64) SQLGetPrivateProfileString(buf, "oemcp", "1", oemcp, sizeof (oemcp), ODBC_INI); #endif SQLGetPrivateProfileString(buf, "bigint", "", biflag, sizeof (biflag), ODBC_INI); #endif tracef[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #else SQLGetPrivateProfileString(buf, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); #endif if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } d->nowchar = getbool(nwflag); d->shortnames = getbool(snflag); d->longnames = getbool(lnflag); d->nocreat = getbool(ncflag); d->fksupport = getbool(fkflag); #if defined(_WIN32) || defined(_WIN64) d->oemcp = getbool(oemcp); #else d->oemcp = 0; #endif d->dobigint = getbool(biflag); d->pwd = pwd; d->pwdLen = 0; if (d->pwd) { d->pwdLen = (pwdLen == SQL_NTS) ? strlen(d->pwd) : pwdLen; } ret = dbopen(d, dbname, isu, (char *) dsn, sflag, spflag, ntflag, jmode, busy); if (ret == SQL_SUCCESS) { dbloadext(d, loadext); } return ret; } #ifndef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pwd password string or NULL * @param pwdLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen, SQLCHAR *uid, SQLSMALLINT uidLen, SQLCHAR *pwd, SQLSMALLINT pwdLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvconnect(dbc, dsn, dsnLen, (char *) pwd, pwdLen, 0); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pwd password string or NULL * @param pwdLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnectW(SQLHDBC dbc, SQLWCHAR *dsn, SQLSMALLINT dsnLen, SQLWCHAR *uid, SQLSMALLINT uidLen, SQLWCHAR *pwd, SQLSMALLINT pwdLen) { char *dsna = NULL; char *pwda = NULL; SQLRETURN ret; HDBC_LOCK(dbc); if (dsn) { dsna = uc_to_utf_c(dsn, dsnLen); if (!dsna) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); ret = SQL_ERROR; goto done; } } if (pwd) { pwda = uc_to_utf_c(pwd, pwdLen); if (!pwda) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); ret = SQL_ERROR; goto done; } } ret = drvconnect(dbc, (SQLCHAR *) dsna, SQL_NTS, pwda, SQL_NTS, 1); done: HDBC_UNLOCK(dbc); uc_free(dsna); uc_free(pwda); return ret; } #endif /** * Internal disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvdisconnect(SQLHDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->intrans) { setstatd(d, -1, "incomplete transaction", "25000"); return SQL_ERROR; } if (d->cur_s3stmt) { s3stmt_end(d->cur_s3stmt); } if (d->sqlite) { if (d->trace) { fprintf(d->trace, "-- sqlite3_close: '%s'\n", d->dbname); fflush(d->trace); } sqlite3_close(d->sqlite); d->sqlite = NULL; } freep(&d->dbname); freep(&d->dsn); return SQL_SUCCESS; } /** * Disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLDisconnect(SQLHDBC dbc) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdisconnect(dbc); HDBC_UNLOCK(dbc); return ret; } #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64)) /** * Internal standalone (w/o driver manager) database connect. * @param dbc database connection handle * @param hwnd dummy window handle or NULL * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { DBC *d; int len; SQLRETURN ret; char buf[SQL_MAX_MESSAGE_LENGTH * 6], dbname[SQL_MAX_MESSAGE_LENGTH]; char dsn[SQL_MAX_MESSAGE_LENGTH / 4], busy[SQL_MAX_MESSAGE_LENGTH / 4]; char tracef[SQL_MAX_MESSAGE_LENGTH], loadext[SQL_MAX_MESSAGE_LENGTH]; char pwd[SQL_MAX_MESSAGE_LENGTH]; char sflag[32], spflag[32], ntflag[32], snflag[32], lnflag[32]; char ncflag[32], nwflag[32], fkflag[32], jmode[32], biflag[32]; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } if (drvcompl != SQL_DRIVER_COMPLETE && drvcompl != SQL_DRIVER_COMPLETE_REQUIRED && drvcompl != SQL_DRIVER_PROMPT && drvcompl != SQL_DRIVER_NOPROMPT) { return SQL_NO_DATA; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (connInLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(connInLen, sizeof (buf) - 1); } if (connIn != NULL) { strncpy(buf, (char *) connIn, len); } buf[len] = '\0'; if (!buf[0]) { setstatd(d, -1, "invalid connect attributes", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } dsn[0] = '\0'; getdsnattr(buf, "DSN", dsn, sizeof (dsn)); /* special case: connIn is sole DSN value without keywords */ if (!dsn[0] && !strchr(buf, ';') && !strchr(buf, '=')) { strncpy(dsn, buf, sizeof (dsn) - 1); dsn[sizeof (dsn) - 1] = '\0'; } busy[0] = '\0'; getdsnattr(buf, "timeout", busy, sizeof (busy)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !busy[0]) { SQLGetPrivateProfileString(dsn, "timeout", "100000", busy, sizeof (busy), ODBC_INI); } #endif dbname[0] = '\0'; getdsnattr(buf, "database", dbname, sizeof (dbname)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !dbname[0]) { SQLGetPrivateProfileString(dsn, "database", "", dbname, sizeof (dbname), ODBC_INI); } #endif sflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !sflag[0]) { SQLGetPrivateProfileString(dsn, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); } #endif spflag[0] = '\0'; getdsnattr(buf, "syncpragma", spflag, sizeof (spflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !spflag[0]) { SQLGetPrivateProfileString(dsn, "syncpragma", "NORMAL", spflag, sizeof (spflag), ODBC_INI); } #endif ntflag[0] = '\0'; getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !ntflag[0]) { SQLGetPrivateProfileString(dsn, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); } #endif snflag[0] = '\0'; getdsnattr(buf, "shortnames", snflag, sizeof (snflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !snflag[0]) { SQLGetPrivateProfileString(dsn, "shortnames", "", snflag, sizeof (snflag), ODBC_INI); } #endif lnflag[0] = '\0'; getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !lnflag[0]) { SQLGetPrivateProfileString(dsn, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); } #endif ncflag[0] = '\0'; getdsnattr(buf, "nocreat", ncflag, sizeof (ncflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !ncflag[0]) { SQLGetPrivateProfileString(dsn, "nocreat", "", ncflag, sizeof (ncflag), ODBC_INI); } #endif nwflag[0] = '\0'; getdsnattr(buf, "nowchar", nwflag, sizeof (nwflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !nwflag[0]) { SQLGetPrivateProfileString(dsn, "nowchar", "", nwflag, sizeof (nwflag), ODBC_INI); } #endif fkflag[0] = '\0'; getdsnattr(buf, "fksupport", fkflag, sizeof (fkflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !fkflag[0]) { SQLGetPrivateProfileString(dsn, "fksupport", "", fkflag, sizeof (fkflag), ODBC_INI); } #endif loadext[0] = '\0'; getdsnattr(buf, "loadext", loadext, sizeof (loadext)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !loadext[0]) { SQLGetPrivateProfileString(dsn, "loadext", "", loadext, sizeof (loadext), ODBC_INI); } #endif jmode[0] = '\0'; getdsnattr(buf, "journalmode", jmode, sizeof (jmode)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !jmode[0]) { SQLGetPrivateProfileString(dsn, "journalmode", "", jmode, sizeof (jmode), ODBC_INI); } #endif biflag[0] = '\0'; getdsnattr(buf, "bigint", biflag, sizeof (biflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !biflag[0]) { SQLGetPrivateProfileString(dsn, "bigint", "", biflag, sizeof (biflag), ODBC_INI); } #endif pwd[0] = '\0'; getdsnattr(buf, "pwd", pwd, sizeof (pwd)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !pwd[0]) { SQLGetPrivateProfileString(dsn, "pwd", "", pwd, sizeof (pwd), ODBC_INI); } #endif if (!dbname[0] && !dsn[0]) { strcpy(dsn, "SQLite"); strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } tracef[0] = '\0'; getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !tracef[0]) { SQLGetPrivateProfileString(dsn, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); } #endif if (connOut || connOutLen) { int count; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), "DSN=%s;Database=%s;StepAPI=%s;Timeout=%s;" "SyncPragma=%s;NoTXN=%s;ShortNames=%s;LongNames=%s;" "NoCreat=%s;NoWCHAR=%s;FKSupport=%s;Tracefile=%s;" "JournalMode=%s;LoadExt=%s;BigInt=%s;PWD=%s", dsn, dbname, sflag, busy, spflag, ntflag, snflag, lnflag, ncflag, nwflag, fkflag, tracef, jmode, loadext, biflag,pwd); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } d->shortnames = getbool(snflag); d->longnames = getbool(lnflag); d->nocreat = getbool(ncflag); d->nowchar = getbool(nwflag); d->fksupport = getbool(fkflag); d->dobigint = getbool(biflag); d->oemcp = 0; d->pwdLen = strlen(pwd); d->pwd = (d->pwdLen > 0) ? pwd : NULL; ret = dbopen(d, dbname, 0, dsn, sflag, spflag, ntflag, jmode, busy); memset(pwd, 0, sizeof (pwd)); if (ret == SQL_SUCCESS) { dbloadext(d, loadext); } return ret; } #endif /** * Internal free function for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN freestmt(SQLHSTMT stmt) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; s3stmt_drop(s); freeresult(s, 1); freep(&s->query); d = (DBC *) s->dbc; if (d && d->magic == DBC_MAGIC) { STMT *p, *n; p = NULL; n = d->stmt; while (n) { if (n == s) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = s->next; } else { d->stmt = s->next; } } } freeparams(s); freep(&s->bindparms); if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); s->rowset_size = 1; s->row_status0 = &s->row_status1; } xfree(s); return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC (driver internal version). * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ static SQLRETURN drvallocstmt(SQLHDBC dbc, SQLHSTMT *stmt) { DBC *d; STMT *s, *sl, *pl; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC || stmt == NULL) { return SQL_INVALID_HANDLE; } s = (STMT *) xmalloc(sizeof (STMT)); if (s == NULL) { *stmt = SQL_NULL_HSTMT; return SQL_ERROR; } *stmt = (SQLHSTMT) s; memset(s, 0, sizeof (STMT)); s->dbc = dbc; s->ov3 = d->ov3; s->oemcp = &d->oemcp; s->nowchar[0] = d->nowchar; s->nowchar[1] = 0; s->dobigint = d->dobigint; s->curtype = d->curtype; s->row_status0 = &s->row_status1; s->rowset_size = 1; s->longnames = d->longnames; s->retr_data = SQL_RD_ON; s->max_rows = 0; s->bind_type = SQL_BIND_BY_COLUMN; s->bind_offs = NULL; s->paramset_size = 1; s->parm_bind_type = SQL_PARAM_BIND_BY_COLUMN; #ifdef _WIN64 sprintf((char *) s->cursorname, "CUR_%I64X", (SQLUBIGINT) *stmt); #else sprintf((char *) s->cursorname, "CUR_%016lX", (long) *stmt); #endif sl = d->stmt; pl = NULL; while (sl) { pl = sl; sl = sl->next; } if (pl) { pl->next = s; } else { d->stmt = s; } return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC. * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocStmt(SQLHDBC dbc, SQLHSTMT *stmt) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvallocstmt(dbc, stmt); HDBC_UNLOCK(dbc); return ret; } /** * Internal function to perform certain kinds of free/close on STMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ static SQLRETURN drvfreestmt(SQLHSTMT stmt, SQLUSMALLINT opt) { STMT *s; SQLRETURN ret = SQL_SUCCESS; SQLHDBC dbc; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_LOCK(stmt); s = (STMT *) stmt; dbc = s->dbc; switch (opt) { case SQL_RESET_PARAMS: freeparams(s); break; case SQL_UNBIND: unbindcols(s); break; case SQL_CLOSE: s3stmt_end_if(s); freeresult(s, 0); break; case SQL_DROP: s3stmt_end_if(s); ret = freestmt(stmt); break; default: setstat(s, -1, "unsupported option", (*s->ov3) ? "HYC00" : "S1C00"); ret = SQL_ERROR; break; } HDBC_UNLOCK(dbc); return ret; } /** * Free HSTMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT opt) { return drvfreestmt(stmt, opt); } /** * Cancel HSTMT closing cursor. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) { if (stmt != SQL_NULL_HSTMT) { DBC *d = (DBC *) ((STMT *) stmt)->dbc; #if defined(_WIN32) || defined(_WIN64) /* interrupt when other thread owns critical section */ int i; for (i = 0; i < 2; i++) { if (d->magic == DBC_MAGIC && d->env && d->env->magic == ENV_MAGIC && d->env->owner != GetCurrentThreadId() && d->env->owner != 0) { d->busyint = 1; sqlite3_interrupt(d->sqlite); } Sleep(1); } #else if (d->magic == DBC_MAGIC) { d->busyint = 1; sqlite3_interrupt(d->sqlite); } #endif } return drvfreestmt(stmt, SQL_CLOSE); } /** * Internal function to get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ static SQLRETURN drvgetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (lenp && !cursor) { *lenp = strlen((char *) s->cursorname); return SQL_SUCCESS; } if (cursor) { if (buflen > 0) { strncpy((char *) cursor, (char *) s->cursorname, buflen - 1); cursor[buflen - 1] = '\0'; } if (lenp) { *lenp = min(strlen((char *) s->cursorname), buflen - 1); } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvgetcursorname(stmt, cursor, buflen, lenp); goto done; } ret = drvgetcursorname(stmt, cursor, buflen, &len); if (ret == SQL_SUCCESS) { char *c = NULL; if (cursor) { c = utf_to_wmb((char *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } c[len] = 0; len = strlen(c); if (buflen > 0) { strncpy((char *) cursor, c, buflen - 1); cursor[buflen - 1] = 0; } uc_free(c); } if (lenp) { *lenp = min(len, buflen - 1); } } done: ; #else ret = drvgetcursorname(stmt, cursor, buflen, lenp); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get cursor name of STMT (UNICODE version). * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvgetcursorname(stmt, (SQLCHAR *) cursor, buflen, &len); if (ret == SQL_SUCCESS) { SQLWCHAR *c = NULL; if (cursor) { c = uc_from_utf((SQLCHAR *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } c[len] = 0; len = uc_strlen(c); if (buflen > 0) { uc_strncpy(cursor, c, buflen - 1); cursor[buflen - 1] = 0; } uc_free(c); } if (lenp) { *lenp = min(len, buflen - 1); } } done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal function to set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ static SQLRETURN drvsetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!cursor || !((cursor[0] >= 'A' && cursor[0] <= 'Z') || (cursor[0] >= 'a' && cursor[0] <= 'z'))) { setstat(s, -1, "invalid cursor name", (*s->ov3) ? "HYC00" : "S1C00"); return SQL_ERROR; } if (len == SQL_NTS) { len = sizeof (s->cursorname) - 1; } else { len = min(sizeof (s->cursorname) - 1, len); } strncpy((char *) s->cursorname, (char *) cursor, len); s->cursorname[len] = '\0'; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvsetcursorname(stmt, cursor, len); goto done2; } if (cursor) { c = wmb_to_utf_c((char *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } } ret = drvsetcursorname(stmt, (SQLCHAR *) c, SQL_NTS); #else ret = drvsetcursorname(stmt, cursor, len); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set cursor name on STMT (UNICODE version). * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT len) { char *c = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cursor) { c = uc_to_utf_c(cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } } ret = drvsetcursorname(stmt, (SQLCHAR *) c, SQL_NTS); done: uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Close open cursor. * @param stmt statement handle * @return ODBC error code */ SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt) { return drvfreestmt(stmt, SQL_CLOSE); } /** * Allocate a HENV, HDBC, or HSTMT handle. * @param type handle type * @param input input handle (HENV, HDBC) * @param output pointer to output handle (HENV, HDBC, HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE input, SQLHANDLE *output) { SQLRETURN ret; switch (type) { case SQL_HANDLE_ENV: ret = drvallocenv((SQLHENV *) output); if (ret == SQL_SUCCESS) { ENV *e = (ENV *) *output; if (e && e->magic == ENV_MAGIC) { e->ov3 = 1; } } return ret; case SQL_HANDLE_DBC: return drvallocconnect((SQLHENV) input, (SQLHDBC *) output); case SQL_HANDLE_STMT: HDBC_LOCK((SQLHDBC) input); ret = drvallocstmt((SQLHDBC) input, (SQLHSTMT *) output); HDBC_UNLOCK((SQLHDBC) input); return ret; } return SQL_ERROR; } /** * Free a HENV, HDBC, or HSTMT handle. * @param type handle type * @param h handle (HENV, HDBC, or HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE h) { switch (type) { case SQL_HANDLE_ENV: return drvfreeenv((SQLHENV) h); case SQL_HANDLE_DBC: return drvfreeconnect((SQLHDBC) h); case SQL_HANDLE_STMT: return drvfreestmt((SQLHSTMT) h, SQL_DROP); } return SQL_ERROR; } /** * Free dynamically allocated column descriptions of STMT. * @param s statement pointer */ static void freedyncols(STMT *s) { if (s->dyncols) { int i; for (i = 0; i < s->dcols; i++) { freep(&s->dyncols[i].typename); } if (s->cols == s->dyncols) { s->cols = NULL; s->ncols = 0; } freep(&s->dyncols); } s->dcols = 0; } /** * Free statement's result. * @param s statement pointer * @param clrcols flag to clear column information * * The result rows are free'd using the rowfree function pointer. * If clrcols is greater than zero, then column bindings and dynamic column * descriptions are free'd. * If clrcols is less than zero, then dynamic column descriptions are free'd. */ static void freeresult(STMT *s, int clrcols) { freep(&s->bincache); s->bincell = NULL; s->binlen = 0; if (s->rows) { if (s->rowfree) { s->rowfree(s->rows); s->rowfree = NULL; } s->rows = NULL; } s->nrows = -1; if (clrcols > 0) { freep(&s->bindcols); s->nbindcols = 0; } if (clrcols) { freedyncols(s); s->cols = NULL; s->ncols = 0; s->nowchar[1] = 0; } } /** * Reset bound columns to unbound state. * @param s statement pointer */ static void unbindcols(STMT *s) { int i; s->bkmrkcol.type = -1; s->bkmrkcol.max = 0; s->bkmrkcol.lenp = NULL; s->bkmrkcol.valp = NULL; s->bkmrkcol.index = 0; s->bkmrkcol.offs = 0; for (i = 0; s->bindcols && i < s->nbindcols; i++) { s->bindcols[i].type = -1; s->bindcols[i].max = 0; s->bindcols[i].lenp = NULL; s->bindcols[i].valp = NULL; s->bindcols[i].index = i; s->bindcols[i].offs = 0; } } /** * Reallocate space for bound columns. * @param s statement pointer * @param ncols number of columns * @result ODBC error code */ static SQLRETURN mkbindcols(STMT *s, int ncols) { if (s->bindcols) { if (s->nbindcols < ncols) { int i; BINDCOL *bindcols = xrealloc(s->bindcols, ncols * sizeof (BINDCOL)); if (!bindcols) { return nomem(s); } for (i = s->nbindcols; i < ncols; i++) { bindcols[i].type = -1; bindcols[i].max = 0; bindcols[i].lenp = NULL; bindcols[i].valp = NULL; bindcols[i].index = i; bindcols[i].offs = 0; } s->bindcols = bindcols; s->nbindcols = ncols; } } else if (ncols > 0) { s->bindcols = (BINDCOL *) xmalloc(ncols * sizeof (BINDCOL)); if (!s->bindcols) { return nomem(s); } s->nbindcols = ncols; unbindcols(s); } return SQL_SUCCESS; } /** * Internal function to retrieve row data, used by SQLFetch() and * friends and SQLGetData(). * @param s statement pointer * @param col column number, 0 based * @param otype output data type * @param val output buffer * @param len length of output buffer * @param lenp output length * @param partial flag for partial data retrieval * @result ODBC error code */ static SQLRETURN getrowdata(STMT *s, SQLUSMALLINT col, SQLSMALLINT otype, SQLPOINTER val, SQLINTEGER len, SQLLEN *lenp, int partial) { char **data, valdummy[16]; SQLLEN dummy; SQLINTEGER *ilenp = NULL; int valnull = 0; int type = otype; SQLRETURN sret = SQL_NO_DATA; if (!lenp) { lenp = &dummy; } /* workaround for JDK 1.7.0 on x86_64 */ if (((SQLINTEGER *) lenp) + 1 == (SQLINTEGER *) val) { ilenp = (SQLINTEGER *) lenp; lenp = &dummy; } if (col >= s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!s->rows) { *lenp = SQL_NULL_DATA; goto done; } if (s->rowp < 0 || s->rowp >= s->nrows) { *lenp = SQL_NULL_DATA; goto done; } if (s->retr_data != SQL_RD_ON) { return SQL_SUCCESS; } type = mapdeftype(type, s->cols[col].type, s->cols[col].nosign ? 1 : 0, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 3 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && otype == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif data = s->rows + s->ncols + (s->rowp * s->ncols) + col; if (!val) { valnull = 1; val = (SQLPOINTER) valdummy; } if (*data == NULL) { *lenp = SQL_NULL_DATA; switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif *((SQLCHAR *) val) = 0; break; case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((SQLSMALLINT *) val) = 0; break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = 0; break; #ifdef SQL_BIGINT case SQL_C_SBIGINT: case SQL_C_UBIGINT: *((SQLBIGINT *) val) = 0; break; #endif case SQL_C_FLOAT: *((float *) val) = 0; break; case SQL_C_DOUBLE: *((double *) val) = 0; break; case SQL_C_BINARY: case SQL_C_CHAR: *((SQLCHAR *) val) = '\0'; break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: *((SQLWCHAR *) val) = '\0'; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: memset((DATE_STRUCT *) val, 0, sizeof (DATE_STRUCT)); break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: memset((TIME_STRUCT *) val, 0, sizeof (TIME_STRUCT)); break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: memset((TIMESTAMP_STRUCT *) val, 0, sizeof (TIMESTAMP_STRUCT)); break; default: return SQL_ERROR; } } else { char *endp = NULL; #if defined(_WIN32) || defined(_WIN64) #ifdef SQL_BIGINT char endc; #endif #endif switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: *((SQLCHAR *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLCHAR); } break; #ifdef SQL_BIT case SQL_C_BIT: *((SQLCHAR *) val) = getbool(*data); *lenp = sizeof (SQLCHAR); break; #endif case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((SQLSMALLINT *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLSMALLINT); } break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLINTEGER); } break; #ifdef SQL_BIGINT case SQL_C_UBIGINT: #if defined(_WIN32) || defined(_WIN64) if (sscanf(*data, "%I64u%c", (SQLUBIGINT *) val, &endc) != 1) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLUBIGINT); } #else #ifdef __osf__ *((SQLUBIGINT *) val) = strtoul(*data, &endp, 0); #else *((SQLUBIGINT *) val) = strtoull(*data, &endp, 0); #endif if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLUBIGINT); } #endif break; case SQL_C_SBIGINT: #if defined(_WIN32) || defined(_WIN64) if (sscanf(*data, "%I64d%c", (SQLBIGINT *) val, &endc) != 1) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLBIGINT); } #else #ifdef __osf__ *((SQLBIGINT *) val) = strtol(*data, &endp, 0); #else *((SQLBIGINT *) val) = strtoll(*data, &endp, 0); #endif if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLBIGINT); } #endif break; #endif case SQL_C_FLOAT: *((float *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (float); } break; case SQL_C_DOUBLE: *((double *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (double); } break; case SQL_C_BINARY: { int dlen, offs = 0; char *bin; if (valnull) { freep(&s->bincache); s->binlen = 0; goto doCHAR; } if (*data == s->bincell) { if (s->bincache) { bin = s->bincache; dlen = s->binlen; } else { goto doCHAR; } } else { char *dp; int i; freep(&s->bincache); dp = *data; dlen = strlen(dp); s->bincell = dp; s->binlen = 0; if (!(dp[0] == 'x' || dp[0] == 'X') || dp[1] != '\'' || dp[dlen - 1] != '\'') { goto doCHAR; } dlen -= 2; dp += 2; dlen = dlen / 2; s->bincache = bin = xmalloc(dlen); if (!bin) { return nomem(s); } s->binlen = dlen; memset(s->bincache, 0, dlen); for (i = 0; i < dlen; i++) { char *x; int v; if (!*dp || !(x = strchr(xdigits, *dp))) { goto converr; } v = x - xdigits; bin[i] = (v >= 16) ? ((v - 6) << 4) : (v << 4); ++dp; if (!*dp || !(x = strchr(xdigits, *dp))) { converr: freep(&s->bincache); s->binlen = 0; setstat(s, -1, "conversion error", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } v = x - xdigits; bin[i] |= (v >= 16) ? (v - 6) : v; ++dp; } bin = s->bincache; } if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { *lenp = 0; if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && len) { memcpy(val, bin + offs, min(len, dlen)); } if (len < 1) { *lenp = dlen; } else { *lenp = min(len, dlen); if (*lenp == len && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } } if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } doCHAR: #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif case SQL_C_CHAR: { int doz, zlen = len - 1; int dlen = strlen(*data); int offs = 0; #ifdef WCHARSUPPORT SQLWCHAR *ucdata = NULL; SQLCHAR *cdata = (SQLCHAR *) *data; #endif #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 2 (reserved error -7748) */ if (!valnull && (s->cols == statSpec2P || s->cols == statSpec3P) && type == SQL_C_WCHAR) { if (len > 0 && len <= sizeof (SQLWCHAR)) { ((char *) val)[0] = data[0][0]; memset((char *) val + 1, 0, len - 1); *lenp = 1; sret = SQL_SUCCESS; goto done; } } #endif #ifdef WCHARSUPPORT switch (type) { case SQL_C_CHAR: doz = 1; break; case SQL_C_WCHAR: doz = sizeof (SQLWCHAR); break; default: doz = 0; break; } if (type == SQL_C_WCHAR) { ucdata = uc_from_utf(cdata, dlen); if (!ucdata) { return nomem(s); } dlen = uc_strlen(ucdata) * sizeof (SQLWCHAR); } #if defined(_WIN32) || defined(_WIN64) else if (*s->oemcp && type == SQL_C_CHAR) { ucdata = (SQLWCHAR *) utf_to_wmb((char *) cdata, dlen); if (!ucdata) { return nomem(s); } cdata = (SQLCHAR *) ucdata; dlen = strlen((char *) cdata); } #endif #else doz = (type == SQL_C_CHAR) ? 1 : 0; #endif if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { #ifdef WCHARSUPPORT uc_free(ucdata); #endif *lenp = 0; if (doz && val) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[0] = 0; } else { ((char *) val)[0] = '\0'; } #else ((char *) val)[0] = '\0'; #endif } if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && !valnull && len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { uc_strncpy(val, ucdata + offs / sizeof (SQLWCHAR), (len - doz) / sizeof (SQLWCHAR)); } else { strncpy(val, (char *) cdata + offs, len - doz); } #else strncpy(val, *data + offs, len - doz); #endif } if (valnull || len < 1) { *lenp = dlen; } else { *lenp = min(len - doz, dlen); if (*lenp == len - doz && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } else if (*lenp < zlen) { zlen = *lenp; } } if (len && !valnull && doz) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[zlen / sizeof (SQLWCHAR)] = 0; } else { ((char *) val)[zlen] = '\0'; } #else ((char *) val)[zlen] = '\0'; #endif } #ifdef WCHARSUPPORT uc_free(ucdata); #endif if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len - doz; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: if (str2date(*data, (DATE_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (DATE_STRUCT); } break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: if (str2time(*data, (TIME_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIME_STRUCT); } break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: if (str2timestamp(*data, (TIMESTAMP_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIMESTAMP_STRUCT); } switch (s->cols[col].prec) { case 0: ((TIMESTAMP_STRUCT *) val)->fraction = 0; break; case 1: ((TIMESTAMP_STRUCT *) val)->fraction /= 100000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 100000000; break; case 2: ((TIMESTAMP_STRUCT *) val)->fraction /= 10000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 10000000; break; } break; default: return SQL_ERROR; } } sret = SQL_SUCCESS; done: if (ilenp) { *ilenp = *lenp; } return sret; } /** * Interal bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ static SQLRETURN drvbindcol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { STMT *s; int sz = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col < 1) { if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { s->bkmrkcol.type = type; s->bkmrkcol.max = sizeof (SQLINTEGER); s->bkmrkcol.lenp = lenp; s->bkmrkcol.valp = val; s->bkmrkcol.offs = 0; if (lenp) { *lenp = 0; } return SQL_SUCCESS; } setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (mkbindcols(s, col) != SQL_SUCCESS) { return SQL_ERROR; } --col; if (type == SQL_C_DEFAULT) { type = mapdeftype(type, s->cols[col].type, 0, s->nowchar[0] || s->nowchar[1]); } switch (type) { case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: sz = sizeof (SQLINTEGER); break; case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: sz = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: sz = sizeof (SQLSMALLINT); break; case SQL_C_FLOAT: sz = sizeof (SQLFLOAT); break; case SQL_C_DOUBLE: sz = sizeof (SQLDOUBLE); break; case SQL_C_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; case SQL_C_TIME: sz = sizeof (SQL_TIME_STRUCT); break; case SQL_C_DATE: sz = sizeof (SQL_DATE_STRUCT); break; case SQL_C_CHAR: break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: break; #endif #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: sz = sizeof (SQL_DATE_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: sz = sizeof (SQL_TIME_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; #endif #ifdef SQL_BIT case SQL_C_BIT: sz = sizeof (SQLCHAR); break; #endif case SQL_C_BINARY: break; #ifdef SQL_BIGINT case SQL_C_SBIGINT: case SQL_C_UBIGINT: sz = sizeof (SQLBIGINT); break; #endif default: if (val == NULL) { /* fall through, unbinding column */ break; } setstat(s, -1, "invalid type %d", "HY003", type); return SQL_ERROR; } if (val == NULL) { /* unbind column */ s->bindcols[col].type = -1; s->bindcols[col].max = 0; s->bindcols[col].lenp = NULL; s->bindcols[col].valp = NULL; s->bindcols[col].offs = 0; } else { if (sz == 0 && max < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } s->bindcols[col].type = type; s->bindcols[col].max = (sz == 0) ? max : sz; s->bindcols[col].lenp = lenp; s->bindcols[col].valp = val; s->bindcols[col].offs = 0; if (lenp) { *lenp = 0; } } return SQL_SUCCESS; } /** * Bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindcol(stmt, col, type, val, max, lenp); HSTMT_UNLOCK(stmt); return ret; } /** * Columns for result set of SQLTables(). */ static COL tableSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; static COL tableSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, asize, rc, size, npatt; char *errp = NULL, *sql, tname[512]; char *where = "(type = 'table' or type = 'view')"; ret = mkresultset(stmt, tableSpec2, array_size(tableSpec2), tableSpec3, array_size(tableSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] == '%') { int size = 3 * asize; s->rows = xmalloc(size * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } memset(s->rows, 0, sizeof (char *) * size); s->ncols = asize; s->rows[s->ncols + 0] = ""; s->rows[s->ncols + 1] = ""; s->rows[s->ncols + 2] = ""; s->rows[s->ncols + 3] = "TABLE"; s->rows[s->ncols + 5] = ""; s->rows[s->ncols + 6] = ""; s->rows[s->ncols + 7] = ""; s->rows[s->ncols + 8] = "VIEW"; #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = sqlite3_free; #endif s->nrows = 2; s->rowp = -1; return SQL_SUCCESS; } if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] != '\0') { char tmp[256], *t; int with_view = 0, with_table = 0; if (typeLen == SQL_NTS) { strncpy(tmp, (char *) type, sizeof (tmp)); tmp[sizeof (tmp) - 1] = '\0'; } else { int len = min(sizeof (tmp) - 1, typeLen); strncpy(tmp, (char *) type, len); tmp[len] = '\0'; } t = tmp; while (*t) { *t = TOLOWER(*t); t++; } t = tmp; unescpat(t); while (t) { if (t[0] == '\'') { ++t; } if (strncmp(t, "table", 5) == 0) { with_table++; } else if (strncmp(t, "view", 4) == 0) { with_view++; } t = strchr(t, ','); if (t) { ++t; } } if (with_view && with_table) { /* where is already preset */ } else if (with_view && !with_table) { where = "type = 'view'"; } else if (!with_view && with_table) { where = "type = 'table'"; } else { return SQL_SUCCESS; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); #if defined(_WIN32) || defined(_WIN64) sql = sqlite3_mprintf("select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s %Q", d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", where, npatt ? "like" : "=", tname); #else sql = sqlite3_mprintf("select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s %Q", where, npatt ? "like" : "=", tname); #endif if (!sql) { return nomem(s); } ret = starttran(s); if (ret != SQL_SUCCESS) { sqlite3_free(sql); return ret; } dbtraceapi(d, "sqlite3_get_table", sql); rc = sqlite3_get_table(d->sqlite, sql, &s->rows, &s->nrows, &ncols, &errp); sqlite3_free(sql); if (rc == SQLITE_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = sqlite3_free_table; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite3_free(errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL, *y = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvtables(stmt, cat, catLen, schema, schemaLen, table, tableLen, type, typeLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (type) { y = wmb_to_utf_c((char *) type, typeLen); if (!y) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtables(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) y, SQL_NTS); #else ret = drvtables(stmt, cat, catLen, schema, schemaLen, table, tableLen, type, typeLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(y); uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablesW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *type, SQLSMALLINT typeLen) { char *c = NULL, *s = NULL, *t = NULL, *y = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (type) { y = uc_to_utf_c(type, typeLen); if (!y) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtables(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) y, SQL_NTS); done: uc_free(y); uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLColumns(). */ static COL colSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "SCALE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL colSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NUM_PREC_RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; /** * Internal retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvcolumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { SQLRETURN sret; STMT *s; DBC *d; int ret, nrows, ncols, asize, i, k, roffs, namec; int tnrows, tncols, npatt; PTRDIFF_T size; char *errp = NULL, *sql, tname[512], cname[512], **rowp, **trows; sret = mkresultset(stmt, colSpec2, array_size(colSpec2), colSpec3, array_size(colSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); size = 0; if (col) { if (colLen == SQL_NTS) { size = sizeof (cname) - 1; } else { size = min(sizeof (cname) - 1, colLen); } strncpy(cname, (char *) col, size); } cname[size] = '\0'; if (!strcmp(cname, "%")) { cname[0] = '\0'; } sql = sqlite3_mprintf("select tbl_name from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", npatt ? "like" : "=", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite3_free(sql); return sret; } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &trows, &tnrows, &tncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } /* pass 1: compute number of rows of result set */ if (tncols * tnrows <= 0) { sqlite3_free_table(trows); return SQL_SUCCESS; } size = 0; for (i = 1; i <= tnrows; i++) { sql = sqlite3_mprintf("PRAGMA table_info(%Q)", trows[i]); if (!sql) { sqlite3_free_table(trows); return nomem(s); } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } sqlite3_free_table(trows); return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } if (ncols * nrows > 0) { namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { if (namec >= 0) { for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { size++; } } } } else { size += nrows; } } sqlite3_free_table(rowp); } /* pass 2: fill result set */ if (size <= 0) { sqlite3_free_table(trows); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; sqlite3_free_table(trows); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; roffs = 1; for (i = 1; i <= tnrows; i++) { sql = sqlite3_mprintf("PRAGMA table_info(%Q)", trows[i]); if (!sql) { sqlite3_free_table(trows); return nomem(s); } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } sqlite3_free_table(trows); return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } if (ncols * nrows > 0) { int m, mr, nr = nrows; namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { nr = 0; if (namec >= 0) { for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { nr++; } } } } for (k = 0; k < nr; k++) { m = asize * (roffs + k); s->rows[m + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[m + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[m + 1] = xstrdup(""); #endif s->rows[m + 2] = xstrdup(trows[i]); s->rows[m + 8] = xstrdup("10"); s->rows[m + 9] = xstrdup("0"); s->rows[m + 15] = xstrdup("16384"); } for (k = 0; nr && k < ncols; k++) { if (strcmp(rowp[k], "cid") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char buf[256]; int ir, coln = k; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); sscanf(rowp[m * ncols + k], "%d", &coln); sprintf(buf, "%d", coln + 1); s->rows[ir + 16] = xstrdup(buf); ++mr; } } else if (k == namec) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 3] = xstrdup(rowp[m * ncols + k]); ++mr; } } else if (strcmp(rowp[k], "notnull") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); if (*rowp[m * ncols + k] != '0') { s->rows[ir + 10] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[ir + 10] = xstrdup(stringify(SQL_TRUE)); } s->rows[ir + 17] = xstrdup((*rowp[m * ncols + k] != '0') ? "NO" : "YES"); ++mr; } } else if (strcmp(rowp[k], "dflt_value") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *dflt = unquote(rowp[m * ncols + k]); int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 12] = xstrdup(dflt ? dflt : "NULL"); ++mr; } } else if (strcmp(rowp[k], "type") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *typename = rowp[m * ncols + k]; int sqltype, mm, dd, ir; char buf[256]; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 5] = xstrdup(typename); sqltype = mapsqltype(typename, NULL, *s->ov3, s->nowchar[0], s->dobigint); getmd(typename, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } sprintf(buf, "%d", sqltype); s->rows[ir + 4] = xstrdup(buf); s->rows[ir + 13] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[ir + 7] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[ir + 6] = xstrdup(buf); ++mr; } } } roffs += nr; } sqlite3_free_table(rowp); } sqlite3_free_table(trows); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL, *k = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolumns(stmt, cat, catLen, schema, schemaLen, table, tableLen, col, colLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (col) { k = wmb_to_utf_c((char *) col, colLen); if (!k) { ret = nomem((STMT *) stmt); goto done; } } ret = drvcolumns(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) k, SQL_NTS); #else ret = drvcolumns(stmt, cat, catLen, schema, schemaLen, table, tableLen, col, colLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(k); uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column information on table (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *col, SQLSMALLINT colLen) { char *c = NULL, *s = NULL, *t = NULL, *k = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (col) { k = uc_to_utf_c(col, colLen); if (!k) { ret = nomem((STMT *) stmt); goto done; } } ret = drvcolumns(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) k, SQL_NTS); done: uc_free(k); uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLGetTypeInfo(). */ static COL typeSpec2[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "PRECISION", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MONEY", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_INCREMENT", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 } }; static COL typeSpec3[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "COLUMN_SIZE", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "FIXED_PREC_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_UNIQUE_VALUE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATETIME_SUB", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "NUM_PREC_RADIX", SQL_INTEGER, 4 }, { "SYSTEM", "TYPE", "INTERVAL_PRECISION", SQL_SMALLINT, 2 } }; /** * Internal function to build up data type information as row in result set. * @param s statement pointer * @param row row number * @param asize number of items in a row * @param typename name of type * @param type integer SQL type * @param tind type index */ static void mktypeinfo(STMT *s, int row, int asize, char *typename, int type, int tind) { int offs = row * asize; char *tcode, *crpar = NULL, *quote = NULL, *sign = stringify(SQL_FALSE); static char tcodes[32 * 32]; if (tind <= 0) { tind = row; } tcode = tcodes + tind * 32; sprintf(tcode, "%d", type); s->rows[offs + 0] = typename; s->rows[offs + 1] = tcode; if (asize >= 17) { s->rows[offs + 15] = tcode; s->rows[offs + 16] = "0"; } switch (type) { default: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #ifdef WINTERFACE case SQL_WLONGVARCHAR: #endif crpar = "length"; quote = "'"; sign = NULL; s->rows[offs + 2] = "65536"; break; #endif #ifdef SQL_BIT case SQL_BIT: sign = NULL; s->rows[offs + 2] = "1"; break; #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #endif s->rows[offs + 2] = "255"; crpar = "length"; quote = "'"; sign = NULL; break; case SQL_TINYINT: s->rows[offs + 2] = "3"; break; case SQL_SMALLINT: s->rows[offs + 2] = "5"; break; case SQL_INTEGER: s->rows[offs + 2] = "9"; break; #ifdef SQL_BIGINT case SQL_BIGINT: s->rows[offs + 2] = "19"; break; #endif case SQL_FLOAT: s->rows[offs + 2] = "7"; break; case SQL_DOUBLE: s->rows[offs + 2] = "15"; break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: s->rows[offs + 2] = "10"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: s->rows[offs + 2] = "8"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 2] = "32"; quote = "'"; sign = NULL; break; case SQL_VARBINARY: sign = NULL; s->rows[offs + 2] = "255"; break; case SQL_LONGVARBINARY: sign = NULL; s->rows[offs + 2] = "65536"; break; } s->rows[offs + 3] = s->rows[offs + 4] = quote; s->rows[offs + 5] = crpar; s->rows[offs + 6] = stringify(SQL_NULLABLE); s->rows[offs + 7] = stringify(SQL_FALSE); s->rows[offs + 8] = stringify(SQL_SEARCHABLE); s->rows[offs + 9] = sign; s->rows[offs + 10] = stringify(SQL_FALSE); s->rows[offs + 11] = stringify(SQL_FALSE); s->rows[offs + 12] = typename; switch (type) { case SQL_DATE: case SQL_TIME: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "0"; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "3"; break; default: s->rows[offs + 13] = NULL; s->rows[offs + 14] = NULL; break; } } /** * Helper function to sort type information. * Callback for qsort(). * @param a first item to compare * @param b second item to compare * @result ==0, <0, >0 according to data type number */ static int typeinfosort(const void *a, const void *b) { char **pa = (char **) a; char **pb = (char **) b; int na, nb; na = strtol(pa[1], NULL, 0); nb = strtol(pb[1], NULL, 0); return na - nb; } /** * Internal return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ static SQLRETURN drvgettypeinfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; STMT *s; int asize; ret = mkresultset(stmt, typeSpec2, array_size(typeSpec2), typeSpec3, array_size(typeSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; #ifdef SQL_LONGVARCHAR s->nrows = (sqltype == SQL_ALL_TYPES) ? 13 : 1; #else s->nrows = (sqltype == SQL_ALL_TYPES) ? 12 : 1; #endif if (sqltype == SQL_ALL_TYPES) { #ifdef WINTERFACE s->nrows += 2; #ifdef SQL_WLONGVARCHAR s->nrows += 2; #endif #endif } if (sqltype == SQL_ALL_TYPES) { s->nrows += 2; #ifdef SQL_BIT s->nrows += 1; #endif #ifdef SQL_BIGINT s->nrows += 1; #endif } s->rows = (char **) xmalloc(sizeof (char *) * (s->nrows + 1) * asize); if (!s->rows) { s->nrows = 0; return nomem(s); } #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = sqlite3_free; #endif memset(s->rows, 0, sizeof (char *) * (s->nrows + 1) * asize); if (sqltype == SQL_ALL_TYPES) { int cc = 1; mktypeinfo(s, cc++, asize, "varchar", SQL_VARCHAR, 0); mktypeinfo(s, cc++, asize, "tinyint", SQL_TINYINT, 0); mktypeinfo(s, cc++, asize, "smallint", SQL_SMALLINT, 0); mktypeinfo(s, cc++, asize, "integer", SQL_INTEGER, 0); mktypeinfo(s, cc++, asize, "float", SQL_FLOAT, 0); mktypeinfo(s, cc++, asize, "double", SQL_DOUBLE, 0); #ifdef SQL_TYPE_DATE mktypeinfo(s, cc++, asize, "date", (*s->ov3) ? SQL_TYPE_DATE : SQL_DATE, 0); #else mktypeinfo(s, cc++, asize, "date", SQL_DATE, 0); #endif #ifdef SQL_TYPE_TIME mktypeinfo(s, cc++, asize, "time", (*s->ov3) ? SQL_TYPE_TIME : SQL_TIME, 0); #else mktypeinfo(s, cc++, asize, "time", SQL_TIME, 0); #endif #ifdef SQL_TYPE_TIMESTAMP mktypeinfo(s, cc++, asize, "timestamp", (*s->ov3) ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP, 0); #else mktypeinfo(s, cc++, asize, "timestamp", SQL_TIMESTAMP, 0); #endif mktypeinfo(s, cc++, asize, "char", SQL_CHAR, 0); mktypeinfo(s, cc++, asize, "numeric", SQL_DOUBLE, 0); #ifdef SQL_LONGVARCHAR mktypeinfo(s, cc++, asize, "text", SQL_LONGVARCHAR, 0); mktypeinfo(s, cc++, asize, "longvarchar", SQL_LONGVARCHAR, 0); #else mktypeinfo(s, cc++, asize, "text", SQL_VARCHAR, 0); #endif mktypeinfo(s, cc++, asize, "varbinary", SQL_VARBINARY, 0); mktypeinfo(s, cc++, asize, "longvarbinary", SQL_LONGVARBINARY, 0); #ifdef SQL_BIT mktypeinfo(s, cc++, asize, "bit", SQL_BIT, 0); #endif #ifdef SQL_BIGINT mktypeinfo(s, cc++, asize, "bigint", SQL_BIGINT, 0); #endif #ifdef WINTERFACE mktypeinfo(s, cc++, asize, "wvarchar", SQL_WVARCHAR, 0); mktypeinfo(s, cc++, asize, "wchar", SQL_WCHAR, 0); #ifdef SQL_WLONGVARCHAR mktypeinfo(s, cc++, asize, "wtext", SQL_WLONGVARCHAR, 0); mktypeinfo(s, cc++, asize, "longwvarchar", SQL_WLONGVARCHAR, 0); #endif #endif qsort(s->rows + asize, s->nrows, sizeof (char *) * asize, typeinfosort); } else { switch (sqltype) { case SQL_CHAR: mktypeinfo(s, 1, asize, "char", SQL_CHAR, 10); break; case SQL_VARCHAR: mktypeinfo(s, 1, asize, "varchar", SQL_VARCHAR, 1); break; case SQL_TINYINT: mktypeinfo(s, 1, asize, "tinyint", SQL_TINYINT, 2); break; case SQL_SMALLINT: mktypeinfo(s, 1, asize, "smallint", SQL_SMALLINT, 3); break; case SQL_INTEGER: mktypeinfo(s, 1, asize, "integer", SQL_INTEGER, 4); break; case SQL_FLOAT: mktypeinfo(s, 1, asize, "float", SQL_FLOAT, 5); break; case SQL_DOUBLE: mktypeinfo(s, 1, asize, "double", SQL_DOUBLE, 6); break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: mktypeinfo(s, 1, asize, "date", SQL_TYPE_DATE, 25); break; #endif case SQL_DATE: mktypeinfo(s, 1, asize, "date", SQL_DATE, 7); break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: mktypeinfo(s, 1, asize, "time", SQL_TYPE_TIME, 26); break; #endif case SQL_TIME: mktypeinfo(s, 1, asize, "time", SQL_TIME, 8); break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TYPE_TIMESTAMP, 27); break; #endif case SQL_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TIMESTAMP, 9); break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: mktypeinfo(s, 1, asize, "longvarchar", SQL_LONGVARCHAR, 12); break; #endif case SQL_VARBINARY: mktypeinfo(s, 1, asize, "varbinary", SQL_VARBINARY, 30); break; case SQL_LONGVARBINARY: mktypeinfo(s, 1, asize, "longvarbinary", SQL_LONGVARBINARY, 31); break; #ifdef SQL_BIT case SQL_BIT: mktypeinfo(s, 1, asize, "bit", SQL_BIT, 29); break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: mktypeinfo(s, 1, asize, "bigint", SQL_BIGINT, 28); break; #endif #ifdef WINTERFACE #ifdef SQL_WCHAR case SQL_WCHAR: mktypeinfo(s, 1, asize, "wchar", SQL_WCHAR, 18); break; #endif #ifdef SQL_WVARCHAR case SQL_WVARCHAR: mktypeinfo(s, 1, asize, "wvarchar", SQL_WVARCHAR, 19); break; #endif #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: mktypeinfo(s, 1, asize, "longwvarchar", SQL_WLONGVARCHAR, 20); break; #endif #endif default: s->nrows = 0; } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return data type information (UNICODE version). * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfoW(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLStatistics(). */ static COL statSpec2[] = { { "SYSTEM", "STATISTICS", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "SEQ_IN_INDEX", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "COLLATION", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; static COL statSpec3[] = { { "SYSTEM", "STATISTICS", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "ASC_OR_DESC", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; /** * Internal return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ static SQLRETURN drvstatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { SQLRETURN sret; STMT *s; DBC *d; int i, asize, ret, nrows, ncols, offs, namec, uniquec, addipk = 0; PTRDIFF_T size; char **rowp, *errp = NULL, *sql, tname[512]; sret = mkresultset(stmt, statSpec2, array_size(statSpec2), statSpec3, array_size(statSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } /* * Try integer primary key (autoincrement) first */ if (itype == SQL_INDEX_UNIQUE || itype == SQL_INDEX_ALL) { rowp = 0; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA table_info(%Q)", tname); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, NULL); sqlite3_free(sql); } if (ret == SQLITE_OK) { int colid, typec, npk = 0; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); colid = findcol(rowp, ncols, "cid"); if (namec < 0 || uniquec < 0 || typec < 0 || colid < 0) { goto noipk; } for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0' && strlen(rowp[i * ncols + typec]) == 7 && strncasecmp(rowp[i * ncols + typec], "integer", 7) == 0) { npk++; } } if (npk == 1) { addipk = 1; } } noipk: sqlite3_free_table(rowp); } sql = sqlite3_mprintf("PRAGMA index_list(%Q)", tname); if (!sql) { return nomem(s); } dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite3_free(sql); if (ret != SQLITE_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite3_free(errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite3_free(errp); errp = NULL; } size = 0; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata; } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; if (isuniq || itype == SQL_INDEX_ALL) { ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret == SQLITE_OK) { size += nnrows; sqlite3_free_table(rowpp); } } } nodata: if (addipk) { size++; } if (size == 0) { sqlite3_free_table(rowp); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; if (addipk) { char **rowpp = 0; int nrows2, ncols2; sql = sqlite3_mprintf("PRAGMA table_info(%Q)", tname); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nrows2, &ncols2, NULL); sqlite3_free(sql); } if (ret == SQLITE_OK) { int colid, typec, roffs, namecc, uniquecc; namecc = findcol(rowpp, ncols2, "name"); uniquecc = findcol(rowpp, ncols2, "pk"); typec = findcol(rowpp, ncols2, "type"); colid = findcol(rowpp, ncols2, "cid"); if (namecc < 0 || uniquecc < 0 || typec < 0 || colid < 0) { addipk = 0; s->nrows--; goto nodata2; } for (i = 1; i <= nrows2; i++) { if (*rowpp[i * ncols2 + uniquecc] != '0' && strlen(rowpp[i * ncols2 + typec]) == 7 && strncasecmp(rowpp[i * ncols2 + typec], "integer", 7) == 0) { break; } } if (i > nrows2) { addipk = 0; s->nrows--; goto nodata2; } roffs = s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); s->rows[roffs + 5] = xstrdup("sqlite_autoindex_0"); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 7] = xstrdup("1"); s->rows[roffs + 8] = xstrdup(rowpp[i * ncols2 + namecc]); s->rows[roffs + 9] = xstrdup("A"); } nodata2: sqlite3_free_table(rowpp); } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = 0; if (*rowp[i * ncols + uniquec] != '0' || itype == SQL_INDEX_ALL) { int k; ret = SQLITE_ERROR; sql = sqlite3_mprintf("PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite3_get_table", sql); ret = sqlite3_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite3_free(sql); } if (ret != SQLITE_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; s->rows[roffs + 0] = xstrdup(""); s->rows[roffs + 1] = xstrdup(""); s->rows[roffs + 2] = xstrdup(tname); if (isuniq) { s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[roffs + 3] = xstrdup(stringify(SQL_TRUE)); } s->rows[roffs + 5] = xstrdup(rowp[i * ncols + namec]); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 8] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 9] = xstrdup("A"); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 7] = xstrdup(buf); } } } offs += nnrows; sqlite3_free_table(rowpp); } } sqlite3_free_table(rowp); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvstatistics(stmt, cat, catLen, schema, schemaLen, table, tableLen, itype, resv); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvstatistics(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, itype, resv); #else ret = drvstatistics(stmt, cat, catLen, schema, schemaLen, table, tableLen, itype, resv); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return statistic information on table indices (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatisticsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvstatistics(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, itype, resv); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Retrieve row data after fetch. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN len, SQLLEN *lenp) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { *((long *) val) = s->rowp; if (lenp) { *lenp = sizeof (long); } ret = SQL_SUCCESS; goto done; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); goto done; } --col; ret = getrowdata(s, col, type, val, len, lenp, 1); done: HSTMT_UNLOCK(stmt); return ret; } /** * Internal: fetch and bind from statement's current row * @param s statement pointer * @param rsi rowset index * @result ODBC error code */ static SQLRETURN dofetchbind(STMT *s, int rsi) { int ret, i, withinfo = 0; s->row_status0[rsi] = SQL_ROW_SUCCESS; if (s->bkmrk && s->bkmrkcol.valp) { long *val; if (s->bind_type != SQL_BIND_BY_COLUMN) { val = (long *) ((char *) s->bkmrkcol.valp + s->bind_type * rsi); } else { val = (long *) s->bkmrkcol.valp + rsi; } if (s->bind_offs) { val = (long *) ((char *) val + *s->bind_offs); } *val = s->rowp; if (s->bkmrkcol.lenp) { SQLLEN *ival; if (s->bind_type != SQL_BIND_BY_COLUMN) { ival = (SQLLEN *) ((char *) s->bkmrkcol.lenp + s->bind_type * rsi); } else { ival = &s->bkmrkcol.lenp[rsi]; } if (s->bind_offs) { ival = (SQLLEN *) ((char *) ival + *s->bind_offs); } *ival = sizeof (long); } } ret = SQL_SUCCESS; for (i = 0; s->bindcols && i < s->ncols; i++) { BINDCOL *b = &s->bindcols[i]; SQLPOINTER dp = 0; SQLLEN *lp = 0; b->offs = 0; if (b->valp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { dp = (SQLPOINTER) ((char *) b->valp + s->bind_type * rsi); } else { dp = (SQLPOINTER) ((char *) b->valp + b->max * rsi); } if (s->bind_offs) { dp = (SQLPOINTER) ((char *) dp + *s->bind_offs); } } if (b->lenp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { lp = (SQLLEN *) ((char *) b->lenp + s->bind_type * rsi); } else { lp = b->lenp + rsi; } if (s->bind_offs) { lp = (SQLLEN *) ((char *) lp + *s->bind_offs); } } if (dp || lp) { ret = getrowdata(s, (SQLUSMALLINT) i, b->type, dp, b->max, lp, 0); if (!SQL_SUCCEEDED(ret)) { s->row_status0[rsi] = SQL_ROW_ERROR; break; } if (ret != SQL_SUCCESS) { withinfo = 1; #ifdef SQL_ROW_SUCCESS_WITH_INFO s->row_status0[rsi] = SQL_ROW_SUCCESS_WITH_INFO; #endif } } } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } return ret; } /** * Internal fetch function for SQLFetchScroll() and SQLExtendedFetch(). * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ static SQLRETURN drvfetchscroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLINTEGER offset) { STMT *s; int i, withinfo = 0; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_NOROW; } if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = 0; if (s->row_count) { *s->row_count = s->row_count0; } if (!s->bindcols) { for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_ERROR; } ret = SQL_ERROR; i = 0; goto done2; } if (s->isselect != 1 && s->isselect != -1) { setstat(s, -1, "no result set available", "24000"); ret = SQL_ERROR; i = s->nrows; goto done2; } if (s->curtype == SQL_CURSOR_FORWARD_ONLY && orient != SQL_FETCH_NEXT) { setstat(s, -1, "wrong fetch direction", "01000"); ret = SQL_ERROR; i = 0; goto done2; } ret = SQL_SUCCESS; i = 0; if (((DBC *) (s->dbc))->cur_s3stmt == s && s->s3stmt) { s->rowp = 0; for (; i < s->rowset_size; i++) { if (s->max_rows && s->s3stmt_rownum + 1 >= s->max_rows) { ret = (i == 0) ? SQL_NO_DATA : SQL_SUCCESS; break; } ret = s3stmt_step(s); if (ret != SQL_SUCCESS) { s->row_status0[i] = SQL_ROW_ERROR; break; } if (s->nrows < 1) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } else if (s->rows) { switch (orient) { case SQL_FETCH_NEXT: if (s->nrows < 1) { return SQL_NO_DATA; } if (s->rowp < 0) { s->rowp = -1; } if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } break; case SQL_FETCH_PRIOR: if (s->nrows < 1 || s->rowp <= 0) { s->rowp = -1; return SQL_NO_DATA; } s->rowp -= s->rowset_size + 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } break; case SQL_FETCH_FIRST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = -1; break; case SQL_FETCH_LAST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = s->nrows - s->rowset_size; if (--s->rowp < -1) { s->rowp = -1; } break; case SQL_FETCH_ABSOLUTE: if (offset == 0) { s->rowp = -1; return SQL_NO_DATA; } else if (offset < 0) { if (0 - offset <= s->nrows) { s->rowp = s->nrows + offset - 1; break; } s->rowp = -1; return SQL_NO_DATA; } else if (offset > s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } s->rowp = offset - 1 - 1; break; case SQL_FETCH_RELATIVE: if (offset >= 0) { s->rowp += offset * s->rowset_size - 1; if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } } else { s->rowp += offset * s->rowset_size - 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } } break; case SQL_FETCH_BOOKMARK: if (s->bkmrk) { if (offset < 0 || offset >= s->nrows) { return SQL_NO_DATA; } s->rowp = offset - 1; break; } /* fall through */ default: s->row_status0[0] = SQL_ROW_ERROR; ret = SQL_ERROR; goto done; } for (; i < s->rowset_size; i++) { ++s->rowp; if (s->rowp < 0 || s->rowp >= s->nrows) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } done: if (i == 0) { if (SQL_SUCCEEDED(ret)) { return SQL_NO_DATA; } return ret; } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } done2: if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = i; if (s->row_count) { *s->row_count = s->row_count0; } return ret; } /** * Fetch next result row. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, SQL_FETCH_NEXT, 0); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLLEN offset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, orient, offset); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling and row status. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @param rowcount output number of fetched rows * @param rowstatus array for row stati * @result ODBC error code */ SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT orient, SQLROWOFFSET offset, SQLROWSETSIZE *rowcount, SQLUSMALLINT *rowstatus) { STMT *s; SQLRETURN ret; SQLUSMALLINT *rst; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; /* temporarily turn off SQL_ATTR_ROW_STATUS_PTR */ rst = s->row_status; s->row_status = 0; ret = drvfetchscroll(stmt, orient, offset); s->row_status = rst; if (rowstatus) { memcpy(rowstatus, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } if (rowcount) { *rowcount = s->row_count0; } HSTMT_UNLOCK(stmt); return ret; } /** * Return number of affected rows of HSTMT. * @param stmt statement handle * @param nrows output number of rows * @result ODBC error code */ SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN *nrows) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (nrows) { *nrows = s->isselect ? 0 : s->nrows; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Return number of columns of result set given HSTMT. * @param stmt statement handle * @param ncols output number of columns * @result ODBC error code */ SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *ncols) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (ncols) { *ncols = s->ncols; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Internal describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ static SQLRETURN drvdescribecol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { STMT *s; COL *c; int didname = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { setstat(s, -1, "no columns", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } c = s->cols + col - 1; if (name && nameMax > 0) { strncpy((char *) name, c->column, nameMax); name[nameMax - 1] = '\0'; didname = 1; } if (nameLen) { if (didname) { *nameLen = strlen((char *) name); } else { *nameLen = strlen(c->column); } } if (type) { *type = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (c->type) { case SQL_WCHAR: *type = SQL_CHAR; break; case SQL_WVARCHAR: *type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: *type = SQL_LONGVARCHAR; break; #endif } } #endif } if (size) { *size = c->size; } if (digits) { *digits = 0; } if (nullable) { *nullable = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvdescribecol(stmt, col, name, nameMax, nameLen, type, size, digits, nullable); goto done; } ret = drvdescribecol(stmt, col, name, nameMax, &len, type, size, digits, nullable); if (ret == SQL_SUCCESS) { if (name) { if (len > 0) { SQLCHAR *n = NULL; n = (SQLCHAR *) utf_to_wmb((char *) name, len); if (n) { strncpy((char *) name, (char *) n, nameMax); n[len] = 0; len = min(nameMax, strlen((char *) n)); uc_free(n); } else { len = 0; } } if (len <= 0) { len = 0; if (nameMax > 0) { name[0] = 0; } } } else { STMT *s = (STMT *) stmt; COL *c = s->cols + col - 1; len = 0; if (c->column) { len = strlen(c->column); } } if (nameLen) { *nameLen = len; } } done: ; #else ret = drvdescribecol(stmt, col, name, nameMax, nameLen, type, size, digits, nullable); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Describe column information (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeColW(SQLHSTMT stmt, SQLUSMALLINT col, SQLWCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvdescribecol(stmt, col, (SQLCHAR *) name, (SQLSMALLINT) (nameMax * sizeof (SQLWCHAR)), &len, type, size, digits, nullable); if (ret == SQL_SUCCESS) { if (name) { if (len > 0) { SQLWCHAR *n = NULL; n = uc_from_utf((SQLCHAR *) name, len); if (n) { uc_strncpy(name, n, nameMax); n[len] = 0; len = min(nameMax, uc_strlen(n)); uc_free(n); } else { len = 0; } } if (len <= 0) { len = 0; if (nameMax > 0) { name[0] = 0; } } } else { STMT *s = (STMT *) stmt; COL *c = s->cols + col - 1; len = 0; if (c->column) { len = strlen(c->column); } } if (nameLen) { *nameLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { STMT *s; COL *c; SQLSMALLINT dummy; char *valc = (char *) val; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (!valLen) { valLen = &dummy; } if (id == SQL_COLUMN_COUNT) { if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; } if (id == SQL_COLUMN_TYPE && col == 0) { if (val2) { *val2 = SQL_INTEGER; } *valLen = sizeof (int); return SQL_SUCCESS; } #ifdef SQL_DESC_OCTET_LENGTH if (id == SQL_DESC_OCTET_LENGTH && col == 0) { if (val2) { *val2 = 4; } *valLen = sizeof (int); return SQL_SUCCESS; } #endif if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009": "S1002"); return SQL_ERROR; } c = s->cols + col - 1; switch (id) { case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; #ifdef SQL_DESC_BASE_COLUMN_NAME if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_COLUMN_TYPE: case SQL_DESC_TYPE: #ifdef WINTERFACE { int type = c->type; if (s->nowchar[0] || s->nowchar[1]) { switch (type) { case SQL_WCHAR: type = SQL_CHAR; break; case SQL_WVARCHAR: type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: type = SQL_LONGVARCHAR; break; } } if (val2) { *val2 = type; } #endif } #else if (val2) { *val2 = c->type; } #endif *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_DISPLAY_SIZE: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UNSIGNED: if (val2) { *val2 = c->nosign ? SQL_TRUE : SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: if (val2) { *val2 = c->scale; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: if (val2) { switch (c->type) { case SQL_SMALLINT: *val2 = 5; break; case SQL_INTEGER: *val2 = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: *val2 = 15; break; case SQL_DATE: *val2 = 0; break; case SQL_TIME: *val2 = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: *val2 = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: *val2 = c->prec; break; } } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_MONEY: if (val2) { *val2 = SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_AUTO_INCREMENT: if (val2) { *val2 = c->autoinc; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_NULLABLE: case SQL_DESC_NULLABLE: if (val2) { *val2 = c->notnull; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SEARCHABLE: if (val2) { *val2 = SQL_SEARCHABLE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_CASE_SENSITIVE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UPDATABLE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_DESC_COUNT: if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: if (val2) { switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: *val2 = 0; break; default: *val2 = 2; } } *valLen = sizeof (int); return SQL_SUCCESS; #endif } setstat(s, -1, "unsupported column attributes %d", "HY091", id); return SQL_ERROR; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolattributes(stmt, col, id, val, valMax, valLen, val2); goto done; } ret = drvcolattributes(stmt, col, id, val, valMax, &len, val2); if (SQL_SUCCEEDED(ret)) { char *v = NULL; switch (id) { case SQL_COLUMN_LABEL: case SQL_COLUMN_NAME: case SQL_DESC_NAME: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (val && valMax > 0) { int vmax = valMax; v = utf_to_wmb((char *) val, SQL_NTS); if (v) { strncpy(val, v, vmax); len = min(vmax, strlen(v)); uc_free(v); } if (vmax > 0) { v = (char *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } done: ; #else ret = drvcolattributes(stmt, col, id, val, valMax, valLen, val2); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributesW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattributes(stmt, col, id, val, valMax, &len, val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_COLUMN_LABEL: case SQL_COLUMN_NAME: case SQL_DESC_NAME: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLPOINTER val2) { STMT *s; COL *c; int v = 0; char *valc = (char *) val; SQLSMALLINT dummy; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!valLen) { valLen = &dummy; } c = s->cols + col - 1; switch (id) { case SQL_DESC_COUNT: v = s->ncols; break; case SQL_DESC_CATALOG_NAME: if (valc && valMax > 0) { strncpy(valc, c->db, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->db); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } break; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: v = c->size; break; case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); goto checkLen; case SQL_DESC_SCHEMA_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_DESC_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_DESC_OCTET_LENGTH: v = c->size; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { v *= sizeof (SQLWCHAR); } } #endif break; #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_COLUMN_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif case SQL_DESC_TABLE_NAME: if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; case SQL_DESC_TYPE: v = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (v) { case SQL_WCHAR: v = SQL_CHAR; break; case SQL_WVARCHAR: v = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: v = SQL_LONGVARCHAR; break; #endif } } #endif break; case SQL_DESC_CONCISE_TYPE: switch (c->type) { case SQL_INTEGER: v = SQL_C_LONG; break; case SQL_TINYINT: v = SQL_C_TINYINT; break; case SQL_SMALLINT: v = SQL_C_SHORT; break; case SQL_FLOAT: v = SQL_C_FLOAT; break; case SQL_DOUBLE: v = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: v = SQL_C_TIMESTAMP; break; case SQL_TIME: v = SQL_C_TIME; break; case SQL_DATE: v = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: v = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: v = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: v = SQL_C_TYPE_DATE; break; #endif #ifdef SQL_BIT case SQL_BIT: v = SQL_C_BIT; break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: v = SQL_C_SBIGINT; break; #endif default: #ifdef WINTERFACE v = (s->nowchar[0] || s->nowchar[1]) ? SQL_C_CHAR : SQL_C_WCHAR; #else v = SQL_C_CHAR; #endif break; } break; case SQL_DESC_UPDATABLE: v = SQL_TRUE; break; case SQL_COLUMN_DISPLAY_SIZE: v = c->size; break; case SQL_COLUMN_UNSIGNED: v = c->nosign ? SQL_TRUE : SQL_FALSE; break; case SQL_COLUMN_SEARCHABLE: v = SQL_SEARCHABLE; break; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: v = c->scale; break; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: switch (c->type) { case SQL_SMALLINT: v = 5; break; case SQL_INTEGER: v = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: v = 15; break; case SQL_DATE: v = 0; break; case SQL_TIME: v = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: v = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: v = c->prec; break; } break; case SQL_COLUMN_MONEY: v = SQL_FALSE; break; case SQL_COLUMN_AUTO_INCREMENT: v = c->autoinc; break; case SQL_DESC_NULLABLE: v = c->notnull; break; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: v = 0; break; default: v = 2; } break; #endif default: setstat(s, -1, "unsupported column attribute %d", "HY091", id); return SQL_ERROR; } if (val2) { *(SQLLEN *) val2 = v; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolattribute(stmt, col, id, val, valMax, valLen, (SQLPOINTER) val2); goto done; } ret = drvcolattribute(stmt, col, id, val, valMax, &len, (SQLPOINTER) val2); if (SQL_SUCCEEDED(ret)) { char *v = NULL; switch (id) { case SQL_DESC_SCHEMA_NAME: case SQL_DESC_CATALOG_NAME: case SQL_COLUMN_LABEL: case SQL_DESC_NAME: case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif case SQL_DESC_TYPE_NAME: if (val && valMax > 0) { int vmax = valMax; v = utf_to_wmb((char *) val, SQL_NTS); if (v) { strncpy(val, v, vmax); len = min(vmax, strlen(v)); uc_free(v); } if (vmax > 0) { v = (char *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } done: ; #else ret = drvcolattribute(stmt, col, id, val, valMax, valLen, (SQLPOINTER) val2); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattribute(stmt, col, id, val, valMax, &len, (SQLPOINTER) val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_DESC_SCHEMA_NAME: case SQL_DESC_CATALOG_NAME: case SQL_COLUMN_LABEL: case SQL_DESC_NAME: case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif case SQL_DESC_TYPE_NAME: if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ static SQLRETURN drverror(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { SQLCHAR dummy0[6]; SQLINTEGER dummy1; SQLSMALLINT dummy2; if (env == SQL_NULL_HENV && dbc == SQL_NULL_HDBC && stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } if (sqlState) { sqlState[0] = '\0'; } else { sqlState = dummy0; } if (!nativeErr) { nativeErr = &dummy1; } *nativeErr = 0; if (!errlen) { errlen = &dummy2; } *errlen = 0; if (errmsg) { if (errmax > 0) { errmsg[0] = '\0'; } } else { errmsg = dummy0; errmax = 0; } if (stmt) { STMT *s = (STMT *) stmt; HSTMT_LOCK(stmt); if (s->logmsg[0] == '\0') { HSTMT_UNLOCK(stmt); goto noerr; } *nativeErr = s->naterr; strcpy((char *) sqlState, s->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) s->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) s->logmsg, errmax - 8); } *errlen = min(strlen((char *) s->logmsg) + 8, errmax); } s->logmsg[0] = '\0'; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } if (dbc) { DBC *d = (DBC *) dbc; HDBC_LOCK(dbc); if (d->magic != DBC_MAGIC || d->logmsg[0] == '\0') { HDBC_UNLOCK(dbc); goto noerr; } *nativeErr = d->naterr; strcpy((char *) sqlState, d->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) d->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) d->logmsg, errmax - 8); } *errlen = min(strlen((char *) d->logmsg) + 8, errmax); } d->logmsg[0] = '\0'; HDBC_UNLOCK(dbc); return SQL_SUCCESS; } noerr: sqlState[0] = '\0'; errmsg[0] = '\0'; *nativeErr = 0; *errlen = 0; return SQL_NO_DATA; } #ifndef WINTERFACE /** * Return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLError(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { return drverror(env, dbc, stmt, sqlState, nativeErr, errmsg, errmax, errlen); } #endif #ifdef WINTERFACE /** * Return last HDBC or HSTMT error message (UNICODE version). * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLErrorW(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLWCHAR *sqlState, SQLINTEGER *nativeErr, SQLWCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { char state[16]; SQLSMALLINT len = 0; SQLRETURN ret; ret = drverror(env, dbc, stmt, (SQLCHAR *) state, nativeErr, (SQLCHAR *) errmsg, errmax, &len); if (ret == SQL_SUCCESS) { if (sqlState) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlState, 6 * sizeof (SQLWCHAR)); } if (errmsg) { if (len > 0) { SQLWCHAR *e = NULL; e = uc_from_utf((SQLCHAR *) errmsg, len); if (e) { if (errmax > 0) { uc_strncpy(errmsg, e, errmax); e[len] = 0; len = min(errmax, uc_strlen(e)); } else { len = uc_strlen(e); } uc_free(e); } else { len = 0; } } if (len <= 0) { len = 0; if (errmax > 0) { errmsg[0] = 0; } } } else { len = 0; } if (errlen) { *errlen = len; } } else if (ret == SQL_NO_DATA) { if (sqlState) { sqlState[0] = 0; } if (errmsg) { if (errmax > 0) { errmsg[0] = 0; } } if (errlen) { *errlen = 0; } } return ret; } #endif /** * Return information for more result sets. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt) { HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_UNLOCK(stmt); return SQL_NO_DATA; } /** * Internal function to setup column name/type information * @param s statement poiner * @param s3stmt SQLite3 statement pointer * @param ncolsp pointer to preinitialized number of colums * @result ODBC error code */ static SQLRETURN setupdyncols(STMT *s, sqlite3_stmt *s3stmt, int *ncolsp) { int ncols = *ncolsp, guessed_types = 0; SQLRETURN ret = SQL_SUCCESS; if (ncols > 0) { int i; PTRDIFF_T size; char *p; COL *dyncols; DBC *d = (DBC *) s->dbc; const char *colname, *typename; #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) char *tblname; #endif for (i = size = 0; i < ncols; i++) { colname = sqlite3_column_name(s3stmt, i); size += 3 + 3 * strlen(colname); } #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) tblname = (char *) size; for (i = 0; i < ncols; i++) { p = (char *) sqlite3_column_table_name(s3stmt, i); size += 2 + (p ? strlen(p) : 0); } #endif dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); *ncolsp = 0; ret = SQL_ERROR; } else { p = (char *) (dyncols + ncols); #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) tblname = p + (PTRDIFF_T) tblname; #endif for (i = 0; i < ncols; i++) { char *q; colname = sqlite3_column_name(s3stmt, i); if (d->trace) { fprintf(d->trace, "-- column %d name: '%s'\n", i + 1, colname); fflush(d->trace); } #if defined(HAVE_SQLITE3COLUMNTABLENAME) && (HAVE_SQLITE3COLUMNTABLENAME) q = (char *) sqlite3_column_table_name(s3stmt, i); strcpy(tblname, q ? q : ""); if (d->trace) { fprintf(d->trace, "-- table %d name: '%s'\n", i + 1, tblname); fflush(d->trace); } dyncols[i].table = tblname; tblname += strlen(tblname) + 1; #endif typename = s3stmt_coltype(s3stmt, i, d, &guessed_types); dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, colname); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(colname, '.'); if (q) { char *q2 = strchr(q + 1, '.'); /* SQLite 3.3.4 produces view.table.column sometimes */ if (q2) { q = q2; } } if (q) { #if !defined(HAVE_SQLITE3COLUMNTABLENAME) || !(HAVE_SQLITE3COLUMNTABLENAME) dyncols[i].table = p; #endif strncpy(p, colname, q - colname); p[q - colname] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { #if !defined(HAVE_SQLITE3COLUMNTABLENAME) || !(HAVE_SQLITE3COLUMNTABLENAME) dyncols[i].table = ""; #endif strcpy(p, colname); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; #if defined(HAVE_SQLITE3TABLECOLUMNMETADATA) && (HAVE_SQLITE3TABLECOLUMNMETADATA) s3stmt_addmeta(s3stmt, i, d, &dyncols[i]); #else dyncols[i].autoinc = SQL_FALSE; dyncols[i].notnull = SQL_NULLABLE; #endif dyncols[i].typename = xstrdup(typename); } freedyncols(s); s->dyncols = s->cols = dyncols; s->dcols = ncols; fixupdyncols(s, d); s->guessed_types = guessed_types; } } return ret; } /** * Internal query preparation used by SQLPrepare() and SQLExecDirect(). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { STMT *s; DBC *d; char *errp = NULL; SQLRETURN sret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = s->dbc; if (!d->sqlite) { goto noconn; } s3stmt_end(s); s3stmt_drop(s); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } freep(&s->query); s->query = (SQLCHAR *) fixupsql((char *) query, queryLen, &s->nparams, &s->isselect, &errp); if (!s->query) { if (errp) { setstat(s, -1, "%s", (*s->ov3) ? "HY000" : "S1000", errp); return SQL_ERROR; } return nomem(s); } errp = NULL; freeresult(s, -1); if (s->isselect == 1) { int ret, ncols, nretry = 0; const char *rest; sqlite3_stmt *s3stmt = NULL; #if defined(HAVE_SQLITE3PREPAREV2) && (HAVE_SQLITE3PREPAREV2) dbtraceapi(d, "sqlite3_prepare_v2", (char *) s->query); #else dbtraceapi(d, "sqlite3_prepare", (char *) s->query); #endif do { s3stmt = NULL; #if defined(HAVE_SQLITE3PREPAREV2) && (HAVE_SQLITE3PREPAREV2) ret = sqlite3_prepare_v2(d->sqlite, (char *) s->query, -1, &s3stmt, &rest); #else ret = sqlite3_prepare(d->sqlite, (char *) s->query, -1, &s3stmt, &rest); #endif if (ret != SQLITE_OK) { if (s3stmt) { sqlite3_finalize(s3stmt); s3stmt = NULL; } } } while (ret == SQLITE_SCHEMA && (++nretry) < 2); dbtracerc(d, ret, NULL); if (ret != SQLITE_OK) { if (s3stmt) { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s3stmt); } setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", sqlite3_errmsg(d->sqlite), ret); return SQL_ERROR; } if (sqlite3_bind_parameter_count(s3stmt) != s->nparams) { dbtraceapi(d, "sqlite3_finalize", 0); sqlite3_finalize(s3stmt); setstat(s, SQLITE_ERROR, "parameter marker count incorrect", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } ncols = sqlite3_column_count(s3stmt); s->guessed_types = 0; setupdyncols(s, s3stmt, &ncols); s->ncols = ncols; s->s3stmt = s3stmt; } mkbindcols(s, s->ncols); s->paramset_count = 0; return SQL_SUCCESS; } /** * Internal query execution used by SQLExecute() and SQLExecDirect(). * @param stmt statement handle * @param initial false when called from SQLPutData() * @result ODBC error code */ static SQLRETURN drvexecute(SQLHSTMT stmt, int initial) { STMT *s; DBC *d; char *errp = NULL; int rc, i, ncols = 0, nrows = 0, busy_count; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } if (!s->query) { setstat(s, -1, "no query prepared", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (s->nbindparms < s->nparams) { unbound: setstat(s, -1, "unbound parameters in query", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (!p->bound) { goto unbound; } if (initial) { SQLLEN *lenp = p->lenp; if (lenp && *lenp < 0 && *lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *lenp != SQL_NTS && *lenp != SQL_NULL_DATA && *lenp != SQL_DATA_AT_EXEC) { setstat(s, -1, "invalid length reference", "HY009"); return SQL_ERROR; } if (lenp && (*lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } ret = starttran(s); if (ret != SQL_SUCCESS) { goto cleanup; } busy_count = 0; again: s3stmt_end(s); if (initial) { /* fixup data-at-execution parameters and alloc'ed blobs */ s->pdcount = -1; for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->need <= 0 && p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } if (s->nparams) { for (i = 0; i < s->nparams; i++) { ret = setupparam(s, (char *) s->query, i); if (ret != SQL_SUCCESS) { goto cleanup; } } } freeresult(s, 0); if (s->isselect == 1 && !d->intrans && s->curtype == SQL_CURSOR_FORWARD_ONLY && d->step_enable && s->nparams == 0 && d->cur_s3stmt == NULL) { s->nrows = -1; ret = s3stmt_start(s); if (ret == SQL_SUCCESS) { goto done2; } } rc = drvgettable(s, s->s3stmt ? NULL : (char *) s->query, &s->rows, &s->nrows, &ncols, &errp, s->nparams, s->bindparms); dbtracerc(d, rc, errp); if (rc == SQLITE_BUSY) { if (busy_handler((void *) d, ++busy_count)) { if (errp) { sqlite3_free(errp); errp = NULL; } for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { p->param = p->param0; } p->lenp = p->lenp0; } s->nrows = 0; goto again; } } if (rc != SQLITE_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); if (errp) { sqlite3_free(errp); errp = NULL; } ret = SQL_ERROR; goto cleanup; } if (errp) { sqlite3_free(errp); errp = NULL; } s->rowfree = freerows; if (s->isselect <= 0 || s->isselect > 1) { /* * INSERT/UPDATE/DELETE or DDL results are immediately released. */ freeresult(s, -1); nrows += sqlite3_changes(d->sqlite); s->nrows = nrows; goto done; } if (s->ncols != ncols) { /* * Weird result. */ setstat(s, -1, "broken result set %d/%d", (*s->ov3) ? "HY000" : "S1000", s->ncols, ncols); ret = SQL_ERROR; goto cleanup; } done: mkbindcols(s, s->ncols); done2: ret = SQL_SUCCESS; s->rowp = -1; s->paramset_count++; s->paramset_nrows = s->nrows; if (s->paramset_count < s->paramset_size) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->lenp0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->lenp = (SQLLEN *) ((char *) p->lenp0 + s->paramset_count * s->parm_bind_type); } else if (p->lenp0 && p->inc > 0) { p->lenp = p->lenp0 + s->paramset_count; } if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { if (p->param0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->param = (char *) p->param0 + s->paramset_count * s->parm_bind_type; } else if (p->param0 && p->inc > 0) { p->param = (char *) p->param0 + s->paramset_count * p->inc; } } else if (p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } goto again; } cleanup: if (ret != SQL_NEED_DATA) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { p->param = p->param0; } p->lenp = p->lenp0; } s->nrows = s->paramset_nrows; if (s->parm_proc) { *s->parm_proc = s->paramset_count; } s->paramset_count = 0; s->paramset_nrows = 0; } /* * For INSERT/UPDATE/DELETE statements change the return code * to SQL_NO_DATA if the number of rows affected was 0. */ if (*s->ov3 && s->isselect == 0 && ret == SQL_SUCCESS && nrows == 0) { ret = SQL_NO_DATA; } return ret; } #ifndef WINTERFACE /** * Prepare HSTMT. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) char *q; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprepare(stmt, query, queryLen); goto done; } q = wmb_to_utf_c((char *) query, queryLen); if (!q) { ret = nomem((STMT *) stmt); goto done; } query = (SQLCHAR *) q; queryLen = SQL_NTS; #endif ret = drvprepare(stmt, query, queryLen); #if defined(_WIN32) || defined(_WIN64) uc_free(q); done: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Prepare HSTMT (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepareW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Execute query. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvexecute(stmt, 1); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Execute query directly. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) char *q; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprepare(stmt, query, queryLen); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } goto done; } q = wmb_to_utf_c((char *) query, queryLen); if (!q) { ret = nomem((STMT *) stmt); goto done; } query = (SQLCHAR *) q; queryLen = SQL_NTS; #endif ret = drvprepare(stmt, query, queryLen); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } #if defined(_WIN32) || defined(_WIN64) uc_free(q); done: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Execute query directly (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } done: HSTMT_UNLOCK(stmt); return ret; } #endif #if defined(_WIN32) || defined(_WIN64) #ifndef WITHOUT_DRIVERMGR /* * Windows configuration dialog stuff. */ #include #include #define MAXPATHLEN (259+1) /* Max path length */ #define MAXKEYLEN (15+1) /* Max keyword length */ #define MAXDESC (255+1) /* Max description length */ #define MAXDSNAME (32+1) /* Max data source name length */ #define MAXTONAME (32+1) /* Max timeout length */ #define MAXDBNAME MAXPATHLEN /* Attribute key indexes into an array of Attr structs, see below */ #define KEY_DSN 0 #define KEY_DESC 1 #define KEY_DBNAME 2 #define KEY_BUSY 3 #define KEY_DRIVER 4 #define KEY_STEPAPI 5 #define KEY_SYNCP 6 #define KEY_NOTXN 7 #define KEY_SHORTNAM 8 #define KEY_LONGNAM 9 #define KEY_NOCREAT 10 #define KEY_NOWCHAR 11 #define KEY_LOADEXT 12 #define KEY_JMODE 13 #define KEY_FKSUPPORT 14 #define KEY_OEMCP 15 #define KEY_BIGINT 16 #define KEY_PASSWD 17 #define NUMOFKEYS 18 typedef struct { BOOL supplied; char attr[MAXPATHLEN*4]; } ATTR; typedef struct { SQLHWND parent; LPCSTR driver; ATTR attr[NUMOFKEYS]; char DSN[MAXDSNAME]; BOOL newDSN; BOOL defDSN; } SETUPDLG; static struct { char *key; int ikey; } attrLookup[] = { { "DSN", KEY_DSN }, { "DESC", KEY_DESC }, { "Description", KEY_DESC}, { "Database", KEY_DBNAME }, { "Timeout", KEY_BUSY }, { "Driver", KEY_DRIVER }, { "StepAPI", KEY_STEPAPI }, { "SyncPragma", KEY_SYNCP }, { "NoTXN", KEY_NOTXN }, { "ShortNames", KEY_SHORTNAM }, { "LongNames", KEY_LONGNAM }, { "NoCreat", KEY_NOCREAT }, { "NoWCHAR", KEY_NOWCHAR }, { "LoadExt", KEY_LOADEXT }, { "JournalMode", KEY_JMODE }, { "FKSupport", KEY_FKSUPPORT }, { "OEMCP", KEY_OEMCP }, { "BigInt", KEY_BIGINT }, { "PWD", KEY_PASSWD }, { NULL, 0 } }; /** * Setup dialog data from datasource attributes. * @param attribs attribute string * @param setupdlg pointer to dialog data */ static void ParseAttributes(LPCSTR attribs, SETUPDLG *setupdlg) { char *str = (char *) attribs, *start, key[MAXKEYLEN]; int elem, nkey; while (*str) { start = str; if ((str = strchr(str, '=')) == NULL) { return; } elem = -1; nkey = str - start; if (nkey < sizeof (key)) { int i; memcpy(key, start, nkey); key[nkey] = '\0'; for (i = 0; attrLookup[i].key; i++) { if (strcasecmp(attrLookup[i].key, key) == 0) { elem = attrLookup[i].ikey; break; } } } start = ++str; while (*str && *str != ';') { ++str; } if (elem >= 0) { int end = min(str - start, sizeof (setupdlg->attr[elem].attr) - 1); setupdlg->attr[elem].supplied = TRUE; memcpy(setupdlg->attr[elem].attr, start, end); setupdlg->attr[elem].attr[end] = '\0'; } ++str; } } /** * Set datasource attributes in registry. * @param parent handle of parent window * @param setupdlg pointer to dialog data * @result true or false */ static BOOL SetDSNAttributes(HWND parent, SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (setupdlg->newDSN && strlen(dsn) == 0) { return FALSE; } if (!SQLWriteDSNToIni(dsn, setupdlg->driver)) { if (parent) { char buf[MAXPATHLEN], msg[MAXPATHLEN]; LoadString(hModule, IDS_BADDSN, buf, sizeof (buf)); wsprintf(msg, buf, dsn); LoadString(hModule, IDS_MSGTITLE, buf, sizeof (buf)); MessageBox(parent, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } return FALSE; } if (parent || setupdlg->attr[KEY_DESC].supplied) { SQLWritePrivateProfileString(dsn, "Description", setupdlg->attr[KEY_DESC].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_DBNAME].supplied) { SQLWritePrivateProfileString(dsn, "Database", setupdlg->attr[KEY_DBNAME].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_BUSY].supplied) { SQLWritePrivateProfileString(dsn, "Timeout", setupdlg->attr[KEY_BUSY].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_STEPAPI].supplied) { SQLWritePrivateProfileString(dsn, "StepAPI", setupdlg->attr[KEY_STEPAPI].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_SYNCP].supplied) { SQLWritePrivateProfileString(dsn, "SyncPragma", setupdlg->attr[KEY_SYNCP].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOTXN].supplied) { SQLWritePrivateProfileString(dsn, "NoTXN", setupdlg->attr[KEY_NOTXN].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_SHORTNAM].supplied) { SQLWritePrivateProfileString(dsn, "ShortNames", setupdlg->attr[KEY_SHORTNAM].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_LONGNAM].supplied) { SQLWritePrivateProfileString(dsn, "LongNames", setupdlg->attr[KEY_LONGNAM].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOCREAT].supplied) { SQLWritePrivateProfileString(dsn, "NoCreat", setupdlg->attr[KEY_NOCREAT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOWCHAR].supplied) { SQLWritePrivateProfileString(dsn, "NoWCHAR", setupdlg->attr[KEY_NOWCHAR].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_FKSUPPORT].supplied) { SQLWritePrivateProfileString(dsn, "FKSupport", setupdlg->attr[KEY_FKSUPPORT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_OEMCP].supplied) { SQLWritePrivateProfileString(dsn, "OEMCP", setupdlg->attr[KEY_OEMCP].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_LOADEXT].supplied) { SQLWritePrivateProfileString(dsn, "LoadExt", setupdlg->attr[KEY_LOADEXT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_BIGINT].supplied) { SQLWritePrivateProfileString(dsn, "BigInt", setupdlg->attr[KEY_BIGINT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_PASSWD].supplied) { SQLWritePrivateProfileString(dsn, "PWD", setupdlg->attr[KEY_PASSWD].attr, ODBC_INI); } if (setupdlg->attr[KEY_DSN].supplied && strcasecmp(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr)) { SQLRemoveDSNFromIni(setupdlg->DSN); } return TRUE; } /** * Get datasource attributes from registry. * @param setupdlg pointer to dialog data */ static void GetAttributes(SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (!setupdlg->attr[KEY_DESC].supplied) { SQLGetPrivateProfileString(dsn, "Description", "", setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr), ODBC_INI); } if (!setupdlg->attr[KEY_DBNAME].supplied) { SQLGetPrivateProfileString(dsn, "Database", "", setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr), ODBC_INI); } if (!setupdlg->attr[KEY_BUSY].supplied) { SQLGetPrivateProfileString(dsn, "Timeout", "100000", setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr), ODBC_INI); } if (!setupdlg->attr[KEY_STEPAPI].supplied) { SQLGetPrivateProfileString(dsn, "StepAPI", "0", setupdlg->attr[KEY_STEPAPI].attr, sizeof (setupdlg->attr[KEY_STEPAPI].attr), ODBC_INI); } if (!setupdlg->attr[KEY_SYNCP].supplied) { SQLGetPrivateProfileString(dsn, "SyncPragma", "NORMAL", setupdlg->attr[KEY_SYNCP].attr, sizeof (setupdlg->attr[KEY_SYNCP].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOTXN].supplied) { SQLGetPrivateProfileString(dsn, "NoTXN", "", setupdlg->attr[KEY_NOTXN].attr, sizeof (setupdlg->attr[KEY_NOTXN].attr), ODBC_INI); } if (!setupdlg->attr[KEY_SHORTNAM].supplied) { SQLGetPrivateProfileString(dsn, "ShortNames", "", setupdlg->attr[KEY_SHORTNAM].attr, sizeof (setupdlg->attr[KEY_SHORTNAM].attr), ODBC_INI); } if (!setupdlg->attr[KEY_LONGNAM].supplied) { SQLGetPrivateProfileString(dsn, "LongNames", "", setupdlg->attr[KEY_LONGNAM].attr, sizeof (setupdlg->attr[KEY_LONGNAM].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOCREAT].supplied) { SQLGetPrivateProfileString(dsn, "NoCreat", "", setupdlg->attr[KEY_NOCREAT].attr, sizeof (setupdlg->attr[KEY_NOCREAT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOWCHAR].supplied) { SQLGetPrivateProfileString(dsn, "NoWCHAR", "", setupdlg->attr[KEY_NOWCHAR].attr, sizeof (setupdlg->attr[KEY_NOWCHAR].attr), ODBC_INI); } if (!setupdlg->attr[KEY_FKSUPPORT].supplied) { SQLGetPrivateProfileString(dsn, "FKSupport", "", setupdlg->attr[KEY_FKSUPPORT].attr, sizeof (setupdlg->attr[KEY_FKSUPPORT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_OEMCP].supplied) { SQLGetPrivateProfileString(dsn, "OEMCP", "", setupdlg->attr[KEY_OEMCP].attr, sizeof (setupdlg->attr[KEY_OEMCP].attr), ODBC_INI); } if (!setupdlg->attr[KEY_LOADEXT].supplied) { SQLGetPrivateProfileString(dsn, "LoadExt", "", setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_JMODE].supplied) { SQLGetPrivateProfileString(dsn, "JournalMode", "", setupdlg->attr[KEY_JMODE].attr, sizeof (setupdlg->attr[KEY_JMODE].attr), ODBC_INI); } if (!setupdlg->attr[KEY_BIGINT].supplied) { SQLGetPrivateProfileString(dsn, "BigInt", "", setupdlg->attr[KEY_BIGINT].attr, sizeof (setupdlg->attr[KEY_BIGINT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_PASSWD].supplied) { SQLGetPrivateProfileString(dsn, "PWD", "", setupdlg->attr[KEY_PASSWD].attr, sizeof (setupdlg->attr[KEY_PASSWD].attr), ODBC_INI); } } /** * Open file dialog for selection of SQLite database file. * @param hdlg handle of originating dialog window */ static void GetDBFile(HWND hdlg) { #ifdef _WIN64 SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); ofn.lStructSize = sizeof (ofn); ofn.hwndOwner = hdlg; #ifdef _WIN64 ofn.hInstance = (HINSTANCE) GetWindowLongPtr(hdlg, GWLP_HINSTANCE); #else ofn.hInstance = (HINSTANCE) GetWindowLong(hdlg, GWL_HINSTANCE); #endif ofn.lpstrFile = (LPTSTR) setupdlg->attr[KEY_DBNAME].attr; ofn.nMaxFile = MAXPATHLEN; ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_FILEMUSTEXIST; if (GetOpenFileName(&ofn)) { SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); setupdlg->attr[KEY_DBNAME].supplied = TRUE; } } /** * Dialog procedure for ConfigDSN(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK ConfigDlgProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg = NULL; WORD index; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLongPtr(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; GetAttributes(setupdlg); SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_LOADEXT, EM_LIMITTEXT, (WPARAM) (MAXPATHLEN*4 - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_SHORTNAM, getbool(setupdlg->attr[KEY_SHORTNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOCREAT, getbool(setupdlg->attr[KEY_NOCREAT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_FKSUPPORT, getbool(setupdlg->attr[KEY_FKSUPPORT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_OEMCP, getbool(setupdlg->attr[KEY_OEMCP].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_BIGINT, getbool(setupdlg->attr[KEY_BIGINT].attr) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_LIMITTEXT, (WPARAM) 10, (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "NORMAL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "OFF"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "FULL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_DSNAME: if (GET_WM_COMMAND_CMD(wparam, lparam) == EN_CHANGE) { char item[MAXDSNAME]; EnableWindow(GetDlgItem(hdlg, IDOK), GetDlgItemText(hdlg, IDC_DSNAME, item, sizeof (item))); return TRUE; } break; case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif if (!setupdlg->defDSN) { GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); } GetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); GetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr)); index = SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); if (index != (WORD) CB_ERR) { SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETLBTEXT, index, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); } strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_SHORTNAM].attr, (IsDlgButtonChecked(hdlg, IDC_SHORTNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOCREAT].attr, (IsDlgButtonChecked(hdlg, IDC_NOCREAT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_FKSUPPORT].attr, (IsDlgButtonChecked(hdlg, IDC_FKSUPPORT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_OEMCP].attr, (IsDlgButtonChecked(hdlg, IDC_OEMCP) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_BIGINT].attr, (IsDlgButtonChecked(hdlg, IDC_BIGINT) == BST_CHECKED) ? "1" : "0"); SetDSNAttributes(hdlg, setupdlg); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, wparam); return TRUE; } break; } return FALSE; } /** * ODBC INSTAPI procedure for DSN configuration. * @param hwnd parent window handle * @param request type of request * @param driver driver name * @param attribs attribute string of DSN * @result true or false */ BOOL INSTAPI ConfigDSN(HWND hwnd, WORD request, LPCSTR driver, LPCSTR attribs) { BOOL success; SETUPDLG *setupdlg; setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return FALSE; } memset(setupdlg, 0, sizeof (SETUPDLG)); if (attribs) { ParseAttributes(attribs, setupdlg); } if (setupdlg->attr[KEY_DSN].supplied) { strcpy(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr); } else { setupdlg->DSN[0] = '\0'; } if (request == ODBC_REMOVE_DSN) { if (!setupdlg->attr[KEY_DSN].supplied) { success = FALSE; } else { success = SQLRemoveDSNFromIni(setupdlg->attr[KEY_DSN].attr); } } else { setupdlg->parent = hwnd; setupdlg->driver = driver; setupdlg->newDSN = request == ODBC_ADD_DSN; setupdlg->defDSN = strcasecmp(setupdlg->attr[KEY_DSN].attr, "Default") == 0; if (hwnd) { success = DialogBoxParam(hModule, MAKEINTRESOURCE(CONFIGDSN), hwnd, (DLGPROC) ConfigDlgProc, (LPARAM) setupdlg) == IDOK; } else if (setupdlg->attr[KEY_DSN].supplied) { success = SetDSNAttributes(hwnd, setupdlg); } else { success = FALSE; } } xfree(setupdlg); return success; } /** * Dialog procedure for SQLDriverConnect(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK DriverConnectProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg; WORD index; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLongPtr(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_LOADEXT, EM_LIMITTEXT, (WPARAM) (MAXPATHLEN*4 - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_SHORTNAM, getbool(setupdlg->attr[KEY_SHORTNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOCREAT, getbool(setupdlg->attr[KEY_NOCREAT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_FKSUPPORT, getbool(setupdlg->attr[KEY_FKSUPPORT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_OEMCP, getbool(setupdlg->attr[KEY_OEMCP].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_BIGINT, getbool(setupdlg->attr[KEY_BIGINT].attr) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_LIMITTEXT, (WPARAM) 10, (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "NORMAL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "OFF"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "FULL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_SELECTSTRING, (WORD) -1, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); GetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr)); index = SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); if (index != (WORD) CB_ERR) { SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETLBTEXT, index, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); } strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_SHORTNAM].attr, (IsDlgButtonChecked(hdlg, IDC_SHORTNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOCREAT].attr, (IsDlgButtonChecked(hdlg, IDC_NOCREAT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_FKSUPPORT].attr, (IsDlgButtonChecked(hdlg, IDC_FKSUPPORT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_OEMCP].attr, (IsDlgButtonChecked(hdlg, IDC_OEMCP) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_BIGINT].attr, (IsDlgButtonChecked(hdlg, IDC_BIGINT) == BST_CHECKED) ? "1" : "0"); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wparam, lparam) == IDOK); return TRUE; } } return FALSE; } /** * Internal connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { BOOL maybeprompt, prompt = FALSE, defaultdsn = FALSE; DBC *d; SETUPDLG *setupdlg; SQLRETURN ret; char *dsn = NULL, *driver = NULL, *dbname = NULL; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return SQL_ERROR; } memset(setupdlg, 0, sizeof (SETUPDLG)); maybeprompt = drvcompl == SQL_DRIVER_COMPLETE || drvcompl == SQL_DRIVER_COMPLETE_REQUIRED; if (connIn == NULL || !connInLen || (connInLen == SQL_NTS && !connIn[0])) { prompt = TRUE; } else { ParseAttributes((LPCSTR) connIn, setupdlg); if (!setupdlg->attr[KEY_DSN].attr[0] && drvcompl == SQL_DRIVER_COMPLETE_REQUIRED) { strcpy(setupdlg->attr[KEY_DSN].attr, "DEFAULT"); defaultdsn = TRUE; } GetAttributes(setupdlg); if (drvcompl == SQL_DRIVER_PROMPT || (maybeprompt && !setupdlg->attr[KEY_DBNAME].attr[0])) { prompt = TRUE; } } retry: if (prompt) { short dlgret; setupdlg->defDSN = setupdlg->attr[KEY_DRIVER].attr[0] != '\0'; dlgret = DialogBoxParam(hModule, MAKEINTRESOURCE(DRIVERCONNECT), hwnd, (DLGPROC) DriverConnectProc, (LPARAM) setupdlg); if (!dlgret || dlgret == -1) { xfree(setupdlg); return SQL_NO_DATA; } } dsn = setupdlg->attr[KEY_DSN].attr; driver = setupdlg->attr[KEY_DRIVER].attr; dbname = setupdlg->attr[KEY_DBNAME].attr; if (connOut || connOutLen) { char buf[SQL_MAX_MESSAGE_LENGTH * 4]; int len, count; char dsn_0 = (dsn && !defaultdsn) ? dsn[0] : '\0'; char drv_0 = driver ? driver[0] : '\0'; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), "%s%s%s%s%s%sDatabase=%s;StepAPI=%s;" "SyncPragma=%s;NoTXN=%s;Timeout=%s;" "ShortNames=%s;LongNames=%s;" "NoCreat=%s;NoWCHAR=%s;" "FKSupport=%s;JournalMode=%s;OEMCP=%s;LoadExt=%s;" "BigInt=%s;PWD=%s", dsn_0 ? "DSN=" : "", dsn_0 ? dsn : "", dsn_0 ? ";" : "", drv_0 ? "Driver=" : "", drv_0 ? driver : "", drv_0 ? ";" : "", dbname ? dbname : "", setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_SYNCP].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_BUSY].attr, setupdlg->attr[KEY_SHORTNAM].attr, setupdlg->attr[KEY_LONGNAM].attr, setupdlg->attr[KEY_NOCREAT].attr, setupdlg->attr[KEY_NOWCHAR].attr, setupdlg->attr[KEY_FKSUPPORT].attr, setupdlg->attr[KEY_JMODE].attr, setupdlg->attr[KEY_OEMCP].attr, setupdlg->attr[KEY_LOADEXT].attr, setupdlg->attr[KEY_BIGINT].attr, setupdlg->attr[KEY_PASSWD].attr); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } if (dsn[0]) { char tracef[SQL_MAX_MESSAGE_LENGTH]; tracef[0] = '\0'; SQLGetPrivateProfileString(setupdlg->attr[KEY_DSN].attr, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } } d->nowchar = getbool(setupdlg->attr[KEY_NOWCHAR].attr); d->shortnames = getbool(setupdlg->attr[KEY_SHORTNAM].attr); d->longnames = getbool(setupdlg->attr[KEY_LONGNAM].attr); d->nocreat = getbool(setupdlg->attr[KEY_NOCREAT].attr); d->fksupport = getbool(setupdlg->attr[KEY_FKSUPPORT].attr); d->oemcp = getbool(setupdlg->attr[KEY_OEMCP].attr); d->dobigint = getbool(setupdlg->attr[KEY_BIGINT].attr); d->pwdLen = strlen(setupdlg->attr[KEY_PASSWD].attr); d->pwd = (d->pwdLen > 0) ? setupdlg->attr[KEY_PASSWD].attr : NULL; ret = dbopen(d, dbname ? dbname : "", 0, dsn ? dsn : "", setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_SYNCP].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_JMODE].attr, setupdlg->attr[KEY_BUSY].attr); if (ret != SQL_SUCCESS) { if (maybeprompt && !prompt) { prompt = TRUE; goto retry; } } memset(setupdlg->attr[KEY_PASSWD].attr, 0, sizeof (setupdlg->attr[KEY_PASSWD].attr)); if (ret == SQL_SUCCESS) { dbloadext(d, setupdlg->attr[KEY_LOADEXT].attr); } xfree(setupdlg); return ret; } #endif /* WITHOUT_DRIVERMGR */ #endif /* _WIN32 || _WIN64 */ #ifndef WINTERFACE /** * Connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdriverconnect(dbc, hwnd, connIn, connInLen, connOut, connOutMax, connOutLen, drvcompl); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect using a driver connection string (UNICODE version). * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnectW(SQLHDBC dbc, SQLHWND hwnd, SQLWCHAR *connIn, SQLSMALLINT connInLen, SQLWCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; char *ci = NULL; SQLSMALLINT len = 0; HDBC_LOCK(dbc); if (connIn) { #if defined(_WIN32) || defined(_WIN64) if (connInLen == SQL_NTS) { connInLen = -1; } ci = uc_to_wmb(connIn, connInLen); #else ci = uc_to_utf(connIn, connInLen); #endif if (!ci) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); HDBC_UNLOCK(dbc); return SQL_ERROR; } } ret = drvdriverconnect(dbc, hwnd, (SQLCHAR *) ci, SQL_NTS, (SQLCHAR *) connOut, connOutMax, &len, drvcompl); HDBC_UNLOCK(dbc); uc_free(ci); if (ret == SQL_SUCCESS) { SQLWCHAR *co = NULL; if (connOut) { if (len > 0) { #if defined(_WIN32) || defined(_WIN64) co = wmb_to_uc((char *) connOut, len); #else co = uc_from_utf((SQLCHAR *) connOut, len); #endif if (co) { uc_strncpy(connOut, co, connOutMax / sizeof (SQLWCHAR)); len = min(connOutMax / sizeof (SQLWCHAR), uc_strlen(co)); uc_free(co); } else { len = 0; } } if (len <= 0) { len = 0; connOut[0] = 0; } } else { len = 0; } if (connOutLen) { *connOutLen = len; } } return ret; } #endif #if defined(_WIN32) || defined(_WIN64) /** * DLL initializer for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ BOOL APIENTRY LibMain(HANDLE hinst, DWORD reason, LPVOID reserved) { static int initialized = 0; switch (reason) { case DLL_PROCESS_ATTACH: if (!initialized++) { hModule = hinst; #ifdef WINTERFACE /* MS Access hack part 1 (reserved error -7748) */ statSpec2P = statSpec2; statSpec3P = statSpec3; #endif #ifdef SQLITE_DYNLOAD dls_init(); #endif #ifdef SQLITE_HAS_CODEC sqlite3_activate_see(SQLITE_ACTIVATION_KEY); #endif } #if defined(ENABLE_NVFS) && (ENABLE_NVFS) nvfs_init(); #endif break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: if (--initialized <= 0) { #ifdef SQLITE_DYNLOAD dls_fini(); #endif } break; case DLL_THREAD_DETACH: break; default: break; } return TRUE; } /** * DLL entry point for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ int __stdcall DllMain(HANDLE hinst, DWORD reason, LPVOID reserved) { return LibMain(hinst, reason, reserved); } #ifndef WITHOUT_INSTALLER /** * Handler for driver installer/uninstaller error messages. * @param name name of API function for which to show error messages * @result true when error message retrieved */ static BOOL InUnError(char *name) { WORD err = 1; DWORD code; char errmsg[301]; WORD errlen, errmax = sizeof (errmsg) - 1; int sqlret; BOOL ret = FALSE; do { errmsg[0] = '\0'; sqlret = SQLInstallerError(err, &code, errmsg, errmax, &errlen); if (SQL_SUCCEEDED(sqlret)) { MessageBox(NULL, errmsg, name, MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ret = TRUE; } err++; } while (sqlret != SQL_NO_DATA); return ret; } /** * Built in driver installer/uninstaller. * @param remove true for uninstall * @param cmdline command line string of rundll32 */ static BOOL InUn(int remove, char *cmdline) { #ifdef SQLITE_HAS_CODEC static char *drivername = "SQLite3 ODBC Driver (SEE)"; static char *dsname = "SQLite3 SEE Datasource"; #else static char *drivername = "SQLite3 ODBC Driver"; static char *dsname = "SQLite3 Datasource"; #endif char *dllname, *p; char dllbuf[301], path[301], driver[300], attr[300], inst[400]; WORD pathmax = sizeof (path) - 1, pathlen; DWORD usecnt, mincnt; int quiet = 0; dllbuf[0] = '\0'; GetModuleFileName(hModule, dllbuf, sizeof (dllbuf)); p = strrchr(dllbuf, '\\'); dllname = p ? (p + 1) : dllbuf; quiet = cmdline && strstr(cmdline, "quiet"); if (SQLInstallDriverManager(path, pathmax, &pathlen)) { sprintf(driver, "%s;Driver=%s;Setup=%s;", drivername, dllname, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } usecnt = 0; path[0] = '\0'; SQLInstallDriverEx(driver, NULL, path, pathmax, NULL, ODBC_INSTALL_INQUIRY, &usecnt); pathlen = strlen(path); while (pathlen > 0 && path[pathlen - 1] == '\\') { --pathlen; path[pathlen] = '\0'; } sprintf(driver, "%s;Driver=%s\\%s;Setup=%s\\%s;", drivername, path, dllname, path, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } sprintf(inst, "%s\\%s", path, dllname); if (!remove && usecnt > 0) { /* first install try: copy over driver dll, keeping DSNs */ if (GetFileAttributesA(dllbuf) != INVALID_FILE_ATTRIBUTES && CopyFile(dllbuf, inst, 0)) { if (!quiet) { char buf[512]; sprintf(buf, "%s replaced.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } return TRUE; } } mincnt = remove ? 1 : 0; while (usecnt != mincnt) { if (!SQLRemoveDriver(driver, TRUE, &usecnt)) { break; } } if (remove) { if (usecnt && !SQLRemoveDriver(driver, TRUE, &usecnt)) { InUnError("SQLRemoveDriver"); return FALSE; } if (!usecnt) { char buf[512]; DeleteFile(inst); if (!quiet) { sprintf(buf, "%s uninstalled.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION |MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); return TRUE; } if (GetFileAttributesA(dllbuf) == INVALID_FILE_ATTRIBUTES) { return FALSE; } if (strcmp(dllbuf, inst) != 0 && !CopyFile(dllbuf, inst, 0)) { char buf[512]; sprintf(buf, "Copy %s to %s failed.", dllbuf, inst); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP |MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); return FALSE; } if (!SQLInstallDriverEx(driver, path, path, pathmax, &pathlen, ODBC_INSTALL_COMPLETE, &usecnt)) { InUnError("SQLInstallDriverEx"); return FALSE; } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, drivername, attr)) { InUnError("SQLConfigDataSource"); return FALSE; } if (!quiet) { char buf[512]; sprintf(buf, "%s installed.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } else { InUnError("SQLInstallDriverManager"); return FALSE; } return TRUE; } /** * RunDLL32 entry point for driver installation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK install(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(0, lpszCmdLine); } /** * RunDLL32 entry point for driver uninstallation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK uninstall(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(1, lpszCmdLine); } #endif /* WITHOUT_INSTALLER */ #ifndef WITHOUT_SHELL /** * Setup argv vector from string * @param argcp pointer to argc * @param argvp pointer to argv * @param cmdline command line string * @param argv0 0th element for argv or NULL, must be static */ static void setargv(int *argcp, char ***argvp, char *cmdline, char *argv0) { char *p, *arg, *argspace, **argv; int argc, size, inquote, copy, slashes; size = 2 + (argv0 ? 1 : 0); for (p = cmdline; *p != '\0'; p++) { if (ISSPACE(*p)) { size++; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } } } argspace = malloc(size * sizeof (char *) + strlen(cmdline) + 1); argv = (char **) argspace; argspace += size * sizeof (char *); size--; argc = 0; if (argv0) { argv[argc++] = argv0; } p = cmdline; for (; argc < size; argc++) { argv[argc] = arg = argspace; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if (inquote && p[1] == '"') { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if (*p == '\0' || (!inquote && ISSPACE(*p))) { break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argspace = arg + 1; } argv[argc] = 0; *argcp = argc; *argvp = argv; } /** * RunDLL32 entry point for SQLite shell * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK shell(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int argc, needcon = 0; char **argv; extern int sqlite3_main(int, char **); static const char *name = "SQLite3 Shell"; DWORD ftype0, ftype1, ftype2; ftype0 = GetFileType(GetStdHandle(STD_INPUT_HANDLE)); ftype1 = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); ftype2 = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); if (ftype0 != FILE_TYPE_DISK && ftype0 != FILE_TYPE_CHAR && ftype0 != FILE_TYPE_PIPE) { fclose(stdin); ++needcon; ftype0 = FILE_TYPE_UNKNOWN; } if (ftype1 != FILE_TYPE_DISK && ftype1 != FILE_TYPE_CHAR && ftype1 != FILE_TYPE_PIPE) { fclose(stdout); ++needcon; ftype1 = FILE_TYPE_UNKNOWN; } if (ftype2 != FILE_TYPE_DISK && ftype2 != FILE_TYPE_CHAR && ftype2 != FILE_TYPE_PIPE) { fclose(stderr); ++needcon; ftype2 = FILE_TYPE_UNKNOWN; } if (needcon > 0) { AllocConsole(); SetConsoleTitle(name); } if (ftype0 == FILE_TYPE_UNKNOWN) { freopen("CONIN$", "r", stdin); } if (ftype1 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stdout); } if (ftype2 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stderr); } setargv(&argc, &argv, lpszCmdLine, (char *) name); #if defined(ENABLE_NVFS) && (ENABLE_NVFS) nvfs_init(); #endif sqlite3_main(argc, argv); } #endif /* WITHOUT_SHELL */ #endif /* _WIN32 || _WIN64 */ #if defined(HAVE_ODBCINSTEXT_H) && (HAVE_ODBCINSTEXT_H) /* * unixODBC property page for this driver, * may or may not work depending on unixODBC version. */ #include int ODBCINSTGetProperties(HODBCINSTPROPERTY prop) { static const char *instYN[] = { "No", "Yes", NULL }; static const char *syncPragma[] = { "NORMAL", "OFF", "FULL", NULL }; static const char *jmPragma[] = { "DELETE", "PERSIST", "OFF", "TRUNCATE", "MEMORY", "WAL", NULL }; prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_FILENAME; strncpy(prop->szName, "Database", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strncpy(prop->szName, "Timeout", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "100000", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "StepAPI", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "ShortNames", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "LongNames", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "NoCreat", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #ifdef WINTERFACE prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "NoWCHAR", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #endif prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "FKSupport", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (syncPragma)); memcpy(prop->aPromptData, syncPragma, sizeof (syncPragma)); strncpy(prop->szName, "SyncPragma", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "NORMAL", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (jmPragma)); memcpy(prop->aPromptData, jmPragma, sizeof (jmPragma)); strncpy(prop->szName, "JournalMode", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "DELETE", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strncpy(prop->szName, "LoadExt", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "BigInt", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); return 1; } #endif /* HAVE_ODBCINSTEXT_H */ #ifdef SQLITE_DYNLOAD /* * SQLite3 shared library/DLL stubs. */ static void dls_void(void) { } static int dls_error(void) { return SQLITE_ERROR; } static int dls_0(void) { return 0; } static double dls_00(void) { return 0; } static void * dls_null(void) { return NULL; } static const char * dls_empty(void) { return ""; } static int dls_snull(void) { return SQLITE_NULL; } #define DLS_ENT(name, func) \ { "sqlite3_" #name, offsetof(struct dl_sqlite3_funcs, name), \ (void *) func } #define DLS_ENT3(name, off, func) \ { "sqlite3_" #name, offsetof(struct dl_sqlite3_funcs, off), \ (void *) func } #define DLS_END { NULL, 0, NULL } static struct { const char *name; int offset; void *func; } dls_nametab[] = { DLS_ENT(activate_see, dls_void), DLS_ENT(bind_blob, dls_error), DLS_ENT(bind_double, dls_error), DLS_ENT(bind_int, dls_error), DLS_ENT(bind_int64, dls_error), DLS_ENT(bind_null, dls_error), DLS_ENT(bind_parameter_count, dls_0), DLS_ENT(bind_text, dls_error), DLS_ENT(busy_handler, dls_error), DLS_ENT(changes, dls_0), DLS_ENT(close, dls_error), DLS_ENT(column_blob, dls_null), DLS_ENT(column_bytes, dls_0), DLS_ENT(column_count, dls_0), DLS_ENT(column_database_name, dls_empty), DLS_ENT(column_decltype, dls_empty), DLS_ENT(column_double, dls_00), DLS_ENT(column_name, dls_empty), DLS_ENT(column_origin_name, dls_null), DLS_ENT(column_table_name, dls_null), DLS_ENT(column_text, dls_null), DLS_ENT(column_type, dls_snull), DLS_ENT(create_function, dls_error), DLS_ENT(enable_load_extension, dls_error), DLS_ENT(errcode, dls_error), DLS_ENT(errmsg, dls_empty), DLS_ENT(exec, dls_error), DLS_ENT(finalize, dls_error), DLS_ENT(free, free), DLS_ENT(free_table, dls_void), DLS_ENT(get_table, dls_error), DLS_ENT(interrupt, dls_void), DLS_ENT(key, dls_error), DLS_ENT(libversion, dls_empty), DLS_ENT(load_extension, dls_error), DLS_ENT(malloc, malloc), DLS_ENT(mprintf, dls_null), DLS_ENT(open, dls_error), DLS_ENT(open16, dls_error), DLS_ENT(open_v2, dls_error), DLS_ENT(prepare, dls_error), DLS_ENT(prepare_v2, dls_error), DLS_ENT(profile, dls_null), DLS_ENT(realloc, realloc), DLS_ENT(rekey, dls_error), DLS_ENT(reset, dls_error), DLS_ENT(result_blob, dls_void), DLS_ENT(result_error, dls_void), DLS_ENT(result_int, dls_void), DLS_ENT(result_null, dls_void), DLS_ENT(step, dls_error), #if defined(_WIN32) || defined(_WIN64) DLS_ENT3(strnicmp, xstrnicmp, _strnicmp), #else DLS_ENT3(strnicmp, xstrnicmp, strncasecmp), #endif DLS_ENT(table_column_metadata, dls_error), DLS_ENT(trace, dls_null), DLS_ENT(user_data, dls_null), DLS_ENT(value_blob, dls_null), DLS_ENT(value_bytes, dls_0), DLS_ENT(value_text, dls_empty), DLS_ENT(value_type, dls_snull), DLS_END }; #if defined(_WIN32) || defined(_WIN64) static HMODULE sqlite3_dll = 0; static void dls_init(void) { int i; static const char *dll_names[] = { "System.Data.SQLite.dll", "sqlite3.dll", NULL, }; i = 0; while (dll_names[i]) { sqlite3_dll = LoadLibrary(dll_names[i]); if (sqlite3_dll) { break; } ++i; } i = 0; while (dls_nametab[i].name) { void *func = 0, **loc; if (sqlite3_dll) { func = (void *) GetProcAddress(sqlite3_dll, dls_nametab[i].name); } if (!func) { func = dls_nametab[i].func; } loc = (void **) ((char *) &dls_funcs + dls_nametab[i].offset); *loc = func; ++i; } if (!sqlite3_dll) { char buf[MAXPATHLEN], msg[MAXPATHLEN]; LoadString(hModule, IDS_DRVTITLE, buf, sizeof (buf)); LoadString(hModule, IDS_DLLERR, msg, sizeof (msg)); MessageBox(NULL, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } static void dls_fini(void) { if (sqlite3_dll) { FreeLibrary(sqlite3_dll); sqlite3_dll = 0; } } #else #include static void *libsqlite3_so = 0; void dls_init(void) { int i; libsqlite3_so = dlopen("libsqlite3.so.0", RTLD_NOW | RTLD_GLOBAL); i = 0; while (dls_nametab[i].name) { void *func = 0, **loc; if (libsqlite3_so) { func = dlsym(libsqlite3_so, dls_nametab[i].name); } if (!func) { func = dls_nametab[i].func; } loc = (void **) ((char *) &dls_funcs + dls_nametab[i].offset); *loc = func; ++i; } if (!libsqlite3_so) { const char errmsg[] = "SQLite3 shared library not found.\n"; write(2, errmsg, sizeof (errmsg) - 1); } } void dls_fini(void) { if (libsqlite3_so) { dlclose(libsqlite3_so); libsqlite3_so = 0; } } #endif #endif ./sqliteodbc-0.992/sqlite3odbc.h0100644000076400001440000002265612074001655015130 0ustar chwusers#ifndef _SQLITE3ODBC_H #define _SQLITE3ODBC_H /** * @mainpage * @section readme README * @verbinclude README * @section changelog ChangeLog * @verbinclude ChangeLog * @section copying License Terms * @verbinclude license.terms */ /** * @file sqlite3odbc.h * Header file for SQLite3 ODBC driver. * * $Id: sqlite3odbc.h,v 1.41 2013/01/11 12:20:56 chw Exp chw $ * * Copyright (c) 2004-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #if defined(_WIN32) || defined(_WIN64) #include #include #include #else #include #include #include #include #include #endif #include #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) #include #endif #include #include #include #include #include #include #include "sqlite3.h" #ifdef HAVE_IODBC #include #endif #if defined(HAVE_UNIXODBC) || defined(_WIN32) || defined(_WIN64) #include #endif #ifndef SQL_API #define SQL_API #endif #ifndef HAVE_SQLLEN #define SQLLEN SQLINTEGER #endif #define SQLLEN_PTR SQLLEN * #ifndef HAVE_SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef HAVE_SQLROWCOUNT #define SQLROWCOUNT SQLUINTEGER #endif #ifndef HAVE_SQLSETPOSIROW #define SQLSETPOSIROW SQLUSMALLINT #endif #ifndef HAVE_SQLROWOFFSET #define SQLROWOFFSET SQLLEN #endif #ifndef HAVE_SQLROWSETSIZE #define SQLROWSETSIZE SQLULEN #endif struct dbc; struct stmt; /** * @typedef ENV * @struct ENV * Driver internal structure for environment (HENV). */ typedef struct { int magic; /**< Magic cookie */ int ov3; /**< True for SQL_OV_ODBC3 */ #if defined(_WIN32) || defined(_WIN64) CRITICAL_SECTION cs; /**< For serializing most APIs */ DWORD owner; /**< Current owner of CS or 0 */ #endif struct dbc *dbcs; /**< Pointer to first DBC */ } ENV; /** * @typedef DBC * @struct dbc * Driver internal structure for database connection (HDBC). */ typedef struct dbc { int magic; /**< Magic cookie */ ENV *env; /**< Pointer to environment */ struct dbc *next; /**< Pointer to next DBC */ sqlite3 *sqlite; /**< SQLITE database handle */ int version; /**< SQLITE version number */ char *dbname; /**< SQLITE database name */ char *dsn; /**< ODBC data source name */ int timeout; /**< Lock timeout value */ long t0; /**< Start time for SQLITE busy handler */ int busyint; /**< Interrupt busy handler from SQLCancel() */ int *ov3; /**< True for SQL_OV_ODBC3 */ int ov3val; /**< True for SQL_OV_ODBC3 */ int autocommit; /**< Auto commit state */ int intrans; /**< True when transaction started */ struct stmt *stmt; /**< STMT list of this DBC */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar; /**< Don't try to use WCHAR */ int dobigint; /**< Force SQL_BIGINT for INTEGER columns */ int shortnames; /**< Always use short column names */ int longnames; /**< Don't shorten column names */ int nocreat; /**< Don't auto create database file */ int fksupport; /**< Foreign keys on or off */ int curtype; /**< Default cursor type */ int step_enable; /**< True for sqlite_compile/step/finalize */ int trans_disable; /**< True for no transaction support */ int oemcp; /**< True for Win32 OEM CP translation */ struct stmt *cur_s3stmt; /**< Current STMT executing sqlite statement */ int s3stmt_needmeta; /**< True to get meta data in s3stmt_step(). */ FILE *trace; /**< sqlite3_trace() file pointer or NULL */ char *pwd; /**< Password or NULL */ int pwdLen; /**< Length of password */ #ifdef USE_DLOPEN_FOR_GPPS void *instlib; int (*gpps)(); #endif #if defined(_WIN32) || defined(_WIN64) int xcelqrx; #endif } DBC; /** * @typedef COL * @struct COL * Internal structure to describe a column in a result set. */ typedef struct { char *db; /**< Database name */ char *table; /**< Table name */ char *column; /**< Column name */ int type; /**< Data type of column */ int size; /**< Size of column */ int index; /**< Index of column in result */ int nosign; /**< Unsigned type */ int scale; /**< Scale of column */ int prec; /**< Precision of column */ int autoinc; /**< AUTO_INCREMENT column */ int notnull; /**< NOT NULL constraint on column */ char *typename; /**< Column type name or NULL */ char *label; /**< Column label or NULL */ } COL; /** * @typedef BINDCOL * @struct BINDCOL * Internal structure for bound column (SQLBindCol). */ typedef struct { SQLSMALLINT type; /**< ODBC type */ SQLINTEGER max; /**< Max. size of value buffer */ SQLLEN *lenp; /**< Value return, actual size of value buffer */ SQLPOINTER valp; /**< Value buffer */ int index; /**< Index of column in result */ int offs; /**< Byte offset for SQLGetData() */ } BINDCOL; /** * @typedef BINDPARM * @struct BINDPARM * Internal structure for bound parameter (SQLBindParameter). */ typedef struct { int type, stype; /**< ODBC and SQL types */ int coldef, scale; /**< from SQLBindParameter() */ SQLLEN max; /**< Max. size size of parameter buffer */ SQLLEN *lenp; /**< Actual size of parameter buffer */ SQLLEN *lenp0; /**< Actual size of parameter buffer, initial value */ void *param; /**< Parameter buffer */ void *param0; /**< Parameter buffer, initial value */ int inc; /**< Increment for paramset size > 1 */ int need; /**< True when SQL_LEN_DATA_AT_EXEC */ int bound; /**< True when SQLBindParameter() called */ int offs, len; /**< Offset/length for SQLParamData()/SQLPutData() */ void *parbuf; /**< Buffer for SQL_LEN_DATA_AT_EXEC etc. */ char strbuf[64]; /**< String buffer for scalar data */ int s3type; /**< SQLite3 type */ int s3size; /**< SQLite3 size */ void *s3val; /**< SQLite3 value buffer */ int s3ival; /**< SQLite3 integer value */ sqlite_int64 s3lival; /**< SQLite3 64bit integer value */ double s3dval; /**< SQLite3 float value */ } BINDPARM; /** * @typedef STMT * @struct stmt * Driver internal structure representing SQL statement (HSTMT). */ typedef struct stmt { struct stmt *next; /**< Linkage for STMT list in DBC */ HDBC dbc; /**< Pointer to DBC */ SQLCHAR cursorname[32]; /**< Cursor name */ SQLCHAR *query; /**< Current query, raw string */ int *ov3; /**< True for SQL_OV_ODBC3 */ int *oemcp; /**< True for Win32 OEM CP translation */ int isselect; /**< > 0 if query is a SELECT statement */ int ncols; /**< Number of result columns */ COL *cols; /**< Result column array */ COL *dyncols; /**< Column array, but malloc()ed */ int dcols; /**< Number of entries in dyncols */ int bkmrk; /**< True when bookmarks used */ BINDCOL bkmrkcol; /**< Bookmark bound column */ BINDCOL *bindcols; /**< Array of bound columns */ int nbindcols; /**< Number of entries in bindcols */ int nbindparms; /**< Number bound parameters */ BINDPARM *bindparms; /**< Array of bound parameters */ int nparams; /**< Number of parameters in query */ int pdcount; /**< SQLParamData() counter */ int nrows; /**< Number of result rows */ int rowp; /**< Current result row */ char **rows; /**< 2-dim array, result set */ void (*rowfree)(); /**< Free function for rows */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar[2]; /**< Don't try to use WCHAR */ int dobigint; /**< Force SQL_BIGINT for INTEGER columns */ int longnames; /**< Don't shorten column names */ SQLULEN retr_data; /**< SQL_ATTR_RETRIEVE_DATA */ SQLULEN rowset_size; /**< Size of rowset */ SQLUSMALLINT *row_status; /**< Row status pointer */ SQLUSMALLINT *row_status0; /**< Internal status array */ SQLUSMALLINT row_status1; /**< Internal status array for 1 row rowsets */ SQLULEN *row_count; /**< Row count pointer */ SQLULEN row_count0; /**< Row count */ SQLULEN paramset_size; /**< SQL_ATTR_PARAMSET_SIZE */ SQLULEN paramset_count; /**< Internal for paramset */ SQLUINTEGER paramset_nrows; /**< Row count for paramset handling */ SQLULEN max_rows; /**< SQL_ATTR_MAX_ROWS */ SQLULEN bind_type; /**< SQL_ATTR_ROW_BIND_TYPE */ SQLULEN *bind_offs; /**< SQL_ATTR_ROW_BIND_OFFSET_PTR */ /* Dummies to make ADO happy */ SQLULEN *parm_bind_offs; /**< SQL_ATTR_PARAM_BIND_OFFSET_PTR */ SQLUSMALLINT *parm_oper; /**< SQL_ATTR_PARAM_OPERATION_PTR */ SQLUSMALLINT *parm_status; /**< SQL_ATTR_PARAMS_STATUS_PTR */ SQLULEN *parm_proc; /**< SQL_ATTR_PARAMS_PROCESSED_PTR */ SQLULEN parm_bind_type; /**< SQL_ATTR_PARAM_BIND_TYPE */ int curtype; /**< Cursor type */ sqlite3_stmt *s3stmt; /**< SQLite statement handle or NULL */ int s3stmt_noreset; /**< False when sqlite3_reset() needed. */ int s3stmt_rownum; /**< Current row number */ char *bincell; /**< Cache for blob data */ char *bincache; /**< Cache for blob data */ int binlen; /**< Length of blob data */ int guessed_types; /**< Flag for drvprepare()/drvexecute() */ } STMT; #endif ./sqliteodbc-0.992/sqlite3odbc.rc0100644000076400001440000001445112074001072015270 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" #ifndef SQLITE_VERSION #define SQLITE_VERSION "?.?.?" #endif ///////////////////////////////////////////////////////////////////////////// // // Dialog // DRIVERCONNECT DIALOG DISCARDABLE 65, 43, 277, 175 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "SQLite3 ODBC Driver Connect" FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,50,52,15 CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,225,50,52,15 COMBOBOX IDC_SYNCP,82,67,69,52,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Short Column Names",IDC_SHORTNAM,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,65,95,15 CONTROL "Foreign Keys",IDC_FKSUPPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,75,15 CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,95,15 CONTROL "OEMCP Translation",IDC_OEMCP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,95,75,15 CONTROL "Don't Create Database",IDC_NOCREAT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,95,95,15 CONTROL "Always BIGINT",IDC_BIGINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,110,75,15 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,110,52,15 EDITTEXT IDC_LOADEXT,82,130,185,12,ES_AUTOHSCROLL | WS_GROUP DEFPUSHBUTTON "OK",IDOK,175,150,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,150,40,14 CTEXT "Enter options for connect",1003,95,6,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP RTEXT "Sync.Mode:",IDC_SYNCPTEXT,6,69,72,9,NOT WS_GROUP RTEXT "Load Extensions:",IDC_LOADEXTTEXT,6,132,73,9,NOT WS_GROUP END CONFIGDSN DIALOG DISCARDABLE 65, 43, 277, 175 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "SQLite3 ODBC DSN Configuration" FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,50,52,15 CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,225,50,52,15 COMBOBOX IDC_SYNCP,82,67,69,52,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Short Column Names",IDC_SHORTNAM,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,65,95,15 CONTROL "Foreign Keys",IDC_FKSUPPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,75,15 CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,95,15 CONTROL "OEMCP Translation",IDC_OEMCP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,95,75,15 CONTROL "Don't Create Database",IDC_NOCREAT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,95,95,15 CONTROL "Always BIGINT",IDC_BIGINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,110,75,15 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,110,52,15 EDITTEXT IDC_LOADEXT,82,130,185,12,ES_AUTOHSCROLL | WS_GROUP DEFPUSHBUTTON "OK",IDOK,175,150,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,150,40,14 CTEXT "Enter options for connect",1003,95,6,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP RTEXT "Sync.Mode:",IDC_SYNCPTEXT,6,69,72,9,NOT WS_GROUP RTEXT "Load Extensions:",IDC_LOADEXTTEXT,6,132,73,9,NOT WS_GROUP END ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 ODBC Driver\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "SQLITE3ODBC\0" VALUE "LegalCopyright", "Copyright İ 2004-2013 \0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3ODBC.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_MSGTITLE "SQLite3 ODBC Setup" IDS_BADDSN "%s cannot be used as a data source name." IDS_EXTTITLE "SQLite3 ODBC Extension" IDS_EXTERR "Extension '%s' did not load:\n%s" IDS_DRVTITLE "SQLite3 ODBC Driver" IDS_DLLERR "No usable SQLite3 DLL found." END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/sqlite3odbc.mak0100644000076400001440000000411511161421407015434 0ustar chwusers# VC++ 6 Makefile # uses the SQLite3 amalgamation source which must # be unpacked below in the same folder as this makefile CC= cl LN= link RC= rc !IF "$(DEBUG)" == "1" LDEBUG= /DEBUG CDEBUG= -Zi !ELSE LDEBUG= /RELEASE !ENDIF CFLAGS= -I. -Gs -GX -D_WIN32 -D_DLL -nologo $(CDEBUG) \ -DHAVE_SQLITE3COLUMNTABLENAME=1 \ -DHAVE_SQLITE3PREPAREV2=1 \ -DHAVE_SQLITE3VFS=1 \ -DHAVE_SQLITE3LOADEXTENSION=1 \ -DSQLITE_ENABLE_COLUMN_METADATA=1 \ -DWITHOUT_SHELL=1 CFLAGSEXE= -I. -Gs -GX -D_WIN32 -nologo $(CDEBUG) DLLLFLAGS= /NODEFAULTLIB $(LDEBUG) /NOLOGO /MACHINE:IX86 \ /SUBSYSTEM:WINDOWS /DLL DLLLIBS= msvcrt.lib odbccp32.lib kernel32.lib \ user32.lib comdlg32.lib DRVDLL= sqlite3odbc.dll OBJECTS= sqlite3odbc.obj sqlite3.obj .c.obj: $(CC) $(CFLAGS) /c $< all: $(DRVDLL) inst.exe uninst.exe adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe SQLiteODBCInstaller.exe clean: del *.obj del *.res del *.exp del *.ilk del *.pdb del *.res del resource3.h del *.exe cd .. uninst.exe: inst.exe copy inst.exe uninst.exe inst.exe: inst.c $(CC) $(CFLAGSEXE) inst.c odbc32.lib odbccp32.lib \ kernel32.lib user32.lib remdsn.exe: adddsn.exe copy adddsn.exe remdsn.exe adddsn.exe: adddsn.c $(CC) $(CFLAGSEXE) adddsn.c odbc32.lib odbccp32.lib \ kernel32.lib user32.lib remsysdsn.exe: adddsn.exe copy adddsn.exe remsysdsn.exe addsysdsn.exe: adddsn.exe copy adddsn.exe addsysdsn.exe fixup.exe: fixup.c $(CC) $(CFLAGSEXE) fixup.c mkopc3.exe: mkopc3.c $(CC) $(CFLAGSEXE) mkopc3.c SQLiteODBCInstaller.exe: SQLiteODBCInstaller.c $(CC) $(CFLAGSEXE) SQLiteODBCInstaller.c \ kernel32.lib user32.lib sqlite3odbc.c: resource3.h sqlite3odbc.res: sqlite3odbc.rc resource3.h $(RC) -I. -fo sqlite3odbc.res -r sqlite3odbc.rc sqlite3odbc.dll: $(OBJECTS) sqlite3odbc.res $(LN) $(DLLLFLAGS) $(OBJECTS) sqlite3odbc.res \ -def:sqlite3odbc.def -out:$@ $(DLLLIBS) VERSION_C: fixup.exe VERSION .\fixup < VERSION > VERSION_C . , resource3.h: resource.h.in VERSION_C fixup.exe .\fixup < resource.h.in > resource3.h \ --VERS-- @VERSION \ --VERS_C-- @VERSION_C ./sqliteodbc-0.992/sqlite3odbc.def0100644000076400001440000000233410473774465015447 0ustar chwusersLIBRARY SQLITE3ODBC DESCRIPTION 'SQLite3 ODBC Driver ' SEGMENTS DLL_TEXT PRELOAD INIT_TEXT PRELOAD HEAPSIZE 1024 EXPORTS SQLBulkOperations SQLDataSourcesW SQLDriversW SQLBrowseConnectW SQLPutData SQLBindParameter SQLBindParam SQLNumParams SQLParamData SQLDescribeParam SQLSetParam SQLParamOptions SQLTablePrivilegesW SQLColumnPrivilegesW SQLPrimaryKeysW SQLSpecialColumnsW SQLForeignKeysW SQLEndTran SQLTransact SQLNativeSqlW SQLProceduresW SQLProcedureColumnsW SQLGetEnvAttr SQLSetEnvAttr SQLGetDiagRecW SQLGetDiagFieldW SQLGetStmtOptionW SQLSetStmtOptionW SQLGetStmtOption SQLSetStmtOption SQLSetPos SQLSetScrollOptions SQLGetInfoW SQLGetFunctions SQLGetConnectAttrW SQLSetConnectAttrW SQLGetConnectOptionW SQLSetConnectOptionW SQLConnectW SQLDisconnect SQLDriverConnectW SQLCancel SQLGetCursorNameW SQLSetCursorNameW SQLCloseCursor SQLBindCol SQLTablesW SQLColumnsW SQLGetTypeInfoW SQLStatisticsW SQLGetData SQLFetch SQLFetchScroll SQLExtendedFetch SQLRowCount SQLNumResultCols SQLDescribeColW SQLColAttributesW SQLColAttributeW SQLErrorW SQLMoreResults SQLPrepareW SQLExecute SQLExecDirectW SQLAllocHandle SQLFreeHandle SQLGetStmtAttrW SQLSetStmtAttrW SQLAllocStmt SQLFreeStmt SQLAllocConnect SQLFreeConnect ConfigDSN install uninstall ./sqliteodbc-0.992/sqlite4odbc.c0100644000076400001440000155616012113324642015125 0ustar chwusers/** * @file sqlite4odbc.c * SQLite4 ODBC Driver main module. * * $Id: sqlite4odbc.c,v 1.2 2013/02/27 06:36:58 chw Exp chw $ * * Copyright (c) 2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #if defined(SQLITE_HAS_CODEC) && defined(SQLITE_API) #undef WITH_SQLITE_DLLS #undef SQLITE_DYNLOAD #include "sqlite4.c" #endif #if defined(WITH_SQLITE_DLLS) && (WITH_SQLITE_DLLS > 1) #define SQLITE_DYNLOAD 1 #endif #include "sqlite4odbc.h" #ifdef SQLITE_DYNLOAD #undef MEMORY_DEBUG #if defined(_WIN32) || defined(_WIN64) static void dls_init(void); static void dls_fini(void); #else void dls_init(void); void dls_fini(void); #endif static struct dl_sqlite4_funcs { int (*bind_blob)(sqlite4_stmt *p0, int p1, const void *p2, int p3, void (*p4)(void *)); int (*bind_double)(sqlite4_stmt *p0, int p1, double p2); int (*bind_int)(sqlite4_stmt *p0, int p1, int p2); int (*bind_int64)(sqlite4_stmt *p0, int p1, sqlite4_int64 p2); int (*bind_null)(sqlite4_stmt *p0, int p1); int (*bind_parameter_count)(sqlite4_stmt *p0); int (*bind_text)(sqlite4_stmt *p0, int p1, const char *p2, int p3, void (*p4)(void *)); int (*changes)(sqlite4 *p0); int (*close)(sqlite4 *p0); const void * (*column_blob)(sqlite4_stmt *p0, int p1); int (*column_bytes)(sqlite4_stmt *p0, int p1); int (*column_count)(sqlite4_stmt *p0); const char * (*column_database_name)(sqlite4_stmt *p0, int p1); const char * (*column_decltype)(sqlite4_stmt *p0, int p1); double (*column_double)(sqlite4_stmt *p0); const char * (*column_name)(sqlite4_stmt *p0, int p1); const char * (*column_origin_name)(sqlite4_stmt *p0, int p1); const char * (*column_table_name)(sqlite4_stmt *p0, int p1); const unsigned char * (*column_text)(sqlite4_stmt *p0, int p1); int (*column_type)(sqlite4_stmt *p0, int p1); int (*create_function)(sqlite4 *p0, const char *p1, int p2, int p3, void *p4, void (*p5)(sqlite4_context *, int, sqlite4_value **), void (*p6)(sqlite4_context *, int, sqlite4_value **), void (*p7)(sqlite4_context *)); int (*errcode)(sqlite4 *p0); const char * (*errmsg)(sqlite4 *p0); int (*exec)(sqlite4 *p0, const char *p1, int (*p2)(void *, int, char **, char **), void *p3, char **p4); int (*finalize)(sqlite4_stmt *p0); void (*free)(sqlite4_env *p0, void *p1); void (*interrupt)(sqlite4 *p0); const char * (*libversion)(void); #if 0 int (*load_extension)(sqlite4 *p0, const char *p1, const char *p2, char **p3); #endif void * (*malloc)(sqlite4_env *p0, int p1); char * (*mprintf)(sqlite4_env *p0, const char *p1, ...); int (*open)(sqlite4_env *p0, const char *p1, sqlite4 **p2, ...); int (*prepare)(sqlite4 *p0, const char *p1, int p2, sqlite4_stmt **p3, const char **p4); void * (*profile)(sqlite4 *p0, void (*p1)(void *, const char *, sqlite4_uint64), void *p2); void * (*realloc)(sqlite4_env *p0, void *p1, int p2); int (*reset)(sqlite4_stmt *p0); void (*result_blob)(sqlite4_context *p0, const void *p1, int p2, void (*p3)(void *)); void (*result_error)(sqlite4_context *p0, const char *p1, int p2); void (*result_int)(sqlite4_context *p0, int p1); void (*result_null)(sqlite4_context *p0); int (*step)(sqlite4_stmt *p0); int (*xstrnicmp)(const char *p0, const char *p1, int p2); #if 0 int (*table_column_metadata)(sqlite4 *p0, const char *p1, const char *p2, const char *p3, char const **p4, char const **p5, int *p6, int *p7, int *p8); #endif void * (*trace)(sqlite4 *p0, void (*p1)(void *, const char *), void *p2); void * (*user_data)(sqlite4_context *p0); const void * (*value_blob)(sqlite4_value *p0); int (*value_bytes)(sqlite4_value *p0); const unsigned char * (*value_text)(sqlite4_value *p0); int (*value_type)(sqlite4_value *p0); } dls_funcs; #define sqlite4_bind_blob dls_funcs.bind_blob #define sqlite4_bind_double dls_funcs.bind_double #define sqlite4_bind_int dls_funcs.bind_int #define sqlite4_bind_int64 dls_funcs.bind_int64 #define sqlite4_bind_null dls_funcs.bind_null #define sqlite4_bind_parameter_count dls_funcs.bind_parameter_count #define sqlite4_bind_text dls_funcs.bind_text #define sqlite4_changes dls_funcs.changes #define sqlite4_close dls_funcs.close #define sqlite4_column_blob dls_funcs.column_blob #define sqlite4_column_bytes dls_funcs.column_bytes #define sqlite4_column_count dls_funcs.column_count #define sqlite4_column_database_name dls_funcs.column_database_name #define sqlite4_column_decltype dls_funcs.column_decltype #define sqlite4_column_double dls_funcs.column_double #define sqlite4_column_name dls_funcs.column_name #define sqlite4_column_origin_name dls_funcs.column_origin_name #define sqlite4_column_table_name dls_funcs.column_table_name #define sqlite4_column_text dls_funcs.column_text #define sqlite4_column_type dls_funcs.column_type #define sqlite4_create_function dls_funcs.create_function #define sqlite4_errcode dls_funcs.errcode #define sqlite4_errmsg dls_funcs.errmsg #define sqlite4_exec dls_funcs.exec #define sqlite4_finalize dls_funcs.finalize #define sqlite4_free dls_funcs.free #define sqlite4_interrupt dls_funcs.interrupt #define sqlite4_libversion dls_funcs.libversion #if 0 #define sqlite4_load_extension dls_funcs.load_extension #endif #define sqlite4_malloc dls_funcs.malloc #define sqlite4_mprintf dls_funcs.mprintf #define sqlite4_open dls_funcs.open #define sqlite4_prepare dls_funcs.prepare #define sqlite4_profile dls_funcs.profile #define sqlite4_realloc dls_funcs.realloc #define sqlite4_reset dls_funcs.reset #define sqlite4_result_blob dls_funcs.result_blob #define sqlite4_result_error dls_funcs.result_error #define sqlite4_result_int dls_funcs.result_int #define sqlite4_result_null dls_funcs.result_null #define sqlite4_step dls_funcs.step #define sqlite4_strnicmp dls_funcs.xstrnicmp #if 0 #define sqlite4_table_column_metadata dls_funcs.table_column_metadata #endif #define sqlite4_trace dls_funcs.trace #define sqlite4_user_data dls_funcs.user_data #define sqlite4_value_blob dls_funcs.value_blob #define sqlite4_value_bytes dls_funcs.value_bytes #define sqlite4_value_text dls_funcs.value_text #define sqlite4_value_type dls_funcs.value_type #endif #ifndef WITHOUT_WINTERFACE #define WINTERFACE #define WCHARSUPPORT #endif #if !defined(_WIN32) && !defined(_WIN64) #if !defined(WCHARSUPPORT) && defined(HAVE_SQLWCHAR) && (HAVE_SQLWCHAR) #define WCHARSUPPORT #endif #endif #if defined(WINTERFACE) #include #endif #if defined(_WIN32) || defined(_WIN64) #include "resource3.h" #define ODBC_INI "ODBC.INI" #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO VERSION #endif #else #define ODBC_INI ".odbc.ini" #endif #ifndef DRIVER_VER_INFO #define DRIVER_VER_INFO "0.0" #endif #ifndef COLATTRIBUTE_LAST_ARG_TYPE #ifdef _WIN64 #define COLATTRIBUTE_LAST_ARG_TYPE SQLLEN * #else #define COLATTRIBUTE_LAST_ARG_TYPE SQLPOINTER #endif #endif #ifndef SETSTMTOPTION_LAST_ARG_TYPE #define SETSTMTOPTION_LAST_ARG_TYPE SQLROWCOUNT #endif #undef min #define min(a, b) ((a) < (b) ? (a) : (b)) #undef max #define max(a, b) ((a) < (b) ? (b) : (a)) #ifndef PTRDIFF_T #define PTRDIFF_T int #endif #define array_size(x) (sizeof (x) / sizeof (x[0])) #define stringify1(s) #s #define stringify(s) stringify1(s) #define verinfo(maj, min, lev) ((maj) << 16 | (min) << 8 | (lev)) /* Column types for static string column descriptions (SQLTables etc.) */ #if defined(WINTERFACE) && !defined(_WIN32) && !defined(_WIN64) #define SCOL_VARCHAR SQL_WVARCHAR #define SCOL_CHAR SQL_WCHAR #else #define SCOL_VARCHAR SQL_VARCHAR #define SCOL_CHAR SQL_CHAR #endif #define ENV_MAGIC 0x53544145 #define DBC_MAGIC 0x53544144 #define DEAD_MAGIC 0xdeadbeef static const char *xdigits = "0123456789ABCDEFabcdef"; #ifdef MEMORY_DEBUG static void * xmalloc_(int n, char *file, int line) { int nn = n + 4 * sizeof (long); long *p; p = malloc(nn); if (!p) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\tNULL\t%s:%d\n", n, file, line); #endif return NULL; } p[0] = 0xdead1234; nn = nn / sizeof (long) - 1; p[1] = n; p[nn] = 0xdead5678; #if (MEMORY_DEBUG > 1) fprintf(stderr, "malloc\t%d\t%p\t%s:%d\n", n, &p[2], file, line); #endif return (void *) &p[2]; } static void * xrealloc_(void *old, int n, char *file, int line) { int nn = n + 4 * sizeof (long), nnn; long *p, *pp; if (n == 0 || !old) { return xmalloc_(n, file, line); } p = &((long *) old)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", old); abort(); } nnn = p[1] + 4 * sizeof (long); nnn = nnn / sizeof (long) - 1; if (p[nnn] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", old); abort(); } pp = realloc(p, nn); if (!pp) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\tNULL\t%s:%d\n", old, n, file, line); #endif return NULL; } #if (MEMORY_DEBUG > 1) fprintf(stderr, "realloc\t%p,%d\t%p\t%s:%d\n", old, n, &pp[2], file, line); #endif p = pp; p[1] = n; nn = nn / sizeof (long) - 1; p[nn] = 0xdead5678; return (void *) &p[2]; } static void xfree_(void *x, char *file, int line) { long *p; int n; if (!x) { return; } p = &((long *) x)[-2]; if (p[0] != 0xdead1234) { fprintf(stderr, "*** low end corruption @ %p\n", x); abort(); } n = p[1] + 4 * sizeof (long); n = n / sizeof (long) - 1; if (p[n] != 0xdead5678) { fprintf(stderr, "*** high end corruption @ %p\n", x); abort(); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "free\t%p\t\t%s:%d\n", x, file, line); #endif free(p); } static void xfree__(void *x) { xfree_(x, "unknown location", 0); } static char * xstrdup_(const char *str, char *file, int line) { char *p; if (!str) { #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\tNULL\tNULL\t%s:%d\n", file, line); #endif return NULL; } p = xmalloc_(strlen(str) + 1, file, line); if (p) { strcpy(p, str); } #if (MEMORY_DEBUG > 1) fprintf(stderr, "strdup\t%p\t%p\t%s:%d\n", str, p, file, line); #endif return p; } #define xmalloc(x) xmalloc_(x, __FILE__, __LINE__) #define xrealloc(x,y) xrealloc_(x, y, __FILE__, __LINE__) #define xfree(x) xfree_(x, __FILE__, __LINE__) #define xstrdup(x) xstrdup_(x, __FILE__, __LINE__) #else #define xmalloc(x) sqlite4_malloc(0, x) #define xrealloc(x,y) sqlite4_realloc(0, x, y) #define xfree(x) sqlite4_free(0, x) #define xstrdup(x) strdup_(x) #endif #if defined(_WIN32) || defined(_WIN64) #define vsnprintf _vsnprintf #define snprintf _snprintf #define strcasecmp _stricmp #define strncasecmp _strnicmp static HINSTANCE NEAR hModule; /* Saved module handle for resources */ #endif #undef strncasecmp #define strncasecmp(A,B,C) sqlite4_strnicmp(A,B,C) #undef strcasecmp #define strcasecmp(A,B) strcasecmp_(A,B) #if defined(__GNUC__) && (__GNUC__ >= 2) static int strcasecmp_(const char *a, const char *b) __attribute__((__unused__)); #endif static int strcasecmp_(const char *a, const char *b) { int c = strlen(a), d = strlen(b); if (c > d) { return strncasecmp(a, b, c); } return strncasecmp(a, b, d); } #if defined(_WIN32) || defined(_WIN64) /* * SQLHENV, SQLHDBC, and SQLHSTMT synchronization * is done using a critical section in ENV structure. */ #define HDBC_LOCK(hdbc) \ { \ DBC *d; \ \ if ((hdbc) == SQL_NULL_HDBC) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) (hdbc); \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HDBC_UNLOCK(hdbc) \ if ((hdbc) != SQL_NULL_HDBC) { \ DBC *d; \ \ d = (DBC *) (hdbc); \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #define HSTMT_LOCK(hstmt) \ { \ DBC *d; \ \ if ((hstmt) == SQL_NULL_HSTMT) { \ return SQL_INVALID_HANDLE; \ } \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic != DBC_MAGIC || !d->env) { \ return SQL_INVALID_HANDLE; \ } \ if (d->env->magic != ENV_MAGIC) { \ return SQL_INVALID_HANDLE; \ } \ EnterCriticalSection(&d->env->cs); \ d->env->owner = GetCurrentThreadId(); \ } #define HSTMT_UNLOCK(hstmt) \ if ((hstmt) != SQL_NULL_HSTMT) { \ DBC *d; \ \ d = (DBC *) ((STMT *) (hstmt))->dbc; \ if (d->magic == DBC_MAGIC && d->env && \ d->env->magic == ENV_MAGIC) { \ d->env->owner = 0; \ LeaveCriticalSection(&d->env->cs); \ } \ } #else /* * On UN*X assume that we are single-threaded or * the driver manager provides serialization for us. * * In iODBC (3.52.x) serialization can be turned * on using the DSN property "ThreadManager=yes". * * In unixODBC that property is named * "Threading=0-3" and takes one of these values: * * 0 - no protection * 1 - statement level protection * 2 - connection level protection * 3 - environment level protection * * unixODBC 2.2.11 uses environment level protection * by default when it has been built with pthread * support. */ #define HDBC_LOCK(hdbc) #define HDBC_UNLOCK(hdbc) #define HSTMT_LOCK(hdbc) #define HSTMT_UNLOCK(hdbc) #endif /* * tolower() replacement w/o locale */ static const char upper_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char lower_chars[] = "abcdefghijklmnopqrstuvwxyz"; static int TOLOWER(int c) { if (c) { char *p = strchr(upper_chars, c); if (p) { c = lower_chars[p - upper_chars]; } } return c; } /* * isdigit() replacement w/o ctype.h */ static const char digit_chars[] = "0123456789"; #define ISDIGIT(c) \ ((c) && strchr(digit_chars, (c)) != NULL) /* * isspace() replacement w/o ctype.h */ static const char space_chars[] = " \f\n\r\t\v"; #define ISSPACE(c) \ ((c) && strchr(space_chars, (c)) != NULL) /* * Forward declarations of static functions. */ static void dbtraceapi(DBC *d, char *fn, const char *sql); static void freedyncols(STMT *s); static void freeresult(STMT *s, int clrcols); static void freerows(char **rowp); static void unbindcols(STMT *s); static void s4stmt_drop(STMT *s); static SQLRETURN drvexecute(SQLHSTMT stmt, int initial); static SQLRETURN freestmt(HSTMT stmt); static SQLRETURN mkbindcols(STMT *s, int ncols); static SQLRETURN setupdyncols(STMT *s, sqlite4_stmt *s4stmt, int *ncolsp); static SQLRETURN setupparbuf(STMT *s, BINDPARM *p); static SQLRETURN starttran(STMT *s); static SQLRETURN setupparam(STMT *s, char *sql, int pnum); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 1 (reserved error -7748) */ static COL *statSpec2P, *statSpec3P; #endif #if (MEMORY_DEBUG < 1) /** * Duplicate string using xmalloc(). * @param str string to be duplicated * @result pointer to new string or NULL */ static char * strdup_(const char *str) { char *p = NULL; if (str) { p = xmalloc(strlen(str) + 1); if (p) { strcpy(p, str); } } return p; } #endif #ifdef WCHARSUPPORT /** * Return length of UNICODE string. * @param str UNICODE string * @result length of string in characters */ static int uc_strlen(SQLWCHAR *str) { int len = 0; if (str) { while (*str) { ++len; ++str; } } return len; } /** * Copy UNICODE string like strncpy(). * @param dest destination area * @param src source area * @param len length of source area in characters * @return pointer to destination area */ static SQLWCHAR * uc_strncpy(SQLWCHAR *dest, SQLWCHAR *src, int len) { int i = 0; while (i < len) { if (!src[i]) { break; } dest[i] = src[i]; ++i; } if (i < len) { dest[i] = 0; } return dest; } /** * Make UNICODE string from UTF8 string into buffer. * @param str UTF8 string to be converted * @param len length in characters of str or -1 * @param uc destination area to receive UNICODE string * @param ucLen byte length of destination area */ static void uc_from_utf_buf(unsigned char *str, int len, SQLWCHAR *uc, int ucLen) { ucLen = ucLen / sizeof (SQLWCHAR); if (!uc || ucLen < 0) { return; } if (len < 0) { len = ucLen * 5; } uc[0] = 0; if (str) { int i = 0; while (i < len && *str && i < ucLen) { unsigned char c = str[0]; if (c < 0x80) { uc[i++] = c; ++str; } else if (c <= 0xc1 || c >= 0xf5) { /* illegal, ignored */ ++str; } else if (c < 0xe0) { if ((str[1] & 0xc0) == 0x80) { unsigned long t = ((c & 0x1f) << 6) | (str[1] & 0x3f); uc[i++] = t; str += 2; } else { uc[i++] = c; ++str; } } else if (c < 0xf0) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80) { unsigned long t = ((c & 0x0f) << 12) | ((str[1] & 0x3f) << 6) | (str[2] & 0x3f); uc[i++] = t; str += 3; } else { uc[i++] = c; ++str; } } else if (c < 0xf8) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80) { unsigned long t = ((c & 0x03) << 18) | ((str[1] & 0x3f) << 12) | ((str[2] & 0x3f) << 6) | (str[3] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 4; } else { uc[i++] = c; ++str; } } else if (c < 0xfc) { if ((str[1] & 0xc0) == 0x80 && (str[2] & 0xc0) == 0x80 && (str[3] & 0xc0) == 0x80 && (str[4] & 0xc0) == 0x80) { unsigned long t = ((c & 0x01) << 24) | ((str[1] & 0x3f) << 18) | ((str[2] & 0x3f) << 12) | ((str[3] & 0x3f) << 6) | (str[4] & 0x3f); if (sizeof (SQLWCHAR) == 2 * sizeof (char) && t >= 0x10000) { t -= 0x10000; uc[i++] = 0xd800 | ((t >> 10) & 0x3ff); if (i >= ucLen) { break; } t = 0xdc00 | (t & 0x3ff); } uc[i++] = t; str += 5; } else { uc[i++] = c; ++str; } } else { /* ignore */ ++str; } } if (i < ucLen) { uc[i] = 0; } } } /** * Make UNICODE string from UTF8 string. * @param str UTF8 string to be converted * @param len length of UTF8 string * @return alloc'ed UNICODE string to be free'd by uc_free() */ static SQLWCHAR * uc_from_utf(unsigned char *str, int len) { SQLWCHAR *uc = NULL; int ucLen; if (str) { if (len == SQL_NTS) { len = strlen((char *) str); } ucLen = sizeof (SQLWCHAR) * (len + 1); uc = xmalloc(ucLen); if (uc) { uc_from_utf_buf(str, len, uc, ucLen); } } return uc; } /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in bytes * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf(SQLWCHAR *str, int len) { int i; char *cp, *ret = NULL; if (!str) { return ret; } if (len == SQL_NTS) { len = uc_strlen(str); } else { len = len / sizeof (SQLWCHAR); } cp = xmalloc(len * 6 + 1); if (!cp) { return ret; } ret = cp; for (i = 0; i < len; i++) { unsigned long c = str[i]; if (sizeof (SQLWCHAR) == 2 * sizeof (char)) { c &= 0xffff; } if (c < 0x80) { *cp++ = c; } else if (c < 0x800) { *cp++ = 0xc0 | ((c >> 6) & 0x1f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x10000) { if (sizeof (SQLWCHAR) == 2 * sizeof (char) && c >= 0xd800 && c <= 0xdbff && i + 1 < len) { unsigned long c2 = str[i + 1] & 0xffff; if (c2 >= 0xdc00 && c2 <= 0xdfff) { c = (((c & 0x3ff) << 10) | (c2 & 0x3ff)) + 0x10000; *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); ++i; continue; } } *cp++ = 0xe0 | ((c >> 12) & 0x0f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x200000) { *cp++ = 0xf0 | ((c >> 18) & 0x07); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x4000000) { *cp++ = 0xf8 | ((c >> 24) & 0x03); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } else if (c < 0x80000000) { *cp++ = 0xfc | ((c >> 31) & 0x01); *cp++ = 0x80 | ((c >> 24) & 0x3f); *cp++ = 0x80 | ((c >> 18) & 0x3f); *cp++ = 0x80 | ((c >> 12) & 0x3f); *cp++ = 0x80 | ((c >> 6) & 0x3f); *cp++ = 0x80 | (c & 0x3f); } } *cp = '\0'; return ret; } #endif #ifdef WINTERFACE /** * Make UTF8 string from UNICODE string. * @param str UNICODE string to be converted * @param len length of UNICODE string in characters * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * uc_to_utf_c(SQLWCHAR *str, int len) { if (len != SQL_NTS) { len = len * sizeof (SQLWCHAR); } return uc_to_utf(str, len); } #endif #if defined(WCHARSUPPORT) || defined(_WIN32) || defined(_WIN64) /** * Free converted UTF8 or UNICODE string. * @param str string to be free'd */ static void uc_free(void *str) { if (str) { xfree(str); } } #endif #if defined(_WIN32) || defined(_WIN64) /** * Convert multibyte, current code page string to UTF8 string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * wmb_to_utf(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(cp, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(cp, 0, str, len, wstr, nchar); wstr[nchar] = 0; str = xmalloc((nchar + 1) * 7); if (!str) { xfree(wstr); return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, nchar * 7, 0, 0); str[nchar] = '\0'; xfree(wstr); return str; } #ifndef WINTERFACE /** * Convert multibyte, current code page string to UTF8 string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UTF8 string to be free'd by uc_free() */ static char * wmb_to_utf_c(char *str, int len) { if (len == SQL_NTS) { len = strlen(str); } return wmb_to_utf(str, len); } #endif /** * Convert UTF8 string to multibyte, current code page string, * @param str UTF8 string to be converted * @param len length of UTF8 string * @return alloc'ed multibyte string to be free'd by uc_free() */ static char * utf_to_wmb(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(CP_UTF8, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(CP_UTF8, 0, str, len, wstr, nchar); wstr[nchar] = 0; str = xmalloc((nchar + 1) * 7); if (!str) { xfree(wstr); return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(cp, 0, wstr, -1, str, nchar * 7, 0, 0); str[nchar] = '\0'; xfree(wstr); return str; } #ifdef WINTERFACE /** * Convert multibyte, current code page string to UNICODE string, * @param str multibyte string to be converted * @param len length of multibyte string * @return alloc'ed UNICODE string to be free'd by uc_free() */ static WCHAR * wmb_to_uc(char *str, int len) { WCHAR *wstr; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = MultiByteToWideChar(cp, 0, str, len, NULL, 0); wstr = xmalloc((nchar + 1) * sizeof (WCHAR)); if (!wstr) { return NULL; } wstr[0] = 0; nchar = MultiByteToWideChar(cp, 0, str, len, wstr, nchar); wstr[nchar] = 0; return wstr; } /** * Convert UNICODE string to multibyte, current code page string, * @param str UNICODE string to be converted * @param len length of UNICODE string * @return alloc'ed multibyte string to be free'd by uc_free() */ static char * uc_to_wmb(WCHAR *wstr, int len) { char *str; OSVERSIONINFO ovi; int nchar, is2k, cp = CP_OEMCP; ovi.dwOSVersionInfoSize = sizeof (ovi); GetVersionEx(&ovi); is2k = ovi.dwPlatformId == VER_PLATFORM_WIN32_NT && ovi.dwMajorVersion > 4; if (AreFileApisANSI()) { cp = is2k ? CP_THREAD_ACP : CP_ACP; } nchar = WideCharToMultiByte(cp, 0, wstr, len, NULL, 0, 0, 0); str = xmalloc((nchar + 1) * 2); if (!str) { return NULL; } str[0] = '\0'; nchar = WideCharToMultiByte(cp, 0, wstr, len, str, nchar * 2, 0, 0); str[nchar] = '\0'; return str; } #endif /* WINTERFACE */ #endif /* _WIN32 || _WIN64 */ #ifdef USE_DLOPEN_FOR_GPPS #include #define SQLGetPrivateProfileString(A,B,C,D,E,F) drvgpps(d,A,B,C,D,E,F) /* * EXPERIMENTAL: SQLGetPrivateProfileString infrastructure using * dlopen(), in theory this makes the driver independent from the * driver manager, i.e. the same driver binary can run with iODBC * and unixODBC. */ static void drvgetgpps(DBC *d) { void *lib; int (*gpps)(); lib = dlopen("libodbcinst.so.1", RTLD_LAZY); if (!lib) { lib = dlopen("libodbcinst.so", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so.2", RTLD_LAZY); } if (!lib) { lib = dlopen("libiodbcinst.so", RTLD_LAZY); } if (lib) { gpps = (int (*)()) dlsym(lib, "SQLGetPrivateProfileString"); if (!gpps) { dlclose(lib); return; } d->instlib = lib; d->gpps = gpps; } } static void drvrelgpps(DBC *d) { if (d->instlib) { dlclose(d->instlib); d->instlib = 0; } } static int drvgpps(DBC *d, char *sect, char *ent, char *def, char *buf, int bufsiz, char *fname) { if (d->gpps) { return d->gpps(sect, ent, def, buf, bufsiz, fname); } strncpy(buf, def, bufsiz); buf[bufsiz - 1] = '\0'; return 1; } #else #include #define drvgetgpps(d) #define drvrelgpps(d) #endif /* * Internal function to bind sqlite4 parameters. */ static void s4bind(DBC *d, sqlite4_stmt *stmt, int nparams, BINDPARM *p) { int i; if (stmt && p && nparams > 0) { for (i = 0; i < nparams; i++, p++) { switch (p->s4type) { default: case SQLITE4_NULL: sqlite4_bind_null(stmt, i + 1); if (d->trace) { fprintf(d->trace, "-- parameter %d: NULL\n", i + 1); fflush(d->trace); } break; case SQLITE4_TEXT: sqlite4_bind_text(stmt, i + 1, p->s4val, p->s4size, SQLITE4_STATIC); if (d->trace) { fprintf(d->trace, "-- parameter %d: '%*s'\n", i + 1, p->s4size, (char *) p->s4val); fflush(d->trace); } break; case SQLITE4_BLOB: sqlite4_bind_blob(stmt, i + 1, p->s4val, p->s4size, SQLITE4_STATIC); if (d->trace) { fprintf(d->trace, "-- parameter %d: [BLOB]'\n", i + 1); fflush(d->trace); } break; case SQLITE4_FLOAT: sqlite4_bind_double(stmt, i + 1, p->s4dval); if (d->trace) { fprintf(d->trace, "-- parameter %d: %g\n", i + 1, p->s4dval); fflush(d->trace); } break; case SQLITE4_INTEGER: if (p->s4size > sizeof (int)) { sqlite4_bind_int64(stmt, i + 1, p->s4lival); if (d->trace) { fprintf(d->trace, #ifdef _WIN32 "-- parameter %d: %I64d\n", #else "-- parameter %d: %lld\n", #endif i + 1, p->s4lival); fflush(d->trace); } } else { sqlite4_bind_int(stmt, i + 1, p->s4ival); if (d->trace) { fprintf(d->trace, "-- parameter %d: %d\n", i + 1, p->s4ival); fflush(d->trace); } } break; } } } } /** * @typedef TBLRES * @struct tblres * Internal structure for managing driver's * sqlite4_get_table() implementation. */ typedef struct tblres { char **resarr; /**< result array */ char *errmsg; /**< error message or NULL */ sqlite4_stmt *stmt; /**< sqlite4 statement pointer */ STMT *s; /**< Driver statement pointer */ int nalloc; /**< alloc'ed size of result array */ int nrow; /**< number of rows in result array */ int ncol; /**< number of columns in result array */ PTRDIFF_T ndata; /**< index into result array */ int rc; /**< SQLite return code */ } TBLRES; /* * Driver's version of sqlite4_get_table() and friends which are * capable of dealing with blobs. */ static int drvgettable_row(TBLRES *t, int ncol, int rc) { int need; int i; char *p; if (t->nrow == 0 && rc == SQLITE4_ROW) { need = ncol * 2; } else { need = ncol; } if (t->ndata + need >= t->nalloc) { char **resnew; int nalloc = t->nalloc * 2 + need + 1; resnew = xrealloc(t->resarr, sizeof (char *) * nalloc); if (!resnew) { nomem: t->rc = SQLITE4_NOMEM; return 1; } t->nalloc = nalloc; t->resarr = resnew; } /* column names when first row */ if (t->nrow == 0) { t->ncol = ncol; for (i = 0; i < ncol; i++) { p = (char *) sqlite4_column_name(t->stmt, i); if (p) { char *q = xmalloc(strlen(p) + 1); if (!q) { goto nomem; } strcpy(q, p); p = q; } t->resarr[t->ndata++] = p; } if (t->s && t->s->guessed_types) { int ncol2 = ncol; setupdyncols(t->s, t->stmt, &ncol2); t->s->guessed_types = 0; t->s->ncols = ncol; } } else if (t->ncol != ncol) { t->errmsg = sqlite4_mprintf(0, "drvgettable() called with two or" " more incompatible queries"); t->rc = SQLITE4_ERROR; return 1; } /* copy row data */ if (rc == SQLITE4_ROW) { for (i = 0; i < ncol; i++) { int coltype = sqlite4_column_type(t->stmt, i); p = NULL; if (coltype == SQLITE4_BLOB) { int k, nbytes = sqlite4_column_bytes(t->stmt, i); char *qp; unsigned const char *bp; bp = sqlite4_column_blob(t->stmt, i); qp = xmalloc(nbytes * 2 + 4); if (!qp) { goto nomem; } p = qp; *qp++ = 'X'; *qp++ = '\''; for (k = 0; k < nbytes; k++) { *qp++ = xdigits[(bp[k] >> 4)]; *qp++ = xdigits[(bp[k] & 0xF)]; } *qp++ = '\''; *qp = '\0'; } else if (coltype != SQLITE4_NULL) { p = xstrdup((char *) sqlite4_column_text(t->stmt, i)); if (!p) { goto nomem; } } t->resarr[t->ndata++] = p; } t->nrow++; } return 0; } static int drvgettable(STMT *s, const char *sql, char ***resp, int *nrowp, int *ncolp, char **errp, int nparam, BINDPARM *p) { DBC *d = (DBC *) s->dbc; int rc = SQLITE4_OK, keep = sql == NULL; TBLRES tres; const char *sqlleft = 0; int nretry = 0, haveerr = 0; if (!resp) { return SQLITE4_ERROR; } *resp = NULL; if (nrowp) { *nrowp = 0; } if (ncolp) { *ncolp = 0; } tres.errmsg = NULL; tres.nrow = 0; tres.ncol = 0; tres.ndata = 1; tres.nalloc = 20; tres.rc = SQLITE4_OK; tres.resarr = xmalloc(sizeof (char *) * tres.nalloc); tres.stmt = NULL; tres.s = s; if (!tres.resarr) { return SQLITE4_NOMEM; } tres.resarr[0] = 0; if (sql == NULL) { tres.stmt = s->s4stmt; if (tres.stmt == NULL) { return SQLITE4_NOMEM; } goto retrieve; } while (sql && *sql && (rc == SQLITE4_OK || (rc == SQLITE4_SCHEMA && (++nretry) < 2))) { int ncol; tres.stmt = NULL; dbtraceapi(d, "sqlite4_prepare", sql); rc = sqlite4_prepare(d->sqlite, sql, -1, &tres.stmt, &sqlleft); if (rc != SQLITE4_OK) { if (tres.stmt) { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(tres.stmt); tres.stmt = NULL; } continue; } if (!tres.stmt) { /* this happens for a comment or white-space */ sql = sqlleft; continue; } retrieve: if (sqlite4_bind_parameter_count(tres.stmt) != nparam) { if (errp) { *errp = sqlite4_mprintf(0, "%s", "parameter marker count incorrect"); } haveerr = 1; rc = SQLITE4_ERROR; goto tbldone; } s4bind(d, tres.stmt, nparam, p); ncol = sqlite4_column_count(tres.stmt); while (1) { if (s->max_rows && tres.nrow >= s->max_rows) { rc = SQLITE4_OK; break; } rc = sqlite4_step(tres.stmt); if (rc == SQLITE4_ROW || rc == SQLITE4_DONE) { if (drvgettable_row(&tres, ncol, rc)) { rc = SQLITE4_ABORT; goto tbldone; } } if (rc != SQLITE4_ROW) { if (keep) { dbtraceapi(d, "sqlite4_reset", 0); rc = sqlite4_reset(tres.stmt); s->s4stmt_noreset = 1; } else { dbtraceapi(d, "sqlite4_finalize", 0); rc = sqlite4_finalize(tres.stmt); } tres.stmt = 0; if (rc != SQLITE4_SCHEMA) { nretry = 0; sql = sqlleft; while (sql && ISSPACE(*sql)) { sql++; } } if (rc == SQLITE4_DONE) { rc = SQLITE4_OK; } break; } } } tbldone: if (tres.stmt) { if (keep) { if (!s->s4stmt_noreset) { dbtraceapi(d, "sqlite4_reset", 0); sqlite4_reset(tres.stmt); s->s4stmt_noreset = 1; } } else { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(tres.stmt); } } if (haveerr) { /* message already in *errp if any */ } else if (rc != SQLITE4_OK && rc == sqlite4_errcode(d->sqlite) && errp) { *errp = sqlite4_mprintf(0, "%s", sqlite4_errmsg(d->sqlite)); } else if (errp) { *errp = NULL; } if (tres.resarr) { tres.resarr[0] = (char *) (tres.ndata - 1); } if (rc == SQLITE4_ABORT) { freerows(&tres.resarr[1]); if (tres.errmsg) { if (errp) { if (*errp) { sqlite4_free(0, *errp); } *errp = tres.errmsg; } else { sqlite4_free(0, tres.errmsg); } } return tres.rc; } sqlite4_free(0, tres.errmsg); if (rc != SQLITE4_OK) { freerows(&tres.resarr[1]); return rc; } *resp = &tres.resarr[1]; if (ncolp) { *ncolp = tres.ncol; } if (nrowp) { *nrowp = tres.nrow; } return rc; } static int sqlite4_get_table(sqlite4 *db, const char *sql, char ***resp, int *nrowp, int *ncolp, char **errp) { int rc = SQLITE4_OK; TBLRES tres; const char *sqlleft = 0; int nretry = 0, haveerr = 0; if (!resp) { return SQLITE4_ERROR; } *resp = NULL; if (nrowp) { *nrowp = 0; } if (ncolp) { *ncolp = 0; } tres.errmsg = NULL; tres.nrow = 0; tres.ncol = 0; tres.ndata = 1; tres.nalloc = 20; tres.rc = SQLITE4_OK; tres.resarr = xmalloc(sizeof (char *) * tres.nalloc); tres.stmt = NULL; tres.s = 0; if (!tres.resarr) { return SQLITE4_NOMEM; } tres.resarr[0] = 0; while (sql && *sql && (rc == SQLITE4_OK || (rc == SQLITE4_SCHEMA && (++nretry) < 2))) { int ncol; tres.stmt = NULL; rc = sqlite4_prepare(db, sql, -1, &tres.stmt, &sqlleft); if (rc != SQLITE4_OK) { if (tres.stmt) { sqlite4_finalize(tres.stmt); tres.stmt = NULL; } continue; } if (!tres.stmt) { /* this happens for a comment or white-space */ sql = sqlleft; continue; } ncol = sqlite4_column_count(tres.stmt); while (1) { rc = sqlite4_step(tres.stmt); if (rc == SQLITE4_ROW || rc == SQLITE4_DONE) { if (drvgettable_row(&tres, ncol, rc)) { rc = SQLITE4_ABORT; goto tbldone; } } if (rc != SQLITE4_ROW) { rc = sqlite4_finalize(tres.stmt); tres.stmt = 0; if (rc != SQLITE4_SCHEMA) { nretry = 0; sql = sqlleft; while (sql && ISSPACE(*sql)) { sql++; } } if (rc == SQLITE4_DONE) { rc = SQLITE4_OK; } break; } } } tbldone: if (tres.stmt) { sqlite4_finalize(tres.stmt); } if (haveerr) { /* message already in *errp if any */ } else if (rc != SQLITE4_OK && rc == sqlite4_errcode(db) && errp) { *errp = sqlite4_mprintf(0, "%s", sqlite4_errmsg(db)); } else if (errp) { *errp = NULL; } if (tres.resarr) { tres.resarr[0] = (char *) (tres.ndata - 1); } if (rc == SQLITE4_ABORT) { freerows(&tres.resarr[1]); if (tres.errmsg) { if (errp) { if (*errp) { sqlite4_free(0, *errp); } *errp = tres.errmsg; } else { sqlite4_free(0, tres.errmsg); } } return tres.rc; } sqlite4_free(0, tres.errmsg); if (rc != SQLITE4_OK) { freerows(&tres.resarr[1]); return rc; } *resp = &tres.resarr[1]; if (ncolp) { *ncolp = tres.ncol; } if (nrowp) { *nrowp = tres.nrow; } return rc; } /** * Set error message and SQL state on DBC * @param d database connection pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstatd(DBC *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstatd(DBC *d, int naterr, char *msg, char *st, ...) { va_list ap; if (!d) { return; } d->naterr = naterr; d->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) d->logmsg, sizeof (d->logmsg), msg, ap); va_end(ap); if (count < 0) { d->logmsg[sizeof (d->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(d->sqlstate, st, 5); d->sqlstate[5] = '\0'; } /** * Set error message and SQL state on statement * @param s statement pointer * @param naterr native error code * @param msg error message * @param st SQL state */ #if defined(__GNUC__) && (__GNUC__ >= 2) static void setstat(STMT *, int, char *, char *, ...) __attribute__((format (printf, 3, 5))); #endif static void setstat(STMT *s, int naterr, char *msg, char *st, ...) { va_list ap; if (!s) { return; } s->naterr = naterr; s->logmsg[0] = '\0'; if (msg) { int count; va_start(ap, st); count = vsnprintf((char *) s->logmsg, sizeof (s->logmsg), msg, ap); va_end(ap); if (count < 0) { s->logmsg[sizeof (s->logmsg) - 1] = '\0'; } } if (!st) { st = "?????"; } strncpy(s->sqlstate, st, 5); s->sqlstate[5] = '\0'; } /** * Report IM001 (not implemented) SQL error code for HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvunimpldbc(HDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; setstatd(d, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Report IM001 (not implemented) SQL error code for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN drvunimplstmt(HSTMT stmt) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; setstat(s, -1, "not supported", "IM001"); return SQL_ERROR; } /** * Free memory given pointer to memory pointer. * @param x pointer to pointer to memory to be free'd */ static void freep(void *x) { if (x && ((char **) x)[0]) { xfree(((char **) x)[0]); ((char **) x)[0] = NULL; } } /** * Report S1000 (out of memory) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN nomem(STMT *s) { setstat(s, -1, "out of memory", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Report S1000 (not connected) SQL error given STMT. * @param s statement pointer * @result ODBC error code */ static SQLRETURN noconn(STMT *s) { setstat(s, -1, "not connected", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal locale neutral strtod function. * @param data pointer to string * @param endp pointer for ending character * @result double value */ #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) static double ln_strtod(const char *data, char **endp) { static struct lconv *lc = 0; char buf[128], *p, *end; double value; if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { strncpy(buf, data, sizeof (buf) - 1); buf[sizeof (buf) - 1] = '\0'; p = strchr(buf, '.'); if (p) { *p = lc->decimal_point[0]; } p = buf; } else { p = (char *) data; } value = strtod(p, &end); end = (char *) data + (end - p); if (endp) { *endp = end; } return value; } #else #define ln_strtod(A,B) strtod(A,B) #endif /** * Strip quotes from quoted string in-place. * @param str string */ static char * unquote(char *str) { if (str) { int len = strlen(str); if (len > 1) { if ((str[0] == '\'' && str[len - 1] == '\'') || (str[0] == '"' && str[len - 1] == '"') || (str[0] == '[' && str[len - 1] == ']')) { str[len - 1] = '\0'; strcpy(str, str + 1); } } } return str; } /** * Unescape search pattern for e.g. table name in * catalog functions. Replacements in string are done in-place. * @param str string * @result number of pattern characters in string or 0 */ static int unescpat(char *str) { char *p, *q; int count = 0; p = str; while ((q = strchr(p, '_')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '%')) != NULL) { if (q == str || q[-1] != '\\') { count++; } p = q + 1; } p = str; while ((q = strchr(p, '\\')) != NULL) { if (q[1] == '\\' || q[1] == '_' || q[1] == '%') { strcpy(q, q + 1); } p = q + 1; } return count; } /** * SQL LIKE string match with optional backslash escape handling. * @param str string * @param pat pattern * @param esc when true, treat literally "\\" as "\", "\%" as "%", "\_" as "_" * @result true when pattern matched */ static int namematch(char *str, char *pat, int esc) { int cp, ch; while (1) { cp = TOLOWER(*pat); if (cp == '\0') { if (*str != '\0') { goto nomatch; } break; } if (*str == '\0' && cp != '%') { goto nomatch; } if (cp == '%') { while (*pat == '%') { ++pat; } cp = TOLOWER(*pat); if (cp == '\0') { break; } while (1) { if (cp != '_' && cp != '\\') { while (*str) { ch = TOLOWER(*str); if (ch == cp) { break; } ++str; } } if (namematch(str, pat, esc)) { goto match; } if (*str == '\0') { goto nomatch; } ch = TOLOWER(*str); ++str; } } if (cp == '_') { pat++; str++; continue; } if (esc && cp == '\\' && (pat[1] == '\\' || pat[1] == '%' || pat[1] == '_')) { ++pat; cp = TOLOWER(*pat); } ch = TOLOWER(*str++); ++pat; if (ch != cp) { goto nomatch; } } match: return 1; nomatch: return 0; } /** * Set SQLite options (PRAGMAs) given SQLite handle. * @param x SQLite database handle * @param d DBC pointer * @result SQLite error code * * SQLite < 3.3.x and not shortnames DSN option: * "full_column_names" is always turned on and "short_column_names" * is always turned off, to get the table names in column labels. */ static int setsqliteopts(sqlite4 *x, DBC *d) { int count = 0, step = 0, max, rc = SQLITE4_ERROR; max = d->longnames ? 3 : 1; if (d->shortnames) { max = 3; } while (step < max) { if (step < 1) { rc = sqlite4_exec(x, "PRAGMA empty_result_callbacks = on;", NULL, NULL, NULL); if (rc == SQLITE4_OK) { rc = sqlite4_exec(x, d->fksupport ? "PRAGMA foreign_keys = on;" : "PRAGMA foreign_keys = off;", NULL, NULL, NULL); } } else if (step < 2) { rc = sqlite4_exec(x, d->shortnames ? "PRAGMA full_column_names = off;" : "PRAGMA full_column_names = on;", NULL, NULL, NULL); } else if (step < 3) { rc = sqlite4_exec(x, d->shortnames ? "PRAGMA short_column_names = on;" : "PRAGMA short_column_names = off;", NULL, NULL, NULL); } if (rc != SQLITE4_OK) { return rc; } count = 0; ++step; } return SQLITE4_OK; } /** * Free counted array of char pointers. * @param rowp pointer to char pointer array * * The -1-th element of the array holds the array size. * All non-NULL pointers of the array and then the array * itself are free'd. */ static void freerows(char **rowp) { PTRDIFF_T size, i; if (!rowp) { return; } --rowp; size = (PTRDIFF_T) rowp[0]; for (i = 1; i <= size; i++) { freep(&rowp[i]); } freep(&rowp); } /** * Map SQL field type from string to ODBC integer type code. * @param typename field type string * @param nosign pointer to indicator for unsigned field or NULL * @param ov3 boolean, true for SQL_OV_ODBC3 * @param nowchar boolean, for WINTERFACE don't use WCHAR * @param dobigint boolean, force SQL_BIGINT on INTEGER columns * @result SQL data type */ static int mapsqltype(const char *typename, int *nosign, int ov3, int nowchar, int dobigint) { char *p, *q; int testsign = 0, result; #ifdef WINTERFACE result = nowchar ? SQL_VARCHAR : SQL_WVARCHAR; #else result = SQL_VARCHAR; #endif if (!typename) { return result; } q = p = xmalloc(strlen(typename) + 1); if (!p) { return result; } strcpy(p, typename); while (*q) { *q = TOLOWER(*q); ++q; } if (strncmp(p, "inter", 5) == 0) { } else if (strncmp(p, "int", 3) == 0 || strncmp(p, "mediumint", 9) == 0) { testsign = 1; result = SQL_INTEGER; } else if (strncmp(p, "numeric", 7) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "tinyint", 7) == 0) { testsign = 1; result = SQL_TINYINT; } else if (strncmp(p, "smallint", 8) == 0) { testsign = 1; result = SQL_SMALLINT; } else if (strncmp(p, "float", 5) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "double", 6) == 0 || strncmp(p, "real", 4) == 0) { result = SQL_DOUBLE; } else if (strncmp(p, "timestamp", 9) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "datetime", 8) == 0) { #ifdef SQL_TYPE_TIMESTAMP result = ov3 ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP; #else result = SQL_TIMESTAMP; #endif } else if (strncmp(p, "time", 4) == 0) { #ifdef SQL_TYPE_TIME result = ov3 ? SQL_TYPE_TIME : SQL_TIME; #else result = SQL_TIME; #endif } else if (strncmp(p, "date", 4) == 0) { #ifdef SQL_TYPE_DATE result = ov3 ? SQL_TYPE_DATE : SQL_DATE; #else result = SQL_DATE; #endif #ifdef SQL_LONGVARCHAR } else if (strncmp(p, "text", 4) == 0 || strncmp(p, "memo", 4) == 0 || strncmp(p, "longvarchar", 11) == 0) { #ifdef WINTERFACE result = nowchar ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else result = SQL_LONGVARCHAR; #endif #ifdef WINTERFACE } else if (strncmp(p, "wtext", 5) == 0 || strncmp(p, "wvarchar", 8) == 0 || strncmp(p, "longwvarchar", 12) == 0) { result = SQL_WLONGVARCHAR; #endif #endif #ifdef SQL_BIT } else if (strncmp(p, "bool", 4) == 0 || strncmp(p, "bit", 3) == 0) { result = SQL_BIT; #endif #ifdef SQL_BIGINT } else if (strncmp(p, "bigint", 6) == 0) { testsign = 1; result = SQL_BIGINT; #endif } else if (strncmp(p, "blob", 4) == 0) { result = SQL_BINARY; } else if (strncmp(p, "varbinary", 9) == 0) { result = SQL_VARBINARY; } else if (strncmp(p, "longvarbinary", 13) == 0) { result = SQL_LONGVARBINARY; } if (nosign) { if (testsign) { *nosign = strstr(p, "unsigned") != NULL; } else { *nosign = 1; } } #ifdef SQL_BIGINT if (dobigint && result == SQL_INTEGER) { result = SQL_BIGINT; } #endif xfree(p); return result; } /** * Get maximum display size and number of digits after decimal point * from field type specification. * @param typename field type specification * @param sqltype target SQL data type * @param mp pointer to maximum display size or NULL * @param dp pointer to number of digits after decimal point or NULL */ static void getmd(const char *typename, int sqltype, int *mp, int *dp) { int m = 0, d = 0; switch (sqltype) { case SQL_INTEGER: m = 10; d = 9; break; case SQL_TINYINT: m = 4; d = 3; break; case SQL_SMALLINT: m = 6; d = 5; break; case SQL_FLOAT: m = 25; d = 24; break; case SQL_DOUBLE: m = 54; d = 53; break; case SQL_VARCHAR: m = 255; d = 0; break; #ifdef WINTERFACE #ifdef SQL_WVARCHAR case SQL_WVARCHAR: m = 255; d = 0; break; #endif #endif #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: m = 10; d = 0; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: m = 8; d = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: m = 32; d = 3; break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR : m = 65536; d = 0; break; #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: m = 65536; d = 0; break; #endif #endif case SQL_VARBINARY: m = 255; d = 0; break; case SQL_LONGVARBINARY: m = 65536; d = 0; break; #ifdef SQL_BIGINT case SQL_BIGINT: m = 20; d = 19; break; #endif #ifdef SQL_BIT case SQL_BIT: m = 1; d = 1; break; #endif } if (m && typename) { int mm, dd; if (sscanf(typename, "%*[^(](%d)", &mm) == 1) { if (sqltype == SQL_TIMESTAMP) { d = mm; } #ifdef SQL_TYPE_TIMESTAMP else if (sqltype == SQL_TYPE_TIMESTAMP) { d = mm; } #endif else { m = d = mm; } } else if (sscanf(typename, "%*[^(](%d,%d)", &mm, &dd) == 2) { m = mm; d = dd; } } if (mp) { *mp = m; } if (dp) { *dp = d; } } /** * Map SQL_C_DEFAULT to proper C type. * @param type input C type * @param stype input SQL type * @param nosign 0=signed, 0>unsigned, 0 0) ? SQL_C_ULONG : SQL_C_LONG; break; case SQL_TINYINT: type = (nosign > 0) ? SQL_C_UTINYINT : SQL_C_TINYINT; break; case SQL_SMALLINT: type = (nosign > 0) ? SQL_C_USHORT : SQL_C_SHORT; break; case SQL_FLOAT: type = SQL_C_FLOAT; break; case SQL_DOUBLE: type = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: type = SQL_C_TIMESTAMP; break; case SQL_TIME: type = SQL_C_TIME; break; case SQL_DATE: type = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: type = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: type = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: type = SQL_C_TYPE_DATE; break; #endif #ifdef WINTERFACE case SQL_WVARCHAR: case SQL_WCHAR: #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: #endif type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; break; #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: type = SQL_C_BINARY; break; #ifdef SQL_BIT case SQL_BIT: type = SQL_C_BIT; break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: type = SQL_C_CHAR; break; #endif default: #ifdef WINTERFACE type = nowchar ? SQL_C_CHAR : SQL_C_WCHAR; #else type = SQL_C_CHAR; #endif break; } } return type; } /** * Fixup query string with optional parameter markers. * @param sql original query string * @param sqlLen length of query string or SQL_NTS * @param nparam output number of parameters * @param isselect output indicator for SELECT (1) or DDL statement (2) * @param errmsg output error message * @result newly allocated string containing query string for SQLite or NULL */ static char * fixupsql(char *sql, int sqlLen, int *nparam, int *isselect, char **errmsg) { char *q = sql, *qz = NULL, *p, *inq = NULL, *out; int np = 0, isddl = -1, size; *errmsg = NULL; if (sqlLen != SQL_NTS) { qz = q = xmalloc(sqlLen + 1); if (!qz) { return NULL; } memcpy(q, sql, sqlLen); q[sqlLen] = '\0'; size = sqlLen * 4; } else { size = strlen(sql) * 4; } size += sizeof (char *) - 1; size &= ~(sizeof (char *) - 1); p = xmalloc(size); if (!p) { errout: freep(&qz); return NULL; } memset(p, 0, size); out = p; while (*q) { switch (*q) { case '\'': case '\"': if (q == inq) { inq = NULL; } else if (!inq) { inq = q + 1; while (*inq) { if (*inq == *q) { if (inq[1] == *q) { inq++; } else { break; } } inq++; } } *p++ = *q; break; case '?': *p++ = *q; if (!inq) { np++; } break; case ';': if (!inq) { if (isddl < 0) { char *qq = out; while (*qq && ISSPACE(*qq)) { ++qq; } if (*qq && *qq != ';') { int i; static const struct { int len; const char *str; } ddlstr[] = { { 5, "alter" }, { 7, "analyze" }, { 6, "attach" }, { 5, "begin" }, { 6, "commit" }, { 6, "create" }, { 6, "detach" }, { 4, "drop" }, { 3, "end" }, { 7, "reindex" }, { 7, "release" }, { 8, "rollback" }, { 9, "savepoint" }, { 6, "vacuum" } }; size = strlen(qq); for (i = 0; i < array_size(ddlstr); i++) { if (size >= ddlstr[i].len && strncasecmp(qq, ddlstr[i].str, ddlstr[i].len) == 0) { isddl = 1; break; } } if (isddl != 1) { isddl = 0; } } } if (isddl == 0) { char *qq = q; do { ++qq; } while (*qq && ISSPACE(*qq)); if (*qq && *qq != ';') { freep(&out); *errmsg = "only one SQL statement allowed"; goto errout; } } } *p++ = *q; break; case '{': /* * Deal with escape sequences: * {d 'YYYY-MM-DD'}, {t ...}, {ts ...} * {oj ...}, {fn ...} etc. */ if (!inq) { int ojfn = 0; char *inq2 = NULL, *end = q + 1; if (*end != 'd' && *end != 'D' && *end != 't' && *end != 'T') { ojfn = 1; } while (*end) { if (inq2 && *end == *inq2) { inq2 = NULL; } else if (inq2 == NULL && *end == '}') { break; } else if (inq2 == NULL && (*end == '\'' || *end == '"')) { inq2 = end; } ++end; } if (*end == '}') { char *start = q + 1; char *end2 = end - 1; if (ojfn) { while (start < end) { if (ISSPACE(*start)) { break; } ++start; } while (start < end) { *p++ = *start; ++start; } q = end; break; } else { while (start < end2 && *start != '\'') { ++start; } while (end2 > start && *end2 != '\'') { --end2; } if (*start == '\'' && *end2 == '\'') { while (start <= end2) { *p++ = *start; ++start; } q = end; break; } } } } /* FALL THROUGH */ default: *p++ = *q; } ++q; } freep(&qz); *p = '\0'; if (nparam) { *nparam = np; } if (isselect) { if (isddl > 0) { *isselect = 2; } else { int incom = 0; p = out; while (*p) { switch (*p) { case '-': if (!incom && p[1] == '-') { incom = -1; } break; case '\n': if (incom < 0) { incom = 0; } break; case '/': if (incom > 0 && p[-1] == '*') { incom = 0; p++; continue; } else if (!incom && p[1] == '*') { incom = 1; } break; } if (!incom && !ISSPACE(*p)) { break; } p++; } size = strlen(p); if (size >= 6 && (strncasecmp(p, "select", 6) == 0 || strncasecmp(p, "pragma", 6) == 0)) { *isselect = 1; } else { *isselect = 0; } } } return out; } /** * Find column given name in string array. * @param cols string array * @param ncols number of strings * @param name column name * @result >= 0 on success, -1 on error */ static int findcol(char **cols, int ncols, char *name) { int i; if (cols) { for (i = 0; i < ncols; i++) { if (strcmp(cols[i], name) == 0) { return i; } } } return -1; } /** * Fixup column information for a running statement. * @param s statement to get fresh column information * @param d DBC pointer * * The column labels get the table names stripped * when there's more than one column and all table * names are identical. * * The "dyncols" field of STMT is filled with column * information obtained by SQLite "PRAGMA table_info" * for each column whose table name is known. If the * types are already present as with SQLite 2.5.7 * this information is used instead. */ static void fixupdyncols(STMT *s, DBC *d) { int i; if (!s->dyncols) { return; } /* fixup labels */ if (!s->longnames) { if (s->dcols > 1) { char *table = s->dyncols[0].table; for (i = 1; table[0] && i < s->dcols; i++) { if (strcmp(s->dyncols[i].table, table)) { break; } } if (i >= s->dcols) { for (i = 0; i < s->dcols; i++) { s->dyncols[i].label = s->dyncols[i].column; } } } else if (s->dcols == 1) { s->dyncols[0].label = s->dyncols[0].column; } } for (i = 0; i < s->dcols; i++) { s->dyncols[i].type = mapsqltype(s->dyncols[i].typename, &s->dyncols[i].nosign, *s->ov3, s->nowchar[0] || s->nowchar[1], s->dobigint); getmd(s->dyncols[i].typename, s->dyncols[i].type, &s->dyncols[i].size, &s->dyncols[i].prec); #ifdef SQL_LONGVARCHAR if (s->dyncols[i].type == SQL_VARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (s->dyncols[i].type == SQL_WVARCHAR && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_WLONGVARCHAR; } #endif #endif if (s->dyncols[i].type == SQL_VARBINARY && s->dyncols[i].size > 255) { s->dyncols[i].type = SQL_LONGVARBINARY; } } } /** * Return number of month days. * @param year * @param month 1..12 * @result number of month days or 0 */ static int getmdays(int year, int month) { static const int mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int mday; if (month < 1) { return 0; } mday = mdays[(month - 1) % 12]; if (mday == 28 && year % 4 == 0 && (!(year % 100 == 0) || year % 400 == 0)) { mday++; } return mday; } /** * Convert string to ODBC DATE_STRUCT. * @param str string to be converted * @param ds output DATE_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDD' or 'YYYY-MM-DD' or * 'YYYY/MM/DD' or 'MM/DD/YYYY' are converted to a * DATE_STRUCT. */ static int str2date(char *str, DATE_STRUCT *ds) { int i, err = 0; char *p, *q, sepc = '\0'; ds->year = ds->month = ds->day = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && !ISDIGIT(*q)) { ++i; ++q; } if (i >= 8) { char buf[8]; strncpy(buf, p + 0, 4); buf[4] = '\0'; ds->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ds->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; ds->day = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (!sepc) { sepc = *q; } if (*q == '-' || *q == '/' || *q == '\0' || i == 2) { switch (i) { case 0: ds->year = n; break; case 1: ds->month = n; break; case 2: ds->day = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } done: /* final check for overflow */ if (err || ds->month < 1 || ds->month > 12 || ds->day < 1 || ds->day > getmdays(ds->year, ds->month)) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = ds->year; t[1] = ds->month; t[2] = ds->day; ds->year = t[2]; ds->day = t[1]; ds->month = t[0]; if (ds->month >= 1 && ds->month <= 12 && (ds->day >= 1 || ds->day <= getmdays(ds->year, ds->month))) { return 0; } } return -1; } return 0; } /** * Convert string to ODBC TIME_STRUCT. * @param str string to be converted * @param ts output TIME_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'HHMMSS' or 'HH:MM:SS' * are converted to a TIME_STRUCT. */ static int str2time(char *str, TIME_STRUCT *ts) { int i, err = 0, ampm = -1; char *p, *q; ts->hour = ts->minute = ts->second = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 6) { char buf[4]; strncpy(buf, p + 0, 2); buf[2] = '\0'; ts->hour = strtol(buf, NULL, 10); strncpy(buf, p + 2, 2); buf[2] = '\0'; ts->minute = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; ts->second = strtol(buf, NULL, 10); goto done; } i = 0; while (i < 3) { int n; q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (i == 0) { err = 1; } goto done; } } if (*q == ':' || *q == '\0' || i == 2) { switch (i) { case 0: ts->hour = n; break; case 1: ts->minute = n; break; case 2: ts->second = n; break; } ++i; if (*q) { ++q; } } else { i = 0; while (*q && !ISDIGIT(*q)) { ++q; } } p = q; } if (!err) { while (*p) { if ((p[0] == 'p' || p[0] == 'P') && (p[1] == 'm' || p[1] == 'M')) { ampm = 1; } else if ((p[0] == 'a' || p[0] == 'A') && (p[1] == 'm' || p[1] == 'M')) { ampm = 0; } ++p; } if (ampm > 0) { if (ts->hour < 12) { ts->hour += 12; } } else if (ampm == 0) { if (ts->hour == 12) { ts->hour = 0; } } } done: /* final check for overflow */ if (err || ts->hour > 23 || ts->minute > 59 || ts->second > 59) { return -1; } return 0; } /** * Convert string to ODBC TIMESTAMP_STRUCT. * @param str string to be converted * @param tss output TIMESTAMP_STRUCT * @result 0 on success, -1 on error * * Strings of the format 'YYYYMMDDhhmmssff' or 'YYYY-MM-DD hh:mm:ss ff' * or 'YYYY/MM/DD hh:mm:ss ff' or 'hh:mm:ss ff YYYY-MM-DD' are * converted to a TIMESTAMP_STRUCT. The ISO8601 formats * YYYY-MM-DDThh:mm:ss[.f]Z * YYYY-MM-DDThh:mm:ss[.f]shh:mm * are also supported. In case a time zone field is present, * the resulting TIMESTAMP_STRUCT is expressed in UTC. */ static int str2timestamp(char *str, TIMESTAMP_STRUCT *tss) { int i, m, n, err = 0, ampm = -1; char *p, *q, in = '\0', sepc = '\0'; tss->year = tss->month = tss->day = 0; tss->hour = tss->minute = tss->second = 0; tss->fraction = 0; p = str; while (*p && !ISDIGIT(*p)) { ++p; } q = p; i = 0; while (*q && ISDIGIT(*q)) { ++i; ++q; } if (i >= 14) { char buf[16]; strncpy(buf, p + 0, 4); buf[4] = '\0'; tss->year = strtol(buf, NULL, 10); strncpy(buf, p + 4, 2); buf[2] = '\0'; tss->month = strtol(buf, NULL, 10); strncpy(buf, p + 6, 2); buf[2] = '\0'; tss->day = strtol(buf, NULL, 10); strncpy(buf, p + 8, 2); buf[2] = '\0'; tss->hour = strtol(buf, NULL, 10); strncpy(buf, p + 10, 2); buf[2] = '\0'; tss->minute = strtol(buf, NULL, 10); strncpy(buf, p + 12, 2); buf[2] = '\0'; tss->second = strtol(buf, NULL, 10); if (i > 14) { m = i - 14; strncpy(buf, p + 14, m); while (m < 9) { buf[m] = '0'; ++m; } buf[m] = '\0'; tss->fraction = strtol(buf, NULL, 10); } m = 7; goto done; } m = i = 0; while ((m & 7) != 7) { q = NULL; n = strtol(p, &q, 10); if (!q || q == p) { if (*q == '\0') { if (m < 1) { err = 1; } goto done; } } if (in == '\0') { switch (*q) { case '-': case '/': if ((m & 1) == 0) { in = *q; i = 0; } break; case ':': if ((m & 2) == 0) { in = *q; i = 0; } break; case ' ': case '.': break; default: in = '\0'; i = 0; break; } } switch (in) { case '-': case '/': if (!sepc) { sepc = in; } switch (i) { case 0: tss->year = n; break; case 1: tss->month = n; break; case 2: tss->day = n; break; } if (++i >= 3) { i = 0; m |= 1; if (!(m & 2)) { m |= 8; } goto skip; } else { ++q; } break; case ':': switch (i) { case 0: tss->hour = n; break; case 1: tss->minute = n; break; case 2: tss->second = n; break; } if (++i >= 3) { i = 0; m |= 2; if (*q == '.') { in = '.'; goto skip2; } if (*q == ' ') { if ((m & 1) == 0) { char *e = NULL; (void) strtol(q + 1, &e, 10); if (e && *e == '-') { goto skip; } } in = '.'; goto skip2; } goto skip; } else { ++q; } break; case '.': if (++i >= 1) { int ndig = q - p; if (p[0] == '+' || p[0] == '-') { ndig--; } while (ndig < 9) { n = n * 10; ++ndig; } tss->fraction = n; m |= 4; i = 0; } default: skip: in = '\0'; skip2: while (*q && !ISDIGIT(*q)) { if ((q[0] == 'a' || q[0] == 'A') && (q[1] == 'm' || q[1] == 'M')) { ampm = 0; ++q; } else if ((q[0] == 'p' || q[0] == 'P') && (q[1] == 'm' || q[1] == 'M')) { ampm = 1; ++q; } ++q; } } p = q; } if ((m & 7) > 1 && (m & 8)) { /* ISO8601 timezone */ if (p > str && ISDIGIT(*p)) { int nn, sign; q = p - 1; if (*q != '+' && *q != '-') { goto done; } sign = (*q == '+') ? -1 : 1; q = NULL; n = strtol(p, &q, 10); if (!q || *q++ != ':' || !ISDIGIT(*q)) { goto done; } p = q; q = NULL; nn = strtol(p, &q, 10); tss->minute += nn * sign; if ((SQLSMALLINT) tss->minute < 0) { tss->hour -= 1; tss->minute += 60; } else if (tss->minute >= 60) { tss->hour += 1; tss->minute -= 60; } tss->hour += n * sign; if ((SQLSMALLINT) tss->hour < 0) { tss->day -= 1; tss->hour += 24; } else if (tss->hour >= 24) { tss->day += 1; tss->hour -= 24; } if ((short) tss->day < 1 || tss->day >= 28) { int mday, pday, pmon; mday = getmdays(tss->year, tss->month); pmon = tss->month - 1; if (pmon < 1) { pmon = 12; } pday = getmdays(tss->year, pmon); if ((SQLSMALLINT) tss->day < 1) { tss->month -= 1; tss->day = pday; } else if (tss->day > mday) { tss->month += 1; tss->day = 1; } if ((SQLSMALLINT) tss->month < 1) { tss->year -= 1; tss->month = 12; } else if (tss->month > 12) { tss->year += 1; tss->month = 1; } } } } done: if ((m & 1) && (tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month))) { if (sepc == '/') { /* Try MM/DD/YYYY format */ int t[3]; t[0] = tss->year; t[1] = tss->month; t[2] = tss->day; tss->year = t[2]; tss->day = t[1]; tss->month = t[0]; } } /* Replace missing year/month/day with current date */ if (!err && (m & 1) == 0) { #ifdef _WIN32 SYSTEMTIME t; GetLocalTime(&t); tss->year = t.wYear; tss->month = t.wMonth; tss->day = t.wDay; #else struct timeval tv; struct tm tm; gettimeofday(&tv, NULL); tm = *localtime(&tv.tv_sec); tss->year = tm.tm_year + 1900; tss->month = tm.tm_mon + 1; tss->day = tm.tm_mday; #endif } /* Normalize fraction */ if (tss->fraction < 0) { tss->fraction = 0; } /* Final check for overflow */ if (err || tss->month < 1 || tss->month > 12 || tss->day < 1 || tss->day > getmdays(tss->year, tss->month) || tss->hour > 23 || tss->minute > 59 || tss->second > 59) { return -1; } if ((m & 7) > 1) { if (ampm > 0) { if (tss->hour < 12) { tss->hour += 12; } } else if (ampm == 0) { if (tss->hour == 12) { tss->hour = 0; } } } return ((m & 7) < 1) ? -1 : 0; } /** * Get boolean flag from string. * @param string string to be inspected * @result true or false */ static int getbool(char *string) { if (string) { return string[0] && strchr("Yy123456789Tt", string[0]) != NULL; } return 0; } /** * Internal function to release memory of blob * @param p pointer to memory */ static void blob_free(void *p) { sqlite4_free(0, p); } /** * SQLite function to import a BLOB from a file * @param ctx function context * @param nargs number arguments * @param args arguments */ static void blob_import(sqlite4_context *ctx, int nargs, sqlite4_value **args) { #if 0 DBC *d = (DBC *) sqlite4_user_data(ctx); #endif char *filename = 0; if (nargs > 0) { if (sqlite4_value_type(args[0]) != SQLITE4_NULL) { filename = (char *) sqlite4_value_text(args[0]); } } if (filename) { #ifdef _WIN32 char *wname = utf_to_wmb(filename, -1); FILE *f; #else FILE *f = fopen(filename, "r"); #endif char *p; long n, nn; #ifdef _WIN32 if (wname) { f = fopen(wname, "rb"); } else { sqlite4_result_error(ctx, "out of memory", -1); return; } uc_free(wname); #endif if (f) { if (fseek(f, 0, SEEK_END) == 0) { n = ftell(f); if (fseek(f, 0, SEEK_SET) == 0) { p = sqlite4_malloc(0, n); if (p) { nn = fread(p, 1, n, f); if (nn != n) { sqlite4_result_error(ctx, "read error", -1); sqlite4_free(0, p); } else { sqlite4_result_blob(ctx, p, n, blob_free); } } else { sqlite4_result_error(ctx, "out of memory", -1); } } else { sqlite4_result_error(ctx, "seek error", -1); } } else { sqlite4_result_error(ctx, "seek error", -1); } fclose(f); } else { sqlite4_result_error(ctx, "cannot open file", -1); } } else { sqlite4_result_error(ctx, "no filename given", -1); } } /** * SQLite function to export a BLOB to a file * @param ctx function context * @param nargs number arguments * @param args arguments */ static void blob_export(sqlite4_context *ctx, int nargs, sqlite4_value **args) { #if 0 DBC *d = (DBC *) sqlite4_user_data(ctx); #endif char *filename = 0; char *p = 0; int n = 0; if (nargs > 0) { p = (char *) sqlite4_value_blob(args[0]); n = sqlite4_value_bytes(args[0]); } if (nargs > 1) { if (sqlite4_value_type(args[1]) != SQLITE4_NULL) { filename = (char *) sqlite4_value_text(args[1]); } } if (p) { if (filename) { #ifdef _WIN32 char *wname = utf_to_wmb(filename, -1); FILE *f; #else FILE *f = fopen(filename, "w"); #endif int nn; #ifdef _WIN32 if (wname) { f = fopen(wname, "wb"); } else { sqlite4_result_error(ctx, "out of memory", -1); return; } uc_free(wname); #endif if (f) { nn = fwrite(p, 1, n, f); fclose(f); if (nn != n) { sqlite4_result_error(ctx, "write error", -1); } else { sqlite4_result_int(ctx, nn); } } else { sqlite4_result_error(ctx, "cannot open file", -1); } } else { sqlite4_result_error(ctx, "no filename given", -1); } } else { sqlite4_result_null(ctx); } } /** * SQLite trace or profile callback * @param arg DBC pointer * @param msg log message, SQL text * @param et elapsed time */ static void dbtrace(void *arg, const char *msg, sqlite4_uint64 et) { DBC *d = (DBC *) arg; if (msg && d->trace) { int len = strlen(msg); unsigned long s, f; if (len > 0) { char *end = "\n"; if (msg[len - 1] != ';') { end = ";\n"; } fprintf(d->trace, "%s%s", msg, end); s = et / 1000000000LL; f = et % 1000000000LL; fprintf(d->trace, "-- took %lu.%09lu seconds\n", s, f); fflush(d->trace); } } } /** * Trace function for SQLite API calls * @param d pointer to database connection handle * @param fn SQLite function name * @param sql SQL string */ static void dbtraceapi(DBC *d, char *fn, const char *sql) { if (fn && d->trace) { if (sql) { fprintf(d->trace, "-- %s: %s\n", fn, sql); } else { fprintf(d->trace, "-- %s\n", fn); } fflush(d->trace); } } /** * Trace function for SQLite return codes * @param d pointer to database connection handle * @param rc SQLite return code * @param err error string or NULL */ static void dbtracerc(DBC *d, int rc, char *err) { if (rc != SQLITE4_OK && d->trace) { fprintf(d->trace, "-- SQLITE ERROR CODE %d", rc); fprintf(d->trace, err ? ": %s\n" : "\n", err); fflush(d->trace); } } /** * Open SQLite database file given file name and flags. * @param d DBC pointer * @param name file name * @param isu true/false: file name is UTF8 encoded * @param dsn data source name * @param sflag STEPAPI flag * @param spflag SyncPragma string * @param ntflag NoTransaction string * @param jmode JournalMode string * @param busy busy/lock timeout * @result ODBC error code */ static SQLRETURN dbopen(DBC *d, char *name, int isu, char *dsn, char *sflag, char *spflag, char *ntflag, char *jmode, char *busy) { char *endp = NULL; int rc, tmp, busyto = 100000; int flags = SQLITE4_OPEN_READWRITE | SQLITE4_OPEN_CREATE; char *uname = name; if (d->sqlite) { if (d->trace) { fprintf(d->trace, "-- sqlite4_close (deferred): '%s'\n", d->dbname); fflush(d->trace); } sqlite4_close(d->sqlite); d->sqlite = NULL; } if (d->nocreat) { flags &= ~ SQLITE4_OPEN_CREATE; } #if defined(_WIN32) || defined(_WIN64) if (!isu) { char expname[MAX_PATH]; expname[0] = '\0'; rc = ExpandEnvironmentStrings(name, expname, sizeof (expname)); if (rc <= sizeof (expname)) { uname = wmb_to_utf(expname, rc - 1); } else { uname = wmb_to_utf(name, -1); } if (!uname) { rc = SQLITE4_NOMEM; setstatd(d, rc, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } } #endif #ifdef SQLITE4_OPEN_URI flags |= SQLITE4_OPEN_URI; #endif rc = sqlite4_open(0, uname, &d->sqlite, /* flags ?? */ 0); #if defined(WINTERFACE) || defined(_WIN32) || defined(_WIN64) if (uname != name) { uc_free(uname); } #endif if (rc != SQLITE4_OK) { connfail: setstatd(d, rc, "connect failed", (*d->ov3) ? "HY000" : "S1000"); if (d->sqlite) { sqlite4_close(d->sqlite); d->sqlite = NULL; } return SQL_ERROR; } d->pwd = NULL; d->pwdLen = 0; if (d->trace) { sqlite4_profile(d->sqlite, dbtrace, d); } d->step_enable = getbool(sflag); d->trans_disable = getbool(ntflag); d->curtype = d->step_enable ? SQL_CURSOR_FORWARD_ONLY : SQL_CURSOR_STATIC; tmp = strtol(busy, &endp, 0); if (endp && *endp == '\0' && endp != busy) { busyto = tmp; } if (busyto < 1 || busyto > 1000000) { busyto = 1000000; } d->timeout = busyto; freep(&d->dbname); d->dbname = xstrdup(name); freep(&d->dsn); d->dsn = xstrdup(dsn); if ((rc = setsqliteopts(d->sqlite, d)) != SQLITE4_OK) { if (d->trace) { fprintf(d->trace, "-- sqlite4_close: '%s'\n", d->dbname); fflush(d->trace); } sqlite4_close(d->sqlite); d->sqlite = NULL; goto connfail; } if (!spflag || spflag[0] == '\0') { spflag = "NORMAL"; } if (spflag[0] != '\0') { char syncp[128]; sprintf(syncp, "PRAGMA synchronous = %8.8s;", spflag); sqlite4_exec(d->sqlite, syncp, NULL, NULL, NULL); } if (jmode[0] != '\0') { char jourp[128]; sprintf(jourp, "PRAGMA journal_mode = %16.16s;", jmode); sqlite4_exec(d->sqlite, jourp, NULL, NULL, NULL); } if (d->trace) { fprintf(d->trace, "-- sqlite4_open: '%s'\n", d->dbname); fflush(d->trace); } #if defined(_WIN32) || defined(_WIN64) { char pname[MAX_PATH]; HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()); pname[0] = '\0'; if (h) { HMODULE m = NULL, l = LoadLibrary("psapi.dll"); DWORD need; typedef BOOL (WINAPI *epmfunc)(HANDLE, HMODULE *, DWORD, LPDWORD); typedef BOOL (WINAPI *gmbfunc)(HANDLE, HMODULE, LPSTR, DWORD); epmfunc epm; gmbfunc gmb; if (l) { epm = (epmfunc) GetProcAddress(l, "EnumProcessModules"); gmb = (gmbfunc) GetProcAddress(l, "GetModuleBaseNameA"); if (epm && gmb && epm(h, &m, sizeof (m), &need)) { gmb(h, m, pname, sizeof (pname)); } FreeLibrary(l); } CloseHandle(h); } d->xcelqrx = strncasecmp(pname, "EXCEL", 5) == 0 || strncasecmp(pname, "MSQRY", 5) == 0; if (d->trace && d->xcelqrx) { fprintf(d->trace, "-- enabled EXCEL quirks\n"); fflush(d->trace); } } #endif sqlite4_create_function(d->sqlite, "blob_import", 1, SQLITE4_UTF8, d, blob_import, 0, 0); sqlite4_create_function(d->sqlite, "blob_export", 2, SQLITE4_UTF8, d, blob_export, 0, 0); return SQL_SUCCESS; } /** * Load SQLite extension modules, if any * @param d DBC pointer * @param exts string, comma separated extension names */ static void dbloadext(DBC *d, char *exts) { #if 0 char *p; char path[SQL_MAX_MESSAGE_LENGTH]; int plen = 0; if (!d->sqlite) { return; } #if defined(_WIN32) || defined(_WIN64) GetModuleFileName(hModule, path, sizeof (path)); p = strrchr(path, '\\'); plen = p ? ((p + 1) - path) : 0; #endif do { p = strchr(exts, ','); if (p) { strncpy(path + plen, exts, p - exts); path[plen + (p - exts)] = '\0'; } else { strcpy(path + plen, exts); } if (exts[0]) { char *errmsg = NULL; int rc; #if defined(_WIN32) || defined(_WIN64) char *q; q = path + plen; if (!(q[0] && ((q[1] == ':' && (q[2] == '\\' || q[2] == '/')) || q[0] == '\\' || q[0] == '/' || q[0] == '.'))) { q = path; } rc = sqlite4_load_extension(d->sqlite, q, 0, &errmsg); #else rc = sqlite4_load_extension(d->sqlite, path, 0, &errmsg); #endif if (rc != SQLITE4_OK) { #if defined(_WIN32) || defined(_WIN64) char buf[512], msg[512]; LoadString(hModule, IDS_EXTERR, buf, sizeof (buf)); wsprintf(msg, buf, q, errmsg ? errmsg : "no error info available"); LoadString(hModule, IDS_EXTTITLE, buf, sizeof (buf)); MessageBox(NULL, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); #else fprintf(stderr, "extension '%s' did not load%s%s\n", path, errmsg ? ": " : "", errmsg ? errmsg : ""); #endif } } if (p) { exts = p + 1; } } while (p); #endif } /** * Find out column type * @param s4stmt SQLite statement pointer * @param col column number * @param d DBC pointer (for tracing only) * @param guessed_types flag array * @result type name as string */ static char * s4stmt_coltype(sqlite4_stmt *s4stmt, int col, DBC *d, int *guessed_types) { char *typename = (char *) sqlite4_column_decltype(s4stmt, col); char guess[64]; guess[0] = '\0'; if (!typename) { int coltype = sqlite4_column_type(s4stmt, col); if (guessed_types) { guessed_types[0]++; } if (d->trace) { sprintf(guess, " (guessed from %d)", coltype); } switch (coltype) { case SQLITE4_INTEGER: typename = "integer"; break; case SQLITE4_FLOAT: typename = "double"; break; default: case SQLITE4_TEXT: typename = "varchar"; break; case SQLITE4_BLOB: typename = "blob"; break; #if 0 case SQLITE4_NULL: typename = "null"; break; #endif } } if (d->trace) { fprintf(d->trace, "-- column %d type%s: '%s'\n", col + 1, guess, typename); fflush(d->trace); } return typename; } /** * Add meta data for column * @param s4stmt SQLite statement pointer * @param col column number * @param d DBC pointer (for tracing only) * @param ci pointer to COL */ static void s4stmt_addmeta(sqlite4_stmt *s4stmt, int col, DBC *d, COL *ci) { int nn = 0, pk = 0, ai = 0; const char *dn, *tn, *cn, *dummy1, *dummy2; dn = sqlite4_column_database_name(s4stmt, col); tn = sqlite4_column_table_name(s4stmt, col); cn = sqlite4_column_origin_name(s4stmt, col); #if 0 sqlite4_table_column_metadata(d->sqlite, dn, tn, cn, &dummy1, &dummy2, &nn, &pk, &ai); #endif ci->autoinc = ai ? SQL_TRUE: SQL_FALSE; ci->notnull = nn ? SQL_NO_NULLS : SQL_NULLABLE; if (d->trace) { fprintf(d->trace, "-- column %d %s\n", col + 1, nn ? "notnull" : "nullable"); if (ai) { fprintf(d->trace, "-- column %d autoincrement\n", col + 1); } fflush(d->trace); } } /** * Do one sqlite statement step gathering one result row * @param s statement pointer * @result ODBC error code */ static int s4stmt_step(STMT *s) { DBC *d = (DBC *) s->dbc; char **rowd = NULL; const char *errp = NULL; int i, ncols, rc; if (s != d->cur_s4stmt || !s->s4stmt) { setstat(s, -1, "stale statement", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } rc = sqlite4_step(s->s4stmt); if (rc == SQLITE4_ROW || rc == SQLITE4_DONE) { ++s->s4stmt_rownum; ncols = sqlite4_column_count(s->s4stmt); if (d->s4stmt_needmeta && s->s4stmt_rownum == 0 && ncols > 0) { PTRDIFF_T size; char *p; COL *dyncols; const char *colname, *typename; char *tblname; for (i = size = 0; i < ncols; i++) { colname = sqlite4_column_name(s->s4stmt, i); size += 3 + 3 * strlen(colname); } tblname = (char *) size; for (i = 0; i < ncols; i++) { p = (char *) sqlite4_column_table_name(s->s4stmt, i); size += 2 + (p ? strlen(p) : 0); } dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); s->ncols = 0; dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s->s4stmt); s->s4stmt = NULL; d->cur_s4stmt = NULL; return nomem(s); } p = (char *) (dyncols + ncols); tblname = p + (PTRDIFF_T) tblname; for (i = 0; i < ncols; i++) { char *q; colname = sqlite4_column_name(s->s4stmt, i); if (d->trace) { fprintf(d->trace, "-- column %d name: '%s'\n", i + 1, colname); fflush(d->trace); } q = (char *) sqlite4_column_table_name(s->s4stmt, i); strcpy(tblname, q ? q : ""); if (d->trace) { fprintf(d->trace, "-- table %d name: '%s'\n", i + 1, tblname); fflush(d->trace); } dyncols[i].table = tblname; tblname += strlen(tblname) + 1; typename = s4stmt_coltype(s->s4stmt, i, d, 0); dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, colname); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(colname, '.'); if (q) { char *q2 = strchr(q + 1, '.'); /* SQLite 3.3.4 produces view.table.column sometimes */ if (q2) { q = q2; } } if (q) { strncpy(p, colname, q - colname); p[q - colname] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { strcpy(p, colname); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; s4stmt_addmeta(s->s4stmt, i, d, &dyncols[i]); dyncols[i].typename = xstrdup(typename); } freedyncols(s); s->ncols = s->dcols = ncols; s->dyncols = s->cols = dyncols; fixupdyncols(s, d); mkbindcols(s, s->ncols); d->s4stmt_needmeta = 0; } if (ncols <= 0) { goto killstmt; } if (rc == SQLITE4_DONE) { freeresult(s, 0); s->nrows = 0; dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s->s4stmt); s->s4stmt = NULL; d->cur_s4stmt = NULL; return SQL_SUCCESS; } rowd = xmalloc((1 + 2 * ncols) * sizeof (char *)); if (rowd) { const unsigned char *value; rowd[0] = (char *) ((PTRDIFF_T) (ncols * 2)); ++rowd; for (i = 0; i < ncols; i++) { int coltype = sqlite4_column_type(s->s4stmt, i); rowd[i] = rowd[i + ncols] = NULL; if (coltype == SQLITE4_BLOB) { int k, nbytes = sqlite4_column_bytes(s->s4stmt, i); char *qp; unsigned const char *bp; bp = sqlite4_column_blob(s->s4stmt, i); qp = xmalloc(nbytes * 2 + 4); if (qp) { rowd[i + ncols] = qp; *qp++ = 'X'; *qp++ = '\''; for (k = 0; k < nbytes; k++) { *qp++ = xdigits[(bp[k] >> 4)]; *qp++ = xdigits[(bp[k] & 0xF)]; } *qp++ = '\''; *qp = '\0'; } #ifdef _MSC_VER } else if (coltype == SQLITE4_FLOAT) { static struct lconv *lc = 0; double d = sqlite4_column_double(s->s4stmt, i); char *p, buffer[128]; /* * This avoids floating point rounding * and formatting problems of some SQLite * versions in conjunction with MSVC 2010. */ snprintf(buffer, sizeof (buffer), "%.15g", d); if (!lc) { lc = localeconv(); } if (lc && lc->decimal_point && lc->decimal_point[0] && lc->decimal_point[0] != '.') { p = strchr(buffer, lc->decimal_point[0]); if (p) { *p = '.'; } } rowd[i + ncols] = xstrdup(buffer); #endif } else if (coltype != SQLITE4_NULL) { value = sqlite4_column_text(s->s4stmt, i); rowd[i + ncols] = xstrdup((char *) value); } } for (i = 0; i < ncols; i++) { int coltype = sqlite4_column_type(s->s4stmt, i); value = NULL; if (coltype == SQLITE4_BLOB) { value = sqlite4_column_blob(s->s4stmt, i); } else if (coltype != SQLITE4_NULL) { value = sqlite4_column_text(s->s4stmt, i); } if (value && !rowd[i + ncols]) { freerows(rowd); rowd = 0; break; } } } if (rowd) { freeresult(s, 0); s->nrows = 1; s->rows = rowd; s->rowfree = freerows; if (rc == SQLITE4_DONE) { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s->s4stmt); s->s4stmt = NULL; d->cur_s4stmt = NULL; } return SQL_SUCCESS; } } killstmt: dbtraceapi(d, "sqlite4_reset", 0); rc = sqlite4_reset(s->s4stmt); s->s4stmt_noreset = 1; errp = sqlite4_errmsg(d->sqlite); if (d->cur_s4stmt == s) { d->cur_s4stmt = NULL; } setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); return SQL_ERROR; } /** * Stop running sqlite statement * @param s statement pointer */ static void s4stmt_end(STMT *s) { DBC *d; if (!s || !s->s4stmt) { return; } d = (DBC *) s->dbc; if (d) { d->busyint = 0; } if (!s->s4stmt_noreset) { dbtraceapi(d, "sqlite4_reset", 0); sqlite4_reset(s->s4stmt); s->s4stmt_noreset = 1; s->s4stmt_rownum = -1; } if (d->cur_s4stmt == s) { d->cur_s4stmt = NULL; } } /** * Conditionally stop running sqlite statement * @param s statement pointer */ static void s4stmt_end_if(STMT *s) { DBC *d = (DBC *) s->dbc; if (d) { d->busyint = 0; } if (d && d->cur_s4stmt == s) { s4stmt_end(s); } } /** * Drop running sqlite statement in STMT * @param s statement pointer */ static void s4stmt_drop(STMT *s) { if (s->s4stmt) { DBC *d = (DBC *) s->dbc; if (d) { dbtraceapi(d, "sqlite4_finalize", 0); } sqlite4_finalize(s->s4stmt); s->s4stmt = NULL; s->s4stmt_rownum = 0; } } /** * Start sqlite statement for execution of SELECT statement. * @param s statement pointer * @result ODBC error code */ static SQLRETURN s4stmt_start(STMT *s) { DBC *d = (DBC *) s->dbc; const char *endp; sqlite4_stmt *s4stmt = NULL; int rc, nretry = 0; d->s4stmt_needmeta = 0; if (!s->s4stmt) { dbtraceapi(d, "sqlite4_prepare", (char *) s->query); do { s4stmt = NULL; rc = sqlite4_prepare(d->sqlite, (char *) s->query, -1, &s4stmt, &endp); if (rc != SQLITE4_OK) { if (s4stmt) { sqlite4_finalize(s4stmt); s4stmt = NULL; } } } while (rc == SQLITE4_SCHEMA && (++nretry) < 2); dbtracerc(d, rc, NULL); if (rc != SQLITE4_OK) { if (s4stmt) { dbtraceapi(d, "sqlite4_finalize", NULL); sqlite4_finalize(s4stmt); } setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", sqlite4_errmsg(d->sqlite), rc); return SQL_ERROR; } if (sqlite4_bind_parameter_count(s4stmt) != s->nparams) { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s4stmt); setstat(s, SQLITE4_ERROR, "parameter marker count incorrect", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } s->s4stmt = s4stmt; s->s4stmt_noreset = 1; d->s4stmt_needmeta = 1; } d->cur_s4stmt = s; s->s4stmt_rownum = -1; s4bind(d, s->s4stmt, s->nparams, s->bindparms); return SQL_SUCCESS; } /** * Function not implemented. */ SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt, SQLSMALLINT oper) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSources(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDataSourcesW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *srvname, SQLSMALLINT buflen1, SQLSMALLINT *lenp1, SQLWCHAR *desc, SQLSMALLINT buflen2, SQLSMALLINT *lenp2) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDrivers(SQLHENV env, SQLUSMALLINT dir, SQLCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLDriversW(SQLHENV env, SQLUSMALLINT dir, SQLWCHAR *drvdesc, SQLSMALLINT descmax, SQLSMALLINT *desclenp, SQLWCHAR *drvattr, SQLSMALLINT attrmax, SQLSMALLINT *attrlenp) { if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC dbc, SQLCHAR *connin, SQLSMALLINT conninLen, SQLCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLBrowseConnectW(SQLHDBC dbc, SQLWCHAR *connin, SQLSMALLINT conninLen, SQLWCHAR *connout, SQLSMALLINT connoutMax, SQLSMALLINT *connoutLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvunimpldbc(dbc); HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ static SQLRETURN drvputdata(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { STMT *s; int i, dlen, done = 0; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->query || s->nparams <= 0) { seqerr: setstat(s, -1, "sequence error", "HY010"); return SQL_ERROR; } for (i = (s->pdcount < 0) ? 0 : s->pdcount; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { int type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); if (len == SQL_NULL_DATA) { freep(&p->parbuf); p->param = NULL; p->len = SQL_NULL_DATA; p->need = -1; } else if (type != SQL_C_CHAR #ifdef WCHARSUPPORT && type != SQL_C_WCHAR #endif && type != SQL_C_BINARY) { int size = 0; switch (type) { case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif size = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: size = sizeof (SQLSMALLINT); break; case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: size = sizeof (SQLINTEGER); break; #ifdef SQL_BIGINT case SQL_C_UBIGINT: case SQL_C_SBIGINT: size = sizeof (SQLBIGINT); break; #endif case SQL_C_FLOAT: size = sizeof (float); break; case SQL_C_DOUBLE: size = sizeof (double); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: size = sizeof (DATE_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: size = sizeof (TIME_STRUCT); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: size = sizeof (TIMESTAMP_STRUCT); break; } freep(&p->parbuf); p->parbuf = xmalloc(size); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; memcpy(p->param, data, size); p->len = size; p->need = -1; } else if (len == SQL_NTS && ( type == SQL_C_CHAR #ifdef WCHARSUPPORT || type == SQL_C_WCHAR #endif )) { char *dp = data; #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { dp = uc_to_utf(data, len); if (!dp) { return nomem(s); } } #endif #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { dp = wmb_to_utf(data, strlen (data)); if (!dp) { return nomem(s); } } #endif dlen = strlen(dp); freep(&p->parbuf); p->parbuf = xmalloc(dlen + 1); if (!p->parbuf) { if (dp != data) { uc_free(dp); } return nomem(s); } p->param = p->parbuf; strcpy(p->param, dp); if (dp != data) { uc_free(dp); } p->len = dlen; p->need = -1; } else if (len < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } else { dlen = min(p->len - p->offs, len); if (!p->param) { setstat(s, -1, "no memory for parameter", "HY013"); return SQL_ERROR; } memcpy((char *) p->param + p->offs, data, dlen); p->offs += dlen; if (p->offs >= p->len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->len); char *np; int nlen; if (!dp) { return nomem(s); } nlen = strlen(dp); np = xmalloc(nlen + 1); if (!np) { uc_free(dp); return nomem(s); } strcpy(np, dp); uc_free(dp); if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = np; p->len = nlen; } else { *((char *) p->param + p->len) = '\0'; } p->need = (type == SQL_C_CHAR || type == SQL_C_WCHAR) ? -1 : 0; #else *((char *) p->param + p->len) = '\0'; p->need = (type == SQL_C_CHAR) ? -1 : 0; #endif #if defined(_WIN32) || defined(_WIN64) if (type == SQL_C_CHAR && *s->oemcp && !(p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY)) { char *dp = wmb_to_utf(p->param, p->len); if (!dp) { return nomem(s); } if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->len = strlen(dp); } if (p->type == SQL_C_WCHAR && (p->stype == SQL_VARCHAR || p->stype == SQL_LONGVARCHAR) && p->len == p->coldef * sizeof (SQLWCHAR)) { /* fix for MS-Access */ p->len = p->coldef; } #endif } } done = 1; break; } } if (!done) { goto seqerr; } return SQL_SUCCESS; } /** * Put (partial) parameter data into executing statement. * @param stmt statement handle * @param data pointer to data * @param len length of data * @result ODBC error code */ SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt, SQLPOINTER data, SQLLEN len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvputdata(stmt, data, len); HSTMT_UNLOCK(stmt); return ret; } /** * Clear out parameter bindings, if any. * @param s statement pointer */ static SQLRETURN freeparams(STMT *s) { if (s->bindparms) { int n; for (n = 0; n < s->nbindparms; n++) { freep(&s->bindparms[n].parbuf); memset(&s->bindparms[n], 0, sizeof (BINDPARM)); } } return SQL_SUCCESS; } /** * Setup sqlite4 parameter for statement parameter. * @param s statement pointer * @param sql sql string * @param pnum parameter number * @result ODBC error code * * The parameter is converted within BINDPARM in order to * be presented to sqlite4_bind_*() functions. */ static SQLRETURN setupparam(STMT *s, char *sql, int pnum) { int type, len = 0, needalloc = 0; BINDPARM *p; if (!s->bindparms || pnum < 0 || pnum >= s->nbindparms) { goto error; } p = &s->bindparms[pnum]; type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 4 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && p->type == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif if (p->need > 0) { return setupparbuf(s, p); } p->strbuf[0] = '\0'; if (!p->param || (p->lenp && *p->lenp == SQL_NULL_DATA)) { p->s4type = SQLITE4_NULL; p->s4size = 0; return SQL_SUCCESS; } if (type == SQL_C_CHAR && (p->stype == SQL_BINARY || p->stype == SQL_VARBINARY || p->stype == SQL_LONGVARBINARY)) { type = SQL_C_BINARY; } switch (type) { case SQL_C_BINARY: p->s4type = SQLITE4_BLOB; p->s4size = p->len; p->s4val = p->param; if (p->need < 0) { break; } if (!p->lenp) { len = p->len; } else if (*p->lenp == SQL_DATA_AT_EXEC) { len = p->len; } else { len = *p->lenp; if (len <= SQL_LEN_DATA_AT_EXEC_OFFSET) { len = SQL_LEN_DATA_AT_EXEC(len); } } if (len < 0) { setstat(s, -1, "invalid length", "HY009"); return SQL_ERROR; } p->len = len; p->max = p->len; p->need = -1; p->s4size = len; break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif case SQL_C_CHAR: p->s4type = SQLITE4_TEXT; p->s4size = -1; p->s4val = p->param; if (!p->parbuf && p->lenp) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { if (*p->lenp == SQL_NTS) { p->max = uc_strlen(p->param) * sizeof (SQLWCHAR); } else if (*p->lenp >= 0) { p->max = *p->lenp; } } else #endif if (type == SQL_C_CHAR) { if (*p->lenp == SQL_NTS) { p->len = p->max = strlen(p->param); #if defined(_WIN32) || defined(_WIN64) needalloc = 1; #endif } else if (*p->lenp >= 0) { p->len = p->max = *p->lenp; needalloc = 1; } } } if (p->need < 0 && p->parbuf == p->param) { break; } #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { char *dp = uc_to_utf(p->param, p->max); if (!dp) { return nomem(s); } if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; p->len = strlen(p->param); p->s4val = p->param; p->s4size = p->len; } else #endif if (type == SQL_C_CHAR) { p->s4val = p->param; if (needalloc) { char *dp; #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { dp = wmb_to_utf(p->param, p->len); } else { dp = xmalloc(p->len + 1); } #else dp = xmalloc(p->len + 1); #endif if (!dp) { return nomem(s); } #if defined(_WIN32) || defined(_WIN64) if (*s->oemcp) { p->len = strlen(dp); } else { memcpy(dp, p->param, p->len); dp[p->len] = '\0'; } #else memcpy(dp, p->param, p->len); dp[p->len] = '\0'; #endif if (p->param == p->parbuf) { freep(&p->parbuf); } p->parbuf = p->param = dp; p->need = -1; p->s4val = p->param; p->s4size = p->len; } } break; case SQL_C_UTINYINT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLCHAR *) p->param); break; case SQL_C_TINYINT: case SQL_C_STINYINT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLCHAR *) p->param); break; case SQL_C_USHORT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLUSMALLINT *) p->param); break; case SQL_C_SHORT: case SQL_C_SSHORT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLSMALLINT *) p->param); break; case SQL_C_ULONG: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLUINTEGER *) p->param); break; case SQL_C_LONG: case SQL_C_SLONG: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = *((SQLINTEGER *) p->param); break; #ifdef SQL_BIT case SQL_C_BIT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (int); p->s4ival = (*((SQLCHAR *) p->param)) ? 1 : 0; break; #endif #ifdef SQL_BIGINT case SQL_C_SBIGINT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (sqlite4_int64); p->s4lival = *((sqlite4_int64 *) p->param); break; case SQL_C_UBIGINT: p->s4type = SQLITE4_INTEGER; p->s4size = sizeof (sqlite4_int64); p->s4lival = *((sqlite4_uint64 *) p->param); break; #endif case SQL_C_FLOAT: p->s4type = SQLITE4_FLOAT; p->s4size = sizeof (double); p->s4dval = *((float *) p->param); break; case SQL_C_DOUBLE: p->s4type = SQLITE4_FLOAT; p->s4size = sizeof (double); p->s4dval = *((double *) p->param); break; #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: sprintf(p->strbuf, "%04d-%02d-%02d", ((DATE_STRUCT *) p->param)->year, ((DATE_STRUCT *) p->param)->month, ((DATE_STRUCT *) p->param)->day); p->s4type = SQLITE4_TEXT; p->s4size = -1; p->s4val = p->strbuf; break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: sprintf(p->strbuf, "%02d:%02d:%02d", ((TIME_STRUCT *) p->param)->hour, ((TIME_STRUCT *) p->param)->minute, ((TIME_STRUCT *) p->param)->second); p->s4type = SQLITE4_TEXT; p->s4size = -1; p->s4val = p->strbuf; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: len = (int) ((TIMESTAMP_STRUCT *) p->param)->fraction; len /= 1000000; len = len % 1000; if (len < 0) { len = 0; } if (p->coldef && p->coldef <= 16) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:00.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute); } else if (p->coldef && p->coldef <= 19) { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.000", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second); } else { sprintf(p->strbuf, "%04d-%02d-%02d %02d:%02d:%02d.%03d", ((TIMESTAMP_STRUCT *) p->param)->year, ((TIMESTAMP_STRUCT *) p->param)->month, ((TIMESTAMP_STRUCT *) p->param)->day, ((TIMESTAMP_STRUCT *) p->param)->hour, ((TIMESTAMP_STRUCT *) p->param)->minute, ((TIMESTAMP_STRUCT *) p->param)->second, len); } p->s4type = SQLITE4_TEXT; p->s4size = -1; p->s4val = p->strbuf; break; default: error: setstat(s, -1, "unsupported parameter type", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } return SQL_SUCCESS; } /** * Internal bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ static SQLRETURN drvbindparam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLUINTEGER coldef, SQLSMALLINT scale, SQLPOINTER data, SQLINTEGER buflen, SQLLEN *len) { STMT *s; BINDPARM *p; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (pnum == 0) { setstat(s, -1, "invalid parameter", (*s->ov3) ? "07009" : "S1093"); return SQL_ERROR; } if (!data && !len) { setstat(s, -1, "invalid buffer", "HY003"); return SQL_ERROR; } --pnum; if (s->bindparms) { if (pnum >= s->nbindparms) { BINDPARM *newparms; newparms = xrealloc(s->bindparms, (pnum + 1) * sizeof (BINDPARM)); if (!newparms) { outofmem: return nomem(s); } s->bindparms = newparms; memset(&s->bindparms[s->nbindparms], 0, (pnum + 1 - s->nbindparms) * sizeof (BINDPARM)); s->nbindparms = pnum + 1; } } else { int npar = max(10, pnum + 1); s->bindparms = xmalloc(npar * sizeof (BINDPARM)); if (!s->bindparms) { goto outofmem; } memset(s->bindparms, 0, npar * sizeof (BINDPARM)); s->nbindparms = npar; } switch (buftype) { case SQL_C_STINYINT: case SQL_C_UTINYINT: case SQL_C_TINYINT: #ifdef SQL_C_BIT case SQL_C_BIT: #endif buflen = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: buflen = sizeof (SQLSMALLINT); break; case SQL_C_SLONG: case SQL_C_ULONG: case SQL_C_LONG: buflen = sizeof (SQLINTEGER); break; case SQL_C_FLOAT: buflen = sizeof (float); break; case SQL_C_DOUBLE: buflen = sizeof (double); break; case SQL_C_TIMESTAMP: #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif buflen = sizeof (TIMESTAMP_STRUCT); break; case SQL_C_TIME: #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif buflen = sizeof (TIME_STRUCT); break; case SQL_C_DATE: #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif buflen = sizeof (DATE_STRUCT); break; #ifdef SQL_C_UBIGINT case SQL_C_UBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_SBIGINT case SQL_C_SBIGINT: buflen = sizeof (SQLBIGINT); break; #endif #ifdef SQL_C_BIGINT case SQL_C_BIGINT: buflen = sizeof (SQLBIGINT); break; #endif } p = &s->bindparms[pnum]; p->type = buftype; p->stype = ptype; p->coldef = coldef; p->scale = scale; p->max = buflen; p->inc = buflen; p->lenp = p->lenp0 = len; p->offs = 0; p->len = 0; p->param0 = data; freep(&p->parbuf); p->param = p->param0; p->bound = 1; p->need = 0; return SQL_SUCCESS; } /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param iotype input/output type of parameter * @param buftype type of host variable * @param ptype * @param coldef * @param scale * @param data pointer to host variable * @param buflen length of host variable * @param len output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT iotype, SQLSMALLINT buftype, SQLSMALLINT ptype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER data, SQLLEN buflen, SQLLEN *len) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, iotype, buftype, ptype, coldef, scale, data, buflen, len); HSTMT_UNLOCK(stmt); return ret; } #ifndef HAVE_IODBC /** * Bind parameter on HSTMT. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param vtype input/output type of parameter * @param ptype * @param lenprec * @param scale * @param val pointer to host variable * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT vtype, SQLSMALLINT ptype, SQLULEN lenprec, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, pnum, SQL_PARAM_INPUT, vtype, ptype, lenprec, scale, val, 0, lenp); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Return number of parameters. * @param stmt statement handle * @param nparam output parameter count * @result ODBC error code */ SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT *nparam) { STMT *s; SQLSMALLINT dummy; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!nparam) { nparam = &dummy; } *nparam = s->nparams; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Setup parameter buffer for deferred parameter. * @param s pointer to STMT * @param p pointer to BINDPARM * @result ODBC error code (success indicated by SQL_NEED_DATA) */ static SQLRETURN setupparbuf(STMT *s, BINDPARM *p) { if (!p->parbuf) { if (*p->lenp == SQL_DATA_AT_EXEC) { p->len = p->max; } else { p->len = SQL_LEN_DATA_AT_EXEC(*p->lenp); } if (p->len < 0 && p->len != SQL_NTS && p->len != SQL_NULL_DATA) { setstat(s, -1, "invalid length", "HY009"); return SQL_ERROR; } if (p->len >= 0) { p->parbuf = xmalloc(p->len + 2); if (!p->parbuf) { return nomem(s); } p->param = p->parbuf; } else { p->param = NULL; } } return SQL_NEED_DATA; } /** * Retrieve next parameter for sending data to executing query. * @param stmt statement handle * @param pind pointer to output parameter indicator * @result ODBC error code */ SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt, SQLPOINTER *pind) { STMT *s; int i; SQLPOINTER dummy; SQLRETURN ret; BINDPARM *p; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!pind) { pind = &dummy; } if (s->pdcount < s->nparams) { s->pdcount++; } for (i = 0; i < s->pdcount; i++) { p = &s->bindparms[i]; if (p->need > 0) { int type = mapdeftype(p->type, p->stype, -1, s->nowchar[0]); p->need = (type == SQL_C_CHAR || type == SQL_C_WCHAR) ? -1 : 0; } } for (; i < s->nparams; i++) { p = &s->bindparms[i]; if (p->need > 0) { *pind = (SQLPOINTER) p->param0; ret = setupparbuf(s, p); s->pdcount = i; goto done; } } ret = drvexecute(stmt, 0); done: HSTMT_UNLOCK(stmt); return ret; } /** * Return information about parameter. * @param stmt statement handle * @param pnum parameter number, starting at 1 * @param dtype output type indicator * @param size output size indicator * @param decdigits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt, SQLUSMALLINT pnum, SQLSMALLINT *dtype, SQLULEN *size, SQLSMALLINT *decdigits, SQLSMALLINT *nullable) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; --pnum; if (pnum >= s->nparams) { setstat(s, -1, "invalid parameter index", (*s->ov3) ? "HY000" : "S1000"); goto done; } if (dtype) { #ifdef SQL_LONGVARCHAR #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR; #else *dtype = SQL_LONGVARCHAR; #endif #else #ifdef WINTERFACE *dtype = s->nowchar[0] ? SQL_VARCHAR : SQL_WVARCHAR; #else *dtype = SQL_VARCHAR; #endif #endif } if (size) { #ifdef SQL_LONGVARCHAR *size = 65536; #else *size = 255; #endif } if (decdigits) { *decdigits = 0; } if (nullable) { *nullable = SQL_NULLABLE; } ret = SQL_SUCCESS; done: HSTMT_UNLOCK(stmt); return ret; } /** * Set information on parameter. * @param stmt statement handle * @param par parameter number, starting at 1 * @param type type of host variable * @param sqltype * @param coldef * @param scale * @param val pointer to host variable * @param nval output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLSetParam(SQLHSTMT stmt, SQLUSMALLINT par, SQLSMALLINT type, SQLSMALLINT sqltype, SQLULEN coldef, SQLSMALLINT scale, SQLPOINTER val, SQLLEN *nval) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindparam(stmt, par, SQL_PARAM_INPUT, type, sqltype, coldef, scale, val, SQL_SETPARAM_VALUE_MAX, nval); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt, SQLULEN rows, SQLULEN *rowp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen, SQLINTEGER *strlen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescField(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescFieldW(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT fieldid, SQLPOINTER value, SQLINTEGER buflen) { return SQL_ERROR; } #endif #ifndef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif #ifdef WINTERFACE /** * Function not implemented. */ SQLRETURN SQL_API SQLGetDescRecW(SQLHDESC handle, SQLSMALLINT recno, SQLWCHAR *name, SQLSMALLINT buflen, SQLSMALLINT *strlen, SQLSMALLINT *type, SQLSMALLINT *subtype, SQLLEN *len, SQLSMALLINT *prec, SQLSMALLINT *scale, SQLSMALLINT *nullable) { return SQL_ERROR; } #endif /** * Function not implemented. */ SQLRETURN SQL_API SQLSetDescRec(SQLHDESC handle, SQLSMALLINT recno, SQLSMALLINT type, SQLSMALLINT subtype, SQLLEN len, SQLSMALLINT prec, SQLSMALLINT scale, SQLPOINTER data, SQLLEN *strlen, SQLLEN *indicator) { return SQL_ERROR; } /** * Setup empty result set from constant column specification. * @param stmt statement handle * @param colspec column specification array (default, ODBC2) * @param ncols number of columns (default, ODBC2) * @param colspec3 column specification array (ODBC3) * @param ncols4 number of columns (ODBC3) * @param nret returns number of columns * @result ODBC error code */ static SQLRETURN mkresultset(HSTMT stmt, COL *colspec, int ncols, COL *colspec3, int ncols4, int *nret) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } s4stmt_end_if(s); freeresult(s, 0); if (colspec3 && *s->ov3) { s->ncols = ncols4; s->cols = colspec3; } else { s->ncols = ncols; s->cols = colspec; } mkbindcols(s, s->ncols); s->nowchar[1] = 1; s->nrows = 0; s->rowp = -1; s->isselect = -1; if (nret) { *nret = s->ncols; } return SQL_SUCCESS; } /** * Columns for result set of SQLTablePrivileges(). */ static COL tablePrivSpec2[] = { { "SYSTEM", "TABLEPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; static COL tablePrivSpec3[] = { { "SYSTEM", "TABLEPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "TABLEPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 }, { "SYSTEM", "TABLEPRIV", "IS_GRANTABLE", SCOL_VARCHAR, 50 } }; /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtableprivileges(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, rc, size, npatt; char *errp = NULL, *sql, tname[512]; ret = mkresultset(stmt, tablePrivSpec2, array_size(tablePrivSpec2), tablePrivSpec3, array_size(tablePrivSpec3), NULL); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); #if defined(_WIN32) || defined(_WIN64) sql = sqlite4_mprintf(0, "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname, d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", npatt ? "like" : "=", tname); #else sql = sqlite4_mprintf(0, "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'SELECT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'UPDATE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'DELETE' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'INSERT' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q " "UNION " "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "'' as 'GRANTOR', " "'' as 'GRANTEE', " "'REFERENCES' AS 'PRIVILEGE', " "NULL as 'IS_GRANTABLE' " "from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname, npatt ? "like" : "=", tname); #endif if (!sql) { return nomem(s); } ret = starttran(s); if (ret != SQL_SUCCESS) { sqlite4_free(0, sql); return ret; } dbtraceapi(d, "sqlite4_get_table", sql); rc = sqlite4_get_table(d->sqlite, sql, &s->rows, &s->nrows, &ncols, &errp); sqlite4_free(0, sql); if (rc == SQLITE4_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = freerows; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite4_free(0, errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on tables and/or views. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvtableprivileges(stmt, catalog, catalogLen, schema, schemaLen, table, tableLen); goto done2; } if (catalog) { c = wmb_to_utf_c((char *) catalog, catalogLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtableprivileges(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); #else ret = drvtableprivileges(stmt, catalog, catalogLen, schema, schemaLen, table, tableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on tables and/or views (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (catalog) { c = uc_to_utf_c(catalog, catalogLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtableprivileges(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif #endif /** * Columns for result set of SQLColumnPrivileges(). */ static COL colPrivSpec2[] = { { "SYSTEM", "COLPRIV", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; static COL colPrivSpec3[] = { { "SYSTEM", "COLPRIV", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLPRIV", "GRANTOR", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "GRANTEE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLPRIV", "PRIVILEGE", SCOL_VARCHAR, 50 } }; #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Retrieve privileges on columns. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Retrieve privileges on columns (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param column column name or NULL * @param columnLen length of column name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnPrivilegesW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, colPrivSpec2, array_size(colPrivSpec2), colPrivSpec3, array_size(colPrivSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #endif /** * Columns for result set of SQLPrimaryKeys(). */ static COL pkeySpec2[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; static COL pkeySpec3[] = { { "SYSTEM", "PRIMARYKEY", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PRIMARYKEY", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PRIMARYKEY", "KEY_SEQ", SQL_SMALLINT, 50 }, { "SYSTEM", "PRIMARYKEY", "PK_NAME", SCOL_VARCHAR, 50 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprimarykeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nrows2 = 0, ncols2 = 0; int namec = -1, uniquec = -1, namec2 = -1, uniquec2 = -1, offs, seq = 1; PTRDIFF_T size; char **rowp = NULL, **rowp2 = NULL, *errp = NULL, *sql, tname[512]; sret = mkresultset(stmt, pkeySpec2, array_size(pkeySpec2), pkeySpec3, array_size(pkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite4_free(0, sql); return sret; } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } size = 0; if (ncols * nrows > 0) { int typec; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); if (namec >= 0 && uniquec >= 0 && typec >= 0) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { size++; } } } } if (size == 0) { sql = sqlite4_mprintf(0, "PRAGMA index_list(%Q)", tname); if (!sql) { freerows(rowp); return nomem(s); } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp2, &nrows2, &ncols2, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { freerows(rowp); freerows(rowp2); setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } } if (ncols2 * nrows2 > 0) { namec2 = findcol(rowp2, ncols2, "name"); uniquec2 = findcol(rowp2, ncols2, "unique"); if (namec2 >= 0 && uniquec2 >= 0) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols, nlen = 0; char **rowpp; if (rowp2[i * ncols2 + namec2]) { nlen = strlen(rowp2[i * ncols2 + namec2]); } if (nlen < 17 || strncmp(rowp2[i * ncols2 + namec2], "sqlite_autoindex_", 17)) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp2[i * ncols2 + namec2]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret == SQLITE4_OK) { size += nnrows; freerows(rowpp); } } } } } if (size == 0) { freerows(rowp); freerows(rowp2); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; freerows(rowp); freerows(rowp2); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = s->ncols; if (rowp) { for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0') { char buf[32]; s->rows[offs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[offs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[offs + 1] = xstrdup(""); #endif s->rows[offs + 2] = xstrdup(tname); s->rows[offs + 3] = xstrdup(rowp[i * ncols + namec]); sprintf(buf, "%d", seq++); s->rows[offs + 4] = xstrdup(buf); offs += s->ncols; } } } if (rowp2) { for (i = 1; i <= nrows2; i++) { int nnrows, nncols, nlen = 0; char **rowpp; if (rowp2[i * ncols2 + namec2]) { nlen = strlen(rowp2[i * ncols2 + namec2]); } if (nlen < 17 || strncmp(rowp2[i * ncols2 + namec2], "sqlite_autoindex_", 17)) { continue; } if (*rowp2[i * ncols2 + uniquec2] != '0') { int k; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp2[i * ncols2 + namec2]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret != SQLITE4_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 5] = xstrdup(rowp2[i * ncols2 + namec2]); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = offs + (m - 1) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 4] = xstrdup(buf); } } } offs += nnrows * s->ncols; freerows(rowpp); } } } freerows(rowp); freerows(rowp2); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprimarykeys(stmt, cat, catLen, schema, schemaLen, table, tableLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvprimarykeys(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); #else ret = drvprimarykeys(stmt, cat, catLen, schema, schemaLen, table, tableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrimaryKeysW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvprimarykeys(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLSpecialColumns(). */ static COL scolSpec2[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; static COL scolSpec3[] = { { "SYSTEM", "COLUMN", "SCOPE", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "PSEUDO_COLUMN", SQL_SMALLINT, 1 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 1 } }; /** * Internal retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ static SQLRETURN drvspecialcolumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, nnnrows, nnncols, offs; PTRDIFF_T size; int namec = -1, uniquec = -1, namecc = -1, typecc = -1; int notnullcc = -1, mkrowid = 0; char *errp = NULL, *sql, tname[512]; char **rowp = NULL, **rowppp = NULL; sret = mkresultset(stmt, scolSpec2, array_size(scolSpec2), scolSpec3, array_size(scolSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); if (id != SQL_BEST_ROWID) { return SQL_SUCCESS; } sql = sqlite4_mprintf(0, "PRAGMA index_list(%Q)", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite4_free(0, sql); return sret; } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { doerr: setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } size = 0; /* number result rows */ if (ncols * nrows <= 0) { goto nodata_but_rowid; } sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", tname); if (!sql) { return nomem(s); } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowppp, &nnnrows, &nnncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { freerows(rowp); goto doerr; } if (errp) { sqlite4_free(0, errp); errp = NULL; } namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata_but_rowid; } namecc = findcol(rowppp, nnncols, "name"); typecc = findcol(rowppp, nnncols, "type"); notnullcc = findcol(rowppp, nnncols, "notnull"); for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = NULL; if (*rowp[i * ncols + uniquec] != '0') { ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret == SQLITE4_OK) { size += nnrows; freerows(rowpp); } } } nodata_but_rowid: if (size == 0) { size = 1; mkrowid = 1; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; freerows(rowp); freerows(rowppp); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; if (mkrowid) { s->nrows = 0; goto mkrowid; } offs = 0; for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = NULL; if (*rowp[i * ncols + uniquec] != '0') { int k; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret != SQLITE4_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + m) * s->ncols; s->rows[roffs + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[roffs + 1] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 4] = xstrdup("0"); s->rows[roffs + 7] = xstrdup(stringify(SQL_PC_NOT_PSEUDO)); if (namecc >= 0 && typecc >= 0) { int ii; for (ii = 1; ii <= nnnrows; ii++) { if (strcmp(rowppp[ii * nnncols + namecc], rowpp[m * nncols + k]) == 0) { char *typen = rowppp[ii * nnncols + typecc]; int sqltype, mm, dd, isnullable = 0; char buf[32]; s->rows[roffs + 3] = xstrdup(typen); sqltype = mapsqltype(typen, NULL, *s->ov3, s->nowchar[0], s->dobigint); getmd(typen, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } sprintf(buf, "%d", sqltype); s->rows[roffs + 2] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[roffs + 5] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[roffs + 6] = xstrdup(buf); if (notnullcc >= 0) { char *inp = rowppp[ii * nnncols + notnullcc]; isnullable = inp[0] != '0'; } sprintf(buf, "%d", isnullable); s->rows[roffs + 8] = xstrdup(buf); } } } } } } offs += nnrows; freerows(rowpp); } } if (nullable == SQL_NO_NULLS) { for (i = 1; i < s->nrows; i++) { if (s->rows[i * s->ncols + 8][0] == '0') { int m, i1 = i + 1; for (m = 0; m < s->ncols; m++) { freep(&s->rows[i * s->ncols + m]); } size = s->ncols * sizeof (char *) * (s->nrows - i1); if (size > 0) { memmove(s->rows + i * s->ncols, s->rows + i1 * s->ncols, size); memset(s->rows + s->nrows * s->ncols, 0, s->ncols * sizeof (char *)); } s->nrows--; --i; } } } mkrowid: freerows(rowp); freerows(rowppp); if (s->nrows == 0) { s->rows[s->ncols + 0] = xstrdup(stringify(SQL_SCOPE_SESSION)); s->rows[s->ncols + 1] = xstrdup("_ROWID_"); s->rows[s->ncols + 2] = xstrdup(stringify(SQL_INTEGER)); s->rows[s->ncols + 3] = xstrdup("integer"); s->rows[s->ncols + 4] = xstrdup("0"); s->rows[s->ncols + 5] = xstrdup("10"); s->rows[s->ncols + 6] = xstrdup("9"); s->rows[s->ncols + 7] = xstrdup(stringify(SQL_PC_PSEUDO)); s->rows[s->ncols + 8] = xstrdup(stringify(SQL_FALSE)); s->nrows = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about indexed columns. * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt, SQLUSMALLINT id, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvspecialcolumns(stmt, id, cat, catLen, schema, schemaLen, table, tableLen, scope, nullable); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvspecialcolumns(stmt, id, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, scope, nullable); #else ret = drvspecialcolumns(stmt, id, cat, catLen, schema, schemaLen, table, tableLen, scope, nullable); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about indexed columns (UNICODE version). * @param stmt statement handle * @param id type of information, e.g. best row id * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param scope * @param nullable * @result ODBC error code */ SQLRETURN SQL_API SQLSpecialColumnsW(SQLHSTMT stmt, SQLUSMALLINT id, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT scope, SQLUSMALLINT nullable) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvspecialcolumns(stmt, id, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, scope, nullable); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLForeignKeys(). */ static COL fkeySpec2[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; static COL fkeySpec3[] = { { "SYSTEM", "FOREIGNKEY", "PKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "PKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "FOREIGNKEY", "FKTABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "FKCOLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "KEY_SEQ", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "UPDATE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "DELETE_RULE", SQL_SMALLINT, 5 }, { "SYSTEM", "FOREIGNKEY", "FK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "PK_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "FOREIGNKEY", "DEFERRABILITY", SQL_SMALLINT, 5 } }; /** * Internal retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ static SQLRETURN SQL_API drvforeignkeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { STMT *s; DBC *d; SQLRETURN sret; int i, asize, ret, nrows, ncols, offs, namec, seqc, fromc, toc; int onu, ond; PTRDIFF_T size; char **rowp, *errp = NULL, *sql, pname[512], fname[512]; sret = mkresultset(stmt, fkeySpec2, array_size(fkeySpec2), fkeySpec3, array_size(fkeySpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } d = (DBC *) s->dbc; if ((!PKtable || PKtable[0] == '\0' || PKtable[0] == '%') && (!FKtable || FKtable[0] == '\0' || FKtable[0] == '%')) { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } size = 0; if (PKtable) { if (PKtableLen == SQL_NTS) { size = sizeof (pname) - 1; } else { size = min(sizeof (pname) - 1, PKtableLen); } strncpy(pname, (char *) PKtable, size); } pname[size] = '\0'; size = 0; if (FKtable) { if (FKtableLen == SQL_NTS) { size = sizeof (fname) - 1; } else { size = min(sizeof (fname) - 1, FKtableLen); } strncpy(fname, (char *) FKtable, size); } fname[size] = '\0'; if (fname[0] != '\0') { int plen; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA foreign_key_list(%Q)", fname); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); } if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } if (ncols * nrows <= 0) { nodata: freerows(rowp); return SQL_SUCCESS; } size = 0; namec = findcol(rowp, ncols, "table"); seqc = findcol(rowp, ncols, "seq"); fromc = findcol(rowp, ncols, "from"); toc = findcol(rowp, ncols, "to"); onu = findcol(rowp, ncols, "on_update"); ond = findcol(rowp, ncols, "on_delete"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { goto nodata; } plen = strlen(pname); for (i = 1; i <= nrows; i++) { char *ptab = unquote(rowp[i * ncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = rowp[i * ncols + namec]; char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (plen != len || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowp[i * ncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(fname); s->rows[roffs + 7] = xstrdup(rowp[i * ncols + fromc]); sscanf(rowp[i * ncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); if (onu < 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowp[i * ncols + onu], "SET NULL") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowp[i * ncols + onu], "SET DEFAULT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowp[i * ncols + onu], "CASCADE") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowp[i * ncols + onu], "RESTRICT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } } if (ond < 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowp[i * ncols + ond], "SET NULL") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowp[i * ncols + ond], "SET DEFAULT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowp[i * ncols + ond], "CASCADE") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowp[i * ncols + ond], "RESTRICT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } } s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } freerows(rowp); } else { int nnrows, nncols, plen = strlen(pname); char **rowpp; sql = "select name from sqlite_master where type='table'"; dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } if (ncols * nrows <= 0) { goto nodata; } size = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } rowpp = NULL; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA foreign_key_list(%Q)", rowp[i]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret != SQLITE4_OK || nncols * nnrows <= 0) { freerows(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { freerows(rowpp); continue; } for (k = 1; k <= nnrows; k++) { char *ptab = unquote(rowpp[k * nncols + namec]); if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } size++; } freerows(rowpp); } if (size == 0) { goto nodata; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; for (i = 1; i <= nrows; i++) { int k; if (!rowp[i]) { continue; } rowpp = NULL; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA foreign_key_list(%Q)", rowp[i]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret != SQLITE4_OK || nncols * nnrows <= 0) { freerows(rowpp); continue; } namec = findcol(rowpp, nncols, "table"); seqc = findcol(rowpp, nncols, "seq"); fromc = findcol(rowpp, nncols, "from"); toc = findcol(rowpp, nncols, "to"); onu = findcol(rowpp, nncols, "on_update"); ond = findcol(rowpp, nncols, "on_delete"); if (namec < 0 || seqc < 0 || fromc < 0 || toc < 0) { freerows(rowpp); continue; } for (k = 1; k <= nnrows; k++) { int pos = 0, roffs = (offs + 1) * s->ncols; char *ptab = unquote(rowpp[k * nncols + namec]); char buf[32]; if (plen && ptab) { int len = strlen(ptab); if (len != plen || strncasecmp(pname, ptab, plen) != 0) { continue; } } s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(ptab); s->rows[roffs + 3] = xstrdup(rowpp[k * nncols + toc]); s->rows[roffs + 4] = xstrdup(""); s->rows[roffs + 5] = xstrdup(""); s->rows[roffs + 6] = xstrdup(rowp[i]); s->rows[roffs + 7] = xstrdup(rowpp[k * nncols + fromc]); sscanf(rowpp[k * nncols + seqc], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 8] = xstrdup(buf); if (onu < 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowpp[k * nncols + onu], "SET NULL") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowpp[k * nncols + onu], "SET DEFAULT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowpp[k * nncols + onu], "CASCADE") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowpp[k * nncols + onu], "RESTRICT") == 0) { s->rows[roffs + 9] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 9] = xstrdup(stringify(SQL_NO_ACTION)); } } if (ond < 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } else { if (strcmp(rowpp[k * nncols + ond], "SET NULL") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_NULL)); } else if (strcmp(rowpp[k * nncols + ond], "SET DEFAULT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_SET_DEFAULT)); } else if (strcmp(rowpp[k * nncols + ond], "CASCADE") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_CASCADE)); } else if (strcmp(rowpp[k * nncols + ond], "RESTRICT") == 0) { s->rows[roffs + 10] = xstrdup(stringify(SQL_RESTRICT)); } else { s->rows[roffs + 10] = xstrdup(stringify(SQL_NO_ACTION)); } } s->rows[roffs + 11] = NULL; s->rows[roffs + 12] = NULL; s->rows[roffs + 13] = xstrdup(stringify(SQL_NOT_DEFERRABLE)); offs++; } freerows(rowpp); } freerows(rowp); } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information about primary/foreign keys. * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt, SQLCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLCHAR *PKtable, SQLSMALLINT PKtableLen, SQLCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLCHAR *FKtable, SQLSMALLINT FKtableLen) { #if defined(_WIN32) || defined(_WIN64) char *pc = NULL, *ps = NULL, *pt = NULL; char *fc = NULL, *fs = NULL, *ft = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvforeignkeys(stmt, PKcatalog, PKcatalogLen, PKschema, PKschemaLen, PKtable, PKtableLen, FKcatalog, FKcatalogLen, FKschema, FKschemaLen, FKtable, FKtableLen); goto done2; } if (PKcatalog) { pc = wmb_to_utf_c((char *) PKcatalog, PKcatalogLen); if (!pc) { ret = nomem((STMT *) stmt); goto done; } } if (PKschema) { ps = wmb_to_utf_c((char *) PKschema, PKschemaLen); if (!ps) { ret = nomem((STMT *) stmt); goto done; } } if (PKtable) { pt = wmb_to_utf_c((char *) PKtable, PKtableLen); if (!pt) { ret = nomem((STMT *) stmt); goto done; } } if (FKcatalog) { fc = wmb_to_utf_c((char *) FKcatalog, FKcatalogLen); if (!fc) { ret = nomem((STMT *) stmt); goto done; } } if (FKschema) { fs = wmb_to_utf_c((char *) FKschema, FKschemaLen); if (!fs) { ret = nomem((STMT *) stmt); goto done; } } if (FKtable) { ft = wmb_to_utf_c((char *) FKtable, FKtableLen); if (!ft) { ret = nomem((STMT *) stmt); goto done; } } ret = drvforeignkeys(stmt, (SQLCHAR *) pc, SQL_NTS, (SQLCHAR *) ps, SQL_NTS, (SQLCHAR *) pt, SQL_NTS, (SQLCHAR *) fc, SQL_NTS, (SQLCHAR *) fs, SQL_NTS, (SQLCHAR *) ft, SQL_NTS); #else ret = drvforeignkeys(stmt, PKcatalog, PKcatalogLen, PKschema, PKschemaLen, PKtable, PKtableLen, FKcatalog, FKcatalogLen, FKschema, FKschemaLen, FKtable, FKtableLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(ft); uc_free(fs); uc_free(fc); uc_free(pt); uc_free(ps); uc_free(pc); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about primary/foreign keys (UNICODE version). * @param stmt statement handle * @param PKcatalog primary key catalog name/pattern or NULL * @param PKcatalogLen length of PKcatalog or SQL_NTS * @param PKschema primary key schema name/pattern or NULL * @param PKschemaLen length of PKschema or SQL_NTS * @param PKtable primary key table name/pattern or NULL * @param PKtableLen length of PKtable or SQL_NTS * @param FKcatalog foreign key catalog name/pattern or NULL * @param FKcatalogLen length of FKcatalog or SQL_NTS * @param FKschema foreign key schema name/pattern or NULL * @param FKschemaLen length of FKschema or SQL_NTS * @param FKtable foreign key table name/pattern or NULL * @param FKtableLen length of FKtable or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLForeignKeysW(SQLHSTMT stmt, SQLWCHAR *PKcatalog, SQLSMALLINT PKcatalogLen, SQLWCHAR *PKschema, SQLSMALLINT PKschemaLen, SQLWCHAR *PKtable, SQLSMALLINT PKtableLen, SQLWCHAR *FKcatalog, SQLSMALLINT FKcatalogLen, SQLWCHAR *FKschema, SQLSMALLINT FKschemaLen, SQLWCHAR *FKtable, SQLSMALLINT FKtableLen) { char *pc = NULL, *ps = NULL, *pt = NULL; char *fc = NULL, *fs = NULL, *ft = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (PKcatalog) { pc = uc_to_utf_c(PKcatalog, PKcatalogLen); if (!pc) { ret = nomem((STMT *) stmt); goto done; } } if (PKschema) { ps = uc_to_utf_c(PKschema, PKschemaLen); if (!ps) { ret = nomem((STMT *) stmt); goto done; } } if (PKtable) { pt = uc_to_utf_c(PKtable, PKtableLen); if (!pt) { ret = nomem((STMT *) stmt); goto done; } } if (FKcatalog) { fc = uc_to_utf_c(FKcatalog, FKcatalogLen); if (!fc) { ret = nomem((STMT *) stmt); goto done; } } if (FKschema) { fs = uc_to_utf_c(FKschema, FKschemaLen); if (!fs) { ret = nomem((STMT *) stmt); goto done; } } if (FKtable) { ft = uc_to_utf_c(FKtable, FKtableLen); if (!ft) { ret = nomem((STMT *) stmt); goto done; } } ret = drvforeignkeys(stmt, (SQLCHAR *) pc, SQL_NTS, (SQLCHAR *) ps, SQL_NTS, (SQLCHAR *) pt, SQL_NTS, (SQLCHAR *) fc, SQL_NTS, (SQLCHAR *) fs, SQL_NTS, (SQLCHAR *) ft, SQL_NTS); done: uc_free(ft); uc_free(fs); uc_free(fc); uc_free(pt); uc_free(ps); uc_free(pc); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Start transaction when autocommit off * @param s statement pointer * @result ODBC error code */ static SQLRETURN starttran(STMT *s) { int ret = SQL_SUCCESS, rc, busy_count = 0; char *errp = NULL; DBC *d = (DBC *) s->dbc; if (!d->autocommit && !d->intrans && !d->trans_disable) { rc = sqlite4_exec(d->sqlite, "BEGIN TRANSACTION", NULL, NULL, &errp); dbtracerc(d, rc, errp); if (rc != SQLITE4_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); ret = SQL_ERROR; } else { d->intrans = 1; } if (errp) { sqlite4_free(0, errp); errp = NULL; } } return ret; } /** * Internal commit or rollback transaction. * @param d database connection pointer * @param comptype type of transaction's end, SQL_COMMIT or SQL_ROLLBACK * @param force force action regardless of DBC's autocommit state * @result ODBC error code */ static SQLRETURN endtran(DBC *d, SQLSMALLINT comptype, int force) { int ret, busy_count = 0; char *sql, *errp = NULL; if (!d->sqlite) { setstatd(d, -1, "not connected", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if ((!force && d->autocommit) || !d->intrans) { return SQL_SUCCESS; } switch (comptype) { case SQL_COMMIT: sql = "COMMIT TRANSACTION"; goto doit; case SQL_ROLLBACK: sql = "ROLLBACK TRANSACTION"; doit: ret = sqlite4_exec(d->sqlite, sql, NULL, NULL, &errp); dbtracerc(d, ret, errp); d->intrans = 0; if (ret != SQLITE4_OK) { setstatd(d, ret, "%s", (*d->ov3) ? "HY000" : "S1000", errp ? errp : "transaction failed"); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_SUCCESS; } setstatd(d, -1, "invalid completion type", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } /** * Internal commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ static SQLRETURN drvendtran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { DBC *d; int fail = 0; SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) ENV *e; #endif switch (type) { case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); if (handle == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) handle; ret = endtran(d, comptype, 0); HDBC_UNLOCK((SQLHDBC) handle); return ret; case SQL_HANDLE_ENV: if (handle == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) e = (ENV *) handle; if (e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif d = ((ENV *) handle)->dbcs; while (d) { ret = endtran(d, comptype, 0); if (ret != SQL_SUCCESS) { fail++; } d = d->next; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return fail ? SQL_ERROR : SQL_SUCCESS; } return SQL_INVALID_HANDLE; } /** * Commit or rollback transaction. * @param type type of handle * @param handle HDBC, HENV, or HSTMT handle * @param comptype SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLEndTran(SQLSMALLINT type, SQLHANDLE handle, SQLSMALLINT comptype) { return drvendtran(type, handle, comptype); } /** * Commit or rollback transaction. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param type SQL_COMMIT or SQL_ROLLBACK * @result ODBC error code */ SQLRETURN SQL_API SQLTransact(SQLHENV env, SQLHDBC dbc, SQLUSMALLINT type) { if (env != SQL_NULL_HENV) { return drvendtran(SQL_HANDLE_ENV, (SQLHANDLE) env, type); } return drvendtran(SQL_HANDLE_DBC, (SQLHANDLE) dbc, type); } /** * Function not implemented. */ SQLRETURN SQL_API SQLCopyDesc(SQLHDESC source, SQLHDESC target) { return SQL_ERROR; } #ifndef WINTERFACE /** * Translate SQL string. * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSql(SQLHSTMT stmt, SQLCHAR *sqlin, SQLINTEGER sqlinLen, SQLCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = strlen((char *) sqlin); } if (sql) { if (sqlMax > 0) { strncpy((char *) sql, (char *) sqlin, sqlMax - 1); sqlin[sqlMax - 1] = '\0'; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Translate SQL string (UNICODE version). * @param stmt statement handle * @param sqlin input string * @param sqlinLen length of input string * @param sql output string * @param sqlMax max space in output string * @param sqlLen value return for length of output string * @result ODBC error code */ SQLRETURN SQL_API SQLNativeSqlW(SQLHSTMT stmt, SQLWCHAR *sqlin, SQLINTEGER sqlinLen, SQLWCHAR *sql, SQLINTEGER sqlMax, SQLINTEGER *sqlLen) { int outLen = 0; SQLRETURN ret = SQL_SUCCESS; HSTMT_LOCK(stmt); if (sqlinLen == SQL_NTS) { sqlinLen = uc_strlen(sqlin); } if (sql) { if (sqlMax > 0) { uc_strncpy(sql, sqlin, sqlMax - 1); sqlin[sqlMax - 1] = 0; outLen = min(sqlMax - 1, sqlinLen); } } else { outLen = sqlinLen; } if (sqlLen) { *sqlLen = outLen; } if (sql && outLen < sqlinLen) { setstat((STMT *) stmt, -1, "data right truncated", "01004"); ret = SQL_SUCCESS_WITH_INFO; } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedures(). */ static COL procSpec2[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; static COL procSpec3[] = { { "SYSTEM", "PROCEDURE", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "NUM_INPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_OUTPUT_PARAMS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "NUM_RESULT_SETS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCEDURE", "REMARKS", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCEDURE", "PROCEDURE_TYPE", SQL_SMALLINT, 5 } }; #ifndef WINTERFACE /** * Retrieve information about stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProceduresW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procSpec2, array_size(procSpec2), procSpec3, array_size(procSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLProcedureColumns(). */ static COL procColSpec2[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PRECISION", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "SCALE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL procColSpec3[] = { { "SYSTEM", "PROCCOL", "PROCEDURE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "PROCEDURE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "PROCCOL", "COLUMN_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_SIZE", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "BUFFER_LENGTH", SQL_INTEGER, 10 }, { "SYSTEM", "PROCCOL", "DECIMAL_DIGITS", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NUM_PREC_RADIX", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "NULLABLE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "PROCCOL", "SQL_DATA_TYPE", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "SQL_DATETIME_SUB", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "ORDINAL_POSITION", SQL_SMALLINT, 5 }, { "SYSTEM", "PROCCOL", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; #ifndef WINTERFACE /** * Retrieve information about columns in result set of stored procedures. * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt, SQLCHAR *catalog, SQLSMALLINT catalogLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *proc, SQLSMALLINT procLen, SQLCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information about columns in result * set of stored procedures (UNICODE version). * @param stmt statement handle * @param catalog catalog name/pattern or NULL * @param catalogLen length of catalog or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema or SQL_NTS * @param proc procedure name/pattern or NULL * @param procLen length of proc or SQL_NTS * @param column column name/pattern or NULL * @param columnLen length of column or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLProcedureColumnsW(SQLHSTMT stmt, SQLWCHAR *catalog, SQLSMALLINT catalogLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *proc, SQLSMALLINT procLen, SQLWCHAR *column, SQLSMALLINT columnLen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = mkresultset(stmt, procColSpec2, array_size(procColSpec2), procColSpec3, array_size(procColSpec3), NULL); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Get information of HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len, SQLINTEGER *lenp) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_ERROR; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val) { *((SQLINTEGER *) val) = SQL_TRUE; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; case SQL_ATTR_ODBC_VERSION: if (val) { *((SQLINTEGER *) val) = e->ov3 ? SQL_OV_ODBC3 : SQL_OV_ODBC2; } if (lenp) { *lenp = sizeof (SQLINTEGER); } ret = SQL_SUCCESS; break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Set information in HENV. * @param env environment handle * @param attr attribute to be retrieved * @param val parameter buffer * @param len length of parameter * @result ODBC error code */ SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { ENV *e; SQLRETURN ret = SQL_ERROR; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (!e || e->magic != ENV_MAGIC) { return SQL_INVALID_HANDLE; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif switch (attr) { case SQL_ATTR_CONNECTION_POOLING: ret = SQL_SUCCESS; break; case SQL_ATTR_CP_MATCH: ret = SQL_NO_DATA; break; case SQL_ATTR_OUTPUT_NTS: if (val == (SQLPOINTER) SQL_TRUE) { ret = SQL_SUCCESS; } break; case SQL_ATTR_ODBC_VERSION: if (!val) { break; } if (val == (SQLPOINTER) SQL_OV_ODBC2) { e->ov3 = 0; ret = SQL_SUCCESS; } if (val == (SQLPOINTER) SQL_OV_ODBC3) { e->ov3 = 1; ret = SQL_SUCCESS; } break; } #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); #endif return ret; } /** * Internal get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ static SQLRETURN drvgetdiagrec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { DBC *d = NULL; STMT *s = NULL; int len, naterr; char *logmsg, *sqlst; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (sqlstate) { sqlstate[0] = '\0'; } if (msg && buflen > 0) { msg[0] = '\0'; } if (msglen) { *msglen = 0; } if (nativeerr) { *nativeerr = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { goto done; } if (recno > 1) { ret = SQL_NO_DATA; goto done; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (nativeerr) { *nativeerr = naterr; } if (sqlstate) { strcpy((char *) sqlstate, sqlst); } if (msglen) { *msglen = len; } if (len >= buflen) { if (msg && buflen > 0) { strncpy((char *) msg, logmsg, buflen); msg[buflen - 1] = '\0'; logmsg[0] = '\0'; } } else if (msg) { strcpy((char *) msg, logmsg); logmsg[0] = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #if !defined(WINTERFACE) || (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) /** * Get error message given handle (HENV, HDBC, or HSTMT). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLCHAR *sqlstate, SQLINTEGER *nativeerr, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { return drvgetdiagrec(htype, handle, recno, sqlstate, nativeerr, msg, buflen, msglen); } #endif #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) #ifdef WINTERFACE /** * Get error message given handle (HENV, HDBC, or HSTMT) * (UNICODE version). * @param htype handle type * @param handle HENV, HDBC, or HSTMT * @param recno * @param sqlstate output buffer for SQL state * @param nativeerr output buffer of native error code * @param msg output buffer for error message * @param buflen length of output buffer * @param msglen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagRecW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLWCHAR *sqlstate, SQLINTEGER *nativeerr, SQLWCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *msglen) { char state[16]; SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagrec(htype, handle, recno, (SQLCHAR *) state, nativeerr, (SQLCHAR *) msg, buflen, &len); if (ret == SQL_SUCCESS) { if (sqlstate) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlstate, 6 * sizeof (SQLWCHAR)); } if (msg) { if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) msg, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(msg, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { msg[0] = 0; } } } else { /* estimated length !!! */ len *= sizeof (SQLWCHAR); } if (msglen) { *msglen = len; } } else if (ret == SQL_NO_DATA) { if (sqlstate) { sqlstate[0] = 0; } if (msg) { if (buflen > 0) { msg[0] = 0; } } if (msglen) { *msglen = 0; } } return ret; } #endif #endif /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ static SQLRETURN drvgetdiagfield(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { DBC *d = NULL; STMT *s = NULL; int len, naterr, strbuf = 1; char *logmsg, *sqlst, *clrmsg = NULL; SQLRETURN ret = SQL_ERROR; if (handle == SQL_NULL_HANDLE) { return SQL_INVALID_HANDLE; } if (stringlen) { *stringlen = 0; } switch (htype) { case SQL_HANDLE_ENV: case SQL_HANDLE_DESC: return SQL_NO_DATA; case SQL_HANDLE_DBC: HDBC_LOCK((SQLHDBC) handle); d = (DBC *) handle; logmsg = (char *) d->logmsg; sqlst = d->sqlstate; naterr = d->naterr; break; case SQL_HANDLE_STMT: HSTMT_LOCK((SQLHSTMT) handle); s = (STMT *) handle; d = (DBC *) s->dbc; logmsg = (char *) s->logmsg; sqlst = s->sqlstate; naterr = s->naterr; break; default: return SQL_INVALID_HANDLE; } if (buflen < 0) { switch (buflen) { case SQL_IS_POINTER: case SQL_IS_UINTEGER: case SQL_IS_INTEGER: case SQL_IS_USMALLINT: case SQL_IS_SMALLINT: strbuf = 0; break; default: ret = SQL_ERROR; goto done; } } if (recno > 1) { ret = SQL_NO_DATA; goto done; } switch (id) { case SQL_DIAG_CLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_SUBCLASS_ORIGIN: logmsg = "ISO 9075"; if (sqlst[0] == 'I' && sqlst[1] == 'M') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == 'H' && sqlst[1] == 'Y') { logmsg = "ODBC 3.0"; } else if (sqlst[0] == '2' || sqlst[0] == '0' || sqlst[0] == '4') { logmsg = "ODBC 3.0"; } break; case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: logmsg = d->dsn ? d->dsn : "No DSN"; break; case SQL_DIAG_SQLSTATE: logmsg = sqlst; break; case SQL_DIAG_MESSAGE_TEXT: if (info) { clrmsg = logmsg; } break; case SQL_DIAG_NUMBER: naterr = 1; /* fall through */ case SQL_DIAG_NATIVE: len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (info) { *((SQLINTEGER *) info) = naterr; } ret = SQL_SUCCESS; goto done; case SQL_DIAG_DYNAMIC_FUNCTION: logmsg = ""; break; case SQL_DIAG_CURSOR_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = (s->isselect == 1 || s->isselect == -1) ? s->nrows : 0; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; case SQL_DIAG_ROW_COUNT: if (htype == SQL_HANDLE_STMT) { SQLULEN count; count = s->isselect ? 0 : s->nrows; *((SQLULEN *) info) = count; ret = SQL_SUCCESS; } goto done; default: goto done; } if (info && buflen > 0) { ((char *) info)[0] = '\0'; } len = strlen(logmsg); if (len == 0) { ret = SQL_NO_DATA; goto done; } if (stringlen) { *stringlen = len; } if (strbuf) { if (len >= buflen) { if (info && buflen > 0) { if (stringlen) { *stringlen = buflen - 1; } strncpy((char *) info, logmsg, buflen); ((char *) info)[buflen - 1] = '\0'; } } else if (info) { strcpy((char *) info, logmsg); } } if (clrmsg) { *clrmsg = '\0'; } ret = SQL_SUCCESS; done: switch (htype) { case SQL_HANDLE_DBC: HDBC_UNLOCK((SQLHDBC) handle); break; case SQL_HANDLE_STMT: HSTMT_UNLOCK((SQLHSTMT) handle); break; } return ret; } #ifndef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { return drvgetdiagfield(htype, handle, recno, id, info, buflen, stringlen); } #endif #ifdef WINTERFACE /** * Get error record given handle (HDBC or HSTMT). * @param htype handle type * @param handle HDBC or HSTMT * @param recno diag record number for which info to be retrieved * @param id diag id for which info to be retrieved * @param info output buffer for error message * @param buflen length of output buffer * @param stringlen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetDiagFieldW(SQLSMALLINT htype, SQLHANDLE handle, SQLSMALLINT recno, SQLSMALLINT id, SQLPOINTER info, SQLSMALLINT buflen, SQLSMALLINT *stringlen) { SQLSMALLINT len; SQLRETURN ret; ret = drvgetdiagfield(htype, handle, recno, id, info, buflen, &len); if (ret == SQL_SUCCESS) { if (info) { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: if (len > 0) { SQLWCHAR *m = NULL; m = uc_from_utf((unsigned char *) info, len); if (m) { if (buflen) { buflen /= sizeof (SQLWCHAR); uc_strncpy(info, m, buflen); m[len] = 0; len = min(buflen, uc_strlen(m)); } else { len = uc_strlen(m); } uc_free(m); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (buflen > 0) { ((SQLWCHAR *) info)[0] = 0; } } } } else { switch (id) { case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: case SQL_DIAG_CONNECTION_NAME: case SQL_DIAG_SERVER_NAME: case SQL_DIAG_SQLSTATE: case SQL_DIAG_MESSAGE_TEXT: case SQL_DIAG_DYNAMIC_FUNCTION: len *= sizeof (SQLWCHAR); break; } } if (stringlen) { *stringlen = len; } } return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { STMT *s = (STMT *) stmt; SQLULEN *uval = (SQLULEN *) val; switch (attr) { case SQL_QUERY_TIMEOUT: *uval = 0; return SQL_SUCCESS; case SQL_ATTR_CURSOR_TYPE: *uval = s->curtype; return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: *uval = (s->curtype != SQL_CURSOR_FORWARD_ONLY) ? SQL_SCROLLABLE : SQL_NONSCROLLABLE; return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *uval = SQL_UNSPECIFIED; return SQL_SUCCESS; #endif case SQL_ATTR_ROW_NUMBER: if (s->s4stmt) { *uval = (s->s4stmt_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->s4stmt_rownum + 1); } else { *uval = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: *uval = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *uval = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *uval = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *uval = s->rowset_size; return SQL_SUCCESS; /* Needed for some driver managers, but dummies for now */ case SQL_ATTR_IMP_ROW_DESC: case SQL_ATTR_APP_ROW_DESC: case SQL_ATTR_IMP_PARAM_DESC: case SQL_ATTR_APP_PARAM_DESC: *((SQLHDESC *) val) = (SQLHDESC) DEAD_MAGIC; return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: *((SQLUSMALLINT **) val) = s->row_status; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: *((SQLULEN **) val) = s->row_count; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: { STMT *s = (STMT *) stmt; *(SQLUINTEGER *) val = s->bkmrk ? SQL_UB_ON : SQL_UB_OFF; return SQL_SUCCESS; } case SQL_ATTR_PARAM_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->parm_bind_offs; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLULEN *) val) = s->parm_bind_type; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: *((SQLUSMALLINT **) val) = s->parm_oper; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: *((SQLUSMALLINT **) val) = s->parm_status; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: *((SQLULEN **) val) = s->parm_proc; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: *((SQLULEN *) val) = s->paramset_size; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: *(SQLULEN *) val = s->bind_type; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: *((SQLULEN **) val) = s->bind_offs; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: *((SQLULEN *) val) = s->max_rows; case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: *((SQLULEN *) val) = SQL_FALSE; return SQL_SUCCESS; #endif } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Get option of HSTMT. * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be retrieved * @param val output buffer * @param bufmax length of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtattr(stmt, attr, val, bufmax, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ static SQLRETURN drvsetstmtattr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { STMT *s = (STMT *) stmt; #if defined(SQL_BIGINT) && defined(__WORDSIZE) && (__WORDSIZE == 64) SQLBIGINT uval; uval = (SQLBIGINT) val; #else SQLULEN uval; uval = (SQLULEN) val; #endif switch (attr) { case SQL_ATTR_CURSOR_TYPE: if (val == (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } if (val != (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY && val != (SQLPOINTER) SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ATTR_CURSOR_SCROLLABLE: if (val == (SQLPOINTER) SQL_NONSCROLLABLE) { s->curtype = SQL_CURSOR_FORWARD_ONLY; } else { s->curtype = SQL_CURSOR_STATIC; } return SQL_SUCCESS; case SQL_ATTR_ASYNC_ENABLE: if (val != (SQLPOINTER) SQL_ASYNC_ENABLE_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (val != (SQLPOINTER) SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: if (val != (SQLPOINTER) SQL_UNSPECIFIED) { goto e01s02; } return SQL_SUCCESS; #endif case SQL_ATTR_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: if (val != (SQLPOINTER) SQL_RD_ON && val != (SQLPOINTER) SQL_RD_OFF) { goto e01s02; } s->retr_data = uval; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (uval < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (uval > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * uval); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = uval; } return SQL_SUCCESS; case SQL_ATTR_ROW_STATUS_PTR: s->row_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_ROWS_FETCHED_PTR: s->row_count = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: s->parm_bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_BIND_TYPE: s->parm_bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_PARAM_OPERATION_PTR: s->parm_oper = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAM_STATUS_PTR: s->parm_status = (SQLUSMALLINT *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMS_PROCESSED_PTR: s->parm_proc = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_PARAMSET_SIZE: if (uval < 1) { goto e01s02; } s->paramset_size = uval; s->paramset_count = 0; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_TYPE: s->bind_type = uval; return SQL_SUCCESS; case SQL_ATTR_ROW_BIND_OFFSET_PTR: s->bind_offs = (SQLULEN *) val; return SQL_SUCCESS; case SQL_ATTR_USE_BOOKMARKS: if (val != (SQLPOINTER) SQL_UB_OFF && val != (SQLPOINTER) SQL_UB_ON) { goto e01s02; } s->bkmrk = val == (SQLPOINTER) SQL_UB_ON; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: s->max_rows = uval; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: if (val != (SQLPOINTER) 1000000000) { goto e01s02; } return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: if (val != (SQLPOINTER) SQL_FALSE) { goto e01s02; } return SQL_SUCCESS; #endif } return drvunimplstmt(stmt); } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Set option on HSTMT. * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param attr attribute to be set * @param val input buffer (attribute value) * @param buflen length of input buffer * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtAttrW(SQLHSTMT stmt, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER buflen) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtattr(stmt, attr, val, buflen); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { STMT *s = (STMT *) stmt; SQLUINTEGER *ret = (SQLUINTEGER *) param; switch (opt) { case SQL_QUERY_TIMEOUT: *ret = 0; return SQL_SUCCESS; case SQL_CURSOR_TYPE: *ret = s->curtype; return SQL_SUCCESS; case SQL_ROW_NUMBER: if (s->s4stmt) { *ret = (s->s4stmt_rownum < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->s4stmt_rownum + 1); } else { *ret = (s->rowp < 0) ? SQL_ROW_NUMBER_UNKNOWN : (s->rowp + 1); } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: *ret = SQL_ASYNC_ENABLE_OFF; return SQL_SUCCESS; case SQL_CONCURRENCY: *ret = SQL_CONCUR_LOCK; return SQL_SUCCESS; case SQL_ATTR_RETRIEVE_DATA: *ret = s->retr_data; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: *ret = s->rowset_size; return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: *ret = s->max_rows; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: *ret = 1000000000; return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Get option of HSTMT. * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Get option of HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgetstmtoption(stmt, opt, param); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ static SQLRETURN drvsetstmtoption(SQLHSTMT stmt, SQLUSMALLINT opt, SQLUINTEGER param) { STMT *s = (STMT *) stmt; switch (opt) { case SQL_CURSOR_TYPE: if (param == SQL_CURSOR_FORWARD_ONLY) { s->curtype = param; } else { s->curtype = SQL_CURSOR_STATIC; } if (param != SQL_CURSOR_FORWARD_ONLY && param != SQL_CURSOR_STATIC) { goto e01s02; } return SQL_SUCCESS; case SQL_ASYNC_ENABLE: if (param != SQL_ASYNC_ENABLE_OFF) { goto e01s02; } return SQL_SUCCESS; case SQL_CONCURRENCY: if (param != SQL_CONCUR_LOCK) { goto e01s02; } return SQL_SUCCESS; case SQL_QUERY_TIMEOUT: return SQL_SUCCESS; case SQL_RETRIEVE_DATA: if (param != SQL_RD_ON && param != SQL_RD_OFF) { e01s02: setstat(s, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } s->retr_data = (int) param; return SQL_SUCCESS; case SQL_ROWSET_SIZE: case SQL_ATTR_ROW_ARRAY_SIZE: if (param < 1) { setstat(s, -1, "invalid rowset size", "HY000"); return SQL_ERROR; } else { SQLUSMALLINT *rst = &s->row_status1; if (param > 1) { rst = xmalloc(sizeof (SQLUSMALLINT) * param); if (!rst) { return nomem(s); } } if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); } s->row_status0 = rst; s->rowset_size = param; } return SQL_SUCCESS; case SQL_ATTR_MAX_ROWS: s->max_rows = param; return SQL_SUCCESS; case SQL_ATTR_MAX_LENGTH: if (param != 1000000000) { goto e01s02; } return SQL_SUCCESS; } return drvunimplstmt(stmt); } /** * Set option on HSTMT. * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #ifdef WINTERFACE /** * Set option on HSTMT (UNICODE version). * @param stmt statement handle * @param opt option to be set * @param param input buffer (option value) * @result ODBC error code */ SQLRETURN SQL_API SQLSetStmtOptionW(SQLHSTMT stmt, SQLUSMALLINT opt, SETSTMTOPTION_LAST_ARG_TYPE param) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetstmtoption(stmt, opt, (SQLUINTEGER) param); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ static SQLRETURN drvsetpos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { STMT *s = (STMT *) stmt; int rowp; if (op != SQL_POSITION) { return drvunimplstmt(stmt); } rowp = s->rowp + row - 1; if (!s->rows || row <= 0 || rowp < -1 || rowp >= s->nrows) { setstat(s, -1, "row out of range", (*s->ov3) ? "HY107" : "S1107"); return SQL_ERROR; } s->rowp = rowp; return SQL_SUCCESS; } /** * Set position on result in HSTMT. * @param stmt statement handle * @param row row to be positioned * @param op operation code * @param lock locking type * @result ODBC error code */ SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt, SQLSETPOSIROW row, SQLUSMALLINT op, SQLUSMALLINT lock) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvsetpos(stmt, row, op, lock); HSTMT_UNLOCK(stmt); return ret; } /** * Function not implemented. */ SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt, SQLUSMALLINT concur, SQLLEN rowkeyset, SQLUSMALLINT rowset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvunimplstmt(stmt); HSTMT_UNLOCK(stmt); return ret; } #define strmak(dst, src, max, lenp) { \ int len = strlen(src); \ int cnt = min(len + 1, max); \ strncpy(dst, src, cnt); \ *lenp = (cnt > len) ? len : cnt; \ } /** * Internal return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ static SQLRETURN drvgetinfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { DBC *d; char dummyc[16]; SQLSMALLINT dummy; #if defined(_WIN32) || defined(_WIN64) char pathbuf[301], *drvname; #else static char drvname[] = "sqlite4odbc.so"; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (valMax) { valMax--; } if (!valLen) { valLen = &dummy; } if (!val) { val = dummyc; valMax = sizeof (dummyc) - 1; } switch (type) { case SQL_MAX_USER_NAME_LEN: *((SQLSMALLINT *) val) = 16; *valLen = sizeof (SQLSMALLINT); break; case SQL_USER_NAME: strmak(val, "", valMax, valLen); break; case SQL_DRIVER_ODBC_VER: #if 0 strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); #else strmak(val, "03.00", valMax, valLen); #endif break; case SQL_ACTIVE_CONNECTIONS: case SQL_ACTIVE_STATEMENTS: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_ASYNC_MODE case SQL_ASYNC_MODE: *((SQLUINTEGER *) val) = SQL_AM_NONE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_TABLE case SQL_CREATE_TABLE: *((SQLUINTEGER *) val) = SQL_CT_CREATE_TABLE | SQL_CT_COLUMN_DEFAULT | SQL_CT_COLUMN_CONSTRAINT | SQL_CT_CONSTRAINT_NON_DEFERRABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_CREATE_VIEW case SQL_CREATE_VIEW: *((SQLUINTEGER *) val) = SQL_CV_CREATE_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DDL_INDEX case SQL_DDL_INDEX: *((SQLUINTEGER *) val) = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_TABLE case SQL_DROP_TABLE: *((SQLUINTEGER *) val) = SQL_DT_DROP_TABLE; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_DROP_VIEW case SQL_DROP_VIEW: *((SQLUINTEGER *) val) = SQL_DV_DROP_VIEW; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_INDEX_KEYWORDS case SQL_INDEX_KEYWORDS: *((SQLUINTEGER *) val) = SQL_IK_ALL; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DATA_SOURCE_NAME: strmak(val, d->dsn ? d->dsn : "", valMax, valLen); break; case SQL_DRIVER_NAME: #if defined(_WIN32) || defined(_WIN64) GetModuleFileName(hModule, pathbuf, sizeof (pathbuf)); drvname = strrchr(pathbuf, '\\'); if (drvname == NULL) { drvname = strrchr(pathbuf, '/'); } if (drvname == NULL) { drvname = pathbuf; } else { drvname++; } #endif strmak(val, drvname, valMax, valLen); break; case SQL_DRIVER_VER: strmak(val, DRIVER_VER_INFO, valMax, valLen); break; case SQL_FETCH_DIRECTION: *((SQLUINTEGER *) val) = SQL_FD_FETCH_NEXT | SQL_FD_FETCH_FIRST | SQL_FD_FETCH_LAST | SQL_FD_FETCH_PRIOR | SQL_FD_FETCH_ABSOLUTE; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_VER: strmak(val, (*d->ov3) ? "03.00" : "02.50", valMax, valLen); break; case SQL_ODBC_SAG_CLI_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSCC_NOT_COMPLIANT; *valLen = sizeof (SQLSMALLINT); break; case SQL_STANDARD_CLI_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_SCC_XOPEN_CLI_VERSION1; *valLen = sizeof (SQLUINTEGER); break; case SQL_SERVER_NAME: case SQL_DATABASE_NAME: strmak(val, d->dbname ? d->dbname : "", valMax, valLen); break; case SQL_SEARCH_PATTERN_ESCAPE: strmak(val, "\\", valMax, valLen); break; case SQL_ODBC_SQL_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OSC_MINIMUM; *valLen = sizeof (SQLSMALLINT); break; case SQL_ODBC_API_CONFORMANCE: *((SQLSMALLINT *) val) = SQL_OAC_LEVEL1; *valLen = sizeof (SQLSMALLINT); break; case SQL_DBMS_NAME: strmak(val, "SQLite", valMax, valLen); break; case SQL_DBMS_VER: strmak(val, SQLITE4_VERSION, valMax, valLen); break; case SQL_COLUMN_ALIAS: case SQL_NEED_LONG_DATA_LEN: strmak(val, "Y", valMax, valLen); break; case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: strmak(val, "N", valMax, valLen); break; #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "Y" : "N", valMax, valLen); #else strmak(val, "N", valMax, valLen); #endif break; #endif case SQL_DATA_SOURCE_READ_ONLY: strmak(val, "N", valMax, valLen); break; #ifdef SQL_OJ_CAPABILITIES case SQL_OJ_CAPABILITIES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; #endif #ifdef SQL_MAX_IDENTIFIER_LEN case SQL_MAX_IDENTIFIER_LEN: *((SQLUSMALLINT *) val) = 255; *valLen = sizeof (SQLUSMALLINT); break; #endif case SQL_CONCAT_NULL_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CURSOR_COMMIT_BEHAVIOR: case SQL_CURSOR_ROLLBACK_BEHAVIOR: *((SQLSMALLINT *) val) = SQL_CB_PRESERVE; *valLen = sizeof (SQLSMALLINT); break; #ifdef SQL_CURSOR_SENSITIVITY case SQL_CURSOR_SENSITIVITY: *((SQLUINTEGER *) val) = SQL_UNSPECIFIED; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_DEFAULT_TXN_ISOLATION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: strmak(val, "Y", valMax, valLen); break; #endif case SQL_TXN_ISOLATION_OPTION: *((SQLUINTEGER *) val) = SQL_TXN_SERIALIZABLE; *valLen = sizeof (SQLUINTEGER); break; case SQL_IDENTIFIER_CASE: *((SQLSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLSMALLINT); break; case SQL_IDENTIFIER_QUOTE_CHAR: strmak(val, "\"", valMax, valLen); break; case SQL_MAX_TABLE_NAME_LEN: case SQL_MAX_COLUMN_NAME_LEN: *((SQLSMALLINT *) val) = 255; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_CURSOR_NAME_LEN: *((SQLSMALLINT *) val) = 255; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_PROCEDURE_NAME_LEN: *((SQLSMALLINT *) val) = 0; break; case SQL_MAX_QUALIFIER_NAME_LEN: case SQL_MAX_OWNER_NAME_LEN: *((SQLSMALLINT *) val) = 255; break; case SQL_OWNER_TERM: strmak(val, "", valMax, valLen); break; case SQL_PROCEDURE_TERM: strmak(val, "PROCEDURE", valMax, valLen); break; case SQL_QUALIFIER_NAME_SEPARATOR: strmak(val, ".", valMax, valLen); break; case SQL_QUALIFIER_TERM: #if defined(_WIN32) || defined(_WIN64) strmak(val, d->xcelqrx ? "catalog" : "", valMax, valLen); #else strmak(val, "", valMax, valLen); #endif break; case SQL_QUALIFIER_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLUINTEGER *) val) = d->xcelqrx ? (SQL_CU_DML_STATEMENTS | SQL_CU_INDEX_DEFINITION | SQL_CU_TABLE_DEFINITION) : 0; #else *((SQLUINTEGER *) val) = 0; #endif *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_CONCURRENCY: *((SQLUINTEGER *) val) = SQL_SCCO_LOCK; *valLen = sizeof (SQLUINTEGER); break; case SQL_SCROLL_OPTIONS: *((SQLUINTEGER *) val) = SQL_SO_STATIC | SQL_SO_FORWARD_ONLY; *valLen = sizeof (SQLUINTEGER); break; case SQL_TABLE_TERM: strmak(val, "TABLE", valMax, valLen); break; case SQL_TXN_CAPABLE: *((SQLSMALLINT *) val) = SQL_TC_ALL; *valLen = sizeof (SQLSMALLINT); break; case SQL_CONVERT_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_SYSTEM_FUNCTIONS: case SQL_NUMERIC_FUNCTIONS: case SQL_STRING_FUNCTIONS: case SQL_TIMEDATE_FUNCTIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BIGINT: case SQL_CONVERT_BIT: case SQL_CONVERT_CHAR: case SQL_CONVERT_DATE: case SQL_CONVERT_DECIMAL: case SQL_CONVERT_DOUBLE: case SQL_CONVERT_FLOAT: case SQL_CONVERT_INTEGER: case SQL_CONVERT_LONGVARCHAR: case SQL_CONVERT_NUMERIC: case SQL_CONVERT_REAL: case SQL_CONVERT_SMALLINT: case SQL_CONVERT_TIME: case SQL_CONVERT_TIMESTAMP: case SQL_CONVERT_TINYINT: case SQL_CONVERT_VARCHAR: *((SQLUINTEGER *) val) = SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_DOUBLE | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_BIGINT | SQL_CVT_DATE | SQL_CVT_TIME | SQL_CVT_TIMESTAMP; *valLen = sizeof (SQLUINTEGER); break; case SQL_CONVERT_BINARY: case SQL_CONVERT_VARBINARY: case SQL_CONVERT_LONGVARBINARY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_POSITIONED_STATEMENTS: case SQL_LOCK_TYPES: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_BOOKMARK_PERSISTENCE: *((SQLUINTEGER *) val) = SQL_BP_SCROLL; *valLen = sizeof (SQLUINTEGER); break; case SQL_UNION: *((SQLUINTEGER *) val) = SQL_U_UNION | SQL_U_UNION_ALL; *valLen = sizeof (SQLUINTEGER); break; case SQL_OWNER_USAGE: case SQL_SUBQUERIES: case SQL_TIMEDATE_ADD_INTERVALS: case SQL_TIMEDATE_DIFF_INTERVALS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUOTED_IDENTIFIER_CASE: *((SQLUSMALLINT *) val) = SQL_IC_SENSITIVE; *valLen = sizeof (SQLUSMALLINT); break; case SQL_POS_OPERATIONS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ALTER_TABLE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_CORRELATION_NAME: *((SQLSMALLINT *) val) = SQL_CN_DIFFERENT; *valLen = sizeof (SQLSMALLINT); break; case SQL_NON_NULLABLE_COLUMNS: *((SQLSMALLINT *) val) = SQL_NNC_NON_NULL; *valLen = sizeof (SQLSMALLINT); break; case SQL_NULL_COLLATION: *((SQLSMALLINT *) val) = SQL_NC_START; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_COLUMNS_IN_GROUP_BY: case SQL_MAX_COLUMNS_IN_ORDER_BY: case SQL_MAX_COLUMNS_IN_SELECT: case SQL_MAX_COLUMNS_IN_TABLE: case SQL_MAX_ROW_SIZE: case SQL_MAX_TABLES_IN_SELECT: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_BINARY_LITERAL_LEN: case SQL_MAX_CHAR_LITERAL_LEN: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_MAX_COLUMNS_IN_INDEX: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_MAX_INDEX_SIZE: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; #ifdef SQL_MAX_IDENTIFIER_LENGTH case SQL_MAX_IDENTIFIER_LENGTH: *((SQLUINTEGER *) val) = 255; *valLen = sizeof (SQLUINTEGER); break; #endif case SQL_MAX_STATEMENT_LEN: *((SQLUINTEGER *) val) = 16384; *valLen = sizeof (SQLUINTEGER); break; case SQL_QUALIFIER_LOCATION: *((SQLSMALLINT *) val) = SQL_QL_START; *valLen = sizeof (SQLSMALLINT); break; case SQL_GETDATA_EXTENSIONS: *((SQLUINTEGER *) val) = SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER | SQL_GD_BOUND; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_SENSITIVITY: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FILE_USAGE: #if defined(_WIN32) || defined(_WIN64) *((SQLSMALLINT *) val) = d->xcelqrx ? SQL_FILE_CATALOG : SQL_FILE_NOT_SUPPORTED; #else *((SQLSMALLINT *) val) = SQL_FILE_NOT_SUPPORTED; #endif *valLen = sizeof (SQLSMALLINT); break; case SQL_GROUP_BY: *((SQLSMALLINT *) val) = 0; *valLen = sizeof (SQLSMALLINT); break; case SQL_KEYWORDS: strmak(val, "CREATE,SELECT,DROP,DELETE,UPDATE,INSERT," "INTO,VALUES,TABLE,INDEX,FROM,SET,WHERE,AND,CURRENT,OF", valMax, valLen); break; case SQL_SPECIAL_CHARACTERS: #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif strmak(val, "", valMax, valLen); break; case SQL_BATCH_SUPPORT: case SQL_BATCH_ROW_COUNT: case SQL_PARAM_ARRAY_ROW_COUNTS: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_STATIC_CURSOR_ATTRIBUTES1: *((SQLUINTEGER *) val) = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE | SQL_CA1_RELATIVE | SQL_CA1_BOOKMARK; *valLen = sizeof (SQLUINTEGER); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: case SQL_STATIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = SQL_CA2_READ_ONLY_CONCURRENCY | SQL_CA2_LOCK_CONCURRENCY; *valLen = sizeof (SQLUINTEGER); break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: case SQL_KEYSET_CURSOR_ATTRIBUTES2: case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: *((SQLUINTEGER *) val) = 0; *valLen = sizeof (SQLUINTEGER); break; case SQL_ODBC_INTERFACE_CONFORMANCE: *((SQLUINTEGER *) val) = SQL_OIC_CORE; *valLen = sizeof (SQLUINTEGER); break; default: setstatd(d, -1, "unsupported info option %d", (*d->ov3) ? "HYC00" : "S1C00", type); return SQL_ERROR; } return SQL_SUCCESS; } #if (defined(HAVE_UNIXODBC) && (HAVE_UNIXODBC)) || !defined(WINTERFACE) /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfo(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, valLen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Return information about what this ODBC driver supports. * @param dbc database connection handle * @param type type of information to be retrieved * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetInfoW(SQLHDBC dbc, SQLUSMALLINT type, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen) { SQLRETURN ret; SQLSMALLINT len = 0; HDBC_LOCK(dbc); ret = drvgetinfo(dbc, type, val, valMax, &len); HDBC_UNLOCK(dbc); if (ret == SQL_SUCCESS) { SQLWCHAR *v = NULL; switch (type) { case SQL_USER_NAME: case SQL_DRIVER_ODBC_VER: case SQL_DATA_SOURCE_NAME: case SQL_DRIVER_NAME: case SQL_DRIVER_VER: case SQL_ODBC_VER: case SQL_SERVER_NAME: case SQL_DATABASE_NAME: case SQL_SEARCH_PATTERN_ESCAPE: case SQL_DBMS_NAME: case SQL_DBMS_VER: case SQL_NEED_LONG_DATA_LEN: case SQL_ROW_UPDATES: case SQL_ACCESSIBLE_PROCEDURES: case SQL_PROCEDURES: case SQL_EXPRESSIONS_IN_ORDERBY: case SQL_ODBC_SQL_OPT_IEF: case SQL_LIKE_ESCAPE_CLAUSE: case SQL_ORDER_BY_COLUMNS_IN_SELECT: case SQL_OUTER_JOINS: case SQL_COLUMN_ALIAS: case SQL_ACCESSIBLE_TABLES: case SQL_MULT_RESULT_SETS: case SQL_MULTIPLE_ACTIVE_TXN: case SQL_MAX_ROW_SIZE_INCLUDES_LONG: case SQL_DATA_SOURCE_READ_ONLY: #ifdef SQL_DESCRIBE_PARAMETER case SQL_DESCRIBE_PARAMETER: #endif case SQL_IDENTIFIER_QUOTE_CHAR: case SQL_OWNER_TERM: case SQL_PROCEDURE_TERM: case SQL_QUALIFIER_NAME_SEPARATOR: case SQL_QUALIFIER_TERM: case SQL_TABLE_TERM: case SQL_KEYWORDS: case SQL_SPECIAL_CHARACTERS: #ifdef SQL_CATALOG_NAME case SQL_CATALOG_NAME: #endif #ifdef SQL_COLLATION_SEQ case SQL_COLLATION_SEQ: #endif if (val) { if (len > 0) { v = uc_from_utf((SQLCHAR *) val, len); if (v) { int vmax = valMax / sizeof (SQLWCHAR); uc_strncpy(val, v, vmax); v[len] = 0; len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } else { len = 0; } } if (len <= 0) { len = 0; if (valMax >= sizeof (SQLWCHAR)) { *((SQLWCHAR *)val) = 0; } } } else { len *= sizeof (SQLWCHAR); } break; } if (valLen) { *valLen = len; } } return ret; } #endif /** * Return information about supported ODBC API functions. * @param dbc database connection handle * @param func function code to be retrieved * @param flags output indicator * @result ODBC error code */ SQLRETURN SQL_API SQLGetFunctions(SQLHDBC dbc, SQLUSMALLINT func, SQLUSMALLINT *flags) { int i; SQLUSMALLINT exists[100]; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } for (i = 0; i < array_size(exists); i++) { exists[i] = SQL_FALSE; } exists[SQL_API_SQLALLOCCONNECT] = SQL_TRUE; exists[SQL_API_SQLFETCH] = SQL_TRUE; exists[SQL_API_SQLALLOCENV] = SQL_TRUE; exists[SQL_API_SQLFREECONNECT] = SQL_TRUE; exists[SQL_API_SQLALLOCSTMT] = SQL_TRUE; exists[SQL_API_SQLFREEENV] = SQL_TRUE; exists[SQL_API_SQLBINDCOL] = SQL_TRUE; exists[SQL_API_SQLFREESTMT] = SQL_TRUE; exists[SQL_API_SQLCANCEL] = SQL_TRUE; exists[SQL_API_SQLGETCURSORNAME] = SQL_TRUE; exists[SQL_API_SQLCOLATTRIBUTES] = SQL_TRUE; exists[SQL_API_SQLNUMRESULTCOLS] = SQL_TRUE; exists[SQL_API_SQLCONNECT] = SQL_TRUE; exists[SQL_API_SQLPREPARE] = SQL_TRUE; exists[SQL_API_SQLDESCRIBECOL] = SQL_TRUE; exists[SQL_API_SQLROWCOUNT] = SQL_TRUE; exists[SQL_API_SQLDISCONNECT] = SQL_TRUE; exists[SQL_API_SQLSETCURSORNAME] = SQL_FALSE; exists[SQL_API_SQLERROR] = SQL_TRUE; exists[SQL_API_SQLSETPARAM] = SQL_TRUE; exists[SQL_API_SQLEXECDIRECT] = SQL_TRUE; exists[SQL_API_SQLTRANSACT] = SQL_TRUE; exists[SQL_API_SQLEXECUTE] = SQL_TRUE; exists[SQL_API_SQLBINDPARAMETER] = SQL_TRUE; exists[SQL_API_SQLGETTYPEINFO] = SQL_TRUE; exists[SQL_API_SQLCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLPARAMDATA] = SQL_TRUE; exists[SQL_API_SQLDRIVERCONNECT] = SQL_TRUE; exists[SQL_API_SQLPUTDATA] = SQL_TRUE; exists[SQL_API_SQLGETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLSETCONNECTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETDATA] = SQL_TRUE; exists[SQL_API_SQLSETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLGETFUNCTIONS] = SQL_TRUE; exists[SQL_API_SQLSPECIALCOLUMNS] = SQL_TRUE; exists[SQL_API_SQLGETINFO] = SQL_TRUE; exists[SQL_API_SQLSTATISTICS] = SQL_TRUE; exists[SQL_API_SQLGETSTMTOPTION] = SQL_TRUE; exists[SQL_API_SQLTABLES] = SQL_TRUE; exists[SQL_API_SQLBROWSECONNECT] = SQL_FALSE; exists[SQL_API_SQLNUMPARAMS] = SQL_TRUE; exists[SQL_API_SQLCOLUMNPRIVILEGES] = SQL_FALSE; exists[SQL_API_SQLPARAMOPTIONS] = SQL_FALSE; exists[SQL_API_SQLDATASOURCES] = SQL_TRUE; exists[SQL_API_SQLPRIMARYKEYS] = SQL_TRUE; exists[SQL_API_SQLDESCRIBEPARAM] = SQL_TRUE; exists[SQL_API_SQLPROCEDURECOLUMNS] = SQL_TRUE; exists[SQL_API_SQLDRIVERS] = SQL_FALSE; exists[SQL_API_SQLPROCEDURES] = SQL_TRUE; exists[SQL_API_SQLEXTENDEDFETCH] = SQL_TRUE; exists[SQL_API_SQLSETPOS] = SQL_TRUE; exists[SQL_API_SQLFOREIGNKEYS] = SQL_TRUE; exists[SQL_API_SQLSETSCROLLOPTIONS] = SQL_TRUE; exists[SQL_API_SQLMORERESULTS] = SQL_TRUE; exists[SQL_API_SQLTABLEPRIVILEGES] = SQL_TRUE; exists[SQL_API_SQLNATIVESQL] = SQL_TRUE; if (func == SQL_API_ALL_FUNCTIONS) { memcpy(flags, exists, sizeof (exists)); } else if (func == SQL_API_ODBC3_ALL_FUNCTIONS) { int i; #define SET_EXISTS(x) \ flags[(x) >> 4] |= (1 << ((x) & 0xF)) #define CLR_EXISTS(x) \ flags[(x) >> 4] &= ~(1 << ((x) & 0xF)) memset(flags, 0, sizeof (SQLUSMALLINT) * SQL_API_ODBC3_ALL_FUNCTIONS_SIZE); for (i = 0; i < array_size(exists); i++) { if (exists[i]) { flags[i >> 4] |= (1 << (i & 0xF)); } } SET_EXISTS(SQL_API_SQLALLOCHANDLE); SET_EXISTS(SQL_API_SQLFREEHANDLE); SET_EXISTS(SQL_API_SQLGETSTMTATTR); SET_EXISTS(SQL_API_SQLSETSTMTATTR); SET_EXISTS(SQL_API_SQLGETCONNECTATTR); SET_EXISTS(SQL_API_SQLSETCONNECTATTR); SET_EXISTS(SQL_API_SQLGETENVATTR); SET_EXISTS(SQL_API_SQLSETENVATTR); SET_EXISTS(SQL_API_SQLCLOSECURSOR); SET_EXISTS(SQL_API_SQLBINDPARAM); #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ SET_EXISTS(SQL_API_SQLGETDIAGREC); #endif SET_EXISTS(SQL_API_SQLGETDIAGFIELD); SET_EXISTS(SQL_API_SQLFETCHSCROLL); SET_EXISTS(SQL_API_SQLENDTRAN); } else { if (func < array_size(exists)) { *flags = exists[func]; } else { switch (func) { case SQL_API_SQLALLOCHANDLE: case SQL_API_SQLFREEHANDLE: case SQL_API_SQLGETSTMTATTR: case SQL_API_SQLSETSTMTATTR: case SQL_API_SQLGETCONNECTATTR: case SQL_API_SQLSETCONNECTATTR: case SQL_API_SQLGETENVATTR: case SQL_API_SQLSETENVATTR: case SQL_API_SQLCLOSECURSOR: case SQL_API_SQLBINDPARAM: #if !defined(HAVE_UNIXODBC) || !(HAVE_UNIXODBC) /* * Some unixODBC versions have problems with * SQLError() vs. SQLGetDiagRec() with loss * of error/warning messages. */ case SQL_API_SQLGETDIAGREC: #endif case SQL_API_SQLGETDIAGFIELD: case SQL_API_SQLFETCHSCROLL: case SQL_API_SQLENDTRAN: *flags = SQL_TRUE; break; default: *flags = SQL_FALSE; } } } return SQL_SUCCESS; } /** * Internal allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ static SQLRETURN drvallocenv(SQLHENV *env) { ENV *e; if (env == NULL) { return SQL_INVALID_HANDLE; } e = (ENV *) xmalloc(sizeof (ENV)); if (e == NULL) { *env = SQL_NULL_HENV; return SQL_ERROR; } e->magic = ENV_MAGIC; e->ov3 = 0; #if defined(_WIN32) || defined(_WIN64) InitializeCriticalSection(&e->cs); e->owner = 0; #endif e->dbcs = NULL; *env = (SQLHENV) e; return SQL_SUCCESS; } /** * Allocate HENV. * @param env pointer to environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocEnv(SQLHENV *env) { return drvallocenv(env); } /** * Internal free HENV. * @param env environment handle * @result ODBC error code */ static SQLRETURN drvfreeenv(SQLHENV env) { ENV *e; if (env == SQL_NULL_HENV) { return SQL_INVALID_HANDLE; } e = (ENV *) env; if (e->magic != ENV_MAGIC) { return SQL_SUCCESS; } #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif if (e->dbcs) { #if defined(_WIN32) || defined(_WIN64) LeaveCriticalSection(&e->cs); e->owner = 0; #endif return SQL_ERROR; } e->magic = DEAD_MAGIC; #if defined(_WIN32) || defined(_WIN64) e->owner = 0; LeaveCriticalSection(&e->cs); DeleteCriticalSection(&e->cs); #endif xfree(e); return SQL_SUCCESS; } /** * Free HENV. * @param env environment handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeEnv(SQLHENV env) { return drvfreeenv(env); } /** * Internal allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ static SQLRETURN drvallocconnect(SQLHENV env, SQLHDBC *dbc) { DBC *d; ENV *e; const char *verstr; int maj = 0, min = 0, lev = 0; if (dbc == NULL) { return SQL_ERROR; } d = (DBC *) xmalloc(sizeof (DBC)); if (d == NULL) { *dbc = SQL_NULL_HDBC; return SQL_ERROR; } memset(d, 0, sizeof (DBC)); d->curtype = SQL_CURSOR_STATIC; d->ov3 = &d->ov3val; verstr = sqlite4_libversion(); sscanf(verstr, "%d.%d.%d", &maj, &min, &lev); d->version = verinfo(maj & 0xFF, min & 0xFF, lev & 0xFF); e = (ENV *) env; #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); } #endif if (e->magic == ENV_MAGIC) { DBC *n, *p; d->env = e; d->ov3 = &e->ov3; p = NULL; n = e->dbcs; while (n) { p = n; n = n->next; } if (p) { p->next = d; } else { e->dbcs = d; } } #if defined(_WIN32) || defined(_WIN64) if (e->magic == ENV_MAGIC) { e->owner = 0; LeaveCriticalSection(&e->cs); } d->oemcp = 1; #endif d->autocommit = 1; d->magic = DBC_MAGIC; *dbc = (SQLHDBC) d; drvgetgpps(d); return SQL_SUCCESS; } /** * Allocate HDBC. * @param env environment handle * @param dbc pointer to database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC *dbc) { return drvallocconnect(env, dbc); } /** * Internal free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvfreeconnect(SQLHDBC dbc) { DBC *d; ENV *e; SQLRETURN ret = SQL_ERROR; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } e = d->env; if (e && e->magic == ENV_MAGIC) { #if defined(_WIN32) || defined(_WIN64) EnterCriticalSection(&e->cs); e->owner = GetCurrentThreadId(); #endif } else { e = NULL; } if (d->sqlite) { setstatd(d, -1, "not disconnected", (*d->ov3) ? "HY000" : "S1000"); goto done; } while (d->stmt) { freestmt((HSTMT) d->stmt); } if (e && e->magic == ENV_MAGIC) { DBC *n, *p; p = NULL; n = e->dbcs; while (n) { if (n == d) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = d->next; } else { e->dbcs = d->next; } } } drvrelgpps(d); d->magic = DEAD_MAGIC; if (d->trace) { fclose(d->trace); } xfree(d); ret = SQL_SUCCESS; done: #if defined(_WIN32) || defined(_WIN64) if (e) { e->owner = 0; LeaveCriticalSection(&e->cs); } #endif return ret; } /** * Free connection (HDBC). * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLFreeConnect(SQLHDBC dbc) { return drvfreeconnect(dbc); } /** * Internal get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ static SQLRETURN drvgetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!val) { val = (SQLPOINTER) &dummy; } if (!buflen) { buflen = &dummy; } switch (attr) { case SQL_ATTR_CONNECTION_DEAD: *((SQLINTEGER *) val) = d->sqlite ? SQL_CD_FALSE : SQL_CD_TRUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ACCESS_MODE: *((SQLINTEGER *) val) = SQL_MODE_READ_WRITE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_AUTOCOMMIT: *((SQLINTEGER *) val) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_LOGIN_TIMEOUT: *((SQLINTEGER *) val) = 100; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ODBC_CURSORS: *((SQLINTEGER *) val) = SQL_CUR_USE_DRIVER; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PACKET_SIZE: *((SQLINTEGER *) val) = 16384; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TXN_ISOLATION: *((SQLINTEGER *) val) = SQL_TXN_SERIALIZABLE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_TRACEFILE: case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_CURRENT_CATALOG: *((SQLCHAR *) val) = 0; *buflen = 0; break; case SQL_ATTR_TRACE: case SQL_ATTR_QUIET_MODE: case SQL_ATTR_TRANSLATE_OPTION: case SQL_ATTR_KEYSET_SIZE: case SQL_ATTR_QUERY_TIMEOUT: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_PARAM_BIND_TYPE: *((SQLULEN *) val) = SQL_PARAM_BIND_BY_COLUMN; *buflen = sizeof (SQLUINTEGER); break; case SQL_ATTR_ROW_BIND_TYPE: *((SQLULEN *) val) = SQL_BIND_BY_COLUMN; *buflen = sizeof (SQLULEN); break; case SQL_ATTR_USE_BOOKMARKS: *((SQLINTEGER *) val) = SQL_UB_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_ASYNC_ENABLE: *((SQLINTEGER *) val) = SQL_ASYNC_ENABLE_OFF; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_NOSCAN: *((SQLINTEGER *) val) = SQL_NOSCAN_ON; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CONCURRENCY: *((SQLINTEGER *) val) = SQL_CONCUR_LOCK; *buflen = sizeof (SQLINTEGER); break; #ifdef SQL_ATTR_CURSOR_SENSITIVITY case SQL_ATTR_CURSOR_SENSITIVITY: *((SQLINTEGER *) val) = SQL_UNSPECIFIED; *buflen = sizeof (SQLINTEGER); break; #endif case SQL_ATTR_SIMULATE_CURSOR: *((SQLINTEGER *) val) = SQL_SC_NON_UNIQUE; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_MAX_ROWS: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); case SQL_ATTR_MAX_LENGTH: *((SQLINTEGER *) val) = 1000000000; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_CURSOR_TYPE: *((SQLINTEGER *) val) = d->curtype; *buflen = sizeof (SQLINTEGER); break; case SQL_ATTR_RETRIEVE_DATA: *((SQLINTEGER *) val) = SQL_RD_ON; *buflen = sizeof (SQLINTEGER); break; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: *((SQLULEN *) val) = SQL_FALSE; return SQL_SUCCESS; #endif default: *((SQLINTEGER *) val) = 0; *buflen = sizeof (SQLINTEGER); setstatd(d, -1, "unsupported connect attribute %d", (*d->ov3) ? "HYC00" : "S1C00", (int) attr); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be retrieved * @param val output buffer * @param bufmax size of output buffer * @param buflen output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER bufmax, SQLINTEGER *buflen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectattr(dbc, attr, val, bufmax, buflen); if (SQL_SUCCEEDED(ret)) { switch (attr) { case SQL_ATTR_TRACEFILE: case SQL_ATTR_CURRENT_CATALOG: case SQL_ATTR_TRANSLATE_LIB: if (val && bufmax >= sizeof (SQLWCHAR)) { *(SQLWCHAR *) val = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ static SQLRETURN drvsetconnectattr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (attr) { case SQL_AUTOCOMMIT: d->autocommit = val == (SQLPOINTER) SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { s4stmt_end(d->cur_s4stmt); } return SQL_SUCCESS; #ifdef SQL_ATTR_METADATA_ID case SQL_ATTR_METADATA_ID: if (val == (SQLPOINTER) SQL_FALSE) { return SQL_SUCCESS; } /* fall through */ #endif default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set connect attribute of HDBC. * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set connect attribute of HDBC (UNICODE version). * @param dbc database connection handle * @param attr option to be set * @param val option value * @param len size of option * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectAttrW(SQLHDBC dbc, SQLINTEGER attr, SQLPOINTER val, SQLINTEGER len) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectattr(dbc, attr, val, len); HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ static SQLRETURN drvgetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { DBC *d; SQLINTEGER dummy; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (!param) { param = (SQLPOINTER) &dummy; } switch (opt) { case SQL_ACCESS_MODE: *((SQLINTEGER *) param) = SQL_MODE_READ_WRITE; break; case SQL_AUTOCOMMIT: *((SQLINTEGER *) param) = d->autocommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF; break; case SQL_LOGIN_TIMEOUT: *((SQLINTEGER *) param) = 100; break; case SQL_ODBC_CURSORS: *((SQLINTEGER *) param) = SQL_CUR_USE_DRIVER; break; case SQL_PACKET_SIZE: *((SQLINTEGER *) param) = 16384; break; case SQL_TXN_ISOLATION: *((SQLINTEGER *) param) = SQL_TXN_SERIALIZABLE; break; case SQL_OPT_TRACE: case SQL_OPT_TRACEFILE: case SQL_QUIET_MODE: case SQL_TRANSLATE_DLL: case SQL_TRANSLATE_OPTION: case SQL_KEYSET_SIZE: case SQL_QUERY_TIMEOUT: case SQL_BIND_TYPE: case SQL_CURRENT_QUALIFIER: *((SQLINTEGER *) param) = 0; break; case SQL_USE_BOOKMARKS: *((SQLINTEGER *) param) = SQL_UB_OFF; break; case SQL_ASYNC_ENABLE: *((SQLINTEGER *) param) = SQL_ASYNC_ENABLE_OFF; break; case SQL_NOSCAN: *((SQLINTEGER *) param) = SQL_NOSCAN_ON; break; case SQL_CONCURRENCY: *((SQLINTEGER *) param) = SQL_CONCUR_LOCK; break; case SQL_SIMULATE_CURSOR: *((SQLINTEGER *) param) = SQL_SC_NON_UNIQUE; break; case SQL_MAX_ROWS: *((SQLINTEGER *) param) = 0; break; case SQL_ROWSET_SIZE: case SQL_MAX_LENGTH: *((SQLINTEGER *) param) = 1000000000; break; case SQL_CURSOR_TYPE: *((SQLINTEGER *) param) = d->curtype; break; case SQL_RETRIEVE_DATA: *((SQLINTEGER *) param) = SQL_RD_ON; break; default: *((SQLINTEGER *) param) = 0; setstatd(d, -1, "unsupported connect option %d", (*d->ov3) ? "HYC00" : "S1C00", opt); return SQL_ERROR; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get connect option of HDBC. * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Get connect option of HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be retrieved * @param param output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLGetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLPOINTER param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvgetconnectoption(dbc, opt, param); if (SQL_SUCCEEDED(ret)) { switch (opt) { case SQL_OPT_TRACEFILE: case SQL_CURRENT_QUALIFIER: case SQL_TRANSLATE_DLL: if (param) { *(SQLWCHAR *) param = 0; } break; } } HDBC_UNLOCK(dbc); return ret; } #endif /** * Internal set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ static SQLRETURN drvsetconnectoption(SQLHDBC dbc, SQLUSMALLINT opt, SQLUINTEGER param) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; switch (opt) { case SQL_AUTOCOMMIT: d->autocommit = param == SQL_AUTOCOMMIT_ON; if (d->autocommit && d->intrans) { return endtran(d, SQL_COMMIT, 1); } else if (!d->autocommit) { s4stmt_end(d->cur_s4stmt); } break; default: setstatd(d, -1, "option value changed", "01S02"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set option on HDBC. * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Set option on HDBC (UNICODE version). * @param dbc database connection handle * @param opt option to be set * @param param option value * @result ODBC error code */ SQLRETURN SQL_API SQLSetConnectOptionW(SQLHDBC dbc, SQLUSMALLINT opt, SQLULEN param) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvsetconnectoption(dbc, opt, param); HDBC_UNLOCK(dbc); return ret; } #endif #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64)) /** * Handling of SQLConnect() connection attributes * for standalone operation without driver manager. * @param dsn DSN/driver connection string * @param attr attribute string to be retrieved * @param out output buffer * @param outLen length of output buffer * @result true or false */ static int getdsnattr(char *dsn, char *attr, char *out, int outLen) { char *str = dsn, *start; int len = strlen(attr); while (*str) { while (*str && *str == ';') { ++str; } start = str; if ((str = strchr(str, '=')) == NULL) { return 0; } if (str - start == len && strncasecmp(start, attr, len) == 0) { start = ++str; while (*str && *str != ';') { ++str; } len = min(outLen - 1, str - start); strncpy(out, start, len); out[len] = '\0'; return 1; } while (*str && *str != ';') { ++str; } } return 0; } #endif /** * Internal connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param pwd password or NULL * @param pwdLen length of password or SQL_NTS * @param isu true/false: file name is UTF8 encoded * @result ODBC error code */ static SQLRETURN drvconnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen, char *pwd, int pwdLen, int isu) { DBC *d; int len; SQLRETURN ret; char buf[SQL_MAX_MESSAGE_LENGTH], dbname[SQL_MAX_MESSAGE_LENGTH / 4]; char busy[SQL_MAX_MESSAGE_LENGTH / 4], tracef[SQL_MAX_MESSAGE_LENGTH]; char loadext[SQL_MAX_MESSAGE_LENGTH]; char sflag[32], spflag[32], ntflag[32], nwflag[32], biflag[32]; char snflag[32], lnflag[32], ncflag[32], fkflag[32], jmode[32]; #if defined(_WIN32) || defined(_WIN64) char oemcp[32]; #endif if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->sqlite != NULL) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (dsnLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(sizeof (buf) - 1, dsnLen); } if (dsn != NULL) { strncpy(buf, (char *) dsn, len); } buf[len] = '\0'; if (buf[0] == '\0') { setstatd(d, -1, "invalid DSN", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } #if defined(_WIN32) || defined(_WIN64) /* * When DSN is in UTF it must be converted to ANSI * here for ANSI SQLGetPrivateProfileString() */ if (isu) { char *cdsn = utf_to_wmb(buf, len); if (!cdsn) { setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } strcpy(buf, cdsn); uc_free(cdsn); } #endif busy[0] = '\0'; dbname[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "database", dbname, sizeof (dbname)); if (dbname[0] == '\0') { strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } getdsnattr(buf, "timeout", busy, sizeof (busy)); sflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); spflag[0] = '\0'; getdsnattr(buf, "syncpragma", spflag, sizeof (spflag)); ntflag[0] = '\0'; getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); nwflag[0] = '\0'; getdsnattr(buf, "nowchar", nwflag, sizeof (nwflag)); snflag[0] = '\0'; getdsnattr(buf, "shortnames", snflag, sizeof (snflag)); lnflag[0] = '\0'; getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); ncflag[0] = '\0'; getdsnattr(buf, "nocreat", ncflag, sizeof (ncflag)); fkflag[0] = '\0'; getdsnattr(buf, "fksupport", fkflag, sizeof (fkflag)); loadext[0] = '\0'; getdsnattr(buf, "loadext", loadext, sizeof (loadext)); jmode[0] = '\0'; getdsnattr(buf, "journalmode", jmode, sizeof (jmode)); #if defined(_WIN32) || defined(_WIN64) oemcp[0] = '\0'; getdsnattr(buf, "oemcp", oemcp, sizeof (oemcp)); #endif biflag[0] = '\0'; getdsnattr(buf, "bigint", biflag, sizeof (biflag)); #else SQLGetPrivateProfileString(buf, "timeout", "100000", busy, sizeof (busy), ODBC_INI); SQLGetPrivateProfileString(buf, "database", "", dbname, sizeof (dbname), ODBC_INI); #if defined(_WIN32) || defined(_WIN64) /* database name read from registry is not UTF8 !!! */ isu = 0; #endif SQLGetPrivateProfileString(buf, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); SQLGetPrivateProfileString(buf, "syncpragma", "NORMAL", spflag, sizeof (spflag), ODBC_INI); SQLGetPrivateProfileString(buf, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); SQLGetPrivateProfileString(buf, "nowchar", "", nwflag, sizeof (nwflag), ODBC_INI); SQLGetPrivateProfileString(buf, "shortnames", "", snflag, sizeof (snflag), ODBC_INI); SQLGetPrivateProfileString(buf, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); SQLGetPrivateProfileString(buf, "nocreat", "", ncflag, sizeof (ncflag), ODBC_INI); SQLGetPrivateProfileString(buf, "fksupport", "", fkflag, sizeof (fkflag), ODBC_INI); SQLGetPrivateProfileString(buf, "loadext", "", loadext, sizeof (loadext), ODBC_INI); SQLGetPrivateProfileString(buf, "journalmode", "", jmode, sizeof (jmode), ODBC_INI); #if defined(_WIN32) || defined(_WIN64) SQLGetPrivateProfileString(buf, "oemcp", "1", oemcp, sizeof (oemcp), ODBC_INI); #endif SQLGetPrivateProfileString(buf, "bigint", "", biflag, sizeof (biflag), ODBC_INI); #endif tracef[0] = '\0'; #ifdef WITHOUT_DRIVERMGR getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #else SQLGetPrivateProfileString(buf, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); #endif if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } d->nowchar = getbool(nwflag); d->shortnames = getbool(snflag); d->longnames = getbool(lnflag); d->nocreat = getbool(ncflag); d->fksupport = getbool(fkflag); #if defined(_WIN32) || defined(_WIN64) d->oemcp = getbool(oemcp); #else d->oemcp = 0; #endif d->dobigint = getbool(biflag); d->pwd = pwd; d->pwdLen = 0; if (d->pwd) { d->pwdLen = (pwdLen == SQL_NTS) ? strlen(d->pwd) : pwdLen; } ret = dbopen(d, dbname, isu, (char *) dsn, sflag, spflag, ntflag, jmode, busy); if (ret == SQL_SUCCESS) { dbloadext(d, loadext); } return ret; } #ifndef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pwd password string or NULL * @param pwdLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnect(SQLHDBC dbc, SQLCHAR *dsn, SQLSMALLINT dsnLen, SQLCHAR *uid, SQLSMALLINT uidLen, SQLCHAR *pwd, SQLSMALLINT pwdLen) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvconnect(dbc, dsn, dsnLen, (char *) pwd, pwdLen, 0); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect to SQLite database. * @param dbc database connection handle * @param dsn DSN string * @param dsnLen length of DSN string or SQL_NTS * @param uid user id string or NULL * @param uidLen length of user id string or SQL_NTS * @param pwd password string or NULL * @param pwdLen length of password string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLConnectW(SQLHDBC dbc, SQLWCHAR *dsn, SQLSMALLINT dsnLen, SQLWCHAR *uid, SQLSMALLINT uidLen, SQLWCHAR *pwd, SQLSMALLINT pwdLen) { char *dsna = NULL; char *pwda = NULL; SQLRETURN ret; HDBC_LOCK(dbc); if (dsn) { dsna = uc_to_utf_c(dsn, dsnLen); if (!dsna) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); ret = SQL_ERROR; goto done; } } if (pwd) { pwda = uc_to_utf_c(pwd, pwdLen); if (!pwda) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); ret = SQL_ERROR; goto done; } } ret = drvconnect(dbc, (SQLCHAR *) dsna, SQL_NTS, pwda, SQL_NTS, 1); done: HDBC_UNLOCK(dbc); uc_free(dsna); uc_free(pwda); return ret; } #endif /** * Internal disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ static SQLRETURN drvdisconnect(SQLHDBC dbc) { DBC *d; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC) { return SQL_INVALID_HANDLE; } if (d->intrans) { setstatd(d, -1, "incomplete transaction", "25000"); return SQL_ERROR; } if (d->cur_s4stmt) { s4stmt_end(d->cur_s4stmt); } if (d->sqlite) { if (d->trace) { fprintf(d->trace, "-- sqlite4_close: '%s'\n", d->dbname); fflush(d->trace); } sqlite4_close(d->sqlite); d->sqlite = NULL; } freep(&d->dbname); freep(&d->dsn); return SQL_SUCCESS; } /** * Disconnect given HDBC. * @param dbc database connection handle * @result ODBC error code */ SQLRETURN SQL_API SQLDisconnect(SQLHDBC dbc) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdisconnect(dbc); HDBC_UNLOCK(dbc); return ret; } #if defined(WITHOUT_DRIVERMGR) || (!defined(_WIN32) && !defined(_WIN64)) /** * Internal standalone (w/o driver manager) database connect. * @param dbc database connection handle * @param hwnd dummy window handle or NULL * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { DBC *d; int len; SQLRETURN ret; char buf[SQL_MAX_MESSAGE_LENGTH * 6], dbname[SQL_MAX_MESSAGE_LENGTH]; char dsn[SQL_MAX_MESSAGE_LENGTH / 4], busy[SQL_MAX_MESSAGE_LENGTH / 4]; char tracef[SQL_MAX_MESSAGE_LENGTH], loadext[SQL_MAX_MESSAGE_LENGTH]; char pwd[SQL_MAX_MESSAGE_LENGTH]; char sflag[32], spflag[32], ntflag[32], snflag[32], lnflag[32]; char ncflag[32], nwflag[32], fkflag[32], jmode[32], biflag[32]; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } if (drvcompl != SQL_DRIVER_COMPLETE && drvcompl != SQL_DRIVER_COMPLETE_REQUIRED && drvcompl != SQL_DRIVER_PROMPT && drvcompl != SQL_DRIVER_NOPROMPT) { return SQL_NO_DATA; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } buf[0] = '\0'; if (connInLen == SQL_NTS) { len = sizeof (buf) - 1; } else { len = min(connInLen, sizeof (buf) - 1); } if (connIn != NULL) { strncpy(buf, (char *) connIn, len); } buf[len] = '\0'; if (!buf[0]) { setstatd(d, -1, "invalid connect attributes", (*d->ov3) ? "HY090" : "S1090"); return SQL_ERROR; } dsn[0] = '\0'; getdsnattr(buf, "DSN", dsn, sizeof (dsn)); /* special case: connIn is sole DSN value without keywords */ if (!dsn[0] && !strchr(buf, ';') && !strchr(buf, '=')) { strncpy(dsn, buf, sizeof (dsn) - 1); dsn[sizeof (dsn) - 1] = '\0'; } busy[0] = '\0'; getdsnattr(buf, "timeout", busy, sizeof (busy)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !busy[0]) { SQLGetPrivateProfileString(dsn, "timeout", "100000", busy, sizeof (busy), ODBC_INI); } #endif dbname[0] = '\0'; getdsnattr(buf, "database", dbname, sizeof (dbname)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !dbname[0]) { SQLGetPrivateProfileString(dsn, "database", "", dbname, sizeof (dbname), ODBC_INI); } #endif sflag[0] = '\0'; getdsnattr(buf, "stepapi", sflag, sizeof (sflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !sflag[0]) { SQLGetPrivateProfileString(dsn, "stepapi", "", sflag, sizeof (sflag), ODBC_INI); } #endif spflag[0] = '\0'; getdsnattr(buf, "syncpragma", spflag, sizeof (spflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !spflag[0]) { SQLGetPrivateProfileString(dsn, "syncpragma", "NORMAL", spflag, sizeof (spflag), ODBC_INI); } #endif ntflag[0] = '\0'; getdsnattr(buf, "notxn", ntflag, sizeof (ntflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !ntflag[0]) { SQLGetPrivateProfileString(dsn, "notxn", "", ntflag, sizeof (ntflag), ODBC_INI); } #endif snflag[0] = '\0'; getdsnattr(buf, "shortnames", snflag, sizeof (snflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !snflag[0]) { SQLGetPrivateProfileString(dsn, "shortnames", "", snflag, sizeof (snflag), ODBC_INI); } #endif lnflag[0] = '\0'; getdsnattr(buf, "longnames", lnflag, sizeof (lnflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !lnflag[0]) { SQLGetPrivateProfileString(dsn, "longnames", "", lnflag, sizeof (lnflag), ODBC_INI); } #endif ncflag[0] = '\0'; getdsnattr(buf, "nocreat", ncflag, sizeof (ncflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !ncflag[0]) { SQLGetPrivateProfileString(dsn, "nocreat", "", ncflag, sizeof (ncflag), ODBC_INI); } #endif nwflag[0] = '\0'; getdsnattr(buf, "nowchar", nwflag, sizeof (nwflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !nwflag[0]) { SQLGetPrivateProfileString(dsn, "nowchar", "", nwflag, sizeof (nwflag), ODBC_INI); } #endif fkflag[0] = '\0'; getdsnattr(buf, "fksupport", fkflag, sizeof (fkflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !fkflag[0]) { SQLGetPrivateProfileString(dsn, "fksupport", "", fkflag, sizeof (fkflag), ODBC_INI); } #endif loadext[0] = '\0'; getdsnattr(buf, "loadext", loadext, sizeof (loadext)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !loadext[0]) { SQLGetPrivateProfileString(dsn, "loadext", "", loadext, sizeof (loadext), ODBC_INI); } #endif jmode[0] = '\0'; getdsnattr(buf, "journalmode", jmode, sizeof (jmode)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !jmode[0]) { SQLGetPrivateProfileString(dsn, "journalmode", "", jmode, sizeof (jmode), ODBC_INI); } #endif biflag[0] = '\0'; getdsnattr(buf, "bigint", biflag, sizeof (biflag)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !biflag[0]) { SQLGetPrivateProfileString(dsn, "bigint", "", biflag, sizeof (biflag), ODBC_INI); } #endif pwd[0] = '\0'; getdsnattr(buf, "pwd", pwd, sizeof (pwd)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !pwd[0]) { SQLGetPrivateProfileString(dsn, "pwd", "", pwd, sizeof (pwd), ODBC_INI); } #endif if (!dbname[0] && !dsn[0]) { strcpy(dsn, "SQLite"); strncpy(dbname, buf, sizeof (dbname)); dbname[sizeof (dbname) - 1] = '\0'; } tracef[0] = '\0'; getdsnattr(buf, "tracefile", tracef, sizeof (tracef)); #ifndef WITHOUT_DRIVERMGR if (dsn[0] && !tracef[0]) { SQLGetPrivateProfileString(dsn, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); } #endif if (connOut || connOutLen) { int count; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), "DSN=%s;Database=%s;StepAPI=%s;Timeout=%s;" "SyncPragma=%s;NoTXN=%s;ShortNames=%s;LongNames=%s;" "NoCreat=%s;NoWCHAR=%s;FKSupport=%s;Tracefile=%s;" "JournalMode=%s;LoadExt=%s;BigInt=%s;PWD=%s", dsn, dbname, sflag, busy, spflag, ntflag, snflag, lnflag, ncflag, nwflag, fkflag, tracef, jmode, loadext, biflag,pwd); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } d->shortnames = getbool(snflag); d->longnames = getbool(lnflag); d->nocreat = getbool(ncflag); d->nowchar = getbool(nwflag); d->fksupport = getbool(fkflag); d->dobigint = getbool(biflag); d->oemcp = 0; d->pwdLen = strlen(pwd); d->pwd = (d->pwdLen > 0) ? pwd : NULL; ret = dbopen(d, dbname, 0, dsn, sflag, spflag, ntflag, jmode, busy); memset(pwd, 0, sizeof (pwd)); if (ret == SQL_SUCCESS) { dbloadext(d, loadext); } return ret; } #endif /** * Internal free function for HSTMT. * @param stmt statement handle * @result ODBC error code */ static SQLRETURN freestmt(SQLHSTMT stmt) { STMT *s; DBC *d; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; s4stmt_drop(s); freeresult(s, 1); freep(&s->query); d = (DBC *) s->dbc; if (d && d->magic == DBC_MAGIC) { STMT *p, *n; p = NULL; n = d->stmt; while (n) { if (n == s) { break; } p = n; n = n->next; } if (n) { if (p) { p->next = s->next; } else { d->stmt = s->next; } } } freeparams(s); freep(&s->bindparms); if (s->row_status0 != &s->row_status1) { freep(&s->row_status0); s->rowset_size = 1; s->row_status0 = &s->row_status1; } xfree(s); return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC (driver internal version). * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ static SQLRETURN drvallocstmt(SQLHDBC dbc, SQLHSTMT *stmt) { DBC *d; STMT *s, *sl, *pl; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->magic != DBC_MAGIC || stmt == NULL) { return SQL_INVALID_HANDLE; } s = (STMT *) xmalloc(sizeof (STMT)); if (s == NULL) { *stmt = SQL_NULL_HSTMT; return SQL_ERROR; } *stmt = (SQLHSTMT) s; memset(s, 0, sizeof (STMT)); s->dbc = dbc; s->ov3 = d->ov3; s->oemcp = &d->oemcp; s->nowchar[0] = d->nowchar; s->nowchar[1] = 0; s->dobigint = d->dobigint; s->curtype = d->curtype; s->row_status0 = &s->row_status1; s->rowset_size = 1; s->longnames = d->longnames; s->retr_data = SQL_RD_ON; s->max_rows = 0; s->bind_type = SQL_BIND_BY_COLUMN; s->bind_offs = NULL; s->paramset_size = 1; s->parm_bind_type = SQL_PARAM_BIND_BY_COLUMN; #ifdef _WIN64 sprintf((char *) s->cursorname, "CUR_%I64X", (SQLUBIGINT) *stmt); #else sprintf((char *) s->cursorname, "CUR_%016lX", (long) *stmt); #endif sl = d->stmt; pl = NULL; while (sl) { pl = sl; sl = sl->next; } if (pl) { pl->next = s; } else { d->stmt = s; } return SQL_SUCCESS; } /** * Allocate HSTMT given HDBC. * @param dbc database connection handle * @param stmt pointer to statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLAllocStmt(SQLHDBC dbc, SQLHSTMT *stmt) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvallocstmt(dbc, stmt); HDBC_UNLOCK(dbc); return ret; } /** * Internal function to perform certain kinds of free/close on STMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ static SQLRETURN drvfreestmt(SQLHSTMT stmt, SQLUSMALLINT opt) { STMT *s; SQLRETURN ret = SQL_SUCCESS; SQLHDBC dbc; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_LOCK(stmt); s = (STMT *) stmt; dbc = s->dbc; switch (opt) { case SQL_RESET_PARAMS: freeparams(s); break; case SQL_UNBIND: unbindcols(s); break; case SQL_CLOSE: s4stmt_end_if(s); freeresult(s, 0); break; case SQL_DROP: s4stmt_end_if(s); ret = freestmt(stmt); break; default: setstat(s, -1, "unsupported option", (*s->ov3) ? "HYC00" : "S1C00"); ret = SQL_ERROR; break; } HDBC_UNLOCK(dbc); return ret; } /** * Free HSTMT. * @param stmt statement handle * @param opt SQL_RESET_PARAMS, SQL_UNBIND, SQL_CLOSE, or SQL_DROP * @result ODBC error code */ SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT opt) { return drvfreestmt(stmt, opt); } /** * Cancel HSTMT closing cursor. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) { if (stmt != SQL_NULL_HSTMT) { DBC *d = (DBC *) ((STMT *) stmt)->dbc; #if defined(_WIN32) || defined(_WIN64) /* interrupt when other thread owns critical section */ int i; for (i = 0; i < 2; i++) { if (d->magic == DBC_MAGIC && d->env && d->env->magic == ENV_MAGIC && d->env->owner != GetCurrentThreadId() && d->env->owner != 0) { d->busyint = 1; sqlite4_interrupt(d->sqlite); } Sleep(1); } #else if (d->magic == DBC_MAGIC) { d->busyint = 1; sqlite4_interrupt(d->sqlite); } #endif } return drvfreestmt(stmt, SQL_CLOSE); } /** * Internal function to get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ static SQLRETURN drvgetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (lenp && !cursor) { *lenp = strlen((char *) s->cursorname); return SQL_SUCCESS; } if (cursor) { if (buflen > 0) { strncpy((char *) cursor, (char *) s->cursorname, buflen - 1); cursor[buflen - 1] = '\0'; } if (lenp) { *lenp = min(strlen((char *) s->cursorname), buflen - 1); } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Get cursor name of STMT. * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvgetcursorname(stmt, cursor, buflen, lenp); goto done; } ret = drvgetcursorname(stmt, cursor, buflen, &len); if (ret == SQL_SUCCESS) { char *c = NULL; if (cursor) { c = utf_to_wmb((char *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } c[len] = 0; len = strlen(c); if (buflen > 0) { strncpy((char *) cursor, c, buflen - 1); cursor[buflen - 1] = 0; } uc_free(c); } if (lenp) { *lenp = min(len, buflen - 1); } } done: ; #else ret = drvgetcursorname(stmt, cursor, buflen, lenp); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Get cursor name of STMT (UNICODE version). * @param stmt statement handle * @param cursor output buffer * @param buflen length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT buflen, SQLSMALLINT *lenp) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvgetcursorname(stmt, (SQLCHAR *) cursor, buflen, &len); if (ret == SQL_SUCCESS) { SQLWCHAR *c = NULL; if (cursor) { c = uc_from_utf((SQLCHAR *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } c[len] = 0; len = uc_strlen(c); if (buflen > 0) { uc_strncpy(cursor, c, buflen - 1); cursor[buflen - 1] = 0; } uc_free(c); } if (lenp) { *lenp = min(len, buflen - 1); } } done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal function to set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ static SQLRETURN drvsetcursorname(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { STMT *s; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!cursor || !((cursor[0] >= 'A' && cursor[0] <= 'Z') || (cursor[0] >= 'a' && cursor[0] <= 'z'))) { setstat(s, -1, "invalid cursor name", (*s->ov3) ? "HYC00" : "S1C00"); return SQL_ERROR; } if (len == SQL_NTS) { len = sizeof (s->cursorname) - 1; } else { len = min(sizeof (s->cursorname) - 1, len); } strncpy((char *) s->cursorname, (char *) cursor, len); s->cursorname[len] = '\0'; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Set cursor name on STMT. * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt, SQLCHAR *cursor, SQLSMALLINT len) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvsetcursorname(stmt, cursor, len); goto done2; } if (cursor) { c = wmb_to_utf_c((char *) cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } } ret = drvsetcursorname(stmt, (SQLCHAR *) c, SQL_NTS); #else ret = drvsetcursorname(stmt, cursor, len); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Set cursor name on STMT (UNICODE version). * @param stmt statement handle * @param cursor new cursor name * @param len length of cursor name or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLSetCursorNameW(SQLHSTMT stmt, SQLWCHAR *cursor, SQLSMALLINT len) { char *c = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cursor) { c = uc_to_utf_c(cursor, len); if (!c) { ret = nomem((STMT *) stmt); goto done; } } ret = drvsetcursorname(stmt, (SQLCHAR *) c, SQL_NTS); done: uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Close open cursor. * @param stmt statement handle * @return ODBC error code */ SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt) { return drvfreestmt(stmt, SQL_CLOSE); } /** * Allocate a HENV, HDBC, or HSTMT handle. * @param type handle type * @param input input handle (HENV, HDBC) * @param output pointer to output handle (HENV, HDBC, HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE input, SQLHANDLE *output) { SQLRETURN ret; switch (type) { case SQL_HANDLE_ENV: ret = drvallocenv((SQLHENV *) output); if (ret == SQL_SUCCESS) { ENV *e = (ENV *) *output; if (e && e->magic == ENV_MAGIC) { e->ov3 = 1; } } return ret; case SQL_HANDLE_DBC: return drvallocconnect((SQLHENV) input, (SQLHDBC *) output); case SQL_HANDLE_STMT: HDBC_LOCK((SQLHDBC) input); ret = drvallocstmt((SQLHDBC) input, (SQLHSTMT *) output); HDBC_UNLOCK((SQLHDBC) input); return ret; } return SQL_ERROR; } /** * Free a HENV, HDBC, or HSTMT handle. * @param type handle type * @param h handle (HENV, HDBC, or HSTMT) * @result ODBC error code */ SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE h) { switch (type) { case SQL_HANDLE_ENV: return drvfreeenv((SQLHENV) h); case SQL_HANDLE_DBC: return drvfreeconnect((SQLHDBC) h); case SQL_HANDLE_STMT: return drvfreestmt((SQLHSTMT) h, SQL_DROP); } return SQL_ERROR; } /** * Free dynamically allocated column descriptions of STMT. * @param s statement pointer */ static void freedyncols(STMT *s) { if (s->dyncols) { int i; for (i = 0; i < s->dcols; i++) { freep(&s->dyncols[i].typename); } if (s->cols == s->dyncols) { s->cols = NULL; s->ncols = 0; } freep(&s->dyncols); } s->dcols = 0; } /** * Free statement's result. * @param s statement pointer * @param clrcols flag to clear column information * * The result rows are free'd using the rowfree function pointer. * If clrcols is greater than zero, then column bindings and dynamic column * descriptions are free'd. * If clrcols is less than zero, then dynamic column descriptions are free'd. */ static void freeresult(STMT *s, int clrcols) { freep(&s->bincache); s->bincell = NULL; s->binlen = 0; if (s->rows) { if (s->rowfree) { s->rowfree(s->rows); s->rowfree = NULL; } s->rows = NULL; } s->nrows = -1; if (clrcols > 0) { freep(&s->bindcols); s->nbindcols = 0; } if (clrcols) { freedyncols(s); s->cols = NULL; s->ncols = 0; s->nowchar[1] = 0; } } /** * Reset bound columns to unbound state. * @param s statement pointer */ static void unbindcols(STMT *s) { int i; s->bkmrkcol.type = -1; s->bkmrkcol.max = 0; s->bkmrkcol.lenp = NULL; s->bkmrkcol.valp = NULL; s->bkmrkcol.index = 0; s->bkmrkcol.offs = 0; for (i = 0; s->bindcols && i < s->nbindcols; i++) { s->bindcols[i].type = -1; s->bindcols[i].max = 0; s->bindcols[i].lenp = NULL; s->bindcols[i].valp = NULL; s->bindcols[i].index = i; s->bindcols[i].offs = 0; } } /** * Reallocate space for bound columns. * @param s statement pointer * @param ncols number of columns * @result ODBC error code */ static SQLRETURN mkbindcols(STMT *s, int ncols) { if (s->bindcols) { if (s->nbindcols < ncols) { int i; BINDCOL *bindcols = xrealloc(s->bindcols, ncols * sizeof (BINDCOL)); if (!bindcols) { return nomem(s); } for (i = s->nbindcols; i < ncols; i++) { bindcols[i].type = -1; bindcols[i].max = 0; bindcols[i].lenp = NULL; bindcols[i].valp = NULL; bindcols[i].index = i; bindcols[i].offs = 0; } s->bindcols = bindcols; s->nbindcols = ncols; } } else if (ncols > 0) { s->bindcols = (BINDCOL *) xmalloc(ncols * sizeof (BINDCOL)); if (!s->bindcols) { return nomem(s); } s->nbindcols = ncols; unbindcols(s); } return SQL_SUCCESS; } /** * Internal function to retrieve row data, used by SQLFetch() and * friends and SQLGetData(). * @param s statement pointer * @param col column number, 0 based * @param otype output data type * @param val output buffer * @param len length of output buffer * @param lenp output length * @param partial flag for partial data retrieval * @result ODBC error code */ static SQLRETURN getrowdata(STMT *s, SQLUSMALLINT col, SQLSMALLINT otype, SQLPOINTER val, SQLINTEGER len, SQLLEN *lenp, int partial) { char **data, valdummy[16]; SQLLEN dummy; SQLINTEGER *ilenp = NULL; int valnull = 0; int type = otype; SQLRETURN sret = SQL_NO_DATA; if (!lenp) { lenp = &dummy; } /* workaround for JDK 1.7.0 on x86_64 */ if (((SQLINTEGER *) lenp) + 1 == (SQLINTEGER *) val) { ilenp = (SQLINTEGER *) lenp; lenp = &dummy; } if (col >= s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!s->rows) { *lenp = SQL_NULL_DATA; goto done; } if (s->rowp < 0 || s->rowp >= s->nrows) { *lenp = SQL_NULL_DATA; goto done; } if (s->retr_data != SQL_RD_ON) { return SQL_SUCCESS; } type = mapdeftype(type, s->cols[col].type, s->cols[col].nosign ? 1 : 0, s->nowchar[0]); #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 3 (map SQL_C_DEFAULT to SQL_C_CHAR) */ if (type == SQL_C_WCHAR && otype == SQL_C_DEFAULT) { type = SQL_C_CHAR; } #endif data = s->rows + s->ncols + (s->rowp * s->ncols) + col; if (!val) { valnull = 1; val = (SQLPOINTER) valdummy; } if (*data == NULL) { *lenp = SQL_NULL_DATA; switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: #ifdef SQL_BIT case SQL_C_BIT: #endif *((SQLCHAR *) val) = 0; break; case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((SQLSMALLINT *) val) = 0; break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = 0; break; #ifdef SQL_BIGINT case SQL_C_SBIGINT: case SQL_C_UBIGINT: *((SQLBIGINT *) val) = 0; break; #endif case SQL_C_FLOAT: *((float *) val) = 0; break; case SQL_C_DOUBLE: *((double *) val) = 0; break; case SQL_C_BINARY: case SQL_C_CHAR: *((SQLCHAR *) val) = '\0'; break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: *((SQLWCHAR *) val) = '\0'; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: memset((DATE_STRUCT *) val, 0, sizeof (DATE_STRUCT)); break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: memset((TIME_STRUCT *) val, 0, sizeof (TIME_STRUCT)); break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: memset((TIMESTAMP_STRUCT *) val, 0, sizeof (TIMESTAMP_STRUCT)); break; default: return SQL_ERROR; } } else { char *endp = NULL; #if defined(_WIN32) || defined(_WIN64) #ifdef SQL_BIGINT char endc; #endif #endif switch (type) { case SQL_C_UTINYINT: case SQL_C_TINYINT: case SQL_C_STINYINT: *((SQLCHAR *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLCHAR); } break; #ifdef SQL_BIT case SQL_C_BIT: *((SQLCHAR *) val) = getbool(*data); *lenp = sizeof (SQLCHAR); break; #endif case SQL_C_USHORT: case SQL_C_SHORT: case SQL_C_SSHORT: *((SQLSMALLINT *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLSMALLINT); } break; case SQL_C_ULONG: case SQL_C_LONG: case SQL_C_SLONG: *((SQLINTEGER *) val) = strtol(*data, &endp, 0); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLINTEGER); } break; #ifdef SQL_BIGINT case SQL_C_UBIGINT: #if defined(_WIN32) || defined(_WIN64) if (sscanf(*data, "%I64u%c", (SQLUBIGINT *) val, &endc) != 1) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLUBIGINT); } #else #ifdef __osf__ *((SQLUBIGINT *) val) = strtoul(*data, &endp, 0); #else *((SQLUBIGINT *) val) = strtoull(*data, &endp, 0); #endif if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLUBIGINT); } #endif break; case SQL_C_SBIGINT: #if defined(_WIN32) || defined(_WIN64) if (sscanf(*data, "%I64d%c", (SQLBIGINT *) val, &endc) != 1) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLBIGINT); } #else #ifdef __osf__ *((SQLBIGINT *) val) = strtol(*data, &endp, 0); #else *((SQLBIGINT *) val) = strtoll(*data, &endp, 0); #endif if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (SQLBIGINT); } #endif break; #endif case SQL_C_FLOAT: *((float *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (float); } break; case SQL_C_DOUBLE: *((double *) val) = ln_strtod(*data, &endp); if (endp && endp == *data) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (double); } break; case SQL_C_BINARY: { int dlen, offs = 0; char *bin; if (valnull) { freep(&s->bincache); s->binlen = 0; goto doCHAR; } if (*data == s->bincell) { if (s->bincache) { bin = s->bincache; dlen = s->binlen; } else { goto doCHAR; } } else { char *dp; int i; freep(&s->bincache); dp = *data; dlen = strlen(dp); s->bincell = dp; s->binlen = 0; if (!(dp[0] == 'x' || dp[0] == 'X') || dp[1] != '\'' || dp[dlen - 1] != '\'') { goto doCHAR; } dlen -= 2; dp += 2; dlen = dlen / 2; s->bincache = bin = xmalloc(dlen); if (!bin) { return nomem(s); } s->binlen = dlen; memset(s->bincache, 0, dlen); for (i = 0; i < dlen; i++) { char *x; int v; if (!*dp || !(x = strchr(xdigits, *dp))) { goto converr; } v = x - xdigits; bin[i] = (v >= 16) ? ((v - 6) << 4) : (v << 4); ++dp; if (!*dp || !(x = strchr(xdigits, *dp))) { converr: freep(&s->bincache); s->binlen = 0; setstat(s, -1, "conversion error", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } v = x - xdigits; bin[i] |= (v >= 16) ? (v - 6) : v; ++dp; } bin = s->bincache; } if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { *lenp = 0; if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && len) { memcpy(val, bin + offs, min(len, dlen)); } if (len < 1) { *lenp = dlen; } else { *lenp = min(len, dlen); if (*lenp == len && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } } if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } doCHAR: #ifdef WCHARSUPPORT case SQL_C_WCHAR: #endif case SQL_C_CHAR: { int doz, zlen = len - 1; int dlen = strlen(*data); int offs = 0; #ifdef WCHARSUPPORT SQLWCHAR *ucdata = NULL; SQLCHAR *cdata = (SQLCHAR *) *data; #endif #if (defined(_WIN32) || defined(_WIN64)) && defined(WINTERFACE) /* MS Access hack part 2 (reserved error -7748) */ if (!valnull && (s->cols == statSpec2P || s->cols == statSpec3P) && type == SQL_C_WCHAR) { if (len > 0 && len <= sizeof (SQLWCHAR)) { ((char *) val)[0] = data[0][0]; memset((char *) val + 1, 0, len - 1); *lenp = 1; sret = SQL_SUCCESS; goto done; } } #endif #ifdef WCHARSUPPORT switch (type) { case SQL_C_CHAR: doz = 1; break; case SQL_C_WCHAR: doz = sizeof (SQLWCHAR); break; default: doz = 0; break; } if (type == SQL_C_WCHAR) { ucdata = uc_from_utf(cdata, dlen); if (!ucdata) { return nomem(s); } dlen = uc_strlen(ucdata) * sizeof (SQLWCHAR); } #if defined(_WIN32) || defined(_WIN64) else if (*s->oemcp && type == SQL_C_CHAR) { ucdata = (SQLWCHAR *) utf_to_wmb((char *) cdata, dlen); if (!ucdata) { return nomem(s); } cdata = (SQLCHAR *) ucdata; dlen = strlen((char *) cdata); } #endif #else doz = (type == SQL_C_CHAR) ? 1 : 0; #endif if (partial && len && s->bindcols) { if (s->bindcols[col].offs >= dlen) { #ifdef WCHARSUPPORT uc_free(ucdata); #endif *lenp = 0; if (doz && val) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[0] = 0; } else { ((char *) val)[0] = '\0'; } #else ((char *) val)[0] = '\0'; #endif } if (!dlen && s->bindcols[col].offs == dlen) { s->bindcols[col].offs = 1; sret = SQL_SUCCESS; goto done; } s->bindcols[col].offs = 0; sret = SQL_NO_DATA; goto done; } offs = s->bindcols[col].offs; dlen -= offs; } if (val && !valnull && len) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { uc_strncpy(val, ucdata + offs / sizeof (SQLWCHAR), (len - doz) / sizeof (SQLWCHAR)); } else { strncpy(val, (char *) cdata + offs, len - doz); } #else strncpy(val, *data + offs, len - doz); #endif } if (valnull || len < 1) { *lenp = dlen; } else { *lenp = min(len - doz, dlen); if (*lenp == len - doz && *lenp != dlen) { *lenp = SQL_NO_TOTAL; } else if (*lenp < zlen) { zlen = *lenp; } } if (len && !valnull && doz) { #ifdef WCHARSUPPORT if (type == SQL_C_WCHAR) { ((SQLWCHAR *) val)[zlen / sizeof (SQLWCHAR)] = 0; } else { ((char *) val)[zlen] = '\0'; } #else ((char *) val)[zlen] = '\0'; #endif } #ifdef WCHARSUPPORT uc_free(ucdata); #endif if (partial && len && s->bindcols) { if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; s->bindcols[col].offs += len - doz; setstat(s, -1, "data right truncated", "01004"); if (s->bindcols[col].lenp) { *s->bindcols[col].lenp = dlen; } sret = SQL_SUCCESS_WITH_INFO; goto done; } s->bindcols[col].offs += *lenp; } if (*lenp == SQL_NO_TOTAL) { *lenp = dlen; setstat(s, -1, "data right truncated", "01004"); sret = SQL_SUCCESS_WITH_INFO; goto done; } break; } #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: #endif case SQL_C_DATE: if (str2date(*data, (DATE_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (DATE_STRUCT); } break; #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: #endif case SQL_C_TIME: if (str2time(*data, (TIME_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIME_STRUCT); } break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: #endif case SQL_C_TIMESTAMP: if (str2timestamp(*data, (TIMESTAMP_STRUCT *) val) < 0) { *lenp = SQL_NULL_DATA; } else { *lenp = sizeof (TIMESTAMP_STRUCT); } switch (s->cols[col].prec) { case 0: ((TIMESTAMP_STRUCT *) val)->fraction = 0; break; case 1: ((TIMESTAMP_STRUCT *) val)->fraction /= 100000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 100000000; break; case 2: ((TIMESTAMP_STRUCT *) val)->fraction /= 10000000; ((TIMESTAMP_STRUCT *) val)->fraction *= 10000000; break; } break; default: return SQL_ERROR; } } sret = SQL_SUCCESS; done: if (ilenp) { *ilenp = *lenp; } return sret; } /** * Interal bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ static SQLRETURN drvbindcol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { STMT *s; int sz = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col < 1) { if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { s->bkmrkcol.type = type; s->bkmrkcol.max = sizeof (SQLINTEGER); s->bkmrkcol.lenp = lenp; s->bkmrkcol.valp = val; s->bkmrkcol.offs = 0; if (lenp) { *lenp = 0; } return SQL_SUCCESS; } setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (mkbindcols(s, col) != SQL_SUCCESS) { return SQL_ERROR; } --col; if (type == SQL_C_DEFAULT) { type = mapdeftype(type, s->cols[col].type, 0, s->nowchar[0] || s->nowchar[1]); } switch (type) { case SQL_C_LONG: case SQL_C_ULONG: case SQL_C_SLONG: sz = sizeof (SQLINTEGER); break; case SQL_C_TINYINT: case SQL_C_UTINYINT: case SQL_C_STINYINT: sz = sizeof (SQLCHAR); break; case SQL_C_SHORT: case SQL_C_USHORT: case SQL_C_SSHORT: sz = sizeof (SQLSMALLINT); break; case SQL_C_FLOAT: sz = sizeof (SQLFLOAT); break; case SQL_C_DOUBLE: sz = sizeof (SQLDOUBLE); break; case SQL_C_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; case SQL_C_TIME: sz = sizeof (SQL_TIME_STRUCT); break; case SQL_C_DATE: sz = sizeof (SQL_DATE_STRUCT); break; case SQL_C_CHAR: break; #ifdef WCHARSUPPORT case SQL_C_WCHAR: break; #endif #ifdef SQL_C_TYPE_DATE case SQL_C_TYPE_DATE: sz = sizeof (SQL_DATE_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIME case SQL_C_TYPE_TIME: sz = sizeof (SQL_TIME_STRUCT); break; #endif #ifdef SQL_C_TYPE_TIMESTAMP case SQL_C_TYPE_TIMESTAMP: sz = sizeof (SQL_TIMESTAMP_STRUCT); break; #endif #ifdef SQL_BIT case SQL_C_BIT: sz = sizeof (SQLCHAR); break; #endif case SQL_C_BINARY: break; #ifdef SQL_BIGINT case SQL_C_SBIGINT: case SQL_C_UBIGINT: sz = sizeof (SQLBIGINT); break; #endif default: if (val == NULL) { /* fall through, unbinding column */ break; } setstat(s, -1, "invalid type %d", "HY003", type); return SQL_ERROR; } if (val == NULL) { /* unbind column */ s->bindcols[col].type = -1; s->bindcols[col].max = 0; s->bindcols[col].lenp = NULL; s->bindcols[col].valp = NULL; s->bindcols[col].offs = 0; } else { if (sz == 0 && max < 0) { setstat(s, -1, "invalid length", "HY090"); return SQL_ERROR; } s->bindcols[col].type = type; s->bindcols[col].max = (sz == 0) ? max : sz; s->bindcols[col].lenp = lenp; s->bindcols[col].valp = val; s->bindcols[col].offs = 0; if (lenp) { *lenp = 0; } } return SQL_SUCCESS; } /** * Bind C variable to column of result set. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param max length of output buffer * @param lenp output length pointer * @result ODBC error code */ SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN max, SQLLEN *lenp) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvbindcol(stmt, col, type, val, max, lenp); HSTMT_UNLOCK(stmt); return ret; } /** * Columns for result set of SQLTables(). */ static COL tableSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; static COL tableSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "TABLE_TYPE", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 } }; /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvtables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { SQLRETURN ret; STMT *s; DBC *d; int ncols, asize, rc, size, npatt; char *errp = NULL, *sql, tname[512]; char *where = "(type = 'table' or type = 'view')"; ret = mkresultset(stmt, tableSpec2, array_size(tableSpec2), tableSpec3, array_size(tableSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] == '%') { int size = 3 * asize; s->rows = xmalloc(size * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } memset(s->rows, 0, sizeof (char *) * size); s->ncols = asize; s->rows[s->ncols + 0] = ""; s->rows[s->ncols + 1] = ""; s->rows[s->ncols + 2] = ""; s->rows[s->ncols + 3] = "TABLE"; s->rows[s->ncols + 5] = ""; s->rows[s->ncols + 6] = ""; s->rows[s->ncols + 7] = ""; s->rows[s->ncols + 8] = "VIEW"; #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = sqlite4_free; #endif s->nrows = 2; s->rowp = -1; return SQL_SUCCESS; } if (cat && (catLen > 0 || catLen == SQL_NTS) && cat[0] == '%') { table = NULL; goto doit; } if (schema && (schemaLen > 0 || schemaLen == SQL_NTS) && schema[0] == '%') { if ((!cat || catLen == 0 || !cat[0]) && (!table || tableLen == 0 || !table[0])) { table = NULL; goto doit; } } if (type && (typeLen > 0 || typeLen == SQL_NTS) && type[0] != '\0') { char tmp[256], *t; int with_view = 0, with_table = 0; if (typeLen == SQL_NTS) { strncpy(tmp, (char *) type, sizeof (tmp)); tmp[sizeof (tmp) - 1] = '\0'; } else { int len = min(sizeof (tmp) - 1, typeLen); strncpy(tmp, (char *) type, len); tmp[len] = '\0'; } t = tmp; while (*t) { *t = TOLOWER(*t); t++; } t = tmp; unescpat(t); while (t) { if (t[0] == '\'') { ++t; } if (strncmp(t, "table", 5) == 0) { with_table++; } else if (strncmp(t, "view", 4) == 0) { with_view++; } t = strchr(t, ','); if (t) { ++t; } } if (with_view && with_table) { /* where is already preset */ } else if (with_view && !with_table) { where = "type = 'view'"; } else if (!with_view && with_table) { where = "type = 'table'"; } else { return SQL_SUCCESS; } } doit: if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); #if defined(_WIN32) || defined(_WIN64) sql = sqlite4_mprintf(0, "select %s as 'TABLE_QUALIFIER', " "%s as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s %Q", d->xcelqrx ? "''" : "NULL", d->xcelqrx ? "'main'" : "NULL", where, npatt ? "like" : "=", tname); #else sql = sqlite4_mprintf(0, "select NULL as 'TABLE_QUALIFIER', " "NULL as 'TABLE_OWNER', " "tbl_name as 'TABLE_NAME', " "upper(type) as 'TABLE_TYPE', " "NULL as 'REMARKS' " "from sqlite_master where %s " "and tbl_name %s %Q", where, npatt ? "like" : "=", tname); #endif if (!sql) { return nomem(s); } ret = starttran(s); if (ret != SQL_SUCCESS) { sqlite4_free(0, sql); return ret; } dbtraceapi(d, "sqlite4_get_table", sql); rc = sqlite4_get_table(d->sqlite, sql, &s->rows, &s->nrows, &ncols, &errp); sqlite4_free(0, sql); if (rc == SQLITE4_OK) { if (ncols != s->ncols) { freeresult(s, 0); s->nrows = 0; } else { s->rowfree = freerows; } } else { s->nrows = 0; s->rows = NULL; s->rowfree = NULL; } if (errp) { sqlite4_free(0, errp); errp = NULL; } s->rowp = -1; return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *type, SQLSMALLINT typeLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL, *y = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvtables(stmt, cat, catLen, schema, schemaLen, table, tableLen, type, typeLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (type) { y = wmb_to_utf_c((char *) type, typeLen); if (!y) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtables(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) y, SQL_NTS); #else ret = drvtables(stmt, cat, catLen, schema, schemaLen, table, tableLen, type, typeLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(y); uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve information on tables and/or views. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param type types of tables string or NULL * @param typeLen length of types of tables string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLTablesW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *type, SQLSMALLINT typeLen) { char *c = NULL, *s = NULL, *t = NULL, *y = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (type) { y = uc_to_utf_c(type, typeLen); if (!y) { ret = nomem((STMT *) stmt); goto done; } } ret = drvtables(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) y, SQL_NTS); done: uc_free(y); uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLColumns(). */ static COL colSpec2[] = { { "SYSTEM", "COLUMN", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "PRECISION", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "SCALE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; static COL colSpec3[] = { { "SYSTEM", "COLUMN", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "COLUMN", "DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_SIZE", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "BUFFER_LENGTH", SQL_INTEGER, 50 }, { "SYSTEM", "COLUMN", "DECIMAL_DIGITS", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NUM_PREC_RADIX", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "NULLABLE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "REMARKS", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "COLUMN_DEF", SCOL_VARCHAR, 50 }, { "SYSTEM", "COLUMN", "SQL_DATA_TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "SQL_DATETIME_SUB", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "CHAR_OCTET_LENGTH", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "COLUMN", "IS_NULLABLE", SCOL_VARCHAR, 50 } }; /** * Internal retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ static SQLRETURN drvcolumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { SQLRETURN sret; STMT *s; DBC *d; int ret, nrows, ncols, asize, i, k, roffs, namec; int tnrows, tncols, npatt; PTRDIFF_T size; char *errp = NULL, *sql, tname[512], cname[512], **rowp, **trows; sret = mkresultset(stmt, colSpec2, array_size(colSpec2), colSpec3, array_size(colSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table) { size = 1; tname[0] = '%'; } else { if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); } tname[size] = '\0'; npatt = unescpat(tname); size = 0; if (col) { if (colLen == SQL_NTS) { size = sizeof (cname) - 1; } else { size = min(sizeof (cname) - 1, colLen); } strncpy(cname, (char *) col, size); } cname[size] = '\0'; if (!strcmp(cname, "%")) { cname[0] = '\0'; } sql = sqlite4_mprintf(0, "select tbl_name from sqlite_master where " "(type = 'table' or type = 'view') " "and tbl_name %s %Q", npatt ? "like" : "=", tname); if (!sql) { return nomem(s); } sret = starttran(s); if (sret != SQL_SUCCESS) { sqlite4_free(0, sql); return sret; } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &trows, &tnrows, &tncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } /* pass 1: compute number of rows of result set */ if (tncols * tnrows <= 0) { freerows(trows); return SQL_SUCCESS; } size = 0; for (i = 1; i <= tnrows; i++) { sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", trows[i]); if (!sql) { freerows(trows); return nomem(s); } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } freerows(trows); return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } if (ncols * nrows > 0) { namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { if (namec >= 0) { for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { size++; } } } } else { size += nrows; } } freerows(rowp); } /* pass 2: fill result set */ if (size <= 0) { freerows(trows); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; freerows(trows); return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; roffs = 1; for (i = 1; i <= tnrows; i++) { sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", trows[i]); if (!sql) { freerows(trows); return nomem(s); } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } freerows(trows); return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } if (ncols * nrows > 0) { int m, mr, nr = nrows; namec = -1; for (k = 0; k < ncols; k++) { if (strcmp(rowp[k], "name") == 0) { namec = k; break; } } if (cname[0]) { nr = 0; if (namec >= 0) { for (k = 1; k <= nrows; k++) { if (namematch(rowp[k * ncols + namec], cname, 1)) { nr++; } } } } for (k = 0; k < nr; k++) { m = asize * (roffs + k); s->rows[m + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[m + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[m + 1] = xstrdup(""); #endif s->rows[m + 2] = xstrdup(trows[i]); s->rows[m + 8] = xstrdup("10"); s->rows[m + 9] = xstrdup("0"); s->rows[m + 15] = xstrdup("16384"); } for (k = 0; nr && k < ncols; k++) { if (strcmp(rowp[k], "cid") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char buf[256]; int ir, coln = k; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); sscanf(rowp[m * ncols + k], "%d", &coln); sprintf(buf, "%d", coln + 1); s->rows[ir + 16] = xstrdup(buf); ++mr; } } else if (k == namec) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 3] = xstrdup(rowp[m * ncols + k]); ++mr; } } else if (strcmp(rowp[k], "notnull") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); if (*rowp[m * ncols + k] != '0') { s->rows[ir + 10] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[ir + 10] = xstrdup(stringify(SQL_TRUE)); } s->rows[ir + 17] = xstrdup((*rowp[m * ncols + k] != '0') ? "NO" : "YES"); ++mr; } } else if (strcmp(rowp[k], "dflt_value") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *dflt = unquote(rowp[m * ncols + k]); int ir; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 12] = xstrdup(dflt ? dflt : "NULL"); ++mr; } } else if (strcmp(rowp[k], "type") == 0) { for (mr = 0, m = 1; m <= nrows; m++) { char *typename = rowp[m * ncols + k]; int sqltype, mm, dd, ir; char buf[256]; if (cname[0] && !namematch(rowp[m * ncols + namec], cname, 1)) { continue; } ir = asize * (roffs + mr); s->rows[ir + 5] = xstrdup(typename); sqltype = mapsqltype(typename, NULL, *s->ov3, s->nowchar[0], s->dobigint); getmd(typename, sqltype, &mm, &dd); #ifdef SQL_LONGVARCHAR if (sqltype == SQL_VARCHAR && mm > 255) { sqltype = SQL_LONGVARCHAR; } #endif #ifdef WINTERFACE #ifdef SQL_WLONGVARCHAR if (sqltype == SQL_WVARCHAR && mm > 255) { sqltype = SQL_WLONGVARCHAR; } #endif #endif if (sqltype == SQL_VARBINARY && mm > 255) { sqltype = SQL_LONGVARBINARY; } sprintf(buf, "%d", sqltype); s->rows[ir + 4] = xstrdup(buf); s->rows[ir + 13] = xstrdup(buf); sprintf(buf, "%d", mm); s->rows[ir + 7] = xstrdup(buf); sprintf(buf, "%d", dd); s->rows[ir + 6] = xstrdup(buf); ++mr; } } } roffs += nr; } freerows(rowp); } freerows(trows); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column information on table. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLCHAR *col, SQLSMALLINT colLen) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL, *k = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolumns(stmt, cat, catLen, schema, schemaLen, table, tableLen, col, colLen); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (col) { k = wmb_to_utf_c((char *) col, colLen); if (!k) { ret = nomem((STMT *) stmt); goto done; } } ret = drvcolumns(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) k, SQL_NTS); #else ret = drvcolumns(stmt, cat, catLen, schema, schemaLen, table, tableLen, col, colLen); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(k); uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column information on table (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param col column name/pattern or NULL * @param colLen length of column name/pattern or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLColumnsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLWCHAR *col, SQLSMALLINT colLen) { char *c = NULL, *s = NULL, *t = NULL, *k = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } if (col) { k = uc_to_utf_c(col, colLen); if (!k) { ret = nomem((STMT *) stmt); goto done; } } ret = drvcolumns(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, (SQLCHAR *) k, SQL_NTS); done: uc_free(k); uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLGetTypeInfo(). */ static COL typeSpec2[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "PRECISION", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MONEY", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_INCREMENT", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 } }; static COL typeSpec3[] = { { "SYSTEM", "TYPE", "TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "COLUMN_SIZE", SQL_INTEGER, 9 }, { "SYSTEM", "TYPE", "LITERAL_PREFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "LITERAL_SUFFIX", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "CREATE_PARAMS", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "NULLABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "CASE_SENSITIVE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SEARCHABLE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "UNSIGNED_ATTRIBUTE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "FIXED_PREC_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "AUTO_UNIQUE_VALUE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "LOCAL_TYPE_NAME", SCOL_VARCHAR, 50 }, { "SYSTEM", "TYPE", "MINIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "MAXIMUM_SCALE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATA_TYPE", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "SQL_DATETIME_SUB", SQL_SMALLINT, 2 }, { "SYSTEM", "TYPE", "NUM_PREC_RADIX", SQL_INTEGER, 4 }, { "SYSTEM", "TYPE", "INTERVAL_PRECISION", SQL_SMALLINT, 2 } }; /** * Internal function to build up data type information as row in result set. * @param s statement pointer * @param row row number * @param asize number of items in a row * @param typename name of type * @param type integer SQL type * @param tind type index */ static void mktypeinfo(STMT *s, int row, int asize, char *typename, int type, int tind) { int offs = row * asize; char *tcode, *crpar = NULL, *quote = NULL, *sign = stringify(SQL_FALSE); static char tcodes[32 * 32]; if (tind <= 0) { tind = row; } tcode = tcodes + tind * 32; sprintf(tcode, "%d", type); s->rows[offs + 0] = typename; s->rows[offs + 1] = tcode; if (asize >= 17) { s->rows[offs + 15] = tcode; s->rows[offs + 16] = "0"; } switch (type) { default: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #ifdef WINTERFACE case SQL_WLONGVARCHAR: #endif crpar = "length"; quote = "'"; sign = NULL; s->rows[offs + 2] = "65536"; break; #endif #ifdef SQL_BIT case SQL_BIT: sign = NULL; s->rows[offs + 2] = "1"; break; #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #endif s->rows[offs + 2] = "255"; crpar = "length"; quote = "'"; sign = NULL; break; case SQL_TINYINT: s->rows[offs + 2] = "3"; break; case SQL_SMALLINT: s->rows[offs + 2] = "5"; break; case SQL_INTEGER: s->rows[offs + 2] = "9"; break; #ifdef SQL_BIGINT case SQL_BIGINT: s->rows[offs + 2] = "19"; break; #endif case SQL_FLOAT: s->rows[offs + 2] = "7"; break; case SQL_DOUBLE: s->rows[offs + 2] = "15"; break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: #endif case SQL_DATE: s->rows[offs + 2] = "10"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: #endif case SQL_TIME: s->rows[offs + 2] = "8"; quote = "'"; sign = NULL; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 2] = "32"; quote = "'"; sign = NULL; break; case SQL_VARBINARY: sign = NULL; s->rows[offs + 2] = "255"; break; case SQL_LONGVARBINARY: sign = NULL; s->rows[offs + 2] = "65536"; break; } s->rows[offs + 3] = s->rows[offs + 4] = quote; s->rows[offs + 5] = crpar; s->rows[offs + 6] = stringify(SQL_NULLABLE); s->rows[offs + 7] = stringify(SQL_FALSE); s->rows[offs + 8] = stringify(SQL_SEARCHABLE); s->rows[offs + 9] = sign; s->rows[offs + 10] = stringify(SQL_FALSE); s->rows[offs + 11] = stringify(SQL_FALSE); s->rows[offs + 12] = typename; switch (type) { case SQL_DATE: case SQL_TIME: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "0"; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: s->rows[offs + 13] = "0"; s->rows[offs + 14] = "3"; break; default: s->rows[offs + 13] = NULL; s->rows[offs + 14] = NULL; break; } } /** * Helper function to sort type information. * Callback for qsort(). * @param a first item to compare * @param b second item to compare * @result ==0, <0, >0 according to data type number */ static int typeinfosort(const void *a, const void *b) { char **pa = (char **) a; char **pb = (char **) b; int na, nb; na = strtol(pa[1], NULL, 0); nb = strtol(pb[1], NULL, 0); return na - nb; } /** * Internal return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ static SQLRETURN drvgettypeinfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; STMT *s; int asize; ret = mkresultset(stmt, typeSpec2, array_size(typeSpec2), typeSpec3, array_size(typeSpec3), &asize); if (ret != SQL_SUCCESS) { return ret; } s = (STMT *) stmt; #ifdef SQL_LONGVARCHAR s->nrows = (sqltype == SQL_ALL_TYPES) ? 13 : 1; #else s->nrows = (sqltype == SQL_ALL_TYPES) ? 12 : 1; #endif if (sqltype == SQL_ALL_TYPES) { #ifdef WINTERFACE s->nrows += 2; #ifdef SQL_WLONGVARCHAR s->nrows += 2; #endif #endif } if (sqltype == SQL_ALL_TYPES) { s->nrows += 2; #ifdef SQL_BIT s->nrows += 1; #endif #ifdef SQL_BIGINT s->nrows += 1; #endif } s->rows = (char **) xmalloc(sizeof (char *) * (s->nrows + 1) * asize); if (!s->rows) { s->nrows = 0; return nomem(s); } #ifdef MEMORY_DEBUG s->rowfree = xfree__; #else s->rowfree = sqlite4_free; #endif memset(s->rows, 0, sizeof (char *) * (s->nrows + 1) * asize); if (sqltype == SQL_ALL_TYPES) { int cc = 1; mktypeinfo(s, cc++, asize, "varchar", SQL_VARCHAR, 0); mktypeinfo(s, cc++, asize, "tinyint", SQL_TINYINT, 0); mktypeinfo(s, cc++, asize, "smallint", SQL_SMALLINT, 0); mktypeinfo(s, cc++, asize, "integer", SQL_INTEGER, 0); mktypeinfo(s, cc++, asize, "float", SQL_FLOAT, 0); mktypeinfo(s, cc++, asize, "double", SQL_DOUBLE, 0); #ifdef SQL_TYPE_DATE mktypeinfo(s, cc++, asize, "date", (*s->ov3) ? SQL_TYPE_DATE : SQL_DATE, 0); #else mktypeinfo(s, cc++, asize, "date", SQL_DATE, 0); #endif #ifdef SQL_TYPE_TIME mktypeinfo(s, cc++, asize, "time", (*s->ov3) ? SQL_TYPE_TIME : SQL_TIME, 0); #else mktypeinfo(s, cc++, asize, "time", SQL_TIME, 0); #endif #ifdef SQL_TYPE_TIMESTAMP mktypeinfo(s, cc++, asize, "timestamp", (*s->ov3) ? SQL_TYPE_TIMESTAMP : SQL_TIMESTAMP, 0); #else mktypeinfo(s, cc++, asize, "timestamp", SQL_TIMESTAMP, 0); #endif mktypeinfo(s, cc++, asize, "char", SQL_CHAR, 0); mktypeinfo(s, cc++, asize, "numeric", SQL_DOUBLE, 0); #ifdef SQL_LONGVARCHAR mktypeinfo(s, cc++, asize, "text", SQL_LONGVARCHAR, 0); mktypeinfo(s, cc++, asize, "longvarchar", SQL_LONGVARCHAR, 0); #else mktypeinfo(s, cc++, asize, "text", SQL_VARCHAR, 0); #endif mktypeinfo(s, cc++, asize, "varbinary", SQL_VARBINARY, 0); mktypeinfo(s, cc++, asize, "longvarbinary", SQL_LONGVARBINARY, 0); #ifdef SQL_BIT mktypeinfo(s, cc++, asize, "bit", SQL_BIT, 0); #endif #ifdef SQL_BIGINT mktypeinfo(s, cc++, asize, "bigint", SQL_BIGINT, 0); #endif #ifdef WINTERFACE mktypeinfo(s, cc++, asize, "wvarchar", SQL_WVARCHAR, 0); mktypeinfo(s, cc++, asize, "wchar", SQL_WCHAR, 0); #ifdef SQL_WLONGVARCHAR mktypeinfo(s, cc++, asize, "wtext", SQL_WLONGVARCHAR, 0); mktypeinfo(s, cc++, asize, "longwvarchar", SQL_WLONGVARCHAR, 0); #endif #endif qsort(s->rows + asize, s->nrows, sizeof (char *) * asize, typeinfosort); } else { switch (sqltype) { case SQL_CHAR: mktypeinfo(s, 1, asize, "char", SQL_CHAR, 10); break; case SQL_VARCHAR: mktypeinfo(s, 1, asize, "varchar", SQL_VARCHAR, 1); break; case SQL_TINYINT: mktypeinfo(s, 1, asize, "tinyint", SQL_TINYINT, 2); break; case SQL_SMALLINT: mktypeinfo(s, 1, asize, "smallint", SQL_SMALLINT, 3); break; case SQL_INTEGER: mktypeinfo(s, 1, asize, "integer", SQL_INTEGER, 4); break; case SQL_FLOAT: mktypeinfo(s, 1, asize, "float", SQL_FLOAT, 5); break; case SQL_DOUBLE: mktypeinfo(s, 1, asize, "double", SQL_DOUBLE, 6); break; #ifdef SQL_TYPE_DATE case SQL_TYPE_DATE: mktypeinfo(s, 1, asize, "date", SQL_TYPE_DATE, 25); break; #endif case SQL_DATE: mktypeinfo(s, 1, asize, "date", SQL_DATE, 7); break; #ifdef SQL_TYPE_TIME case SQL_TYPE_TIME: mktypeinfo(s, 1, asize, "time", SQL_TYPE_TIME, 26); break; #endif case SQL_TIME: mktypeinfo(s, 1, asize, "time", SQL_TIME, 8); break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TYPE_TIMESTAMP, 27); break; #endif case SQL_TIMESTAMP: mktypeinfo(s, 1, asize, "timestamp", SQL_TIMESTAMP, 9); break; #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: mktypeinfo(s, 1, asize, "longvarchar", SQL_LONGVARCHAR, 12); break; #endif case SQL_VARBINARY: mktypeinfo(s, 1, asize, "varbinary", SQL_VARBINARY, 30); break; case SQL_LONGVARBINARY: mktypeinfo(s, 1, asize, "longvarbinary", SQL_LONGVARBINARY, 31); break; #ifdef SQL_BIT case SQL_BIT: mktypeinfo(s, 1, asize, "bit", SQL_BIT, 29); break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: mktypeinfo(s, 1, asize, "bigint", SQL_BIGINT, 28); break; #endif #ifdef WINTERFACE #ifdef SQL_WCHAR case SQL_WCHAR: mktypeinfo(s, 1, asize, "wchar", SQL_WCHAR, 18); break; #endif #ifdef SQL_WVARCHAR case SQL_WVARCHAR: mktypeinfo(s, 1, asize, "wvarchar", SQL_WVARCHAR, 19); break; #endif #ifdef SQL_WLONGVARCHAR case SQL_WLONGVARCHAR: mktypeinfo(s, 1, asize, "longwvarchar", SQL_WLONGVARCHAR, 20); break; #endif #endif default: s->nrows = 0; } } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return data type information. * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return data type information (UNICODE version). * @param stmt statement handle * @param sqltype which type to retrieve * @result ODBC error code */ SQLRETURN SQL_API SQLGetTypeInfoW(SQLHSTMT stmt, SQLSMALLINT sqltype) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvgettypeinfo(stmt, sqltype); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Columns for result set of SQLStatistics(). */ static COL statSpec2[] = { { "SYSTEM", "STATISTICS", "TABLE_QUALIFIER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_OWNER", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "SEQ_IN_INDEX", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "COLLATION", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; static COL statSpec3[] = { { "SYSTEM", "STATISTICS", "TABLE_CAT", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_SCHEM", SCOL_VARCHAR, 50 }, { "SYSTEM", "STATISTICS", "TABLE_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "NON_UNIQUE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "INDEX_QUALIFIER", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "INDEX_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "TYPE", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "ORDINAL_POSITION", SQL_SMALLINT, 50 }, { "SYSTEM", "STATISTICS", "COLUMN_NAME", SCOL_VARCHAR, 255 }, { "SYSTEM", "STATISTICS", "ASC_OR_DESC", SCOL_CHAR, 1 }, { "SYSTEM", "STATISTICS", "CARDINALITY", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "PAGES", SQL_INTEGER, 50 }, { "SYSTEM", "STATISTICS", "FILTER_CONDITION", SCOL_VARCHAR, 255 } }; /** * Internal return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ static SQLRETURN drvstatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { SQLRETURN sret; STMT *s; DBC *d; int i, asize, ret, nrows, ncols, offs, namec, uniquec, addipk = 0; PTRDIFF_T size; char **rowp, *errp = NULL, *sql, tname[512]; sret = mkresultset(stmt, statSpec2, array_size(statSpec2), statSpec3, array_size(statSpec3), &asize); if (sret != SQL_SUCCESS) { return sret; } s = (STMT *) stmt; d = (DBC *) s->dbc; if (!table || table[0] == '\0' || table[0] == '%') { setstat(s, -1, "need table name", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (tableLen == SQL_NTS) { size = sizeof (tname) - 1; } else { size = min(sizeof (tname) - 1, tableLen); } strncpy(tname, (char *) table, size); tname[size] = '\0'; unescpat(tname); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } /* * Try integer primary key (autoincrement) first */ if (itype == SQL_INDEX_UNIQUE || itype == SQL_INDEX_ALL) { rowp = 0; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", tname); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, NULL); sqlite4_free(0, sql); } if (ret == SQLITE4_OK) { int colid, typec, npk = 0; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "pk"); typec = findcol(rowp, ncols, "type"); colid = findcol(rowp, ncols, "cid"); if (namec < 0 || uniquec < 0 || typec < 0 || colid < 0) { goto noipk; } for (i = 1; i <= nrows; i++) { if (*rowp[i * ncols + uniquec] != '0' && strlen(rowp[i * ncols + typec]) == 7 && strncasecmp(rowp[i * ncols + typec], "integer", 7) == 0) { npk++; } } if (npk == 1) { addipk = 1; } } noipk: freerows(rowp); } sql = sqlite4_mprintf(0, "PRAGMA index_list(%Q)", tname); if (!sql) { return nomem(s); } dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowp, &nrows, &ncols, &errp); sqlite4_free(0, sql); if (ret != SQLITE4_OK) { setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", ret); if (errp) { sqlite4_free(0, errp); errp = NULL; } return SQL_ERROR; } if (errp) { sqlite4_free(0, errp); errp = NULL; } size = 0; namec = findcol(rowp, ncols, "name"); uniquec = findcol(rowp, ncols, "unique"); if (namec < 0 || uniquec < 0) { goto nodata; } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; if (isuniq || itype == SQL_INDEX_ALL) { ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret == SQLITE4_OK) { size += nnrows; freerows(rowpp); } } } nodata: if (addipk) { size++; } if (size == 0) { freerows(rowp); return SQL_SUCCESS; } s->nrows = size; size = (size + 1) * asize; s->rows = xmalloc((size + 1) * sizeof (char *)); if (!s->rows) { s->nrows = 0; return nomem(s); } s->rows[0] = (char *) size; s->rows += 1; memset(s->rows, 0, sizeof (char *) * size); s->rowfree = freerows; offs = 0; if (addipk) { char **rowpp = 0; int nrows2, ncols2; sql = sqlite4_mprintf(0, "PRAGMA table_info(%Q)", tname); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nrows2, &ncols2, NULL); sqlite4_free(0, sql); } if (ret == SQLITE4_OK) { int colid, typec, roffs, namecc, uniquecc; namecc = findcol(rowpp, ncols2, "name"); uniquecc = findcol(rowpp, ncols2, "pk"); typec = findcol(rowpp, ncols2, "type"); colid = findcol(rowpp, ncols2, "cid"); if (namecc < 0 || uniquecc < 0 || typec < 0 || colid < 0) { addipk = 0; s->nrows--; goto nodata2; } for (i = 1; i <= nrows2; i++) { if (*rowpp[i * ncols2 + uniquecc] != '0' && strlen(rowpp[i * ncols2 + typec]) == 7 && strncasecmp(rowpp[i * ncols2 + typec], "integer", 7) == 0) { break; } } if (i > nrows2) { addipk = 0; s->nrows--; goto nodata2; } roffs = s->ncols; s->rows[roffs + 0] = xstrdup(""); #if defined(_WIN32) || defined(_WIN64) s->rows[roffs + 1] = xstrdup(d->xcelqrx ? "main" : ""); #else s->rows[roffs + 1] = xstrdup(""); #endif s->rows[roffs + 2] = xstrdup(tname); s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); s->rows[roffs + 5] = xstrdup("sqlite_autoindex_0"); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 7] = xstrdup("1"); s->rows[roffs + 8] = xstrdup(rowpp[i * ncols2 + namecc]); s->rows[roffs + 9] = xstrdup("A"); } nodata2: freerows(rowpp); } for (i = 1; i <= nrows; i++) { int nnrows, nncols; char **rowpp = 0; if (*rowp[i * ncols + uniquec] != '0' || itype == SQL_INDEX_ALL) { int k; ret = SQLITE4_ERROR; sql = sqlite4_mprintf(0, "PRAGMA index_info(%Q)", rowp[i * ncols + namec]); if (sql) { dbtraceapi(d, "sqlite4_get_table", sql); ret = sqlite4_get_table(d->sqlite, sql, &rowpp, &nnrows, &nncols, NULL); sqlite4_free(0, sql); } if (ret != SQLITE4_OK) { continue; } for (k = 0; nnrows && k < nncols; k++) { if (strcmp(rowpp[k], "name") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int isuniq; isuniq = *rowp[i * ncols + uniquec] != '0'; s->rows[roffs + 0] = xstrdup(""); s->rows[roffs + 1] = xstrdup(""); s->rows[roffs + 2] = xstrdup(tname); if (isuniq) { s->rows[roffs + 3] = xstrdup(stringify(SQL_FALSE)); } else { s->rows[roffs + 3] = xstrdup(stringify(SQL_TRUE)); } s->rows[roffs + 5] = xstrdup(rowp[i * ncols + namec]); s->rows[roffs + 6] = xstrdup(stringify(SQL_INDEX_OTHER)); s->rows[roffs + 8] = xstrdup(rowpp[m * nncols + k]); s->rows[roffs + 9] = xstrdup("A"); } } else if (strcmp(rowpp[k], "seqno") == 0) { int m; for (m = 1; m <= nnrows; m++) { int roffs = (offs + addipk + m) * s->ncols; int pos = m - 1; char buf[32]; sscanf(rowpp[m * nncols + k], "%d", &pos); sprintf(buf, "%d", pos + 1); s->rows[roffs + 7] = xstrdup(buf); } } } offs += nnrows; freerows(rowpp); } } freerows(rowp); return SQL_SUCCESS; } #ifndef WINTERFACE /** * Return statistic information on table indices. * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt, SQLCHAR *cat, SQLSMALLINT catLen, SQLCHAR *schema, SQLSMALLINT schemaLen, SQLCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { #if defined(_WIN32) || defined(_WIN64) char *c = NULL, *s = NULL, *t = NULL; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvstatistics(stmt, cat, catLen, schema, schemaLen, table, tableLen, itype, resv); goto done2; } if (cat) { c = wmb_to_utf_c((char *) cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = wmb_to_utf_c((char *) schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = wmb_to_utf_c((char *) table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvstatistics(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, itype, resv); #else ret = drvstatistics(stmt, cat, catLen, schema, schemaLen, table, tableLen, itype, resv); #endif #if defined(_WIN32) || defined(_WIN64) done: uc_free(t); uc_free(s); uc_free(c); done2: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Return statistic information on table indices (UNICODE version). * @param stmt statement handle * @param cat catalog name/pattern or NULL * @param catLen length of catalog name/pattern or SQL_NTS * @param schema schema name/pattern or NULL * @param schemaLen length of schema name/pattern or SQL_NTS * @param table table name/pattern or NULL * @param tableLen length of table name/pattern or SQL_NTS * @param itype type of index information * @param resv reserved * @result ODBC error code */ SQLRETURN SQL_API SQLStatisticsW(SQLHSTMT stmt, SQLWCHAR *cat, SQLSMALLINT catLen, SQLWCHAR *schema, SQLSMALLINT schemaLen, SQLWCHAR *table, SQLSMALLINT tableLen, SQLUSMALLINT itype, SQLUSMALLINT resv) { char *c = NULL, *s = NULL, *t = NULL; SQLRETURN ret; HSTMT_LOCK(stmt); if (cat) { c = uc_to_utf_c(cat, catLen); if (!c) { ret = nomem((STMT *) stmt); goto done; } } if (schema) { s = uc_to_utf_c(schema, schemaLen); if (!s) { ret = nomem((STMT *) stmt); goto done; } } if (table) { t = uc_to_utf_c(table, tableLen); if (!t) { ret = nomem((STMT *) stmt); goto done; } } ret = drvstatistics(stmt, (SQLCHAR *) c, SQL_NTS, (SQLCHAR *) s, SQL_NTS, (SQLCHAR *) t, SQL_NTS, itype, resv); done: uc_free(t); uc_free(s); uc_free(c); HSTMT_UNLOCK(stmt); return ret; } #endif /** * Retrieve row data after fetch. * @param stmt statement handle * @param col column number, starting at 1 * @param type output type * @param val output buffer * @param len length of output buffer * @param lenp output length * @result ODBC error code */ SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt, SQLUSMALLINT col, SQLSMALLINT type, SQLPOINTER val, SQLLEN len, SQLLEN *lenp) { STMT *s; SQLRETURN ret = SQL_ERROR; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (col == 0 && s->bkmrk && type == SQL_C_BOOKMARK) { *((long *) val) = s->rowp; if (lenp) { *lenp = sizeof (long); } ret = SQL_SUCCESS; goto done; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); goto done; } --col; ret = getrowdata(s, col, type, val, len, lenp, 1); done: HSTMT_UNLOCK(stmt); return ret; } /** * Internal: fetch and bind from statement's current row * @param s statement pointer * @param rsi rowset index * @result ODBC error code */ static SQLRETURN dofetchbind(STMT *s, int rsi) { int ret, i, withinfo = 0; s->row_status0[rsi] = SQL_ROW_SUCCESS; if (s->bkmrk && s->bkmrkcol.valp) { long *val; if (s->bind_type != SQL_BIND_BY_COLUMN) { val = (long *) ((char *) s->bkmrkcol.valp + s->bind_type * rsi); } else { val = (long *) s->bkmrkcol.valp + rsi; } if (s->bind_offs) { val = (long *) ((char *) val + *s->bind_offs); } *val = s->rowp; if (s->bkmrkcol.lenp) { SQLLEN *ival; if (s->bind_type != SQL_BIND_BY_COLUMN) { ival = (SQLLEN *) ((char *) s->bkmrkcol.lenp + s->bind_type * rsi); } else { ival = &s->bkmrkcol.lenp[rsi]; } if (s->bind_offs) { ival = (SQLLEN *) ((char *) ival + *s->bind_offs); } *ival = sizeof (long); } } ret = SQL_SUCCESS; for (i = 0; s->bindcols && i < s->ncols; i++) { BINDCOL *b = &s->bindcols[i]; SQLPOINTER dp = 0; SQLLEN *lp = 0; b->offs = 0; if (b->valp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { dp = (SQLPOINTER) ((char *) b->valp + s->bind_type * rsi); } else { dp = (SQLPOINTER) ((char *) b->valp + b->max * rsi); } if (s->bind_offs) { dp = (SQLPOINTER) ((char *) dp + *s->bind_offs); } } if (b->lenp) { if (s->bind_type != SQL_BIND_BY_COLUMN) { lp = (SQLLEN *) ((char *) b->lenp + s->bind_type * rsi); } else { lp = b->lenp + rsi; } if (s->bind_offs) { lp = (SQLLEN *) ((char *) lp + *s->bind_offs); } } if (dp || lp) { ret = getrowdata(s, (SQLUSMALLINT) i, b->type, dp, b->max, lp, 0); if (!SQL_SUCCEEDED(ret)) { s->row_status0[rsi] = SQL_ROW_ERROR; break; } if (ret != SQL_SUCCESS) { withinfo = 1; #ifdef SQL_ROW_SUCCESS_WITH_INFO s->row_status0[rsi] = SQL_ROW_SUCCESS_WITH_INFO; #endif } } } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } return ret; } /** * Internal fetch function for SQLFetchScroll() and SQLExtendedFetch(). * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ static SQLRETURN drvfetchscroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLINTEGER offset) { STMT *s; int i, withinfo = 0; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_NOROW; } if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = 0; if (s->row_count) { *s->row_count = s->row_count0; } if (!s->bindcols) { for (i = 0; i < s->rowset_size; i++) { s->row_status0[i] = SQL_ROW_ERROR; } ret = SQL_ERROR; i = 0; goto done2; } if (s->isselect != 1 && s->isselect != -1) { setstat(s, -1, "no result set available", "24000"); ret = SQL_ERROR; i = s->nrows; goto done2; } if (s->curtype == SQL_CURSOR_FORWARD_ONLY && orient != SQL_FETCH_NEXT) { setstat(s, -1, "wrong fetch direction", "01000"); ret = SQL_ERROR; i = 0; goto done2; } ret = SQL_SUCCESS; i = 0; if (((DBC *) (s->dbc))->cur_s4stmt == s && s->s4stmt) { s->rowp = 0; for (; i < s->rowset_size; i++) { if (s->max_rows && s->s4stmt_rownum + 1 >= s->max_rows) { ret = (i == 0) ? SQL_NO_DATA : SQL_SUCCESS; break; } ret = s4stmt_step(s); if (ret != SQL_SUCCESS) { s->row_status0[i] = SQL_ROW_ERROR; break; } if (s->nrows < 1) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } else if (s->rows) { switch (orient) { case SQL_FETCH_NEXT: if (s->nrows < 1) { return SQL_NO_DATA; } if (s->rowp < 0) { s->rowp = -1; } if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } break; case SQL_FETCH_PRIOR: if (s->nrows < 1 || s->rowp <= 0) { s->rowp = -1; return SQL_NO_DATA; } s->rowp -= s->rowset_size + 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } break; case SQL_FETCH_FIRST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = -1; break; case SQL_FETCH_LAST: if (s->nrows < 1) { return SQL_NO_DATA; } s->rowp = s->nrows - s->rowset_size; if (--s->rowp < -1) { s->rowp = -1; } break; case SQL_FETCH_ABSOLUTE: if (offset == 0) { s->rowp = -1; return SQL_NO_DATA; } else if (offset < 0) { if (0 - offset <= s->nrows) { s->rowp = s->nrows + offset - 1; break; } s->rowp = -1; return SQL_NO_DATA; } else if (offset > s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } s->rowp = offset - 1 - 1; break; case SQL_FETCH_RELATIVE: if (offset >= 0) { s->rowp += offset * s->rowset_size - 1; if (s->rowp >= s->nrows) { s->rowp = s->nrows; return SQL_NO_DATA; } } else { s->rowp += offset * s->rowset_size - 1; if (s->rowp < -1) { s->rowp = -1; return SQL_NO_DATA; } } break; case SQL_FETCH_BOOKMARK: if (s->bkmrk) { if (offset < 0 || offset >= s->nrows) { return SQL_NO_DATA; } s->rowp = offset - 1; break; } /* fall through */ default: s->row_status0[0] = SQL_ROW_ERROR; ret = SQL_ERROR; goto done; } for (; i < s->rowset_size; i++) { ++s->rowp; if (s->rowp < 0 || s->rowp >= s->nrows) { break; } ret = dofetchbind(s, i); if (!SQL_SUCCEEDED(ret)) { break; } else if (ret == SQL_SUCCESS_WITH_INFO) { withinfo = 1; } } } done: if (i == 0) { if (SQL_SUCCEEDED(ret)) { return SQL_NO_DATA; } return ret; } if (SQL_SUCCEEDED(ret)) { ret = withinfo ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS; } done2: if (s->row_status) { memcpy(s->row_status, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } s->row_count0 = i; if (s->row_count) { *s->row_count = s->row_count0; } return ret; } /** * Fetch next result row. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, SQL_FETCH_NEXT, 0); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @result ODBC error code */ SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT orient, SQLLEN offset) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvfetchscroll(stmt, orient, offset); HSTMT_UNLOCK(stmt); return ret; } /** * Fetch result row with scrolling and row status. * @param stmt statement handle * @param orient fetch direction * @param offset offset for fetch direction * @param rowcount output number of fetched rows * @param rowstatus array for row stati * @result ODBC error code */ SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT orient, SQLROWOFFSET offset, SQLROWSETSIZE *rowcount, SQLUSMALLINT *rowstatus) { STMT *s; SQLRETURN ret; SQLUSMALLINT *rst; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; /* temporarily turn off SQL_ATTR_ROW_STATUS_PTR */ rst = s->row_status; s->row_status = 0; ret = drvfetchscroll(stmt, orient, offset); s->row_status = rst; if (rowstatus) { memcpy(rowstatus, s->row_status0, sizeof (SQLUSMALLINT) * s->rowset_size); } if (rowcount) { *rowcount = s->row_count0; } HSTMT_UNLOCK(stmt); return ret; } /** * Return number of affected rows of HSTMT. * @param stmt statement handle * @param nrows output number of rows * @result ODBC error code */ SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN *nrows) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (nrows) { *nrows = s->isselect ? 0 : s->nrows; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Return number of columns of result set given HSTMT. * @param stmt statement handle * @param ncols output number of columns * @result ODBC error code */ SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *ncols) { STMT *s; HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (ncols) { *ncols = s->ncols; } HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } /** * Internal describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ static SQLRETURN drvdescribecol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { STMT *s; COL *c; int didname = 0; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { setstat(s, -1, "no columns", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } c = s->cols + col - 1; if (name && nameMax > 0) { strncpy((char *) name, c->column, nameMax); name[nameMax - 1] = '\0'; didname = 1; } if (nameLen) { if (didname) { *nameLen = strlen((char *) name); } else { *nameLen = strlen(c->column); } } if (type) { *type = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (c->type) { case SQL_WCHAR: *type = SQL_CHAR; break; case SQL_WVARCHAR: *type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: *type = SQL_LONGVARCHAR; break; #endif } } #endif } if (size) { *size = c->size; } if (digits) { *digits = 0; } if (nullable) { *nullable = 1; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Describe column information. * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT col, SQLCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvdescribecol(stmt, col, name, nameMax, nameLen, type, size, digits, nullable); goto done; } ret = drvdescribecol(stmt, col, name, nameMax, &len, type, size, digits, nullable); if (ret == SQL_SUCCESS) { if (name) { if (len > 0) { SQLCHAR *n = NULL; n = (SQLCHAR *) utf_to_wmb((char *) name, len); if (n) { strncpy((char *) name, (char *) n, nameMax); n[len] = 0; len = min(nameMax, strlen((char *) n)); uc_free(n); } else { len = 0; } } if (len <= 0) { len = 0; if (nameMax > 0) { name[0] = 0; } } } else { STMT *s = (STMT *) stmt; COL *c = s->cols + col - 1; len = 0; if (c->column) { len = strlen(c->column); } } if (nameLen) { *nameLen = len; } } done: ; #else ret = drvdescribecol(stmt, col, name, nameMax, nameLen, type, size, digits, nullable); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Describe column information (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param name buffer for column name * @param nameMax length of name buffer * @param nameLen output length of column name * @param type output SQL type * @param size output column size * @param digits output number of digits * @param nullable output NULL allowed indicator * @result ODBC error code */ SQLRETURN SQL_API SQLDescribeColW(SQLHSTMT stmt, SQLUSMALLINT col, SQLWCHAR *name, SQLSMALLINT nameMax, SQLSMALLINT *nameLen, SQLSMALLINT *type, SQLULEN *size, SQLSMALLINT *digits, SQLSMALLINT *nullable) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvdescribecol(stmt, col, (SQLCHAR *) name, (SQLSMALLINT) (nameMax * sizeof (SQLWCHAR)), &len, type, size, digits, nullable); if (ret == SQL_SUCCESS) { if (name) { if (len > 0) { SQLWCHAR *n = NULL; n = uc_from_utf((SQLCHAR *) name, len); if (n) { uc_strncpy(name, n, nameMax); n[len] = 0; len = min(nameMax, uc_strlen(n)); uc_free(n); } else { len = 0; } } if (len <= 0) { len = 0; if (nameMax > 0) { name[0] = 0; } } } else { STMT *s = (STMT *) stmt; COL *c = s->cols + col - 1; len = 0; if (c->column) { len = strlen(c->column); } } if (nameLen) { *nameLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { STMT *s; COL *c; SQLSMALLINT dummy; char *valc = (char *) val; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (!valLen) { valLen = &dummy; } if (id == SQL_COLUMN_COUNT) { if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; } if (id == SQL_COLUMN_TYPE && col == 0) { if (val2) { *val2 = SQL_INTEGER; } *valLen = sizeof (int); return SQL_SUCCESS; } #ifdef SQL_DESC_OCTET_LENGTH if (id == SQL_DESC_OCTET_LENGTH && col == 0) { if (val2) { *val2 = 4; } *valLen = sizeof (int); return SQL_SUCCESS; } #endif if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009": "S1002"); return SQL_ERROR; } c = s->cols + col - 1; switch (id) { case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; #ifdef SQL_DESC_BASE_COLUMN_NAME if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_COLUMN_TYPE: case SQL_DESC_TYPE: #ifdef WINTERFACE { int type = c->type; if (s->nowchar[0] || s->nowchar[1]) { switch (type) { case SQL_WCHAR: type = SQL_CHAR; break; case SQL_WVARCHAR: type = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: type = SQL_LONGVARCHAR; break; } } if (val2) { *val2 = type; } #endif } #else if (val2) { *val2 = c->type; } #endif *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_DISPLAY_SIZE: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UNSIGNED: if (val2) { *val2 = c->nosign ? SQL_TRUE : SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: if (val2) { *val2 = c->scale; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: if (val2) { switch (c->type) { case SQL_SMALLINT: *val2 = 5; break; case SQL_INTEGER: *val2 = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: *val2 = 15; break; case SQL_DATE: *val2 = 0; break; case SQL_TIME: *val2 = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: *val2 = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: *val2 = c->prec; break; } } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_MONEY: if (val2) { *val2 = SQL_FALSE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_AUTO_INCREMENT: if (val2) { *val2 = c->autoinc; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: if (val2) { *val2 = c->size; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_NULLABLE: case SQL_DESC_NULLABLE: if (val2) { *val2 = c->notnull; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_SEARCHABLE: if (val2) { *val2 = SQL_SEARCHABLE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_CASE_SENSITIVE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_UPDATABLE: if (val2) { *val2 = SQL_TRUE; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_DESC_COUNT: if (val2) { *val2 = s->ncols; } *valLen = sizeof (int); return SQL_SUCCESS; case SQL_COLUMN_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: if (val2) { switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: *val2 = 0; break; default: *val2 = 2; } } *valLen = sizeof (int); return SQL_SUCCESS; #endif } setstat(s, -1, "unsupported column attributes %d", "HY091", id); return SQL_ERROR; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolattributes(stmt, col, id, val, valMax, valLen, val2); goto done; } ret = drvcolattributes(stmt, col, id, val, valMax, &len, val2); if (SQL_SUCCEEDED(ret)) { char *v = NULL; switch (id) { case SQL_COLUMN_LABEL: case SQL_COLUMN_NAME: case SQL_DESC_NAME: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (val && valMax > 0) { int vmax = valMax; v = utf_to_wmb((char *) val, SQL_NTS); if (v) { strncpy(val, v, vmax); len = min(vmax, strlen(v)); uc_free(v); } if (vmax > 0) { v = (char *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } done: ; #else ret = drvcolattributes(stmt, col, id, val, valMax, valLen, val2); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributesW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLLEN *val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattributes(stmt, col, id, val, valMax, &len, val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_COLUMN_LABEL: case SQL_COLUMN_NAME: case SQL_DESC_NAME: case SQL_COLUMN_TYPE_NAME: case SQL_COLUMN_OWNER_NAME: case SQL_COLUMN_QUALIFIER_NAME: case SQL_COLUMN_TABLE_NAME: #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_DESC_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ static SQLRETURN drvcolattribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, SQLPOINTER val2) { STMT *s; COL *c; int v = 0; char *valc = (char *) val; SQLSMALLINT dummy; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (!s->cols) { return SQL_ERROR; } if (col < 1 || col > s->ncols) { setstat(s, -1, "invalid column", (*s->ov3) ? "07009" : "S1002"); return SQL_ERROR; } if (!valLen) { valLen = &dummy; } c = s->cols + col - 1; switch (id) { case SQL_DESC_COUNT: v = s->ncols; break; case SQL_DESC_CATALOG_NAME: if (valc && valMax > 0) { strncpy(valc, c->db, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->db); checkLen: if (*valLen >= valMax) { setstat(s, -1, "data right truncated", "01004"); return SQL_SUCCESS_WITH_INFO; } break; case SQL_COLUMN_LENGTH: case SQL_DESC_LENGTH: v = c->size; break; case SQL_COLUMN_LABEL: if (c->label) { if (valc && valMax > 0) { strncpy(valc, c->label, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->label); goto checkLen; } /* fall through */ case SQL_COLUMN_NAME: case SQL_DESC_NAME: if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->column); goto checkLen; case SQL_DESC_SCHEMA_NAME: { char *z = ""; if (valc && valMax > 0) { strncpy(valc, z, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(z); goto checkLen; } #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: if (strchr(c->column, '(') || strchr(c->column, ')')) { valc[0] = '\0'; *valLen = 0; } else if (valc && valMax > 0) { strncpy(valc, c->column, valMax); valc[valMax - 1] = '\0'; *valLen = strlen(c->column); } goto checkLen; #endif case SQL_DESC_TYPE_NAME: { char *p = NULL, *tn = c->typename ? c->typename : "varchar"; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { if (strcasecmp(tn, "varchar") == 0) { tn = "wvarchar"; } } } #endif if (valc && valMax > 0) { strncpy(valc, tn, valMax); valc[valMax - 1] = '\0'; p = strchr(valc, '('); if (p) { *p = '\0'; while (p > valc && ISSPACE(p[-1])) { --p; *p = '\0'; } } *valLen = strlen(valc); } else { *valLen = strlen(tn); p = strchr(tn, '('); if (p) { *valLen = p - tn; while (p > tn && ISSPACE(p[-1])) { --p; *valLen -= 1; } } } goto checkLen; } case SQL_DESC_OCTET_LENGTH: v = c->size; #ifdef WINTERFACE if (c->type == SQL_WCHAR || c->type == SQL_WVARCHAR || c->type == SQL_WLONGVARCHAR) { if (!(s->nowchar[0] || s->nowchar[1])) { v *= sizeof (SQLWCHAR); } } #endif break; #if (SQL_COLUMN_TABLE_NAME != SQL_DESC_TABLE_NAME) case SQL_COLUMN_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif case SQL_DESC_TABLE_NAME: if (valc && valMax > 0) { strncpy(valc, c->table, valMax); valc[valMax - 1] = '\0'; } *valLen = strlen(c->table); goto checkLen; case SQL_DESC_TYPE: v = c->type; #ifdef WINTERFACE if (s->nowchar[0] || s->nowchar[1]) { switch (v) { case SQL_WCHAR: v = SQL_CHAR; break; case SQL_WVARCHAR: v = SQL_VARCHAR; break; #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: v = SQL_LONGVARCHAR; break; #endif } } #endif break; case SQL_DESC_CONCISE_TYPE: switch (c->type) { case SQL_INTEGER: v = SQL_C_LONG; break; case SQL_TINYINT: v = SQL_C_TINYINT; break; case SQL_SMALLINT: v = SQL_C_SHORT; break; case SQL_FLOAT: v = SQL_C_FLOAT; break; case SQL_DOUBLE: v = SQL_C_DOUBLE; break; case SQL_TIMESTAMP: v = SQL_C_TIMESTAMP; break; case SQL_TIME: v = SQL_C_TIME; break; case SQL_DATE: v = SQL_C_DATE; break; #ifdef SQL_C_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: v = SQL_C_TYPE_TIMESTAMP; break; #endif #ifdef SQL_C_TYPE_TIME case SQL_TYPE_TIME: v = SQL_C_TYPE_TIME; break; #endif #ifdef SQL_C_TYPE_DATE case SQL_TYPE_DATE: v = SQL_C_TYPE_DATE; break; #endif #ifdef SQL_BIT case SQL_BIT: v = SQL_C_BIT; break; #endif #ifdef SQL_BIGINT case SQL_BIGINT: v = SQL_C_SBIGINT; break; #endif default: #ifdef WINTERFACE v = (s->nowchar[0] || s->nowchar[1]) ? SQL_C_CHAR : SQL_C_WCHAR; #else v = SQL_C_CHAR; #endif break; } break; case SQL_DESC_UPDATABLE: v = SQL_TRUE; break; case SQL_COLUMN_DISPLAY_SIZE: v = c->size; break; case SQL_COLUMN_UNSIGNED: v = c->nosign ? SQL_TRUE : SQL_FALSE; break; case SQL_COLUMN_SEARCHABLE: v = SQL_SEARCHABLE; break; case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: v = c->scale; break; case SQL_COLUMN_PRECISION: case SQL_DESC_PRECISION: switch (c->type) { case SQL_SMALLINT: v = 5; break; case SQL_INTEGER: v = 10; break; case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: v = 15; break; case SQL_DATE: v = 0; break; case SQL_TIME: v = 0; break; #ifdef SQL_TYPE_TIMESTAMP case SQL_TYPE_TIMESTAMP: #endif case SQL_TIMESTAMP: v = (c->prec >= 0 && c->prec <= 3) ? c->prec : 3; break; default: v = c->prec; break; } break; case SQL_COLUMN_MONEY: v = SQL_FALSE; break; case SQL_COLUMN_AUTO_INCREMENT: v = c->autoinc; break; case SQL_DESC_NULLABLE: v = c->notnull; break; #ifdef SQL_DESC_NUM_PREC_RADIX case SQL_DESC_NUM_PREC_RADIX: switch (c->type) { #ifdef WINTERFACE case SQL_WCHAR: case SQL_WVARCHAR: #ifdef SQL_LONGVARCHAR case SQL_WLONGVARCHAR: #endif #endif case SQL_CHAR: case SQL_VARCHAR: #ifdef SQL_LONGVARCHAR case SQL_LONGVARCHAR: #endif case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: v = 0; break; default: v = 2; } break; #endif default: setstat(s, -1, "unsupported column attribute %d", "HY091", id); return SQL_ERROR; } if (val2) { *(SQLLEN *) val2 = v; } return SQL_SUCCESS; } #ifndef WINTERFACE /** * Retrieve column attributes. * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { #if defined(_WIN32) || defined(_WIN64) SQLSMALLINT len = 0; #endif SQLRETURN ret; HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvcolattribute(stmt, col, id, val, valMax, valLen, (SQLPOINTER) val2); goto done; } ret = drvcolattribute(stmt, col, id, val, valMax, &len, (SQLPOINTER) val2); if (SQL_SUCCEEDED(ret)) { char *v = NULL; switch (id) { case SQL_DESC_SCHEMA_NAME: case SQL_DESC_CATALOG_NAME: case SQL_COLUMN_LABEL: case SQL_DESC_NAME: case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif case SQL_DESC_TYPE_NAME: if (val && valMax > 0) { int vmax = valMax; v = utf_to_wmb((char *) val, SQL_NTS); if (v) { strncpy(val, v, vmax); len = min(vmax, strlen(v)); uc_free(v); } if (vmax > 0) { v = (char *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } done: ; #else ret = drvcolattribute(stmt, col, id, val, valMax, valLen, (SQLPOINTER) val2); #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Retrieve column attributes (UNICODE version). * @param stmt statement handle * @param col column number, starting at 1 * @param id attribute id * @param val output buffer * @param valMax length of output buffer * @param valLen output length * @param val2 integer output buffer * @result ODBC error code */ SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT stmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER val, SQLSMALLINT valMax, SQLSMALLINT *valLen, COLATTRIBUTE_LAST_ARG_TYPE val2) { SQLRETURN ret; SQLSMALLINT len = 0; HSTMT_LOCK(stmt); ret = drvcolattribute(stmt, col, id, val, valMax, &len, (SQLPOINTER) val2); if (SQL_SUCCEEDED(ret)) { SQLWCHAR *v = NULL; switch (id) { case SQL_DESC_SCHEMA_NAME: case SQL_DESC_CATALOG_NAME: case SQL_COLUMN_LABEL: case SQL_DESC_NAME: case SQL_DESC_TABLE_NAME: #ifdef SQL_DESC_BASE_TABLE_NAME case SQL_DESC_BASE_TABLE_NAME: #endif #ifdef SQL_DESC_BASE_COLUMN_NAME case SQL_DESC_BASE_COLUMN_NAME: #endif case SQL_DESC_TYPE_NAME: if (val && valMax > 0) { int vmax = valMax / sizeof (SQLWCHAR); v = uc_from_utf((SQLCHAR *) val, SQL_NTS); if (v) { uc_strncpy(val, v, vmax); len = min(vmax, uc_strlen(v)); uc_free(v); len *= sizeof (SQLWCHAR); } if (vmax > 0) { v = (SQLWCHAR *) val; v[vmax - 1] = '\0'; } } if (len <= 0) { len = 0; } break; } if (valLen) { *valLen = len; } } HSTMT_UNLOCK(stmt); return ret; } #endif /** * Internal return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ static SQLRETURN drverror(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { SQLCHAR dummy0[6]; SQLINTEGER dummy1; SQLSMALLINT dummy2; if (env == SQL_NULL_HENV && dbc == SQL_NULL_HDBC && stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } if (sqlState) { sqlState[0] = '\0'; } else { sqlState = dummy0; } if (!nativeErr) { nativeErr = &dummy1; } *nativeErr = 0; if (!errlen) { errlen = &dummy2; } *errlen = 0; if (errmsg) { if (errmax > 0) { errmsg[0] = '\0'; } } else { errmsg = dummy0; errmax = 0; } if (stmt) { STMT *s = (STMT *) stmt; HSTMT_LOCK(stmt); if (s->logmsg[0] == '\0') { HSTMT_UNLOCK(stmt); goto noerr; } *nativeErr = s->naterr; strcpy((char *) sqlState, s->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) s->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) s->logmsg, errmax - 8); } *errlen = min(strlen((char *) s->logmsg) + 8, errmax); } s->logmsg[0] = '\0'; HSTMT_UNLOCK(stmt); return SQL_SUCCESS; } if (dbc) { DBC *d = (DBC *) dbc; HDBC_LOCK(dbc); if (d->magic != DBC_MAGIC || d->logmsg[0] == '\0') { HDBC_UNLOCK(dbc); goto noerr; } *nativeErr = d->naterr; strcpy((char *) sqlState, d->sqlstate); if (errmax == SQL_NTS) { strcpy((char *) errmsg, "[SQLite]"); strcat((char *) errmsg, (char *) d->logmsg); *errlen = strlen((char *) errmsg); } else { strncpy((char *) errmsg, "[SQLite]", errmax); if (errmax - 8 > 0) { strncpy((char *) errmsg + 8, (char *) d->logmsg, errmax - 8); } *errlen = min(strlen((char *) d->logmsg) + 8, errmax); } d->logmsg[0] = '\0'; HDBC_UNLOCK(dbc); return SQL_SUCCESS; } noerr: sqlState[0] = '\0'; errmsg[0] = '\0'; *nativeErr = 0; *errlen = 0; return SQL_NO_DATA; } #ifndef WINTERFACE /** * Return last HDBC or HSTMT error message. * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLError(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLCHAR *sqlState, SQLINTEGER *nativeErr, SQLCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { return drverror(env, dbc, stmt, sqlState, nativeErr, errmsg, errmax, errlen); } #endif #ifdef WINTERFACE /** * Return last HDBC or HSTMT error message (UNICODE version). * @param env environment handle or NULL * @param dbc database connection handle or NULL * @param stmt statement handle or NULL * @param sqlState output buffer for SQL state * @param nativeErr output buffer for native error code * @param errmsg output buffer for error message * @param errmax length of output buffer for error message * @param errlen output length of error message * @result ODBC error code */ SQLRETURN SQL_API SQLErrorW(SQLHENV env, SQLHDBC dbc, SQLHSTMT stmt, SQLWCHAR *sqlState, SQLINTEGER *nativeErr, SQLWCHAR *errmsg, SQLSMALLINT errmax, SQLSMALLINT *errlen) { char state[16]; SQLSMALLINT len = 0; SQLRETURN ret; ret = drverror(env, dbc, stmt, (SQLCHAR *) state, nativeErr, (SQLCHAR *) errmsg, errmax, &len); if (ret == SQL_SUCCESS) { if (sqlState) { uc_from_utf_buf((SQLCHAR *) state, -1, sqlState, 6 * sizeof (SQLWCHAR)); } if (errmsg) { if (len > 0) { SQLWCHAR *e = NULL; e = uc_from_utf((SQLCHAR *) errmsg, len); if (e) { if (errmax > 0) { uc_strncpy(errmsg, e, errmax); e[len] = 0; len = min(errmax, uc_strlen(e)); } else { len = uc_strlen(e); } uc_free(e); } else { len = 0; } } if (len <= 0) { len = 0; if (errmax > 0) { errmsg[0] = 0; } } } else { len = 0; } if (errlen) { *errlen = len; } } else if (ret == SQL_NO_DATA) { if (sqlState) { sqlState[0] = 0; } if (errmsg) { if (errmax > 0) { errmsg[0] = 0; } } if (errlen) { *errlen = 0; } } return ret; } #endif /** * Return information for more result sets. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt) { HSTMT_LOCK(stmt); if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } HSTMT_UNLOCK(stmt); return SQL_NO_DATA; } /** * Internal function to setup column name/type information * @param s statement poiner * @param s4stmt sqlite4 statement pointer * @param ncolsp pointer to preinitialized number of colums * @result ODBC error code */ static SQLRETURN setupdyncols(STMT *s, sqlite4_stmt *s4stmt, int *ncolsp) { int ncols = *ncolsp, guessed_types = 0; SQLRETURN ret = SQL_SUCCESS; if (ncols > 0) { int i; PTRDIFF_T size; char *p; COL *dyncols; DBC *d = (DBC *) s->dbc; const char *colname, *typename; char *tblname; for (i = size = 0; i < ncols; i++) { colname = sqlite4_column_name(s4stmt, i); size += 3 + 3 * strlen(colname); } tblname = (char *) size; for (i = 0; i < ncols; i++) { p = (char *) sqlite4_column_table_name(s4stmt, i); size += 2 + (p ? strlen(p) : 0); } dyncols = xmalloc(ncols * sizeof (COL) + size); if (!dyncols) { freedyncols(s); *ncolsp = 0; ret = SQL_ERROR; } else { p = (char *) (dyncols + ncols); tblname = p + (PTRDIFF_T) tblname; for (i = 0; i < ncols; i++) { char *q; colname = sqlite4_column_name(s4stmt, i); if (d->trace) { fprintf(d->trace, "-- column %d name: '%s'\n", i + 1, colname); fflush(d->trace); } q = (char *) sqlite4_column_table_name(s4stmt, i); strcpy(tblname, q ? q : ""); if (d->trace) { fprintf(d->trace, "-- table %d name: '%s'\n", i + 1, tblname); fflush(d->trace); } dyncols[i].table = tblname; tblname += strlen(tblname) + 1; typename = s4stmt_coltype(s4stmt, i, d, &guessed_types); dyncols[i].db = ((DBC *) (s->dbc))->dbname; strcpy(p, colname); dyncols[i].label = p; p += strlen(p) + 1; q = strchr(colname, '.'); if (q) { char *q2 = strchr(q + 1, '.'); /* SQLite 3.3.4 produces view.table.column sometimes */ if (q2) { q = q2; } } if (q) { dyncols[i].table = p; strncpy(p, colname, q - colname); p[q - colname] = '\0'; p += strlen(p) + 1; strcpy(p, q + 1); dyncols[i].column = p; p += strlen(p) + 1; } else { strcpy(p, colname); dyncols[i].column = p; p += strlen(p) + 1; } if (s->longnames) { dyncols[i].column = dyncols[i].label; } #ifdef SQL_LONGVARCHAR dyncols[i].type = SQL_LONGVARCHAR; dyncols[i].size = 65535; #else dyncols[i].type = SQL_VARCHAR; dyncols[i].size = 255; #endif dyncols[i].index = i; dyncols[i].scale = 0; dyncols[i].prec = 0; dyncols[i].nosign = 1; s4stmt_addmeta(s4stmt, i, d, &dyncols[i]); dyncols[i].typename = xstrdup(typename); } freedyncols(s); s->dyncols = s->cols = dyncols; s->dcols = ncols; fixupdyncols(s, d); s->guessed_types = guessed_types; } } return ret; } /** * Internal query preparation used by SQLPrepare() and SQLExecDirect(). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ static SQLRETURN drvprepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { STMT *s; DBC *d; char *errp = NULL; SQLRETURN sret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = s->dbc; if (!d->sqlite) { goto noconn; } s4stmt_end(s); s4stmt_drop(s); sret = starttran(s); if (sret != SQL_SUCCESS) { return sret; } freep(&s->query); s->query = (SQLCHAR *) fixupsql((char *) query, queryLen, &s->nparams, &s->isselect, &errp); if (!s->query) { if (errp) { setstat(s, -1, "%s", (*s->ov3) ? "HY000" : "S1000", errp); return SQL_ERROR; } return nomem(s); } errp = NULL; freeresult(s, -1); if (s->isselect == 1) { int ret, ncols, nretry = 0; const char *rest; sqlite4_stmt *s4stmt = NULL; dbtraceapi(d, "sqlite4_prepare", (char *) s->query); do { s4stmt = NULL; ret = sqlite4_prepare(d->sqlite, (char *) s->query, -1, &s4stmt, &rest); if (ret != SQLITE4_OK) { if (s4stmt) { sqlite4_finalize(s4stmt); s4stmt = NULL; } } } while (ret == SQLITE4_SCHEMA && (++nretry) < 2); dbtracerc(d, ret, NULL); if (ret != SQLITE4_OK) { if (s4stmt) { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s4stmt); } setstat(s, ret, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", sqlite4_errmsg(d->sqlite), ret); return SQL_ERROR; } if (sqlite4_bind_parameter_count(s4stmt) != s->nparams) { dbtraceapi(d, "sqlite4_finalize", 0); sqlite4_finalize(s4stmt); setstat(s, SQLITE4_ERROR, "parameter marker count incorrect", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } ncols = sqlite4_column_count(s4stmt); s->guessed_types = 0; setupdyncols(s, s4stmt, &ncols); s->ncols = ncols; s->s4stmt = s4stmt; } mkbindcols(s, s->ncols); s->paramset_count = 0; return SQL_SUCCESS; } /** * Internal query execution used by SQLExecute() and SQLExecDirect(). * @param stmt statement handle * @param initial false when called from SQLPutData() * @result ODBC error code */ static SQLRETURN drvexecute(SQLHSTMT stmt, int initial) { STMT *s; DBC *d; char *errp = NULL; int rc, i, ncols = 0, nrows = 0, busy_count; SQLRETURN ret; if (stmt == SQL_NULL_HSTMT) { return SQL_INVALID_HANDLE; } s = (STMT *) stmt; if (s->dbc == SQL_NULL_HDBC) { noconn: return noconn(s); } d = (DBC *) s->dbc; if (!d->sqlite) { goto noconn; } if (!s->query) { setstat(s, -1, "no query prepared", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } if (s->nbindparms < s->nparams) { unbound: setstat(s, -1, "unbound parameters in query", (*s->ov3) ? "HY000" : "S1000"); return SQL_ERROR; } for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (!p->bound) { goto unbound; } if (initial) { SQLLEN *lenp = p->lenp; if (lenp && *lenp < 0 && *lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *lenp != SQL_NTS && *lenp != SQL_NULL_DATA && *lenp != SQL_DATA_AT_EXEC) { setstat(s, -1, "invalid length reference", "HY009"); return SQL_ERROR; } if (lenp && (*lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } ret = starttran(s); if (ret != SQL_SUCCESS) { goto cleanup; } busy_count = 0; again: s4stmt_end(s); if (initial) { /* fixup data-at-execution parameters and alloc'ed blobs */ s->pdcount = -1; for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->need <= 0 && p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } } if (s->nparams) { for (i = 0; i < s->nparams; i++) { ret = setupparam(s, (char *) s->query, i); if (ret != SQL_SUCCESS) { goto cleanup; } } } freeresult(s, 0); if (s->isselect == 1 && !d->intrans && s->curtype == SQL_CURSOR_FORWARD_ONLY && d->step_enable && s->nparams == 0 && d->cur_s4stmt == NULL) { s->nrows = -1; ret = s4stmt_start(s); if (ret == SQL_SUCCESS) { goto done2; } } rc = drvgettable(s, s->s4stmt ? NULL : (char *) s->query, &s->rows, &s->nrows, &ncols, &errp, s->nparams, s->bindparms); dbtracerc(d, rc, errp); if (rc != SQLITE4_OK) { setstat(s, rc, "%s (%d)", (*s->ov3) ? "HY000" : "S1000", errp ? errp : "unknown error", rc); if (errp) { sqlite4_free(0, errp); errp = NULL; } ret = SQL_ERROR; goto cleanup; } if (errp) { sqlite4_free(0, errp); errp = NULL; } s->rowfree = freerows; if (s->isselect <= 0 || s->isselect > 1) { /* * INSERT/UPDATE/DELETE or DDL results are immediately released. */ freeresult(s, -1); nrows += sqlite4_changes(d->sqlite); s->nrows = nrows; goto done; } if (s->ncols != ncols) { /* * Weird result. */ setstat(s, -1, "broken result set %d/%d", (*s->ov3) ? "HY000" : "S1000", s->ncols, ncols); ret = SQL_ERROR; goto cleanup; } done: mkbindcols(s, s->ncols); done2: ret = SQL_SUCCESS; s->rowp = -1; s->paramset_count++; s->paramset_nrows = s->nrows; if (s->paramset_count < s->paramset_size) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (p->lenp0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->lenp = (SQLLEN *) ((char *) p->lenp0 + s->paramset_count * s->parm_bind_type); } else if (p->lenp0 && p->inc > 0) { p->lenp = p->lenp0 + s->paramset_count; } if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { if (p->param0 && s->parm_bind_type != SQL_PARAM_BIND_BY_COLUMN) { p->param = (char *) p->param0 + s->paramset_count * s->parm_bind_type; } else if (p->param0 && p->inc > 0) { p->param = (char *) p->param0 + s->paramset_count * p->inc; } } else if (p->lenp && (*p->lenp <= SQL_LEN_DATA_AT_EXEC_OFFSET || *p->lenp == SQL_DATA_AT_EXEC)) { p->need = 1; p->offs = 0; p->len = 0; } } goto again; } cleanup: if (ret != SQL_NEED_DATA) { for (i = 0; i < s->nparams; i++) { BINDPARM *p = &s->bindparms[i]; if (p->param == p->parbuf) { p->param = NULL; } freep(&p->parbuf); if (!p->lenp || (*p->lenp > SQL_LEN_DATA_AT_EXEC_OFFSET && *p->lenp != SQL_DATA_AT_EXEC)) { p->param = p->param0; } p->lenp = p->lenp0; } s->nrows = s->paramset_nrows; if (s->parm_proc) { *s->parm_proc = s->paramset_count; } s->paramset_count = 0; s->paramset_nrows = 0; } /* * For INSERT/UPDATE/DELETE statements change the return code * to SQL_NO_DATA if the number of rows affected was 0. */ if (*s->ov3 && s->isselect == 0 && ret == SQL_SUCCESS && nrows == 0) { ret = SQL_NO_DATA; } return ret; } #ifndef WINTERFACE /** * Prepare HSTMT. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) char *q; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprepare(stmt, query, queryLen); goto done; } q = wmb_to_utf_c((char *) query, queryLen); if (!q) { ret = nomem((STMT *) stmt); goto done; } query = (SQLCHAR *) q; queryLen = SQL_NTS; #endif ret = drvprepare(stmt, query, queryLen); #if defined(_WIN32) || defined(_WIN64) uc_free(q); done: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Prepare HSTMT (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLPrepareW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); done: HSTMT_UNLOCK(stmt); return ret; } #endif /** * Execute query. * @param stmt statement handle * @result ODBC error code */ SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt) { SQLRETURN ret; HSTMT_LOCK(stmt); ret = drvexecute(stmt, 1); HSTMT_UNLOCK(stmt); return ret; } #ifndef WINTERFACE /** * Execute query directly. * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; #if defined(_WIN32) || defined(_WIN64) char *q; #endif HSTMT_LOCK(stmt); #if defined(_WIN32) || defined(_WIN64) if (!((STMT *) stmt)->oemcp[0]) { ret = drvprepare(stmt, query, queryLen); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } goto done; } q = wmb_to_utf_c((char *) query, queryLen); if (!q) { ret = nomem((STMT *) stmt); goto done; } query = (SQLCHAR *) q; queryLen = SQL_NTS; #endif ret = drvprepare(stmt, query, queryLen); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } #if defined(_WIN32) || defined(_WIN64) uc_free(q); done: ; #endif HSTMT_UNLOCK(stmt); return ret; } #endif #ifdef WINTERFACE /** * Execute query directly (UNICODE version). * @param stmt statement handle * @param query query string * @param queryLen length of query string or SQL_NTS * @result ODBC error code */ SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT stmt, SQLWCHAR *query, SQLINTEGER queryLen) { SQLRETURN ret; char *q = uc_to_utf_c(query, queryLen); HSTMT_LOCK(stmt); if (!q) { ret = nomem((STMT *) stmt); goto done; } ret = drvprepare(stmt, (SQLCHAR *) q, SQL_NTS); uc_free(q); if (ret == SQL_SUCCESS) { ret = drvexecute(stmt, 1); } done: HSTMT_UNLOCK(stmt); return ret; } #endif #if defined(_WIN32) || defined(_WIN64) #ifndef WITHOUT_DRIVERMGR /* * Windows configuration dialog stuff. */ #include #include #define MAXPATHLEN (259+1) /* Max path length */ #define MAXKEYLEN (15+1) /* Max keyword length */ #define MAXDESC (255+1) /* Max description length */ #define MAXDSNAME (32+1) /* Max data source name length */ #define MAXTONAME (32+1) /* Max timeout length */ #define MAXDBNAME MAXPATHLEN /* Attribute key indexes into an array of Attr structs, see below */ #define KEY_DSN 0 #define KEY_DESC 1 #define KEY_DBNAME 2 #define KEY_BUSY 3 #define KEY_DRIVER 4 #define KEY_STEPAPI 5 #define KEY_SYNCP 6 #define KEY_NOTXN 7 #define KEY_SHORTNAM 8 #define KEY_LONGNAM 9 #define KEY_NOCREAT 10 #define KEY_NOWCHAR 11 #define KEY_LOADEXT 12 #define KEY_JMODE 13 #define KEY_FKSUPPORT 14 #define KEY_OEMCP 15 #define KEY_BIGINT 16 #define KEY_PASSWD 17 #define NUMOFKEYS 18 typedef struct { BOOL supplied; char attr[MAXPATHLEN*4]; } ATTR; typedef struct { SQLHWND parent; LPCSTR driver; ATTR attr[NUMOFKEYS]; char DSN[MAXDSNAME]; BOOL newDSN; BOOL defDSN; } SETUPDLG; static struct { char *key; int ikey; } attrLookup[] = { { "DSN", KEY_DSN }, { "DESC", KEY_DESC }, { "Description", KEY_DESC}, { "Database", KEY_DBNAME }, { "Timeout", KEY_BUSY }, { "Driver", KEY_DRIVER }, { "StepAPI", KEY_STEPAPI }, { "SyncPragma", KEY_SYNCP }, { "NoTXN", KEY_NOTXN }, { "ShortNames", KEY_SHORTNAM }, { "LongNames", KEY_LONGNAM }, { "NoCreat", KEY_NOCREAT }, { "NoWCHAR", KEY_NOWCHAR }, { "LoadExt", KEY_LOADEXT }, { "JournalMode", KEY_JMODE }, { "FKSupport", KEY_FKSUPPORT }, { "OEMCP", KEY_OEMCP }, { "BigInt", KEY_BIGINT }, { "PWD", KEY_PASSWD }, { NULL, 0 } }; /** * Setup dialog data from datasource attributes. * @param attribs attribute string * @param setupdlg pointer to dialog data */ static void ParseAttributes(LPCSTR attribs, SETUPDLG *setupdlg) { char *str = (char *) attribs, *start, key[MAXKEYLEN]; int elem, nkey; while (*str) { start = str; if ((str = strchr(str, '=')) == NULL) { return; } elem = -1; nkey = str - start; if (nkey < sizeof (key)) { int i; memcpy(key, start, nkey); key[nkey] = '\0'; for (i = 0; attrLookup[i].key; i++) { if (strcasecmp(attrLookup[i].key, key) == 0) { elem = attrLookup[i].ikey; break; } } } start = ++str; while (*str && *str != ';') { ++str; } if (elem >= 0) { int end = min(str - start, sizeof (setupdlg->attr[elem].attr) - 1); setupdlg->attr[elem].supplied = TRUE; memcpy(setupdlg->attr[elem].attr, start, end); setupdlg->attr[elem].attr[end] = '\0'; } ++str; } } /** * Set datasource attributes in registry. * @param parent handle of parent window * @param setupdlg pointer to dialog data * @result true or false */ static BOOL SetDSNAttributes(HWND parent, SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (setupdlg->newDSN && strlen(dsn) == 0) { return FALSE; } if (!SQLWriteDSNToIni(dsn, setupdlg->driver)) { if (parent) { char buf[MAXPATHLEN], msg[MAXPATHLEN]; LoadString(hModule, IDS_BADDSN, buf, sizeof (buf)); wsprintf(msg, buf, dsn); LoadString(hModule, IDS_MSGTITLE, buf, sizeof (buf)); MessageBox(parent, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } return FALSE; } if (parent || setupdlg->attr[KEY_DESC].supplied) { SQLWritePrivateProfileString(dsn, "Description", setupdlg->attr[KEY_DESC].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_DBNAME].supplied) { SQLWritePrivateProfileString(dsn, "Database", setupdlg->attr[KEY_DBNAME].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_BUSY].supplied) { SQLWritePrivateProfileString(dsn, "Timeout", setupdlg->attr[KEY_BUSY].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_STEPAPI].supplied) { SQLWritePrivateProfileString(dsn, "StepAPI", setupdlg->attr[KEY_STEPAPI].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_SYNCP].supplied) { SQLWritePrivateProfileString(dsn, "SyncPragma", setupdlg->attr[KEY_SYNCP].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOTXN].supplied) { SQLWritePrivateProfileString(dsn, "NoTXN", setupdlg->attr[KEY_NOTXN].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_SHORTNAM].supplied) { SQLWritePrivateProfileString(dsn, "ShortNames", setupdlg->attr[KEY_SHORTNAM].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_LONGNAM].supplied) { SQLWritePrivateProfileString(dsn, "LongNames", setupdlg->attr[KEY_LONGNAM].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOCREAT].supplied) { SQLWritePrivateProfileString(dsn, "NoCreat", setupdlg->attr[KEY_NOCREAT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_NOWCHAR].supplied) { SQLWritePrivateProfileString(dsn, "NoWCHAR", setupdlg->attr[KEY_NOWCHAR].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_FKSUPPORT].supplied) { SQLWritePrivateProfileString(dsn, "FKSupport", setupdlg->attr[KEY_FKSUPPORT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_OEMCP].supplied) { SQLWritePrivateProfileString(dsn, "OEMCP", setupdlg->attr[KEY_OEMCP].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_LOADEXT].supplied) { SQLWritePrivateProfileString(dsn, "LoadExt", setupdlg->attr[KEY_LOADEXT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_BIGINT].supplied) { SQLWritePrivateProfileString(dsn, "BigInt", setupdlg->attr[KEY_BIGINT].attr, ODBC_INI); } if (parent || setupdlg->attr[KEY_PASSWD].supplied) { SQLWritePrivateProfileString(dsn, "PWD", setupdlg->attr[KEY_PASSWD].attr, ODBC_INI); } if (setupdlg->attr[KEY_DSN].supplied && strcasecmp(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr)) { SQLRemoveDSNFromIni(setupdlg->DSN); } return TRUE; } /** * Get datasource attributes from registry. * @param setupdlg pointer to dialog data */ static void GetAttributes(SETUPDLG *setupdlg) { char *dsn = setupdlg->attr[KEY_DSN].attr; if (!setupdlg->attr[KEY_DESC].supplied) { SQLGetPrivateProfileString(dsn, "Description", "", setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr), ODBC_INI); } if (!setupdlg->attr[KEY_DBNAME].supplied) { SQLGetPrivateProfileString(dsn, "Database", "", setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr), ODBC_INI); } if (!setupdlg->attr[KEY_BUSY].supplied) { SQLGetPrivateProfileString(dsn, "Timeout", "100000", setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr), ODBC_INI); } if (!setupdlg->attr[KEY_STEPAPI].supplied) { SQLGetPrivateProfileString(dsn, "StepAPI", "0", setupdlg->attr[KEY_STEPAPI].attr, sizeof (setupdlg->attr[KEY_STEPAPI].attr), ODBC_INI); } if (!setupdlg->attr[KEY_SYNCP].supplied) { SQLGetPrivateProfileString(dsn, "SyncPragma", "NORMAL", setupdlg->attr[KEY_SYNCP].attr, sizeof (setupdlg->attr[KEY_SYNCP].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOTXN].supplied) { SQLGetPrivateProfileString(dsn, "NoTXN", "", setupdlg->attr[KEY_NOTXN].attr, sizeof (setupdlg->attr[KEY_NOTXN].attr), ODBC_INI); } if (!setupdlg->attr[KEY_SHORTNAM].supplied) { SQLGetPrivateProfileString(dsn, "ShortNames", "", setupdlg->attr[KEY_SHORTNAM].attr, sizeof (setupdlg->attr[KEY_SHORTNAM].attr), ODBC_INI); } if (!setupdlg->attr[KEY_LONGNAM].supplied) { SQLGetPrivateProfileString(dsn, "LongNames", "", setupdlg->attr[KEY_LONGNAM].attr, sizeof (setupdlg->attr[KEY_LONGNAM].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOCREAT].supplied) { SQLGetPrivateProfileString(dsn, "NoCreat", "", setupdlg->attr[KEY_NOCREAT].attr, sizeof (setupdlg->attr[KEY_NOCREAT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_NOWCHAR].supplied) { SQLGetPrivateProfileString(dsn, "NoWCHAR", "", setupdlg->attr[KEY_NOWCHAR].attr, sizeof (setupdlg->attr[KEY_NOWCHAR].attr), ODBC_INI); } if (!setupdlg->attr[KEY_FKSUPPORT].supplied) { SQLGetPrivateProfileString(dsn, "FKSupport", "", setupdlg->attr[KEY_FKSUPPORT].attr, sizeof (setupdlg->attr[KEY_FKSUPPORT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_OEMCP].supplied) { SQLGetPrivateProfileString(dsn, "OEMCP", "", setupdlg->attr[KEY_OEMCP].attr, sizeof (setupdlg->attr[KEY_OEMCP].attr), ODBC_INI); } if (!setupdlg->attr[KEY_LOADEXT].supplied) { SQLGetPrivateProfileString(dsn, "LoadExt", "", setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_JMODE].supplied) { SQLGetPrivateProfileString(dsn, "JournalMode", "", setupdlg->attr[KEY_JMODE].attr, sizeof (setupdlg->attr[KEY_JMODE].attr), ODBC_INI); } if (!setupdlg->attr[KEY_BIGINT].supplied) { SQLGetPrivateProfileString(dsn, "BigInt", "", setupdlg->attr[KEY_BIGINT].attr, sizeof (setupdlg->attr[KEY_BIGINT].attr), ODBC_INI); } if (!setupdlg->attr[KEY_PASSWD].supplied) { SQLGetPrivateProfileString(dsn, "PWD", "", setupdlg->attr[KEY_PASSWD].attr, sizeof (setupdlg->attr[KEY_PASSWD].attr), ODBC_INI); } } /** * Open file dialog for selection of SQLite database file. * @param hdlg handle of originating dialog window */ static void GetDBFile(HWND hdlg) { #ifdef _WIN64 SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else SETUPDLG *setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); ofn.lStructSize = sizeof (ofn); ofn.hwndOwner = hdlg; #ifdef _WIN64 ofn.hInstance = (HINSTANCE) GetWindowLongPtr(hdlg, GWLP_HINSTANCE); #else ofn.hInstance = (HINSTANCE) GetWindowLong(hdlg, GWL_HINSTANCE); #endif ofn.lpstrFile = (LPTSTR) setupdlg->attr[KEY_DBNAME].attr; ofn.nMaxFile = MAXPATHLEN; ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_FILEMUSTEXIST; if (GetOpenFileName(&ofn)) { SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); setupdlg->attr[KEY_DBNAME].supplied = TRUE; } } /** * Dialog procedure for ConfigDSN(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK ConfigDlgProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg = NULL; WORD index; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLong(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; GetAttributes(setupdlg); SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_LOADEXT, EM_LIMITTEXT, (WPARAM) (MAXPATHLEN*4 - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_SHORTNAM, getbool(setupdlg->attr[KEY_SHORTNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOCREAT, getbool(setupdlg->attr[KEY_NOCREAT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_FKSUPPORT, getbool(setupdlg->attr[KEY_FKSUPPORT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_OEMCP, getbool(setupdlg->attr[KEY_OEMCP].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_BIGINT, getbool(setupdlg->attr[KEY_BIGINT].attr) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_LIMITTEXT, (WPARAM) 10, (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "NORMAL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "OFF"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "FULL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_DSNAME: if (GET_WM_COMMAND_CMD(wparam, lparam) == EN_CHANGE) { char item[MAXDSNAME]; EnableWindow(GetDlgItem(hdlg, IDOK), GetDlgItemText(hdlg, IDC_DSNAME, item, sizeof (item))); return TRUE; } break; case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif if (!setupdlg->defDSN) { GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); } GetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr, sizeof (setupdlg->attr[KEY_DESC].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); GetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr)); index = SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); if (index != (WORD) CB_ERR) { SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETLBTEXT, index, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); } strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_SHORTNAM].attr, (IsDlgButtonChecked(hdlg, IDC_SHORTNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOCREAT].attr, (IsDlgButtonChecked(hdlg, IDC_NOCREAT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_FKSUPPORT].attr, (IsDlgButtonChecked(hdlg, IDC_FKSUPPORT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_OEMCP].attr, (IsDlgButtonChecked(hdlg, IDC_OEMCP) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_BIGINT].attr, (IsDlgButtonChecked(hdlg, IDC_BIGINT) == BST_CHECKED) ? "1" : "0"); SetDSNAttributes(hdlg, setupdlg); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, wparam); return TRUE; } break; } return FALSE; } /** * ODBC INSTAPI procedure for DSN configuration. * @param hwnd parent window handle * @param request type of request * @param driver driver name * @param attribs attribute string of DSN * @result true or false */ BOOL INSTAPI ConfigDSN(HWND hwnd, WORD request, LPCSTR driver, LPCSTR attribs) { BOOL success; SETUPDLG *setupdlg; setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return FALSE; } memset(setupdlg, 0, sizeof (SETUPDLG)); if (attribs) { ParseAttributes(attribs, setupdlg); } if (setupdlg->attr[KEY_DSN].supplied) { strcpy(setupdlg->DSN, setupdlg->attr[KEY_DSN].attr); } else { setupdlg->DSN[0] = '\0'; } if (request == ODBC_REMOVE_DSN) { if (!setupdlg->attr[KEY_DSN].supplied) { success = FALSE; } else { success = SQLRemoveDSNFromIni(setupdlg->attr[KEY_DSN].attr); } } else { setupdlg->parent = hwnd; setupdlg->driver = driver; setupdlg->newDSN = request == ODBC_ADD_DSN; setupdlg->defDSN = strcasecmp(setupdlg->attr[KEY_DSN].attr, "Default") == 0; if (hwnd) { success = DialogBoxParam(hModule, MAKEINTRESOURCE(CONFIGDSN), hwnd, (DLGPROC) ConfigDlgProc, (LPARAM) setupdlg) == IDOK; } else if (setupdlg->attr[KEY_DSN].supplied) { success = SetDSNAttributes(hwnd, setupdlg); } else { success = FALSE; } } xfree(setupdlg); return success; } /** * Dialog procedure for SQLDriverConnect(). * @param hdlg handle of dialog window * @param wmsg type of message * @param wparam wparam of message * @param lparam lparam of message * @result true or false */ static BOOL CALLBACK DriverConnectProc(HWND hdlg, WORD wmsg, WPARAM wparam, LPARAM lparam) { SETUPDLG *setupdlg; WORD index; switch (wmsg) { case WM_INITDIALOG: #ifdef _WIN64 SetWindowLong(hdlg, DWLP_USER, lparam); #else SetWindowLong(hdlg, DWL_USER, lparam); #endif setupdlg = (SETUPDLG *) lparam; SetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr); SetDlgItemText(hdlg, IDC_DESC, setupdlg->attr[KEY_DESC].attr); SetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr); SetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr); SetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr); SendDlgItemMessage(hdlg, IDC_DSNAME, EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DESC, EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_DBNAME, EM_LIMITTEXT, (WPARAM) (MAXDBNAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_TONAME, EM_LIMITTEXT, (WPARAM) (MAXTONAME - 1), (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_LOADEXT, EM_LIMITTEXT, (WPARAM) (MAXPATHLEN*4 - 1), (LPARAM) 0); CheckDlgButton(hdlg, IDC_STEPAPI, getbool(setupdlg->attr[KEY_STEPAPI].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOTXN, getbool(setupdlg->attr[KEY_NOTXN].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_SHORTNAM, getbool(setupdlg->attr[KEY_SHORTNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_LONGNAM, getbool(setupdlg->attr[KEY_LONGNAM].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOCREAT, getbool(setupdlg->attr[KEY_NOCREAT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_NOWCHAR, getbool(setupdlg->attr[KEY_NOWCHAR].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_FKSUPPORT, getbool(setupdlg->attr[KEY_FKSUPPORT].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_OEMCP, getbool(setupdlg->attr[KEY_OEMCP].attr) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hdlg, IDC_BIGINT, getbool(setupdlg->attr[KEY_BIGINT].attr) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_LIMITTEXT, (WPARAM) 10, (LPARAM) 0); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "NORMAL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "OFF"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_ADDSTRING, 0, (LPARAM) "FULL"); SendDlgItemMessage(hdlg, IDC_SYNCP, CB_SELECTSTRING, (WORD) -1, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); if (setupdlg->defDSN) { EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE); } return TRUE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wparam, lparam)) { case IDC_BROWSE: GetDBFile(hdlg); break; case IDOK: #ifdef _WIN64 setupdlg = (SETUPDLG *) GetWindowLongPtr(hdlg, DWLP_USER); #else setupdlg = (SETUPDLG *) GetWindowLong(hdlg, DWL_USER); #endif GetDlgItemText(hdlg, IDC_DSNAME, setupdlg->attr[KEY_DSN].attr, sizeof (setupdlg->attr[KEY_DSN].attr)); GetDlgItemText(hdlg, IDC_DBNAME, setupdlg->attr[KEY_DBNAME].attr, sizeof (setupdlg->attr[KEY_DBNAME].attr)); GetDlgItemText(hdlg, IDC_TONAME, setupdlg->attr[KEY_BUSY].attr, sizeof (setupdlg->attr[KEY_BUSY].attr)); GetDlgItemText(hdlg, IDC_LOADEXT, setupdlg->attr[KEY_LOADEXT].attr, sizeof (setupdlg->attr[KEY_LOADEXT].attr)); index = SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); if (index != (WORD) CB_ERR) { SendDlgItemMessage(hdlg, IDC_SYNCP, CB_GETLBTEXT, index, (LPARAM) setupdlg->attr[KEY_SYNCP].attr); } strcpy(setupdlg->attr[KEY_STEPAPI].attr, (IsDlgButtonChecked(hdlg, IDC_STEPAPI) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOTXN].attr, (IsDlgButtonChecked(hdlg, IDC_NOTXN) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_SHORTNAM].attr, (IsDlgButtonChecked(hdlg, IDC_SHORTNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_LONGNAM].attr, (IsDlgButtonChecked(hdlg, IDC_LONGNAM) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOCREAT].attr, (IsDlgButtonChecked(hdlg, IDC_NOCREAT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_NOWCHAR].attr, (IsDlgButtonChecked(hdlg, IDC_NOWCHAR) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_FKSUPPORT].attr, (IsDlgButtonChecked(hdlg, IDC_FKSUPPORT) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_OEMCP].attr, (IsDlgButtonChecked(hdlg, IDC_OEMCP) == BST_CHECKED) ? "1" : "0"); strcpy(setupdlg->attr[KEY_BIGINT].attr, (IsDlgButtonChecked(hdlg, IDC_BIGINT) == BST_CHECKED) ? "1" : "0"); /* FALL THROUGH */ case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wparam, lparam) == IDOK); return TRUE; } } return FALSE; } /** * Internal connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ static SQLRETURN drvdriverconnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { BOOL maybeprompt, prompt = FALSE, defaultdsn = FALSE; DBC *d; SETUPDLG *setupdlg; SQLRETURN ret; char *dsn = NULL, *driver = NULL, *dbname = NULL; if (dbc == SQL_NULL_HDBC) { return SQL_INVALID_HANDLE; } d = (DBC *) dbc; if (d->sqlite) { setstatd(d, -1, "connection already established", "08002"); return SQL_ERROR; } setupdlg = (SETUPDLG *) xmalloc(sizeof (SETUPDLG)); if (setupdlg == NULL) { return SQL_ERROR; } memset(setupdlg, 0, sizeof (SETUPDLG)); maybeprompt = drvcompl == SQL_DRIVER_COMPLETE || drvcompl == SQL_DRIVER_COMPLETE_REQUIRED; if (connIn == NULL || !connInLen || (connInLen == SQL_NTS && !connIn[0])) { prompt = TRUE; } else { ParseAttributes((LPCSTR) connIn, setupdlg); if (!setupdlg->attr[KEY_DSN].attr[0] && drvcompl == SQL_DRIVER_COMPLETE_REQUIRED) { strcpy(setupdlg->attr[KEY_DSN].attr, "DEFAULT"); defaultdsn = TRUE; } GetAttributes(setupdlg); if (drvcompl == SQL_DRIVER_PROMPT || (maybeprompt && !setupdlg->attr[KEY_DBNAME].attr[0])) { prompt = TRUE; } } retry: if (prompt) { short dlgret; setupdlg->defDSN = setupdlg->attr[KEY_DRIVER].attr[0] != '\0'; dlgret = DialogBoxParam(hModule, MAKEINTRESOURCE(DRIVERCONNECT), hwnd, (DLGPROC) DriverConnectProc, (LPARAM) setupdlg); if (!dlgret || dlgret == -1) { xfree(setupdlg); return SQL_NO_DATA; } } dsn = setupdlg->attr[KEY_DSN].attr; driver = setupdlg->attr[KEY_DRIVER].attr; dbname = setupdlg->attr[KEY_DBNAME].attr; if (connOut || connOutLen) { char buf[SQL_MAX_MESSAGE_LENGTH * 4]; int len, count; char dsn_0 = (dsn && !defaultdsn) ? dsn[0] : '\0'; char drv_0 = driver ? driver[0] : '\0'; buf[0] = '\0'; count = snprintf(buf, sizeof (buf), "%s%s%s%s%s%sDatabase=%s;StepAPI=%s;" "SyncPragma=%s;NoTXN=%s;Timeout=%s;" "ShortNames=%s;LongNames=%s;" "NoCreat=%s;NoWCHAR=%s;" "FKSupport=%s;JournalMode=%s;OEMCP=%s;LoadExt=%s;" "BigInt=%s;PWD=%s", dsn_0 ? "DSN=" : "", dsn_0 ? dsn : "", dsn_0 ? ";" : "", drv_0 ? "Driver=" : "", drv_0 ? driver : "", drv_0 ? ";" : "", dbname ? dbname : "", setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_SYNCP].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_BUSY].attr, setupdlg->attr[KEY_SHORTNAM].attr, setupdlg->attr[KEY_LONGNAM].attr, setupdlg->attr[KEY_NOCREAT].attr, setupdlg->attr[KEY_NOWCHAR].attr, setupdlg->attr[KEY_FKSUPPORT].attr, setupdlg->attr[KEY_JMODE].attr, setupdlg->attr[KEY_OEMCP].attr, setupdlg->attr[KEY_LOADEXT].attr, setupdlg->attr[KEY_BIGINT].attr, setupdlg->attr[KEY_PASSWD].attr); if (count < 0) { buf[sizeof (buf) - 1] = '\0'; } len = min(connOutMax - 1, strlen(buf)); if (connOut) { strncpy((char *) connOut, buf, len); connOut[len] = '\0'; } if (connOutLen) { *connOutLen = len; } } if (dsn[0]) { char tracef[SQL_MAX_MESSAGE_LENGTH]; tracef[0] = '\0'; SQLGetPrivateProfileString(setupdlg->attr[KEY_DSN].attr, "tracefile", "", tracef, sizeof (tracef), ODBC_INI); if (tracef[0] != '\0') { d->trace = fopen(tracef, "a"); } } d->nowchar = getbool(setupdlg->attr[KEY_NOWCHAR].attr); d->shortnames = getbool(setupdlg->attr[KEY_SHORTNAM].attr); d->longnames = getbool(setupdlg->attr[KEY_LONGNAM].attr); d->nocreat = getbool(setupdlg->attr[KEY_NOCREAT].attr); d->fksupport = getbool(setupdlg->attr[KEY_FKSUPPORT].attr); d->oemcp = getbool(setupdlg->attr[KEY_OEMCP].attr); d->dobigint = getbool(setupdlg->attr[KEY_BIGINT].attr); d->pwdLen = strlen(setupdlg->attr[KEY_PASSWD].attr); d->pwd = (d->pwdLen > 0) ? setupdlg->attr[KEY_PASSWD].attr : NULL; ret = dbopen(d, dbname ? dbname : "", 0, dsn ? dsn : "", setupdlg->attr[KEY_STEPAPI].attr, setupdlg->attr[KEY_SYNCP].attr, setupdlg->attr[KEY_NOTXN].attr, setupdlg->attr[KEY_JMODE].attr, setupdlg->attr[KEY_BUSY].attr); if (ret != SQL_SUCCESS) { if (maybeprompt && !prompt) { prompt = TRUE; goto retry; } } memset(setupdlg->attr[KEY_PASSWD].attr, 0, sizeof (setupdlg->attr[KEY_PASSWD].attr)); if (ret == SQL_SUCCESS) { dbloadext(d, setupdlg->attr[KEY_LOADEXT].attr); } xfree(setupdlg); return ret; } #endif /* WITHOUT_DRIVERMGR */ #endif /* _WIN32 || _WIN64 */ #ifndef WINTERFACE /** * Connect using a driver connection string. * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnect(SQLHDBC dbc, SQLHWND hwnd, SQLCHAR *connIn, SQLSMALLINT connInLen, SQLCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; HDBC_LOCK(dbc); ret = drvdriverconnect(dbc, hwnd, connIn, connInLen, connOut, connOutMax, connOutLen, drvcompl); HDBC_UNLOCK(dbc); return ret; } #endif #ifdef WINTERFACE /** * Connect using a driver connection string (UNICODE version). * @param dbc database connection handle * @param hwnd parent window handle * @param connIn driver connect input string * @param connInLen length of driver connect input string or SQL_NTS * @param connOut driver connect output string * @param connOutMax length of driver connect output string * @param connOutLen output length of driver connect output string * @param drvcompl completion type * @result ODBC error code */ SQLRETURN SQL_API SQLDriverConnectW(SQLHDBC dbc, SQLHWND hwnd, SQLWCHAR *connIn, SQLSMALLINT connInLen, SQLWCHAR *connOut, SQLSMALLINT connOutMax, SQLSMALLINT *connOutLen, SQLUSMALLINT drvcompl) { SQLRETURN ret; char *ci = NULL; SQLSMALLINT len = 0; HDBC_LOCK(dbc); if (connIn) { #if defined(_WIN32) || defined(_WIN64) if (connInLen == SQL_NTS) { connInLen = -1; } ci = uc_to_wmb(connIn, connInLen); #else ci = uc_to_utf(connIn, connInLen); #endif if (!ci) { DBC *d = (DBC *) dbc; setstatd(d, -1, "out of memory", (*d->ov3) ? "HY000" : "S1000"); HDBC_UNLOCK(dbc); return SQL_ERROR; } } ret = drvdriverconnect(dbc, hwnd, (SQLCHAR *) ci, SQL_NTS, (SQLCHAR *) connOut, connOutMax, &len, drvcompl); HDBC_UNLOCK(dbc); uc_free(ci); if (ret == SQL_SUCCESS) { SQLWCHAR *co = NULL; if (connOut) { if (len > 0) { #if defined(_WIN32) || defined(_WIN64) co = wmb_to_uc((char *) connOut, len); #else co = uc_from_utf((SQLCHAR *) connOut, len); #endif if (co) { uc_strncpy(connOut, co, connOutMax / sizeof (SQLWCHAR)); len = min(connOutMax / sizeof (SQLWCHAR), uc_strlen(co)); uc_free(co); } else { len = 0; } } if (len <= 0) { len = 0; connOut[0] = 0; } } else { len = 0; } if (connOutLen) { *connOutLen = len; } } return ret; } #endif #if defined(_WIN32) || defined(_WIN64) /** * DLL initializer for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ BOOL APIENTRY LibMain(HANDLE hinst, DWORD reason, LPVOID reserved) { static int initialized = 0; switch (reason) { case DLL_PROCESS_ATTACH: if (!initialized++) { hModule = hinst; #ifdef WINTERFACE /* MS Access hack part 1 (reserved error -7748) */ statSpec2P = statSpec2; statSpec3P = statSpec3; #endif #ifdef SQLITE_DYNLOAD dls_init(); #endif } break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: if (--initialized <= 0) { #ifdef SQLITE_DYNLOAD dls_fini(); #endif } break; case DLL_THREAD_DETACH: break; default: break; } return TRUE; } /** * DLL entry point for WIN32. * @param hinst instance handle * @param reason reason code for entry point * @param reserved * @result always true */ int __stdcall DllMain(HANDLE hinst, DWORD reason, LPVOID reserved) { return LibMain(hinst, reason, reserved); } #ifndef WITHOUT_INSTALLER /** * Handler for driver installer/uninstaller error messages. * @param name name of API function for which to show error messages * @result true when error message retrieved */ static BOOL InUnError(char *name) { WORD err = 1; DWORD code; char errmsg[301]; WORD errlen, errmax = sizeof (errmsg) - 1; int sqlret; BOOL ret = FALSE; do { errmsg[0] = '\0'; sqlret = SQLInstallerError(err, &code, errmsg, errmax, &errlen); if (SQL_SUCCEEDED(sqlret)) { MessageBox(NULL, errmsg, name, MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); ret = TRUE; } err++; } while (sqlret != SQL_NO_DATA); return ret; } /** * Built in driver installer/uninstaller. * @param remove true for uninstall * @param cmdline command line string of rundll32 */ static BOOL InUn(int remove, char *cmdline) { #ifdef SQLITE_HAS_CODEC static char *drivername = "SQLite4 ODBC Driver (SEE)"; static char *dsname = "SQLite4 SEE Datasource"; #else static char *drivername = "SQLite4 ODBC Driver"; static char *dsname = "SQLite4 Datasource"; #endif char *dllname, *p; char dllbuf[301], path[301], driver[300], attr[300], inst[400]; WORD pathmax = sizeof (path) - 1, pathlen; DWORD usecnt, mincnt; int quiet = 0; dllbuf[0] = '\0'; GetModuleFileName(hModule, dllbuf, sizeof (dllbuf)); p = strrchr(dllbuf, '\\'); dllname = p ? (p + 1) : dllbuf; quiet = cmdline && strstr(cmdline, "quiet"); if (SQLInstallDriverManager(path, pathmax, &pathlen)) { sprintf(driver, "%s;Driver=%s;Setup=%s;", drivername, dllname, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } usecnt = 0; path[0] = '\0'; SQLInstallDriverEx(driver, NULL, path, pathmax, NULL, ODBC_INSTALL_INQUIRY, &usecnt); pathlen = strlen(path); while (pathlen > 0 && path[pathlen - 1] == '\\') { --pathlen; path[pathlen] = '\0'; } sprintf(driver, "%s;Driver=%s\\%s;Setup=%s\\%s;", drivername, path, dllname, path, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } sprintf(inst, "%s\\%s", path, dllname); if (!remove && usecnt > 0) { /* first install try: copy over driver dll, keeping DSNs */ if (GetFileAttributesA(dllbuf) != INVALID_FILE_ATTRIBUTES && CopyFile(dllbuf, inst, 0)) { if (!quiet) { char buf[512]; sprintf(buf, "%s replaced.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } return TRUE; } } mincnt = remove ? 1 : 0; while (usecnt != mincnt) { if (!SQLRemoveDriver(driver, TRUE, &usecnt)) { break; } } if (remove) { if (usecnt && !SQLRemoveDriver(driver, TRUE, &usecnt)) { InUnError("SQLRemoveDriver"); return FALSE; } if (!usecnt) { char buf[512]; DeleteFile(inst); if (!quiet) { sprintf(buf, "%s uninstalled.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION |MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); return TRUE; } if (GetFileAttributesA(dllbuf) == INVALID_FILE_ATTRIBUTES) { return FALSE; } if (strcmp(dllbuf, inst) != 0 && !CopyFile(dllbuf, inst, 0)) { char buf[512]; sprintf(buf, "Copy %s to %s failed.", dllbuf, inst); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP |MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); return FALSE; } if (!SQLInstallDriverEx(driver, path, path, pathmax, &pathlen, ODBC_INSTALL_COMPLETE, &usecnt)) { InUnError("SQLInstallDriverEx"); return FALSE; } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, drivername, attr)) { InUnError("SQLConfigDataSource"); return FALSE; } if (!quiet) { char buf[512]; sprintf(buf, "%s installed.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } else { InUnError("SQLInstallDriverManager"); return FALSE; } return TRUE; } /** * RunDLL32 entry point for driver installation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK install(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(0, lpszCmdLine); } /** * RunDLL32 entry point for driver uninstallation. * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK uninstall(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { InUn(1, lpszCmdLine); } #endif /* WITHOUT_INSTALLER */ #ifndef WITHOUT_SHELL /** * Setup argv vector from string * @param argcp pointer to argc * @param argvp pointer to argv * @param cmdline command line string * @param argv0 0th element for argv or NULL, must be static */ static void setargv(int *argcp, char ***argvp, char *cmdline, char *argv0) { char *p, *arg, *argspace, **argv; int argc, size, inquote, copy, slashes; size = 2 + (argv0 ? 1 : 0); for (p = cmdline; *p != '\0'; p++) { if (ISSPACE(*p)) { size++; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } } } argspace = malloc(size * sizeof (char *) + strlen(cmdline) + 1); argv = (char **) argspace; argspace += size * sizeof (char *); size--; argc = 0; if (argv0) { argv[argc++] = argv0; } p = cmdline; for (; argc < size; argc++) { argv[argc] = arg = argspace; while (ISSPACE(*p)) { p++; } if (*p == '\0') { break; } inquote = 0; slashes = 0; while (1) { copy = 1; while (*p == '\\') { slashes++; p++; } if (*p == '"') { if ((slashes & 1) == 0) { copy = 0; if (inquote && p[1] == '"') { p++; copy = 1; } else { inquote = !inquote; } } slashes >>= 1; } while (slashes) { *arg = '\\'; arg++; slashes--; } if (*p == '\0' || (!inquote && ISSPACE(*p))) { break; } if (copy != 0) { *arg = *p; arg++; } p++; } *arg = '\0'; argspace = arg + 1; } argv[argc] = 0; *argcp = argc; *argvp = argv; } /** * RunDLL32 entry point for SQLite shell * @param hwnd window handle of caller * @param hinst of this DLL * @param lpszCmdLine rundll32 command line tail * @param nCmdShow ignored */ void CALLBACK shell(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int argc, needcon = 0; char **argv; extern int sqlite4_main(int, char **); static const char *name = "SQLite4 Shell"; DWORD ftype0, ftype1, ftype2; ftype0 = GetFileType(GetStdHandle(STD_INPUT_HANDLE)); ftype1 = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); ftype2 = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); if (ftype0 != FILE_TYPE_DISK && ftype0 != FILE_TYPE_CHAR && ftype0 != FILE_TYPE_PIPE) { fclose(stdin); ++needcon; ftype0 = FILE_TYPE_UNKNOWN; } if (ftype1 != FILE_TYPE_DISK && ftype1 != FILE_TYPE_CHAR && ftype1 != FILE_TYPE_PIPE) { fclose(stdout); ++needcon; ftype1 = FILE_TYPE_UNKNOWN; } if (ftype2 != FILE_TYPE_DISK && ftype2 != FILE_TYPE_CHAR && ftype2 != FILE_TYPE_PIPE) { fclose(stderr); ++needcon; ftype2 = FILE_TYPE_UNKNOWN; } if (needcon > 0) { AllocConsole(); SetConsoleTitle(name); } if (ftype0 == FILE_TYPE_UNKNOWN) { freopen("CONIN$", "r", stdin); } if (ftype1 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stdout); } if (ftype2 == FILE_TYPE_UNKNOWN) { freopen("CONOUT$", "w", stderr); } setargv(&argc, &argv, lpszCmdLine, (char *) name); sqlite4_main(argc, argv); } #endif /* WITHOUT_SHELL */ #endif /* _WIN32 || _WIN64 */ #if defined(HAVE_ODBCINSTEXT_H) && (HAVE_ODBCINSTEXT_H) /* * unixODBC property page for this driver, * may or may not work depending on unixODBC version. */ #include int ODBCINSTGetProperties(HODBCINSTPROPERTY prop) { static const char *instYN[] = { "No", "Yes", NULL }; static const char *syncPragma[] = { "NORMAL", "OFF", "FULL", NULL }; static const char *jmPragma[] = { "DELETE", "PERSIST", "OFF", "TRUNCATE", "MEMORY", "WAL", NULL }; prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_FILENAME; strncpy(prop->szName, "Database", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strncpy(prop->szName, "Timeout", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "100000", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "StepAPI", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "ShortNames", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "LongNames", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "NoCreat", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #ifdef WINTERFACE prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "NoWCHAR", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); #endif prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "FKSupport", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (syncPragma)); memcpy(prop->aPromptData, syncPragma, sizeof (syncPragma)); strncpy(prop->szName, "SyncPragma", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "NORMAL", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (jmPragma)); memcpy(prop->aPromptData, jmPragma, sizeof (jmPragma)); strncpy(prop->szName, "JournalMode", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "DELETE", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); prop = prop->pNext; memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strncpy(prop->szName, "LoadExt", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "", INI_MAX_PROPERTY_VALUE); prop->pNext = (HODBCINSTPROPERTY) malloc(sizeof (ODBCINSTPROPERTY)); memset(prop, 0, sizeof (ODBCINSTPROPERTY)); prop->nPromptType = ODBCINST_PROMPTTYPE_COMBOBOX; prop->aPromptData = malloc(sizeof (instYN)); memcpy(prop->aPromptData, instYN, sizeof (instYN)); strncpy(prop->szName, "BigInt", INI_MAX_PROPERTY_NAME); strncpy(prop->szValue, "No", INI_MAX_PROPERTY_VALUE); return 1; } #endif /* HAVE_ODBCINSTEXT_H */ #ifdef SQLITE_DYNLOAD /* * SQLite4 shared library/DLL stubs. */ static void dls_void(void) { } static int dls_error(void) { return SQLITE4_ERROR; } static int dls_0(void) { return 0; } static double dls_00(void) { return 0; } static void * dls_null(void) { return NULL; } static const char * dls_empty(void) { return ""; } static int dls_snull(void) { return SQLITE4_NULL; } #define DLS_ENT(name, func) \ { "sqlite4_" #name, offsetof(struct dl_sqlite4_funcs, name), \ (void *) func } #define DLS_ENT3(name, off, func) \ { "sqlite4_" #name, offsetof(struct dl_sqlite4_funcs, off), \ (void *) func } #define DLS_END { NULL, 0, NULL } static struct { const char *name; int offset; void *func; } dls_nametab[] = { DLS_ENT(bind_blob, dls_error), DLS_ENT(bind_double, dls_error), DLS_ENT(bind_int, dls_error), DLS_ENT(bind_int64, dls_error), DLS_ENT(bind_null, dls_error), DLS_ENT(bind_parameter_count, dls_0), DLS_ENT(bind_text, dls_error), DLS_ENT(changes, dls_0), DLS_ENT(close, dls_error), DLS_ENT(column_blob, dls_null), DLS_ENT(column_bytes, dls_0), DLS_ENT(column_count, dls_0), DLS_ENT(column_database_name, dls_empty), DLS_ENT(column_decltype, dls_empty), DLS_ENT(column_double, dls_00), DLS_ENT(column_name, dls_empty), DLS_ENT(column_origin_name, dls_null), DLS_ENT(column_table_name, dls_null), DLS_ENT(column_text, dls_null), DLS_ENT(column_type, dls_snull), DLS_ENT(create_function, dls_error), DLS_ENT(errcode, dls_error), DLS_ENT(errmsg, dls_empty), DLS_ENT(exec, dls_error), DLS_ENT(finalize, dls_error), DLS_ENT(free, free), DLS_ENT(interrupt, dls_void), DLS_ENT(libversion, dls_empty), #if 0 DLS_ENT(load_extension, dls_error), #endif DLS_ENT(malloc, malloc), DLS_ENT(mprintf, dls_null), DLS_ENT(open, dls_error), DLS_ENT(prepare, dls_error), DLS_ENT(profile, dls_null), DLS_ENT(realloc, realloc), DLS_ENT(reset, dls_error), DLS_ENT(result_blob, dls_void), DLS_ENT(result_error, dls_void), DLS_ENT(result_int, dls_void), DLS_ENT(result_null, dls_void), DLS_ENT(step, dls_error), #if defined(_WIN32) || defined(_WIN64) DLS_ENT3(strnicmp, xstrnicmp, _strnicmp), #else DLS_ENT3(strnicmp, xstrnicmp, strncasecmp), #endif #if 0 DLS_ENT(table_column_metadata, dls_error), #endif DLS_ENT(trace, dls_null), DLS_ENT(user_data, dls_null), DLS_ENT(value_blob, dls_null), DLS_ENT(value_bytes, dls_0), DLS_ENT(value_text, dls_empty), DLS_ENT(value_type, dls_snull), DLS_END }; #if defined(_WIN32) || defined(_WIN64) static HMODULE sqlite4_dll = 0; static void dls_init(void) { int i; static const char *dll_names[] = { "System.Data.SQLite.dll", "sqlite4.dll", NULL, }; i = 0; while (dll_names[i]) { sqlite4_dll = LoadLibrary(dll_names[i]); if (sqlite4_dll) { break; } ++i; } i = 0; while (dls_nametab[i].name) { void *func = 0, **loc; if (sqlite4_dll) { func = (void *) GetProcAddress(sqlite4_dll, dls_nametab[i].name); } if (!func) { func = dls_nametab[i].func; } loc = (void **) ((char *) &dls_funcs + dls_nametab[i].offset); *loc = func; ++i; } if (!sqlite4_dll) { char buf[MAXPATHLEN], msg[MAXPATHLEN]; LoadString(hModule, IDS_DRVTITLE, buf, sizeof (buf)); LoadString(hModule, IDS_DLLERR, msg, sizeof (msg)); MessageBox(NULL, msg, buf, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); } } static void dls_fini(void) { if (sqlite4_dll) { FreeLibrary(sqlite4_dll); sqlite4_dll = 0; } } #else #include static void *libsqlite4_so = 0; void dls_init(void) { int i; libsqlite4_so = dlopen("libsqlite4.so.0", RTLD_NOW | RTLD_GLOBAL); i = 0; while (dls_nametab[i].name) { void *func = 0, **loc; if (libsqlite4_so) { func = dlsym(libsqlite4_so, dls_nametab[i].name); } if (!func) { func = dls_nametab[i].func; } loc = (void **) ((char *) &dls_funcs + dls_nametab[i].offset); *loc = func; ++i; } if (!libsqlite4_so) { const char errmsg[] = "sqlite4 shared library not found.\n"; write(2, errmsg, sizeof (errmsg) - 1); } } void dls_fini(void) { if (libsqlite4_so) { dlclose(libsqlite4_so); libsqlite4_so = 0; } } #endif #endif ./sqliteodbc-0.992/sqlite4odbc.h0100644000076400001440000002265112077446235015136 0ustar chwusers#ifndef _SQLITE4ODBC_H #define _SQLITE4ODBC_H /** * @mainpage * @section readme README * @verbinclude README * @section changelog ChangeLog * @verbinclude ChangeLog * @section copying License Terms * @verbinclude license.terms */ /** * @file sqlite4odbc.h * Header file for SQLite4 ODBC driver. * * $Id: sqlite4odbc.h,v 1.1 2013/01/22 08:23:54 chw Exp chw $ * * Copyright (c) 2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #if defined(_WIN32) || defined(_WIN64) #include #include #include #else #include #include #include #include #include #endif #include #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) #include #endif #include #include #include #include #include #include #include "sqlite4.h" #ifdef HAVE_IODBC #include #endif #if defined(HAVE_UNIXODBC) || defined(_WIN32) || defined(_WIN64) #include #endif #ifndef SQL_API #define SQL_API #endif #ifndef HAVE_SQLLEN #define SQLLEN SQLINTEGER #endif #define SQLLEN_PTR SQLLEN * #ifndef HAVE_SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef HAVE_SQLROWCOUNT #define SQLROWCOUNT SQLUINTEGER #endif #ifndef HAVE_SQLSETPOSIROW #define SQLSETPOSIROW SQLUSMALLINT #endif #ifndef HAVE_SQLROWOFFSET #define SQLROWOFFSET SQLLEN #endif #ifndef HAVE_SQLROWSETSIZE #define SQLROWSETSIZE SQLULEN #endif struct dbc; struct stmt; /** * @typedef ENV * @struct ENV * Driver internal structure for environment (HENV). */ typedef struct { int magic; /**< Magic cookie */ int ov3; /**< True for SQL_OV_ODBC3 */ #if defined(_WIN32) || defined(_WIN64) CRITICAL_SECTION cs; /**< For serializing most APIs */ DWORD owner; /**< Current owner of CS or 0 */ #endif struct dbc *dbcs; /**< Pointer to first DBC */ } ENV; /** * @typedef DBC * @struct dbc * Driver internal structure for database connection (HDBC). */ typedef struct dbc { int magic; /**< Magic cookie */ ENV *env; /**< Pointer to environment */ struct dbc *next; /**< Pointer to next DBC */ sqlite4 *sqlite; /**< SQLITE database handle */ int version; /**< SQLITE version number */ char *dbname; /**< SQLITE database name */ char *dsn; /**< ODBC data source name */ int timeout; /**< Lock timeout value */ long t0; /**< Start time for SQLITE busy handler */ int busyint; /**< Interrupt busy handler from SQLCancel() */ int *ov3; /**< True for SQL_OV_ODBC3 */ int ov3val; /**< True for SQL_OV_ODBC3 */ int autocommit; /**< Auto commit state */ int intrans; /**< True when transaction started */ struct stmt *stmt; /**< STMT list of this DBC */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar; /**< Don't try to use WCHAR */ int dobigint; /**< Force SQL_BIGINT for INTEGER columns */ int shortnames; /**< Always use short column names */ int longnames; /**< Don't shorten column names */ int nocreat; /**< Don't auto create database file */ int fksupport; /**< Foreign keys on or off */ int curtype; /**< Default cursor type */ int step_enable; /**< True for sqlite_compile/step/finalize */ int trans_disable; /**< True for no transaction support */ int oemcp; /**< True for Win32 OEM CP translation */ struct stmt *cur_s4stmt; /**< Current STMT executing sqlite statement */ int s4stmt_needmeta; /**< True to get meta data in s4stmt_step(). */ FILE *trace; /**< sqlite4_trace() file pointer or NULL */ char *pwd; /**< Password or NULL */ int pwdLen; /**< Length of password */ #ifdef USE_DLOPEN_FOR_GPPS void *instlib; int (*gpps)(); #endif #if defined(_WIN32) || defined(_WIN64) int xcelqrx; #endif } DBC; /** * @typedef COL * @struct COL * Internal structure to describe a column in a result set. */ typedef struct { char *db; /**< Database name */ char *table; /**< Table name */ char *column; /**< Column name */ int type; /**< Data type of column */ int size; /**< Size of column */ int index; /**< Index of column in result */ int nosign; /**< Unsigned type */ int scale; /**< Scale of column */ int prec; /**< Precision of column */ int autoinc; /**< AUTO_INCREMENT column */ int notnull; /**< NOT NULL constraint on column */ char *typename; /**< Column type name or NULL */ char *label; /**< Column label or NULL */ } COL; /** * @typedef BINDCOL * @struct BINDCOL * Internal structure for bound column (SQLBindCol). */ typedef struct { SQLSMALLINT type; /**< ODBC type */ SQLINTEGER max; /**< Max. size of value buffer */ SQLLEN *lenp; /**< Value return, actual size of value buffer */ SQLPOINTER valp; /**< Value buffer */ int index; /**< Index of column in result */ int offs; /**< Byte offset for SQLGetData() */ } BINDCOL; /** * @typedef BINDPARM * @struct BINDPARM * Internal structure for bound parameter (SQLBindParameter). */ typedef struct { int type, stype; /**< ODBC and SQL types */ int coldef, scale; /**< from SQLBindParameter() */ SQLLEN max; /**< Max. size size of parameter buffer */ SQLLEN *lenp; /**< Actual size of parameter buffer */ SQLLEN *lenp0; /**< Actual size of parameter buffer, initial value */ void *param; /**< Parameter buffer */ void *param0; /**< Parameter buffer, initial value */ int inc; /**< Increment for paramset size > 1 */ int need; /**< True when SQL_LEN_DATA_AT_EXEC */ int bound; /**< True when SQLBindParameter() called */ int offs, len; /**< Offset/length for SQLParamData()/SQLPutData() */ void *parbuf; /**< Buffer for SQL_LEN_DATA_AT_EXEC etc. */ char strbuf[64]; /**< String buffer for scalar data */ int s4type; /**< SQLite4 type */ int s4size; /**< SQLite4 size */ void *s4val; /**< SQLite4 value buffer */ int s4ival; /**< SQLite4 integer value */ sqlite4_int64 s4lival; /**< SQLite4 64bit integer value */ double s4dval; /**< SQLite4 float value */ } BINDPARM; /** * @typedef STMT * @struct stmt * Driver internal structure representing SQL statement (HSTMT). */ typedef struct stmt { struct stmt *next; /**< Linkage for STMT list in DBC */ HDBC dbc; /**< Pointer to DBC */ SQLCHAR cursorname[32]; /**< Cursor name */ SQLCHAR *query; /**< Current query, raw string */ int *ov3; /**< True for SQL_OV_ODBC3 */ int *oemcp; /**< True for Win32 OEM CP translation */ int isselect; /**< > 0 if query is a SELECT statement */ int ncols; /**< Number of result columns */ COL *cols; /**< Result column array */ COL *dyncols; /**< Column array, but malloc()ed */ int dcols; /**< Number of entries in dyncols */ int bkmrk; /**< True when bookmarks used */ BINDCOL bkmrkcol; /**< Bookmark bound column */ BINDCOL *bindcols; /**< Array of bound columns */ int nbindcols; /**< Number of entries in bindcols */ int nbindparms; /**< Number bound parameters */ BINDPARM *bindparms; /**< Array of bound parameters */ int nparams; /**< Number of parameters in query */ int pdcount; /**< SQLParamData() counter */ int nrows; /**< Number of result rows */ int rowp; /**< Current result row */ char **rows; /**< 2-dim array, result set */ void (*rowfree)(); /**< Free function for rows */ int naterr; /**< Native error code */ char sqlstate[6]; /**< SQL state for SQLError() */ SQLCHAR logmsg[1024]; /**< Message for SQLError() */ int nowchar[2]; /**< Don't try to use WCHAR */ int dobigint; /**< Force SQL_BIGINT for INTEGER columns */ int longnames; /**< Don't shorten column names */ SQLULEN retr_data; /**< SQL_ATTR_RETRIEVE_DATA */ SQLULEN rowset_size; /**< Size of rowset */ SQLUSMALLINT *row_status; /**< Row status pointer */ SQLUSMALLINT *row_status0; /**< Internal status array */ SQLUSMALLINT row_status1; /**< Internal status array for 1 row rowsets */ SQLULEN *row_count; /**< Row count pointer */ SQLULEN row_count0; /**< Row count */ SQLULEN paramset_size; /**< SQL_ATTR_PARAMSET_SIZE */ SQLULEN paramset_count; /**< Internal for paramset */ SQLUINTEGER paramset_nrows; /**< Row count for paramset handling */ SQLULEN max_rows; /**< SQL_ATTR_MAX_ROWS */ SQLULEN bind_type; /**< SQL_ATTR_ROW_BIND_TYPE */ SQLULEN *bind_offs; /**< SQL_ATTR_ROW_BIND_OFFSET_PTR */ /* Dummies to make ADO happy */ SQLULEN *parm_bind_offs; /**< SQL_ATTR_PARAM_BIND_OFFSET_PTR */ SQLUSMALLINT *parm_oper; /**< SQL_ATTR_PARAM_OPERATION_PTR */ SQLUSMALLINT *parm_status; /**< SQL_ATTR_PARAMS_STATUS_PTR */ SQLULEN *parm_proc; /**< SQL_ATTR_PARAMS_PROCESSED_PTR */ SQLULEN parm_bind_type; /**< SQL_ATTR_PARAM_BIND_TYPE */ int curtype; /**< Cursor type */ sqlite4_stmt *s4stmt; /**< SQLite statement handle or NULL */ int s4stmt_noreset; /**< False when sqlite4_reset() needed. */ int s4stmt_rownum; /**< Current row number */ char *bincell; /**< Cache for blob data */ char *bincache; /**< Cache for blob data */ int binlen; /**< Length of blob data */ int guessed_types; /**< Flag for drvprepare()/drvexecute() */ } STMT; #endif ./sqliteodbc-0.992/sqlite4odbc.rc0100644000076400001440000001444712077537273015322 0ustar chwusers#include #include #include "resource3.h" #include "sqlite4.h" #ifndef SQLITE4_VERSION #define SQLITE4_VERSION "?.?.?" #endif ///////////////////////////////////////////////////////////////////////////// // // Dialog // DRIVERCONNECT DIALOG DISCARDABLE 65, 43, 277, 175 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "SQLite4 ODBC Driver Connect" FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,50,52,15 CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,225,50,52,15 COMBOBOX IDC_SYNCP,82,67,69,52,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Short Column Names",IDC_SHORTNAM,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,65,95,15 CONTROL "Foreign Keys",IDC_FKSUPPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,75,15 CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,95,15 CONTROL "OEMCP Translation",IDC_OEMCP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,95,75,15 CONTROL "Don't Create Database",IDC_NOCREAT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,95,95,15 CONTROL "Always BIGINT",IDC_BIGINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,110,75,15 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,110,52,15 EDITTEXT IDC_LOADEXT,82,130,185,12,ES_AUTOHSCROLL | WS_GROUP DEFPUSHBUTTON "OK",IDOK,175,150,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,150,40,14 CTEXT "Enter options for connect",1003,95,6,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP RTEXT "Sync.Mode:",IDC_SYNCPTEXT,6,69,72,9,NOT WS_GROUP RTEXT "Load Extensions:",IDC_LOADEXTTEXT,6,132,73,9,NOT WS_GROUP END CONFIGDSN DIALOG DISCARDABLE 65, 43, 277, 175 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "SQLite4 ODBC DSN Configuration" FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_DSNAME,82,20,140,12,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_DBNAME,82,36,140,12,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BROWSE,225,35,40,14 EDITTEXT IDC_TONAME,82,51,53,12,ES_AUTOHSCROLL CONTROL "No TXN",IDC_NOTXN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,50,52,15 CONTROL "Step API",IDC_STEPAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,225,50,52,15 COMBOBOX IDC_SYNCP,82,67,69,52,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Short Column Names",IDC_SHORTNAM,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,65,95,15 CONTROL "Foreign Keys",IDC_FKSUPPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,75,15 CONTROL "Long Column Names",IDC_LONGNAM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,80,95,15 CONTROL "OEMCP Translation",IDC_OEMCP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,95,75,15 CONTROL "Don't Create Database",IDC_NOCREAT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,170,95,95,15 CONTROL "Always BIGINT",IDC_BIGINT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,110,75,15 CONTROL "No WCHAR",IDC_NOWCHAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,110,52,15 EDITTEXT IDC_LOADEXT,82,130,185,12,ES_AUTOHSCROLL | WS_GROUP DEFPUSHBUTTON "OK",IDOK,175,150,40,14 PUSHBUTTON "Cancel",IDCANCEL,225,150,40,14 CTEXT "Enter options for connect",1003,95,6,80,8 RTEXT "Data Source Name:",IDC_DSNAMETEXT,6,22,73,9,NOT WS_GROUP RTEXT "Database Name:",IDC_DBNAMETEXT,7,38,71,9,NOT WS_GROUP RTEXT "Lock Timeout [ms]:",IDC_TONAMETEXT,6,53,73,9,NOT WS_GROUP RTEXT "Sync.Mode:",IDC_SYNCPTEXT,6,69,72,9,NOT WS_GROUP RTEXT "Load Extensions:",IDC_LOADEXTTEXT,6,132,73,9,NOT WS_GROUP END ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite4 ODBC Driver\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "SQLITE4ODBC\0" VALUE "LegalCopyright", "Copyright İ 2013 \0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE4ODBC.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite4 " SQLITE4_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN IDS_MSGTITLE "SQLite4 ODBC Setup" IDS_BADDSN "%s cannot be used as a data source name." IDS_EXTTITLE "SQLite4 ODBC Extension" IDS_EXTERR "Extension '%s' did not load:\n%s" IDS_DRVTITLE "SQLite4 ODBC Driver" IDS_DLLERR "No usable SQLite4 DLL found." END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/sqliteodbc.spec0100644000076400001440000000535112126210134015531 0ustar chwusers%define name sqliteodbc %define version 0.992 %define release 1 Name: %{name} Summary: ODBC driver for SQLite Version: %{version} Release: %{release} Source: http://www.ch-werner.de/sqliteodbc/%{name}-%{version}.tar.gz Group: Applications/Databases URL: http://www.ch-werner.de/sqliteodbc License: BSD BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(id -u) %description ODBC driver for SQLite interfacing SQLite 2.x and/or 3.x using the unixODBC or iODBC driver managers. For more information refer to http://www.sqlite.org - SQLite engine http://www.unixodbc.org - unixODBC Driver Manager http://www.iodbc.org - iODBC Driver Manager %prep %setup -q mv configure.in DONT-configure.in # RPM 3.x, don't run libtoolize %build %configure make %install mkdir -p $RPM_BUILD_ROOT%{_libdir} make install DESTDIR=$RPM_BUILD_ROOT rm -f $RPM_BUILD_ROOT%{_libdir}/libsqliteodbc*.{a,la} rm -f $RPM_BUILD_ROOT%{_libdir}/libsqlite3odbc*.{a,la} rm -f $RPM_BUILD_ROOT%{_libdir}/libsqlite3_mod_*.{a,la} %clean rm -rf $RPM_BUILD_ROOT %post if [ -x /usr/bin/odbcinst ] ; then INST=/tmp/sqliteinst$$ if [ -r %{_libdir}/libsqliteodbc.so ] ; then cat > $INST << 'EOD' [SQLITE] Description=SQLite ODBC 2.X Driver=%{_libdir}/libsqliteodbc.so Setup=%{_libdir}/libsqliteodbc.so Threading=2 FileUsage=1 EOD /usr/bin/odbcinst -q -d -n SQLITE | grep '^\[SQLITE\]' >/dev/null || { /usr/bin/odbcinst -i -d -n SQLITE -f $INST || true } cat > $INST << 'EOD' [SQLite Datasource] Driver=SQLITE EOD /usr/bin/odbcinst -q -s -n "SQLite Datasource" | \ grep '^\[SQLite Datasource\]' >/dev/null || { /usr/bin/odbcinst -i -l -s -n "SQLite Datasource" -f $INST || true } fi if [ -r %{_libdir}/libsqlite3odbc.so ] ; then cat > $INST << 'EOD' [SQLITE3] Description=SQLite ODBC 3.X Driver=%{_libdir}/libsqlite3odbc.so Setup=%{_libdir}/libsqlite3odbc.so Threading=2 FileUsage=1 EOD /usr/bin/odbcinst -q -d -n SQLITE3 | grep '^\[SQLITE3\]' >/dev/null || { /usr/bin/odbcinst -i -d -n SQLITE3 -f $INST || true } cat > $INST << 'EOD' [SQLite3 Datasource] Driver=SQLITE3 EOD /usr/bin/odbcinst -q -s -n "SQLite3 Datasource" | \ grep '^\[SQLite3 Datasource\]' >/dev/null || { /usr/bin/odbcinst -i -l -s -n "SQLite3 Datasource" -f $INST || true } fi rm -f $INST || true fi %preun if [ "$1" = "0" ] ; then test -x /usr/bin/odbcinst && { /usr/bin/odbcinst -u -d -n SQLITE || true /usr/bin/odbcinst -u -l -s -n "SQLite Datasource" || true /usr/bin/odbcinst -u -d -n SQLITE3 || true /usr/bin/odbcinst -u -l -s -n "SQLite3 Datasource" || true } true fi %files %defattr(-, root, root) %doc README license.terms ChangeLog %{_libdir}/*.so* %changelog * Mon Apr 01 2013 ... - automatically recreated by configure ... ./sqliteodbc-0.992/sqliteodbc.spec.in0100644000076400001440000000536211543123712016147 0ustar chwusers%define name sqliteodbc %define version @VER_INFO@ %define release 1 Name: %{name} Summary: ODBC driver for SQLite Version: %{version} Release: %{release} Source: http://www.ch-werner.de/sqliteodbc/%{name}-%{version}.tar.gz Group: Applications/Databases URL: http://www.ch-werner.de/sqliteodbc License: BSD BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(id -u) %description ODBC driver for SQLite interfacing SQLite 2.x and/or 3.x using the unixODBC or iODBC driver managers. For more information refer to http://www.sqlite.org - SQLite engine http://www.unixodbc.org - unixODBC Driver Manager http://www.iodbc.org - iODBC Driver Manager %prep %setup -q mv configure.in DONT-configure.in # RPM 3.x, don't run libtoolize %build %configure make %install mkdir -p $RPM_BUILD_ROOT%{_libdir} make install DESTDIR=$RPM_BUILD_ROOT rm -f $RPM_BUILD_ROOT%{_libdir}/libsqliteodbc*.{a,la} rm -f $RPM_BUILD_ROOT%{_libdir}/libsqlite3odbc*.{a,la} rm -f $RPM_BUILD_ROOT%{_libdir}/libsqlite3_mod_*.{a,la} %clean rm -rf $RPM_BUILD_ROOT %post if [ -x /usr/bin/odbcinst ] ; then INST=/tmp/sqliteinst$$ if [ -r %{_libdir}/libsqliteodbc.so ] ; then cat > $INST << 'EOD' [SQLITE] Description=SQLite ODBC 2.X Driver=%{_libdir}/libsqliteodbc.so Setup=%{_libdir}/libsqliteodbc.so Threading=2 FileUsage=1 EOD /usr/bin/odbcinst -q -d -n SQLITE | grep '^\[SQLITE\]' >/dev/null || { /usr/bin/odbcinst -i -d -n SQLITE -f $INST || true } cat > $INST << 'EOD' [SQLite Datasource] Driver=SQLITE EOD /usr/bin/odbcinst -q -s -n "SQLite Datasource" | \ grep '^\[SQLite Datasource\]' >/dev/null || { /usr/bin/odbcinst -i -l -s -n "SQLite Datasource" -f $INST || true } fi if [ -r %{_libdir}/libsqlite3odbc.so ] ; then cat > $INST << 'EOD' [SQLITE3] Description=SQLite ODBC 3.X Driver=%{_libdir}/libsqlite3odbc.so Setup=%{_libdir}/libsqlite3odbc.so Threading=2 FileUsage=1 EOD /usr/bin/odbcinst -q -d -n SQLITE3 | grep '^\[SQLITE3\]' >/dev/null || { /usr/bin/odbcinst -i -d -n SQLITE3 -f $INST || true } cat > $INST << 'EOD' [SQLite3 Datasource] Driver=SQLITE3 EOD /usr/bin/odbcinst -q -s -n "SQLite3 Datasource" | \ grep '^\[SQLite3 Datasource\]' >/dev/null || { /usr/bin/odbcinst -i -l -s -n "SQLite3 Datasource" -f $INST || true } fi rm -f $INST || true fi %preun if [ "$1" = "0" ] ; then test -x /usr/bin/odbcinst && { /usr/bin/odbcinst -u -d -n SQLITE || true /usr/bin/odbcinst -u -l -s -n "SQLite Datasource" || true /usr/bin/odbcinst -u -d -n SQLITE3 || true /usr/bin/odbcinst -u -l -s -n "SQLite3 Datasource" || true } true fi %files %defattr(-, root, root) %doc README license.terms ChangeLog %{_libdir}/*.so* %changelog * @SPEC_CHANGELOG_TS@ ... - automatically recreated by configure ... ./sqliteodbc-0.992/sqlite.mak0100644000076400001440000002104010425331056014517 0ustar chwusers# VC++ 6.0 Makefile for SQLite 2.8.17 #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. TOP = ..\sqlite #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. BCC = cl -Gs -GX -D_WIN32 -nologo -Zi #### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1 # to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 #OPTS = -DMEMORY_DEBUG=2 #OPTS = -DMEMORY_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. EXE = .exe #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. TCC = cl -Gs -GX -D_WIN32 -DOS_WIN=1 -nologo -Zi #### Should the database engine assume text is coded as UTF-8 or iso8859? !IF "$(ENCODING)" != "UTF8" ENCODING = ISO8859 !ENDIF # You should not have to change anything below this line ############################################################################### # This is how we compile TCCX = $(TCC) $(OPTS) -DWIN32=1 -DTHREADSAFE=1 -I. -I$(TOP)/src TCCXD = $(TCCX) -D_DLL # Object files for the SQLite library. LIBOBJ = attach.obj auth.obj btree.obj btree_rb.obj build.obj copy.obj \ date.obj delete.obj expr.obj func.obj hash.obj insert.obj \ main.obj os.obj pager.obj parse.obj pragma.obj printf.obj \ random.obj select.obj \ table.obj tokenize.obj trigger.obj update.obj util.obj \ vacuum.obj vdbe.obj vdbeaux.obj where.obj \ encode.obj opcodes.obj # All of the source code files. SRC = \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/btree.c \ $(TOP)/src/btree.h \ $(TOP)/src/btree_rb.c \ $(TOP)/src/build.c \ $(TOP)/src/copy.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/insert.c \ $(TOP)/src/main.c \ $(TOP)/src/os.c \ $(TOP)/src/pager.c \ $(TOP)/src/pager.h \ $(TOP)/src/parse.y \ $(TOP)/src/pragma.c \ $(TOP)/src/printf.c \ $(TOP)/src/random.c \ $(TOP)/src/select.c \ $(TOP)/src/shell.c \ $(TOP)/src/sqlite.h.in \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/table.c \ $(TOP)/src/func.c \ $(TOP)/src/tclsqlite.c \ $(TOP)/src/tokenize.c \ $(TOP)/src/trigger.c \ $(TOP)/src/update.c \ $(TOP)/src/util.c \ $(TOP)/src/vacuum.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/where.c \ $(TOP)/src/encode.c # Header files used by all library source files. HDR = \ sqlite.h \ $(TOP)/src/btree.h \ config.h \ $(TOP)/src/hash.h \ opcodes.h \ $(TOP)/src/os.h \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/vdbe.h \ parse.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. all: sqlite.h config.h sqlite.dll libsqlite.lib sqlite.exe sqlite.dll: $(LIBOBJ) sqlite.def echo #include "sqlite.h" > version.c echo const char sqlite_version[] = SQLITE_VERSION; >> version.c echo #ifdef SQLITE_UTF8 >> version.c echo const char sqlite_encoding[] = "UTF-8"; >> version.c echo #else >> version.c echo const char sqlite_encoding[] = "iso8859"; >> version.c echo #endif >> version.c $(TCCX) -c version.c link -release -nodefaultlib -dll msvcrt.lib kernel32.lib \ -def:$(TOP)\sqlite.def -out:$@ $(LIBOBJ) lib sqlite.lib version.obj libsqlite.lib: $(LIBOBJ) lib -out:$@ $(LIBOBJ) sqlite.exe: sqlite.dll $(TCCX) -o $@ $(TOP)/src/shell.c sqlite.lib # Rules to build the LEMON compiler generator lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c $(BCC) -o lemon $(TOP)/tool/lemon.c copy $(TOP)\tool\lempar.c . attach.obj: $(TOP)/src/attach.c $(HDR) $(TCCXD) -c $(TOP)/src/attach.c auth.obj: $(TOP)/src/auth.c $(HDR) $(TCCXD) -c $(TOP)/src/auth.c btree.obj: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h $(TCCXD) -c $(TOP)/src/btree.c btree_rb.obj: $(TOP)/src/btree_rb.c $(HDR) $(TCCXD) -c $(TOP)/src/btree_rb.c build.obj: $(TOP)/src/build.c $(HDR) $(TCCXD) -c $(TOP)/src/build.c copy.obj: $(TOP)/src/copy.c $(HDR) $(TCCXD) -c $(TOP)/src/copy.c main.obj: $(TOP)/src/main.c $(HDR) $(TCCXD) -c $(TOP)/src/main.c pager.obj: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h $(TCCXD) -c $(TOP)/src/pager.c pragma.obj: $(TOP)/src/pragma.c $(HDR) $(TCCXD) -c $(TOP)/src/pragma.c os.obj: $(TOP)/src/os.c $(HDR) $(TCCXD) -c $(TOP)/src/os.c parse.obj: parse.c $(HDR) $(TCCXD) -c parse.c parse.h: parse.c parse.c: $(TOP)/src/parse.y lemon copy $(TOP)\src\parse.y . .\lemon parse.y sqlite.h: $(TOP)/src/sqlite.h.in ..\fixup < $(TOP)\src\sqlite.h.in > sqlite.h \ --VERS-- @$(TOP)\VERSION --ENCODING-- $(ENCODING) config.h: echo #include "stdio.h" >temp.c echo int main(){printf( >>temp.c echo "#define SQLITE_PTR_SZ %d\n",sizeof(char*)); >>temp.c echo exit(0);} >>temp.c $(BCC) -o temp temp.c .\temp >config.h @del temp.* opcodes.h: $(TOP)/src/vdbe.c ..\mkopc <$(TOP)/src/vdbe.c tokenize.obj: $(TOP)/src/tokenize.c $(HDR) $(TCCXD) -c $(TOP)/src/tokenize.c util.obj: $(TOP)/src/util.c $(HDR) $(TCCXD) -c $(TOP)/src/util.c vdbe.obj: $(TOP)/src/vdbe.c $(HDR) $(TCCXD) -c $(TOP)/src/vdbe.c vdbeaux.obj: $(TOP)/src/vdbeaux.c $(HDR) $(TCCXD) -c $(TOP)/src/vdbeaux.c where.obj: $(TOP)/src/where.c $(HDR) $(TCCXD) -c $(TOP)/src/where.c date.obj: $(TOP)/src/date.c $(HDR) $(TCCXD) -c $(TOP)/src/date.c delete.obj: $(TOP)/src/delete.c $(HDR) $(TCCXD) -c $(TOP)/src/delete.c expr.obj: $(TOP)/src/expr.c $(HDR) $(TCCXD) -c $(TOP)/src/expr.c hash.obj: $(TOP)/src/hash.c $(HDR) $(TCCXD) -c $(TOP)/src/hash.c insert.obj: $(TOP)/src/insert.c $(HDR) $(TCCXD) -c $(TOP)/src/insert.c random.obj: $(TOP)/src/random.c $(HDR) $(TCCXD) -c $(TOP)/src/random.c select.obj: $(TOP)/src/select.c $(HDR) $(TCCXD) -c $(TOP)/src/select.c table.obj: $(TOP)/src/table.c $(HDR) $(TCCXD) -c $(TOP)/src/table.c func.obj: $(TOP)/src/func.c $(HDR) $(TCCXD) -c $(TOP)/src/func.c update.obj: $(TOP)/src/update.c $(HDR) $(TCCXD) -c $(TOP)/src/update.c printf.obj: $(TOP)/src/printf.c $(HDR) $(TCCXD) -c $(TOP)/src/printf.c encode.obj: $(TOP)/src/encode.c $(HDR) $(TCCXD) -c $(TOP)/src/encode.c trigger.obj: $(TOP)/src/trigger.c $(HDR) $(TCCXD) -c $(TOP)/src/trigger.c opcodes.obj: $(TOP)/opcodes.c $(HDR) $(TCCXD) -c $(TOP)/opcodes.c vacuum.obj: $(TOP)/src/vacuum.c $(HDR) $(TCCXD) -c $(TOP)/src/vacuum.c sqlite.def: sqlite.h echo LIBRARY SQLITE > sqlite.def echo DESCRIPTION 'SQLite Library' >> sqlite.def echo EXPORTS >> sqlite.def echo sqlite_open >> sqlite.def echo sqlite_close >> sqlite.def echo sqlite_exec >> sqlite.def echo sqlite_last_insert_rowid >> sqlite.def echo sqlite_changes >> sqlite.def echo sqlite_error_string >> sqlite.def echo sqlite_interrupt >> sqlite.def echo sqlite_complete >> sqlite.def echo sqlite_busy_handler >> sqlite.def echo sqlite_busy_timeout >> sqlite.def echo sqlite_get_table >> sqlite.def echo sqlite_free_table >> sqlite.def echo sqlite_exec_printf >> sqlite.def echo sqlite_exec_vprintf >> sqlite.def echo sqlite_get_table_printf >> sqlite.def echo sqlite_get_table_vprintf >> sqlite.def echo sqlite_freemem >> sqlite.def echo sqlite_libversion >> sqlite.def echo sqlite_libencoding >> sqlite.def echo sqlite_create_function >> sqlite.def echo sqlite_create_aggregate >> sqlite.def echo sqlite_function_type >> sqlite.def echo sqlite_set_result_string >> sqlite.def echo sqlite_set_result_int >> sqlite.def echo sqlite_set_result_double >> sqlite.def echo sqlite_set_result_error >> sqlite.def echo sqlite_user_data >> sqlite.def echo sqlite_aggregate_context >> sqlite.def echo sqlite_aggregate_count >> sqlite.def echo sqlite_mprintf >> sqlite.def echo sqliteStrICmp >> sqlite.def echo sqlite_set_authorizer >> sqlite.def echo sqlite_trace >> sqlite.def echo sqlite_compile >> sqlite.def echo sqlite_step >> sqlite.def echo sqlite_finalize >> sqlite.def echo sqlite_vmprintf >> sqlite.def echo sqliteOsFileExists >> sqlite.def echo sqliteIsNumber >> sqlite.def echo sqliteStrNICmp >> sqlite.def echo sqlite_encode_binary >> sqlite.def echo sqlite_decode_binary >> sqlite.def clean: del *.obj del *.pdb del *.dll del *.lib del *.exe del sqlite.h del opcodes.h del opcodes.c del config.h del parse.h del parse.c ./sqliteodbc-0.992/sqlite3.mak0100644000076400001440000002024610637475420014622 0ustar chwusers# VC++ 6.0 Makefile for SQLite 3.4.0 #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. TOP = ..\sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. BCC = cl -Gs -GX -D_WIN32 -nologo -Zi #### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1 # to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 #OPTS = -DMEMORY_DEBUG=2 #OPTS = -DMEMORY_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. EXE = .exe #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. TCC = cl -Gs -GX -D_WIN32 -DOS_WIN=1 -nologo -Zi # You should not have to change anything below this line ############################################################################### # This is how we compile TCCX = $(TCC) $(OPTS) -DWIN32=1 -DTHREADSAFE=1 -DOS_WIN=1 \ -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SOUNDEX=1 \ -DSQLITE_OMIT_LOAD_EXTENSION=1 -I. -I$(TOP)/src TCCXD = $(TCCX) -D_DLL # Object files for the SQLite library. LIBOBJ = alter.obj analyze.obj attach.obj auth.obj btree.obj \ build.obj callback.obj complete.obj \ date.obj delete.obj expr.obj func.obj hash.obj insert.obj \ loadext.obj main.obj malloc.obj opcodes.obj os.obj os_win.obj \ pager.obj parse.obj pragma.obj prepare.obj printf.obj random.obj \ select.obj table.obj tokenize.obj trigger.obj update.obj \ util.obj vacuum.obj vdbe.obj vdbeapi.obj vdbeaux.obj vdbeblob.obj \ vdbefifo.obj vdbemem.obj \ where.obj utf.obj legacy.obj vtab.obj # All of the source code files. SRC = \ $(TOP)/src/alter.c \ $(TOP)/src/analyze.c \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/btree.c \ $(TOP)/src/btree.h \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ $(TOP)/src/func.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/insert.c \ $(TOP)/src/legacy.c \ $(TOP)/src/loadext.c \ $(TOP)/src/main.c \ $(TOP)/src/malloc.c \ $(TOP)/src/os.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ $(TOP)/src/pager.h \ $(TOP)/src/parse.y \ $(TOP)/src/pragma.c \ $(TOP)/src/prepare.c \ $(TOP)/src/printf.c \ $(TOP)/src/random.c \ $(TOP)/src/select.c \ $(TOP)/src/shell.c \ $(TOP)/src/sqlite.h.in \ $(TOP)/src/sqlite3ext.h \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/table.c \ $(TOP)/src/tokenize.c \ $(TOP)/src/trigger.c \ $(TOP)/src/utf.c \ $(TOP)/src/update.c \ $(TOP)/src/util.c \ $(TOP)/src/vacuum.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeapi.c \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbeblob.c \ $(TOP)/src/vdbefifo.c \ $(TOP)/src/vdbemem.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/vtab.c \ $(TOP)/src/where.c # Header files used by all library source files. HDR = \ sqlite3.h \ $(TOP)/src/btree.h \ $(TOP)/src/btreeInt.h \ $(TOP)/src/hash.h \ $(TOP)/src/limits.h \ opcodes.h \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ $(TOP)/src/sqlite3ext.h \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/vdbe.h \ parse.h # Header files used by the VDBE submodule VDBEHDR = \ $(HDR) \ $(TOP)/src/vdbeInt.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. all: sqlite3.h config.h sqlite3.dll libsqlite3.lib sqlite3.exe sqlite3.dll: $(LIBOBJ) $(TOP)/sqlite3.def echo #include "sqlite3.h" > version.c echo const char sqlite3_version[] = SQLITE_VERSION; >> version.c $(TCCX) -c version.c link -release -nodefaultlib -dll msvcrt.lib kernel32.lib \ -def:$(TOP)\sqlite3.def -out:$@ $(LIBOBJ) lib sqlite3.lib version.obj libsqlite3.lib: $(LIBOBJ) lib -out:$@ $(LIBOBJ) sqlite3.exe: sqlite3.dll $(TCCX) -o $@ $(TOP)/src/shell.c sqlite3.lib # Rules to build the LEMON compiler generator lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c $(BCC) -o lemon $(TOP)/tool/lemon.c copy $(TOP)\tool\lempar.c . keywordhash.h: $(TOP)/tool/mkkeywordhash.c $(BCC) -o mkkwhash $(OPTS) $(TOP)/tool/mkkeywordhash.c .\mkkwhash > keywordhash.h alter.obj: $(TOP)/src/alter.c $(HDR) $(TCCXD) -c $(TOP)/src/alter.c analyze.obj: $(TOP)/src/analyze.c $(HDR) $(TCCXD) -c $(TOP)/src/analyze.c attach.obj: $(TOP)/src/attach.c $(HDR) $(TCCXD) -c $(TOP)/src/attach.c auth.obj: $(TOP)/src/auth.c $(HDR) $(TCCXD) -c $(TOP)/src/auth.c btree.obj: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h $(TCCXD) -c $(TOP)/src/btree.c build.obj: $(TOP)/src/build.c $(HDR) $(TCCXD) -c $(TOP)/src/build.c callback.obj: $(TOP)/src/callback.c $(HDR) $(TCCXD) -c $(TOP)/src/callback.c complete.obj: $(TOP)/src/complete.c $(HDR) $(TCCXD) -c $(TOP)/src/complete.c date.obj: $(TOP)/src/date.c $(HDR) $(TCCXD) -c $(TOP)/src/date.c delete.obj: $(TOP)/src/delete.c $(HDR) $(TCCXD) -c $(TOP)/src/delete.c expr.obj: $(TOP)/src/expr.c $(HDR) $(TCCXD) -c $(TOP)/src/expr.c func.obj: $(TOP)/src/func.c $(HDR) $(TCCXD) -c $(TOP)/src/func.c hash.obj: $(TOP)/src/hash.c $(HDR) $(TCCXD) -c $(TOP)/src/hash.c insert.obj: $(TOP)/src/insert.c $(HDR) $(TCCXD) -c $(TOP)/src/insert.c legacy.obj: $(TOP)/src/legacy.c $(HDR) $(TCCXD) -c $(TOP)/src/legacy.c loadext.obj: $(TOP)/src/loadext.c $(HDR) $(TCCXD) -c $(TOP)/src/loadext.c main.obj: $(TOP)/src/main.c $(HDR) $(TCCXD) -c $(TOP)/src/main.c malloc.obj: $(TOP)/src/malloc.c $(HDR) $(TCCXD) -c $(TOP)/src/malloc.c pager.obj: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h $(TCCXD) -c $(TOP)/src/pager.c opcodes.obj: opcodes.c $(HDR) $(TCCXD) -c opcodes.c os.obj: $(TOP)/src/os.c $(HDR) $(TCCXD) -c $(TOP)/src/os.c os_win.obj: $(TOP)/src/os_win.c $(HDR) $(TCCXD) -c $(TOP)/src/os_win.c parse.h: parse.c parse.obj: parse.c $(HDR) $(TCCXD) -c parse.c parse.c: $(TOP)/src/parse.y lemon copy $(TOP)\src\parse.y . .\lemon parse.y pragma.obj: $(TOP)/src/pragma.c $(HDR) $(TCCXD) -c $(TOP)/src/pragma.c prepare.obj: $(TOP)/src/prepare.c $(HDR) $(TCCXD) -c $(TOP)/src/prepare.c printf.obj: $(TOP)/src/printf.c $(HDR) $(TCCXD) -c $(TOP)/src/printf.c random.obj: $(TOP)/src/random.c $(HDR) $(TCCXD) -c $(TOP)/src/random.c select.obj: $(TOP)/src/select.c $(HDR) $(TCCXD) -c $(TOP)/src/select.c table.obj: $(TOP)/src/table.c $(HDR) $(TCCXD) -c $(TOP)/src/table.c tokenize.obj: $(TOP)/src/tokenize.c keywordhash.h $(HDR) $(TCCXD) -c $(TOP)/src/tokenize.c trigger.obj: $(TOP)/src/trigger.c $(HDR) $(TCCXD) -c $(TOP)/src/trigger.c update.obj: $(TOP)/src/update.c $(HDR) $(TCCXD) -c $(TOP)/src/update.c utf.obj: $(TOP)/src/utf.c $(HDR) $(TCCXD) -c $(TOP)/src/utf.c util.obj: $(TOP)/src/util.c $(HDR) $(TCCXD) -c $(TOP)/src/util.c vacuum.obj: $(TOP)/src/vacuum.c $(HDR) $(TCCXD) -c $(TOP)/src/vacuum.c vdbe.obj: $(TOP)/src/vdbe.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbe.c vdbeapi.obj: $(TOP)/src/vdbeapi.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbeapi.c vdbeaux.obj: $(TOP)/src/vdbeaux.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbeaux.c vdbeblob.obj: $(TOP)/src/vdbeblob.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbeblob.c vdbefifo.obj: $(TOP)/src/vdbefifo.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbefifo.c vdbemem.obj: $(TOP)/src/vdbemem.c $(VDBEHDR) $(TCCXD) -c $(TOP)/src/vdbemem.c vtab.obj: $(TOP)/src/vtab.c $(HDR) $(TCCXD) -c $(TOP)/src/vtab.c where.obj: $(TOP)/src/where.c $(HDR) $(TCCXD) -c $(TOP)/src/where.c sqlite3.h: $(TOP)/src/sqlite.h.in ..\fixup < $(TOP)\src\sqlite.h.in > sqlite3.h \ --VERS-- @$(TOP)\VERSION \ --VERSION-NUMBER-- @@$(TOP)\VERSION opcodes.h: $(TOP)/src/vdbe.c parse.h ..\mkopc3 <$(TOP)/src/vdbe.c parse.h ..\fixup < opcodes.c > opcodes.new \ sqliteOpcodeNames sqlite3OpcodeNames del opcodes.c ren opcodes.new opcodes.c clean: del *.obj del *.pdb del *.dll del *.lib del *.exe del sqlite3.h del keywordhash.h del opcodes.h del opcodes.c del parse.h del parse.c ./sqliteodbc-0.992/resource.h.in0100644000076400001440000000204211645347104015140 0ustar chwusers#define VERSION "--VERS--" #define VERSION_C --VERS_C-- #define DRIVERCONNECT 104 #define CONFIGDSN 105 #define IDC_DSNAME 400 #define IDC_DSNAMETEXT 401 #define IDC_DBNAME 402 #define IDC_DBNAMETEXT 403 #define IDC_DESC 404 #define IDC_TONAME 405 #define IDC_TONAMETEXT 406 #define IDC_BROWSE 407 #define IDC_STEPAPI 408 #define IDC_NOWCHAR 409 #define IDC_SYNCP 410 #define IDC_SYNCPTEXT 411 #define IDC_NOTXN 412 #define IDC_LONGNAM 413 #define IDC_NOCREAT 414 #define IDC_SHORTNAM 415 #define IDC_LOADEXT 416 #define IDC_LOADEXTTEXT 417 #define IDC_FKSUPPORT 418 #define IDC_OEMCP 419 #define IDC_BIGINT 420 #define IDS_MSGTITLE 500 #define IDS_BADDSN 501 #define IDS_EXTTITLE 502 #define IDS_EXTERR 503 #define IDS_DRVTITLE 504 #define IDS_DLLERR 505 #define IDC_STATIC -1 ./sqliteodbc-0.992/inst.c0100644000076400001440000001730512077540123013660 0ustar chwusers/** * @file inst.c * SQLite ODBC Driver installer/uninstaller for WIN32 * * $Id: inst.c,v 1.19 2013/01/22 16:37:30 chw Exp chw $ * * Copyright (c) 2001-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. */ #include #include #include #include #include #include #include #include #ifdef SEEEXT #define SEESTR " (SEE)" #define SEESTR2 "SEE " #else #define SEEEXT "" #define SEESTR "" #define SEESTR2 "" #endif #define NUMDRVS 4 static char *DriverName[NUMDRVS] = { "SQLite ODBC Driver", "SQLite ODBC (UTF-8) Driver", "SQLite3 ODBC Driver" SEESTR, "SQLite4 ODBC Driver" }; static char *DSName[NUMDRVS] = { "SQLite Datasource", "SQLite UTF-8 Datasource", "SQLite3 " SEESTR2 "Datasource", "SQLite4 Datasource" }; static char *DriverDLL[NUMDRVS] = { "sqliteodbc.dll", "sqliteodbcu.dll", "sqlite3odbc" SEEEXT ".dll", "sqlite4odbc.dll" }; #ifdef WITH_SQLITE_DLLS static char *EngineDLL[NUMDRVS] = { "sqlite.dll", "sqliteu.dll", "sqlite3.dll", "sqlite4.dll" }; #endif static int quiet = 0; static int nosys = 0; /** * Handler for ODBC installation error messages. * @param name name of API function for which to show error messages */ static BOOL ProcessErrorMessages(char *name) { WORD err = 1; DWORD code; char errmsg[301]; WORD errlen, errmax = sizeof (errmsg) - 1; int rc; BOOL ret = FALSE; do { errmsg[0] = '\0'; rc = SQLInstallerError(err, &code, errmsg, errmax, &errlen); if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { MessageBox(NULL, errmsg, name, MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); ret = TRUE; } err++; } while (rc != SQL_NO_DATA); return ret; } /** * Copy or delete SQLite3 module DLLs * @param dllname file name of driver DLL * @param path install directory for modules * @param del flag, when true, delete DLLs in install directory */ static BOOL CopyOrDelModules(char *dllname, char *path, BOOL del) { char firstpat[MAX_PATH]; WIN32_FIND_DATA fdata; HANDLE h; DWORD err; if (strncmp(dllname, "sqlite3", 7)) { return TRUE; } firstpat[0] = '\0'; if (del) { strcpy(firstpat, path); strcat(firstpat, "\\"); } strcat(firstpat, "sqlite3_mod*.dll"); h = FindFirstFile(firstpat, &fdata); if (h == INVALID_HANDLE_VALUE) { return TRUE; } do { if (del) { DeleteFile(fdata.cFileName); } else { char buf[1024]; sprintf(buf, "%s\\%s", path, fdata.cFileName); if (!CopyFile(fdata.cFileName, buf, 0)) { sprintf(buf, "Copy %s to %s failed", fdata.cFileName, path); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); FindClose(h); return FALSE; } } } while (FindNextFile(h, &fdata)); err = GetLastError(); FindClose(h); return err == ERROR_NO_MORE_FILES; } /** * Driver installer/uninstaller. * @param remove true for uninstall * @param drivername print name of driver * @param dllname file name of driver DLL * @param dll2name file name of additional DLL * @param dsname name for data source */ static BOOL InUn(int remove, char *drivername, char *dllname, char *dll2name, char *dsname) { char path[301], driver[300], attr[300], inst[400], inst2[400]; WORD pathmax = sizeof (path) - 1, pathlen; DWORD usecnt, mincnt; if (SQLInstallDriverManager(path, pathmax, &pathlen)) { char *p; sprintf(driver, "%s;Driver=%s;Setup=%s;", drivername, dllname, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } usecnt = 0; SQLInstallDriverEx(driver, NULL, path, pathmax, &pathlen, ODBC_INSTALL_INQUIRY, &usecnt); sprintf(driver, "%s;Driver=%s\\%s;Setup=%s\\%s;", drivername, path, dllname, path, dllname); p = driver; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } sprintf(inst, "%s\\%s", path, dllname); if (dll2name) { sprintf(inst2, "%s\\%s", path, dll2name); } if (!remove && usecnt > 0) { /* first install try: copy over driver dll, keeping DSNs */ if (GetFileAttributes(dllname) != INVALID_FILE_ATTRIBUTES && CopyFile(dllname, inst, 0) && CopyOrDelModules(dllname, path, 0)) { if (dll2name != NULL) { CopyFile(dll2name, inst2, 0); } return TRUE; } } mincnt = remove ? 1 : 0; while (usecnt != mincnt) { if (!SQLRemoveDriver(driver, TRUE, &usecnt)) { break; } } if (remove) { if (!SQLRemoveDriver(driver, TRUE, &usecnt)) { ProcessErrorMessages("SQLRemoveDriver"); return FALSE; } if (!usecnt) { char buf[512]; DeleteFile(inst); /* but keep inst2 */ CopyOrDelModules(dllname, path, 1); if (!quiet) { sprintf(buf, "%s uninstalled.", drivername); MessageBox(NULL, buf, "Info", MB_ICONINFORMATION|MB_OK|MB_TASKMODAL| MB_SETFOREGROUND); } } if (nosys) { goto done; } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); goto done; } if (GetFileAttributes(dllname) == INVALID_FILE_ATTRIBUTES) { return FALSE; } if (!CopyFile(dllname, inst, 0)) { char buf[512]; sprintf(buf, "Copy %s to %s failed", dllname, inst); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); return FALSE; } if (dll2name != NULL && !CopyFile(dll2name, inst2, 0)) { char buf[512]; sprintf(buf, "Copy %s to %s failed", dll2name, inst2); MessageBox(NULL, buf, "CopyFile", MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); /* but go on hoping that an SQLite engine is in place */ } if (!CopyOrDelModules(dllname, path, 0)) { return FALSE; } if (!SQLInstallDriverEx(driver, path, path, pathmax, &pathlen, ODBC_INSTALL_COMPLETE, &usecnt)) { ProcessErrorMessages("SQLInstallDriverEx"); return FALSE; } if (nosys) { goto done; } sprintf(attr, "DSN=%s;Database=sqlite.db;", dsname); p = attr; while (*p) { if (*p == ';') { *p = '\0'; } ++p; } SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr); if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, drivername, attr)) { ProcessErrorMessages("SQLConfigDataSource"); return FALSE; } } else { ProcessErrorMessages("SQLInstallDriverManager"); return FALSE; } done: return TRUE; } /** * Main function of installer/uninstaller. * This is the Win32 GUI main entry point. * It (un)registers the ODBC driver(s) and deletes or * copies the driver DLL(s) to the system folder. */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char path[300], *p; int i, remove; BOOL ret[3]; GetModuleFileName(NULL, path, sizeof (path)); p = path; while (*p) { *p = tolower(*p); ++p; } p = strrchr(path, '\\'); if (p == NULL) { p = path; } else { *p = '\0'; ++p; SetCurrentDirectory(path); } remove = strstr(p, "uninst") != NULL; quiet = strstr(p, "instq") != NULL; nosys = strstr(p, "nosys") != NULL; for (i = 0; i < NUMDRVS; i++) { #ifdef WITH_SQLITE_DLLS p = EngineDLL[i]; #else p = NULL; #endif ret[i] = InUn(remove, DriverName[i], DriverDLL[i], p, DSName[i]); } for (i = 1; i < NUMDRVS; i++) { ret[0] = ret[0] || ret[i]; } if (!remove && ret[0]) { if (!quiet) { MessageBox(NULL, "SQLite ODBC Driver(s) installed.", "Info", MB_ICONINFORMATION|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); } } exit(0); } ./sqliteodbc-0.992/inst.rc0100644000076400001440000000303612064606714014043 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (63) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLiteODBC Driver Installer\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "inst\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "inst.exe\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqlite.ico" ///////////////////////////////////////////////////////////////////////////// // // Manifest // #ifndef RT_MANIFEST #define RT_MANIFEST 24 #endif #ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #endif CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "inst.manifest" ./sqliteodbc-0.992/inst.manifest0100644000076400001440000000063612064621510015237 0ustar chwusers ./sqliteodbc-0.992/install-sh0100755000076400001440000002533211312032604014531 0ustar chwusers#!/bin/sh # install - install a program, script, or datafile scriptversion=2005-11-07.23 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" posix_glob= posix_mkdir= # Symbolic mode for testing mkdir with directories. # It is the same as 755, but also tests that "u+" works. test_mode=u=rwx,g=rx,o=rx,u+wx # Desired mode of installed file. mode=0755 # Desired mode of newly created intermediate directories. # It is empty if not known yet. intermediate_mode= chmodcmd=$chmodprog chowncmd= chgrpcmd= stripcmd= rmcmd="$rmprog -f" mvcmd="$mvprog" src= dst= dir_arg= dstarg= no_target_directory= usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: -c (ignored) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. --help display this help and exit. --version display version info and exit. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test -n "$1"; do case $1 in -c) shift continue;; -d) dir_arg=true shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; --help) echo "$usage"; exit $?;; -m) mode=$2 shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t) dstarg=$2 shift shift continue;; -T) no_target_directory=true shift continue;; --version) echo "$0 $scriptversion"; exit $?;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. test -n "$dir_arg$dstarg" && break # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dstarg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dstarg" shift # fnord fi shift # arg dstarg=$arg done break;; esac done if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi test -n "$dir_arg" || trap '(exit $?); exit' 1 2 13 15 for src do # Protect names starting with `-'. case $src in -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dstarg # Protect names starting with `-'. case $dst in -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dstarg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') posix_mkdir=false if $mkdirprog -m $test_mode -p -- / >/dev/null 2>&1; then posix_mkdir=true else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./-m "$test_mode" ./-p ./-- 2>/dev/null fi ;; esac if $posix_mkdir && { # With -d, create the new directory with the user-specified mode. # Otherwise, create it using the same intermediate mode that # mkdir -p would use when creating intermediate directories. # POSIX says that this mode is "$(umask -S),u+wx", so use that # if umask -S works. if test -n "$dir_arg"; then mkdir_mode=$mode else case $intermediate_mode in '') if umask_S=`(umask -S) 2>/dev/null`; then intermediate_mode=$umask_S,u+wx else intermediate_mode=$test_mode fi ;; esac mkdir_mode=$intermediate_mode fi $mkdirprog -m "$mkdir_mode" -p -- "$dstdir" } then : else # mkdir does not conform to POSIX, or it failed possibly due to # a race condition. Create the directory the slow way, step by # step, checking for races as we go. case $dstdir in /*) pathcomp=/ ;; -*) pathcomp=./ ;; *) pathcomp= ;; esac case $posix_glob in '') if (set -f) 2>/dev/null; then posix_glob=true else posix_glob=false fi ;; esac oIFS=$IFS IFS=/ $posix_glob && set -f set fnord $dstdir shift $posix_glob && set +f IFS=$oIFS for d do test "x$d" = x && continue pathcomp=$pathcomp$d if test ! -d "$pathcomp"; then $mkdirprog "$pathcomp" # Don't fail if two instances are running concurrently. test -d "$pathcomp" || exit 1 fi pathcomp=$pathcomp/ done obsolete_mkdir_used=true fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd "$mode" "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$mode" "$dsttmp"; } && # Now rename the file to the real destination. { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { if test -f "$dst"; then $doit $rmcmd -f "$dst" 2>/dev/null \ || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } } || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: ./sqliteodbc-0.992/Makefile.in0100644000076400001440000001605512121301737014601 0ustar chwusers# Makefile template for SQLite ODBC Driver prefix = @prefix@ exec_prefix = @exec_prefix@ libdir = @libdir@ drvdir = $(libdir)@DRVDIR@ CC = @CC@ INSTALL = @INSTALL@ LIBTOOL = ./libtool CFLAGS= @CFLAGS@ -DDRIVER_VER_INFO=\"@VER_INFO@\" @SQLITE3_A10N_FLAGS@ SQLITE_INC = @SQLITE_INC@ SQLITE_LIB = @SQLITE_LIB@ SQLITE_FLAGS = -DHAVE_LIBVERSION=@SQLITE_LIBVERSION@ \ -DHAVE_ENCDEC=@SQLITE_ENCDEC@ \ -DHAVE_SQLITEATOF=@SQLITE_ATOF@ \ -DHAVE_SQLITEMPRINTF=@SQLITE_MPRINTF@ \ -DHAVE_SQLITETRACE=@SQLITE_TRACE@ SQLITE3_INC = @SQLITE3_INC@ SQLITE3_LIB = @SQLITE3_LIB@ SQLITE3_FLAGS = -DHAVE_SQLITE3COLUMNTABLENAME=@SQLITE3_COLUMNTABLENAME@ \ -DHAVE_SQLITE3LOADEXTENSION=@SQLITE3_LOADEXTENSION@ \ -DHAVE_SQLITE3OVERLOADFUNCTION=@SQLITE3_OVERLOADFUNCTION@ \ -DHAVE_SQLITE3PREPAREV2=@SQLITE3_PREPARE_V2@ \ -DHAVE_SQLITE3CLEARBINDINGS=@SQLITE3_CLEARBINDINGS@ \ -DHAVE_SQLITE3CREATEMODULEV2=@SQLITE3_CREATEMODULE_V2@ \ -DHAVE_SQLITE3VFS=@SQLITE3_VFS@ \ -DHAVE_SQLITE3PROFILE=@SQLITE3_PROFILE@ \ -DHAVE_SQLITE3STRNICMP=@SQLITE3_STRNICMP@ \ -DHAVE_SQLITE3TABLECOLUMNMETADATA=@SQLITE3_TABLECOLUMNMETADATA@ \ @DL_OPTS@ SQLITE3_A10N_C = @SQLITE3_A10N_C@ SQLITE3_A10N_O = @SQLITE3_A10N_O@ SQLITE4_INC = @SQLITE4_INC@ SQLITE4_FLAGS = @SQLITE4_A10N_FLAGS@ @DL_OPTS@ SQLITE4_A10N_C = @SQLITE4_A10N_C@ SQLITE4_A10N_O = @SQLITE4_A10N_O@ ODBC_FLAGS = @ODBC_FLAGS@ ODBC_LIB = @ODBC_LIB@ @LDFLAGS@ VER_INFO = @VER_INFO@ XML2_FLAGS = @XML2_FLAGS@ XML2_LIBS = @XML2_LIBS@ all: @LIB_TARGETS@ libsqliteodbc.la: sqliteodbc.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o libsqliteodbc.la \ sqliteodbc.lo -rpath $(drvdir) $(SQLITE_LIB) \ $(ODBC_LIB) -release $(VER_INFO) libsqlite3odbc.la: sqlite3odbc.lo $(SQLITE3_A10N_O) $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o libsqlite3odbc.la \ sqlite3odbc.lo $(SQLITE3_A10N_O) -rpath $(drvdir) \ $(SQLITE3_LIB) $(ODBC_LIB) -release $(VER_INFO) \ @DL_INITFINI@ libsqlite4odbc.la: sqlite4odbc.lo $(SQLITE4_A10N_O) $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o libsqlite4odbc.la \ sqlite4odbc.lo $(SQLITE4_A10N_O) -rpath $(drvdir) \ $(ODBC_LIB) -release $(VER_INFO) @DL_INITFINI@ libsqlite3_mod_blobtoxy.la: blobtoxy.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) \ -o libsqlite3_mod_blobtoxy.la \ blobtoxy.lo -rpath $(drvdir) -release $(VER_INFO) libsqlite3_mod_impexp.la: impexp.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) \ -o libsqlite3_mod_impexp.la \ impexp.lo -rpath $(drvdir) -release $(VER_INFO) libsqlite3_mod_csvtable.la: csvtable.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) \ -o libsqlite3_mod_csvtable.la \ csvtable.lo -rpath $(drvdir) -release $(VER_INFO) libsqlite3_mod_zipfile.la: zipfile.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) \ -o libsqlite3_mod_zipfile.la \ zipfile.lo -rpath $(drvdir) -release $(VER_INFO) -lz libsqlite3_mod_xpath.la: xpath.lo $(LIBTOOL) --mode=link $(CC) $(CFLAGS) \ -o libsqlite3_mod_xpath.la \ xpath.lo -rpath $(drvdir) -release $(VER_INFO) $(XML2_LIBS) sqliteodbc.lo: sqliteodbc.c sqliteodbc.h $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE_INC) $(ODBC_FLAGS) \ $(SQLITE_FLAGS) sqliteodbc.c sqlite3odbc.lo: sqlite3odbc.c sqlite3odbc.h $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) $(ODBC_FLAGS) \ $(SQLITE3_FLAGS) sqlite3odbc.c sqlite4odbc.lo: sqlite4odbc.c sqlite4odbc.h $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE4_INC) $(ODBC_FLAGS) \ $(SQLITE4_FLAGS) sqlite4odbc.c $(SQLITE3_A10N_O): $(SQLITE3_A10N_C) $(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) $(SQLITE3_A10N_C) $(SQLITE4_A10N_O): $(SQLITE4_A10N_C) $(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) \ @SQLITE4_A10N_FLAGS@ $(SQLITE4_A10N_C) blobtoxy.lo: blobtoxy.c $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) \ $(SQLITE3_FLAGS) blobtoxy.c impexp.lo: impexp.c $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) \ $(SQLITE3_FLAGS) impexp.c csvtable.lo: csvtable.c $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) \ $(SQLITE3_FLAGS) csvtable.c zipfile.lo: zipfile.c $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) \ $(SQLITE3_FLAGS) zipfile.c xpath.lo: xpath.c $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c \ -I$(SQLITE3_INC) \ $(SQLITE3_FLAGS) $(XML2_FLAGS) xpath.c install-2: libsqliteodbc.la $(LIBTOOL) --mode=install $(INSTALL) \ libsqliteodbc.la $(DESTDIR)$(drvdir) drvinst-2: install-2 sh drvdsninst.sh SQLITE "SQLite Datasource" \ libsqliteodbc.la $(drvdir) drvuninst-2: uninstall-2 sh drvdsnuninst.sh SQLITE "SQLite Datasource" uninstall-2: $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/libsqliteodbc.la install-3: libsqlite3odbc.la @EXT_BLOBTOXY@ @EXT_IMPEXP@ \ @EXT_CSVTABLE@ @EXT_ZIPFILE@ @EXT_XPATH@ $(LIBTOOL) --mode=install $(INSTALL) \ libsqlite3odbc.la $(DESTDIR)$(drvdir) test -z "@EXT_BLOBTOXY@" || \ $(LIBTOOL) --mode=install $(INSTALL) \ @EXT_BLOBTOXY@ $(DESTDIR)$(drvdir) test -z "@EXT_IMPEXP@" || \ $(LIBTOOL) --mode=install $(INSTALL) \ @EXT_IMPEXP@ $(DESTDIR)$(drvdir) test -z "@EXT_CSVTABLE@" || \ $(LIBTOOL) --mode=install $(INSTALL) \ @EXT_CSVTABLE@ $(DESTDIR)$(drvdir) test -z "@EXT_ZIPFILE@" || \ $(LIBTOOL) --mode=install $(INSTALL) \ @EXT_ZIPFILE@ $(DESTDIR)$(drvdir) test -z "@EXT_XPATH@" || \ $(LIBTOOL) --mode=install $(INSTALL) \ @EXT_XPATH@ $(DESTDIR)$(drvdir) uninstall-3: $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/libsqlite3odbc.la test -z "@EXT_BLOBTOXY@" || \ $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/@EXT_BLOBTOXY@ test -z "@EXT_IMPEXP@" || \ $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/@EXT_IMPEXP@ test -z "@EXT_CSVTABLE@" || \ $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/@EXT_CSVTABLE@ test -z "@EXT_ZIPFILE@" || \ $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/@EXT_ZIPFILE@ test -z "@EXT_XPATH@" || \ $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/@EXT_XPATH@ drvinst-3: install-3 sh drvdsninst.sh SQLITE3 "SQLite3 Datasource" \ libsqlite3odbc.la $(drvdir) drvuninst-3: uninstall-3 sh drvdsnuninst.sh SQLITE3 "SQLite3 Datasource" install-4: libsqlite4odbc.la $(LIBTOOL) --mode=install $(INSTALL) \ libsqlite4odbc.la $(DESTDIR)$(drvdir) uninstall-4: $(LIBTOOL) --mode=uninstall \ $(RM) $(DESTDIR)$(drvdir)/libsqlite4odbc.la drvinst-4: install-4 sh drvdsninst.sh SQLITE4 "SQLite4 Datasource" \ libsqlite4odbc.la $(drvdir) drvuninst-4: uninstall-4 sh drvdsnuninst.sh SQLITE4 "SQLite4 Datasource" install: @INST_TARGETS@ uninstall: @UNINST_TARGETS@ drvinst: @DRVINST_TARGETS@ drvuninst: @DRVUNINST_TARGETS@ doxy: doxygen doxygen.conf deb: dpkg-buildpackage $(DPKG_BUILD_OPTS) -tc clean: rm -f *.lo *.la libsqliteodbc.la libsqlite3odbc.la *~ core rm -f *.o rm -rf .libs .deps distclean: clean rm -f config.status config.log config.cache Makefile ./sqliteodbc-0.992/configure.in0100644000076400001440000004642012121301614015036 0ustar chwusers########## # Setup # AC_INIT(sqliteodbc.h) AM_PROG_LIBTOOL AC_PROG_INSTALL CC=${CC:-cc} AC_SUBST(CC) AC_SUBST(CFLAGS) VER_INFO=`cat VERSION` ########## # Find SQLite header file and library # AC_ARG_WITH(sqlite, [ --with-sqlite=DIR use SQLite header/lib from DIR], SQLITE_DIR=$withval) if test -n "$SQLITE_DIR" ; then if test ! -d "$SQLITE_DIR" ; then AC_MSG_ERROR(SQLite directory $SQLITE_DIR does not exist) fi fi SQLITE_INC=UNKNOWN SQLITE_LIB=UNKNOWN if test -z "$SQLITE_DIR" ; then if test -r "$includedir/sqlite.h" -a -r "$libdir/libsqlite.la" ; then SQLITE_INC="$includedir" SQLITE_LIB="$libdir/libsqlite.la" SQLITE_LIBDIR="$libdir" SQLITE_DIR="" else SQLITE_DIR="../sqlite /usr /usr/local /opt" fi fi AC_MSG_CHECKING([for SQLite header and library]) for i in $SQLITE_DIR ; do if test -r "$i/sqlite.h" ; then if test -r "$i/libsqlite.la" ; then SQLITE_INC="$i" SQLITE_LIB="$i/libsqlite.la" SQLITE_LIBDIR=$i break fi elif test -r "$i/include/sqlite.h" ; then SQLITE_INC="$i/include" if test -r "$i/lib/libsqlite.la" ; then SQLITE_LIB="$i/lib/libsqlite.la" SQLITE_LIBDIR="$i/lib" break elif test -d "$i/lib" ; then SQLITE_LIB="-lsqlite" SQLITE_LIBDIR="$i/lib" break fi fi done if test "$SQLITE_INC" = "UNKNOWN" -o "$SQLITE_LIB" = "UNKNOWN" ; then AC_MSG_RESULT(no) AC_MSG_WARN([SQLite header files and/or library not found]) else AC_MSG_RESULT(yes) fi AC_SUBST(SQLITE_INC) AC_SUBST(SQLITE_LIB) # test for availability of sqlite_libversion() et.al. if test -n "$SQLITE_LIBDIR" ; then SQLITE_LIBDIR="-L$SQLITE_LIBDIR" fi saved_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$SQLITE_INC" saved_LIBS=$LIBS LIBS="$LIBS $SQLITE_LIBDIR" AC_CHECK_LIB(sqlite,sqlite_libversion,SQLITE_LIBVERSION=1,SQLITE_LIBVERSION=0) AC_CHECK_LIB(sqlite,sqlite_compile,SQLITE_COMPILE=1,SQLITE_COMPILE=0) AC_CHECK_LIB(sqlite,sqlite_encode_binary,SQLITE_ENCDEC=1,SQLITE_ENCDEC=0) AC_CHECK_LIB(sqlite,sqliteAtoF,SQLITE_ATOF=1,SQLITE_ATOF=0) AC_CHECK_LIB(sqlite,sqlite_mprintf,SQLITE_MPRINTF=1,SQLITE_MPRINTF=0) AC_CHECK_LIB(sqlite,sqlite_trace,SQLITE_TRACE=1,SQLITE_TRACE=0) LIBS=$saved_LIBS CFLAGS=$saved_CFLAGS AC_SUBST(SQLITE_LIBVERSION) AC_SUBST(SQLITE_ENCDEC) AC_SUBST(SQLITE_ATOF) AC_SUBST(SQLITE_MPRINTF) AC_SUBST(SQLITE_TRACE) if test "$SQLITE_COMPILE" = "0" ; then AC_MSG_WARN([SQLite library too old, need 2.8.0 or later]) else LIB_TARGETS="$LIB_TARGETS libsqliteodbc.la" INST_TARGETS="$INST_TARGETS install-2" UNINST_TARGETS="$UNINST_TARGETS uninstall-2" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-2" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-2" fi ########## # Find SQLite3 header file and library # AC_ARG_WITH(sqlite3,[ --with-sqlite3=DIR use SQLite3 hdr/lib from DIR], SQLITE3_DIR=$withval) if test -n "$SQLITE3_DIR" ; then if test ! -d "$SQLITE3_DIR" ; then AC_MSG_WARN([SQLite3 directory $SQLITE3_DIR does not exist]) fi fi SQLITE3_INC=UNKNOWN SQLITE3_LIB=UNKNOWN if test -z "$SQLITE3_DIR" ; then if test -r "$includedir/sqlite3.h" -a -r "$libdir/libsqlite3.la" ; then SQLITE3_INC="$includedir" SQLITE3_LIB="$libdir/libsqlite3.la" SQLITE3_LIBDIR="$libdir" SQLITE3_DIR="" else SQLITE3_DIR="../sqlite /usr /usr/local /opt" fi fi AC_MSG_CHECKING([for SQLite3 header and library]) for i in $SQLITE3_DIR ; do if test -r "$i/sqlite3.h" ; then if test -r "$i/sqlite3.c" ; then SQLITE3_INC="$i" SQLITE3_LIB="unknown" SQLITE3_LIBDIR="" SQLITE3_A10N_C="$i/sqlite3.c" SQLITE3_A10N_O="sqlite3.lo" break elif test -r "$i/libsqlite3.la" ; then SQLITE3_INC="$i" SQLITE3_LIB="$i/libsqlite3.la" SQLITE3_LIBDIR=$i break fi elif test -r "$i/include/sqlite3.h" ; then SQLITE3_INC="$i/include" if test -r "$i/lib/libsqlite3.la" ; then SQLITE3_LIB="$i/lib/libsqlite3.la" SQLITE3_LIBDIR="$i/lib" break elif test -d "$i/lib" ; then SQLITE3_LIB="-lsqlite3" SQLITE3_LIBDIR="$i/lib" break fi fi done if test "$SQLITE3_INC" = "UNKNOWN" -o "$SQLITE3_LIB" = "UNKNOWN" ; then AC_MSG_RESULT(no) AC_MSG_WARN([SQLite3 header files and/or library not found]) else AC_MSG_RESULT(yes) LIB_TARGETS="$LIB_TARGETS libsqlite3odbc.la" INST_TARGETS="$INST_TARGETS install-3" UNINST_TARGETS="$UNINST_TARGETS uninstall-3" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-3" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-3" if test -n "$SQLITE3_A10N_C" ; then SQLITE3_LIB="" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_DLL=1 -DSQLITE_SOUNDEX=1" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_THREADSAFE=1" fi fi AC_SUBST(SQLITE3_INC) AC_SUBST(SQLITE3_A10N_C) AC_SUBST(SQLITE3_A10N_FLAGS) # test for availability of some sqlite3_*() funcs if test -n "$SQLITE3_LIBDIR" ; then SQLITE3_LIBDIR="-L$SQLITE3_LIBDIR" fi if test -n "$SQLITE3_A10N_C" ; then SQLITE3_LOADEXTENSION=1 SQLITE3_COLUMNTABLENAME=1 SQLITE3_OVERLOADFUNCTION=1 SQLITE3_PREPARE_V2=1 SQLITE3_CLEARBINDINGS=1 SQLITE3_CREATEMODULE_V2=1 SQLITE3_VFS=1 SQLITE3_TABLECOLUMNMETADATA=1 SQLITE3_PROFILE=1 SQLITE3_STRNICMP=1 else saved_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$SQLITE3_INC" saved_LIBS=$LIBS LIBS="$LIBS $SQLITE3_LIBDIR" AC_CHECK_LIB(sqlite3,sqlite3_load_extension, SQLITE3_LOADEXTENSION=1, SQLITE3_LOADEXTENSION=0) if test "$SQLITE3_LOADEXTENSION" = "0" ; then unset ac_cv_lib_sqlite3_sqlite3_load_extension # try again with -ldl LIBS="$LIBS -ldl $SQLITE3_LIBDIR" AC_CHECK_LIB(sqlite3,sqlite3_load_extension, SQLITE3_LOADEXTENSION=1, SQLITE3_LOADEXTENSION=0) if test "$SQLITE3_LOADEXTENSION" = "1" ; then SQLITE3_LIB="$SQLITE3_LIB -ldl" fi fi AC_CHECK_LIB(sqlite3,sqlite3_column_table_name, SQLITE3_COLUMNTABLENAME=1, SQLITE3_COLUMNTABLENAME=0) AC_CHECK_LIB(sqlite3,sqlite3_overload_function, SQLITE3_OVERLOADFUNCTION=1, SQLITE3_OVERLOADFUNCTION=0) AC_CHECK_LIB(sqlite3,sqlite3_prepare_v2, SQLITE3_PREPARE_V2=1, SQLITE3_PREPARE_V2=0) AC_CHECK_LIB(sqlite3,sqlite3_clear_bindings, SQLITE3_CLEARBINDINGS=1, SQLITE3_CLEARBINDINGS=0) AC_CHECK_LIB(sqlite3,sqlite3_create_module_v2, SQLITE3_CREATEMODULE_V2=1, SQLITE3_CREATEMODULE_V2=0) AC_CHECK_LIB(sqlite3,sqlite3_vfs_register, SQLITE3_VFS=1, SQLITE3_VFS=0) AC_CHECK_LIB(sqlite3,sqlite3_table_column_metadata, SQLITE3_TABLECOLUMNMETADATA=1, SQLITE3_TABLECOLUMNMETADATA=0) AC_CHECK_LIB(sqlite3,sqlite3_profile, SQLITE3_PROFILE=1, SQLITE3_PROFILE=0) AC_CHECK_LIB(sqlite3,sqlite3_strnicmp, SQLITE3_STRNICMP=1, SQLITE3_STRNICMP=0) LIBS=$saved_LIBS CFLAGS=$saved_CFLAGS fi ######### # Find zlib for zipfile module # LIBZ_OK=no if test "$SQLITE3_LOADEXTENSION" = "1" ; then AC_SEARCH_LIBS(zlibVersion,z,[ AC_CHECK_HEADERS(zlib.h,[LIBZ_OK=yes]) ]) fi ######### # Add extensions to build # if test "$SQLITE3_LOADEXTENSION" = "1" ; then EXT_BLOBTOXY=libsqlite3_mod_blobtoxy.la EXT_IMPEXP=libsqlite3_mod_impexp.la EXT_CSVTABLE=libsqlite3_mod_csvtable.la EXT_ZIPFILE="" LIB_TARGETS="$LIB_TARGETS $EXT_BLOBTOXY $EXT_IMPEXP $EXT_CSVTABLE" if test "$LIBZ_OK" = "yes" ; then EXT_ZIPFILE=libsqlite3_mod_zipfile.la LIB_TARGETS="$LIB_TARGETS $EXT_ZIPFILE" fi else EXT_BLOBTOXY="" EXT_IMPEXP="" EXT_CSVTABLE="" EXT_ZIPFILE="" fi AC_SUBST(SQLITE3_COLUMNTABLENAME) AC_SUBST(SQLITE3_OVERLOADFUNCTION) AC_SUBST(SQLITE3_PREPARE_V2) AC_SUBST(SQLITE3_CLEARBINDINGS) AC_SUBST(SQLITE3_CREATEMODULE_V2) AC_SUBST(SQLITE3_LOADEXTENSION) AC_SUBST(SQLITE3_TABLECOLUMNMETADATA) AC_SUBST(SQLITE3_VFS) AC_SUBST(SQLITE3_PROFILE) AC_SUBST(SQLITE3_STRNICMP) AC_SUBST(EXT_BLOBTOXY) AC_SUBST(EXT_IMPEXP) AC_SUBST(EXT_CSVTABLE) AC_SUBST(EXT_ZIPFILE) ########## # Find SQLite4 header file and library # AC_ARG_WITH(sqlite4,[ --with-sqlite4=DIR use SQLite4 hdr/src from DIR], SQLITE4_DIR=$withval) if test -n "$SQLITE4_DIR" ; then if test ! -d "$SQLITE4_DIR" ; then AC_MSG_WARN([SQLite4 directory $SQLITE4_DIR does not exist]) fi fi SQLITE4_INC=UNKNOWN if test -n "$SQLITE4_DIR" ; then AC_MSG_CHECKING([for SQLite4 header and library]) for i in $SQLITE4_DIR ; do if test -r "$i/sqlite4.h" ; then if test -r "$i/sqlite4.c" ; then SQLITE4_INC="$i" SQLITE4_A10N_C="$i/sqlite4.c" SQLITE4_A10N_O="sqlite4.lo" break fi fi done fi if test "$SQLITE4_INC" = "UNKNOWN" ; then AC_MSG_RESULT(no) AC_MSG_WARN([SQLite4 header file and source not found]) else AC_MSG_RESULT(yes) LIB_TARGETS="$LIB_TARGETS libsqlite4odbc.la" INST_TARGETS="$INST_TARGETS install-4" UNINST_TARGETS="$UNINST_TARGETS uninstall-4" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-4" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-4" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_ENABLE_COLUMN_METADATA=1" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_SOUNDEX=1" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_THREADSAFE=1" fi AC_SUBST(SQLITE4_INC) AC_SUBST(SQLITE4_A10N_C) AC_SUBST(SQLITE4_A10N_FLAGS) ######### # libxml2 support for XPath virtual table module XML2_FLAGS="" XML2_LIBS="" EXT_XPATH="" if test "$SQLITE3_LOADEXTENSION" = "1" ; then AC_MSG_CHECKING([for libxml2 header and library]) XML2_CONFIG="`which xml2-config 2>/dev/null`" if test -n "$XML2_CONFIG" ; then XML2_FLAGS="`xml2-config --cflags`" XML2_LIBS="`xml2-config --libs`" EXT_XPATH=libsqlite3_mod_xpath.la LIB_TARGETS="$LIB_TARGETS $EXT_XPATH" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi fi AC_SUBST(XML2_FLAGS) AC_SUBST(XML2_LIBS) AC_SUBST(EXT_XPATH) ######### # Any SQLite to be done ? if test "X$LIB_TARGETS" = "X" ; then AC_MSG_ERROR([No usable SQLite header/library on this system]) fi AC_SUBST(LIB_TARGETS) AC_SUBST(INST_TARGETS) AC_SUBST(UNINST_TARGETS) AC_SUBST(DRVINST_TARGETS) AC_SUBST(DRVUNINST_TARGETS) ######### # Find ODBC headers and libraries # AC_ARG_WITH(odbc, [ --with-odbc=DIR use ODBC header/libs from DIR], ODBC_DIR=$withval) if test -n "$ODBC_DIR" ; then if test ! -d "$ODBC_DIR" ; then AC_MSG_ERROR([ODBC directory $ODBC_DIR does not exist]) fi fi ODBC_FLAGS=UNKNOWN ODBC_LIB=UNKNOWN if test -z "$ODBC_DIR" ; then if test -r "$includedir/sql.h" -a -r "$includedir/iodbcinst.h" -a -r "$libdir/libiodbcinst.la" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$includedir" ODBC_LIB="$libdir/libiodbcinst.la" ODBC_DIR="" elif test -r "$includedir/iodbc/sql.h" -a -r "$includedir/iodbc/iodbcinst.h" -a -r "$libdir/libiodbcinst.la" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$includedir/iodbc" ODBC_LIB="$libdir/libiodbcinst.la" ODBC_DIR="" elif test -r "$includedir/sql.h" -a -r "$includedir/odbcinst.h" -a -r "$libdir/libodbcinst.la" ; then ODBC_FLAGS="-DHAVE_UNIXODBC=1 -I$includedir" ODBC_LIB="$libdir/libodbcinst.la" if test -r "$includedir/odbcinstext.h" ; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_ODBCINSTEXT_H=1 -Imissing" fi else ODBC_DIR="/usr /usr/local /opt" fi fi AC_MSG_CHECKING([for ODBC headers and libraries]) for i in $ODBC_DIR ; do if test -r "$i/include/iodbc/sql.h" -o -r "$i/include/sql.h" ; then if test -r "$i/include/iodbc/iodbcinst.h" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$i/include/iodbc" if test -r "$i/lib/libiodbcinst.la" ; then ODBC_LIB="$i/lib/libiodbcinst.la" else ODBC_LIB=-liodbcinst fi break elif test -r "$i/include/iodbcinst.h" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$i/include" if test -r "$i/lib/libiodbcinst.la" ; then ODBC_LIB="$i/lib/libiodbcinst.la" else ODBC_LIB=-liodbcinst fi break elif test -r "$i/include/odbcinst.h" ; then ODBC_FLAGS="-DHAVE_UNIXODBC=1 -I$i/include" if test -r "$i/lib/libodbcinst.la" ; then ODBC_LIB="$i/lib/libodbcinst.la" else ODBC_LIB=-lodbcinst fi if test -r "$i/include/odbcinstext.h" ; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_ODBCINSTEXT_H=1" if test -r "$i/include/log.h" -a -r "$i/include/ini.h" ; then : no need for replacements else ODBC_FLAGS="$ODBC_FLAGS -Imissing" fi fi break fi fi done if test "$ODBC_FLAGS" = "UNKNOWN" -o "$ODBC_LIB" = "UNKNOWN" ; then AC_MSG_RESULT(no) AC_MSG_ERROR([ODBC header files and/or libraries not found]) else AC_MSG_RESULT(yes) fi ########## # Test ODBC features. # SAVED_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ODBC_FLAGS" AC_MSG_CHECKING([for SQLLEN availability]) AC_TRY_COMPILE([ #include #include ],[SQLLEN len = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLLEN=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLULEN availability]) AC_TRY_COMPILE([ #include #include ],[SQLULEN len = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLULEN=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLROWCOUNT availability]) AC_TRY_COMPILE([ #include #include ],[SQLROWCOUNT rc = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWCOUNT=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLSETPOSIROW availability]) AC_TRY_COMPILE([ #include #include ],[SQLSETPOSIROW rc = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLSETPOSIROW=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLROWOFFSET availability]) AC_TRY_COMPILE([ #include #include ],[SQLROWOFFSET rc = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWOFFSET=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLROWSETSIZE availability]) AC_TRY_COMPILE([ #include #include ],[SQLROWSETSIZE rc = 1;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWSETSIZE=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLColAttribute signature has SQLLEN]) AC_TRY_COMPILE([ #include #define ODBCVER 0x0300 #include #include #include ],[ SQLHSTMT stmt = SQL_NULL_HSTMT; SQLSMALLINT valLen; SQLLEN val2; extern SQLRETURN SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER charattr, SQLSMALLINT buflen, SQLSMALLINT *slen, SQLLEN *numattr); SQLColAttribute(stmt, 1, 0, NULL, 0, &valLen, &val2); ],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DCOLATTRIBUTE_LAST_ARG_TYPE=SQLLEN_PTR" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLSetStmtOption signature has SQLULEN]) AC_TRY_COMPILE([ #include #define ODBCVER 0x0300 #include #include #include ],[ SQLHSTMT stmt = SQL_NULL_HSTMT; extern SQLRETURN SQLSetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT option, SQLULEN value); SQLSetStmtOption(stmt, 1, 2); ],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DSETSTMTOPTION_LAST_ARG_TYPE=SQLULEN" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLWCHAR availability]) AC_TRY_COMPILE([ #include #include ],[SQLWCHAR thisiswchar;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLWCHAR=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for SQLBIGINT availability]) AC_TRY_COMPILE([ #include #include ],[SQLBIGINT thisisbig;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LONG_LONG=1" ],[AC_MSG_RESULT(no)]) AC_MSG_CHECKING([for ptrdiff_t availability]) AC_TRY_COMPILE([ #include #include ],[ptrdiff_t apdt = 0;],[ AC_MSG_RESULT(yes) ODBC_FLAGS="$ODBC_FLAGS -DPTRDIFF_T=ptrdiff_t" ],[ AC_MSG_RESULT(no) ODBC_FLAGS="$ODBC_FLAGS -DPTRDIFF_T=int" ]) CFLAGS="$SAVED_CFLAGS" ########## # Experimental: dlopen for resolving SQLGetPrivateProfileString dynamically # AC_CHECK_LIB(dl,dlopen,DLOPENFORGPPS=1,DLOPENFORGPPS=0) if test "$DLOPENFORGPPS" = "1" ; then AC_MSG_CHECKING([for SQLGetPrivateProfileString via dlopen]) saved_LIBS=$LIBS LIBS="$LIBS -ldl" AC_TRY_RUN([ #include int main(int argc, char **argv) { void *lib; int (*gpps)(); lib = dlopen("libodbcinst.so", RTLD_LAZY); if (!lib) { lib = dlopen("libiodbcinst.so", RTLD_LAZY); } if (lib) { gpps = (int (*)()) dlsym(lib, "SQLGetPrivateProfileString"); exit(0); } exit(1); } ],[ ODBC_FLAGS="$ODBC_FLAGS -DUSE_DLOPEN_FOR_GPPS" ODBC_LIB="-ldl" AC_MSG_RESULT(yes) ],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)]) LIBS=$saved_LIBS fi AC_SUBST(ODBC_FLAGS) AC_SUBST(ODBC_LIB) AC_SUBST(VER_INFO) ########## # Find out if char ptr array can be passed in place of # a va_list (needed for sqlite_exec_vprintf() and # sqlite_vmprintf()) # AC_MSG_CHECKING([va_list usage]) AC_TRY_RUN([ #include #include static int vatest(char **x, ...) { va_list ap; char *y; int ret; va_start(ap, x); y = va_arg(ap, char *); x = (char **) &x + 1; ret = (y != *x); va_end(ap); return ret; } int main(int argc, char **argv) { exit(vatest(NULL, vatest, 0.0, 0, NULL)); } ],[USE_VFUNCS=1],[USE_VFUNCS=0],[USE_VFUNCS=0]) if test "$USE_VFUNCS" = "1" ; then AC_MSG_RESULT(using sqlite_exec_vprintf/sqlite_vmprintf) else AC_MSG_RESULT(NOT using sqlite_exec_vprintf/sqlite_vmprintf) ODBC_FLAGS="$ODBC_FLAGS -DCANT_PASS_VALIST_AS_CHARPTR=1" fi ########## # Check for usleep() and nanosleep() # AC_CHECK_FUNC(usleep, [ODBC_FLAGS="$ODBC_FLAGS -DHAVE_USLEEP=1"]) AC_CHECK_FUNC(nanosleep, [ODBC_FLAGS="$ODBC_FLAGS -DHAVE_NANOSLEEP=1"]) ########## # Check for localeconv() # AC_CHECK_FUNC(localeconv, [ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LOCALECONV=1"]) ########## # Check for localtime_r() # AC_CHECK_FUNC(localtime_r, [ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LOCALTIME_R=1"]) ########## # Check for gmtime_r() # AC_CHECK_FUNC(gmtime_r, [ODBC_FLAGS="$ODBC_FLAGS -DHAVE_GMTIME_R=1"]) ########## # Allow omission of SQL*W() functions for SQLITE_UTF8 encoding # AC_ARG_ENABLE(winterface, [ --enable-winterface make SQL*W() functions], [ test $enable_winterface = "no" && ODBC_FLAGS="$ODBC_FLAGS -DWITHOUT_WINTERFACE=1" ], [ ODBC_FLAGS="$ODBC_FLAGS -DWITHOUT_WINTERFACE=1" ]) ######### # Install directory (on Debian $libdir/odbc) if test -r /etc/debian_version ; then DRVDIR="/odbc" else DRVDIR="" fi AC_SUBST(DRVDIR) ########## # Experimental: dlopen for resolving SQLite3/SQLite4 symbols # AC_ARG_WITH(dls,[ --with-dls dlopen SQLite3/SQLite4 lib], WITH_DLS=1,WITH_DLS=0) if test "$DLOPENFORGPPS" = "1" ; then if test "$WITH_DLS" = "1" ; then DL_OPTS="-DSQLITE_DYNLOAD=1" SQLITE3_LIB="" SQLITE3_A10N_O="" SQLITE4_A10N_O="" DL_INITFINI="-Wl,-init,dls_init -Wl,-fini,dls_fini" fi fi AC_SUBST(DL_OPTS) AC_SUBST(DL_INITFINI) AC_SUBST(SQLITE3_LIB) AC_SUBST(SQLITE3_A10N_O) AC_SUBST(SQLITE4_A10N_O) ######### # Generate the output files. # SPEC_CHANGELOG_TS=`LANG=C date -u "+%a %b %d %Y"` DEB_CHANGELOG_TS=`LANG=C date "+%a, %d %b %Y %X %z"` AC_SUBST(SPEC_CHANGELOG_TS) AC_SUBST(DEB_CHANGELOG_TS) AC_OUTPUT(Makefile sqliteodbc.spec debian/changelog) ./sqliteodbc-0.992/config.guess0100755000076400001440000012206511312032604015046 0ustar chwusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-06-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown ## for Red Hat Linux if test -f /etc/redhat-release ; then VENDOR=redhat ; else VENDOR= ; fi # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha*:OpenVMS:*:*) echo alpha-hp-vms exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) # Determine whether the default compiler uses glibc. eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #if __GLIBC__ >= 2 LIBC=gnu #else LIBC= #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:[34]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-${VENDOR:-unknown}-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-${VENDOR:-unknown}-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-${VENDOR:-unknown}-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-${VENDOR:-ibm}-linux-gnu exit 0 ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-${VENDOR:-unknown}-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-${VENDOR:-pc}-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) case `uname -p` in *86) UNAME_PROCESSOR=i686 ;; powerpc) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ./sqliteodbc-0.992/config.sub0100755000076400001440000007305511312032604014515 0ustar chwusers#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-06-18' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | s390 | s390x \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | msp430-* \ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | s390-* | s390x-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nv1) basic_machine=nv1-cray os=-unicosmp ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ./sqliteodbc-0.992/ltmain.sh0100644000076400001440000060342611312032604014353 0ustar chwusers# ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. basename="s,^.*/,,g" # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" # The name of this program: progname=`echo "$progpath" | $SED $basename` modename="$progname" # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 PROGRAM=ltmain.sh PACKAGE=libtool VERSION=1.5.22 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi # Check that we have a working $echo. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell, and then maybe $echo will work. exec $SHELL "$progpath" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE fi # Global variables. mode=$default_mode nonopt= prev= prevopt= run= show="$echo" show_help= execute_dlfiles= duplicate_deps=no preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 ##################################### # Shell function definitions: # This seems to be the best place for them # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $mkdir "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || { $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 exit $EXIT_FAILURE } fi $echo "X$my_tmpdir" | $Xsed } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. func_win32_libid () { win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | \ $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $echo $win32_libid_type } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done case "$@ " in " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then $echo "$modename: unable to infer tagged configuration" $echo "$modename: specify a tag with \`--tag'" 1>&2 exit $EXIT_FAILURE # else # $echo "$modename: using $tagname tagged configuration" fi ;; esac fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 exit $EXIT_FAILURE fi } # func_extract_archives gentop oldlib ... func_extract_archives () { my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" my_status="" $show "${rm}r $my_gentop" $run ${rm}r "$my_gentop" $show "$mkdir $my_gentop" $run $mkdir "$my_gentop" my_status=$? if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then exit $my_status fi for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) extracted_serial=`expr $extracted_serial + 1` my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" $show "${rm}r $my_xdir" $run ${rm}r "$my_xdir" $show "$mkdir $my_xdir" $run $mkdir "$my_xdir" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then exit $exit_status fi case $host in *-darwin*) $show "Extracting $my_xabs" # Do not bother doing anything if just a dry run if test -z "$run"; then darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` if test -n "$darwin_arches"; then darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= $show "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we have a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` lipo -create -output "$darwin_file" $darwin_files done # $darwin_filelist ${rm}r unfat-$$ cd "$darwin_orig_dir" else cd "$darwin_orig_dir" func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches fi # $run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # End of Shell function definitions ##################################### # Darwin sucks eval std_shrext=\"$shrext_cmds\" disable_libs=no # Parse our command line options once, thoroughly. while test "$#" -gt 0 do arg="$1" shift case $arg in -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; tag) tagname="$arg" preserve_args="${preserve_args}=$arg" # Check whether tagname contains only valid characters case $tagname in *[!-_A-Za-z0-9,/]*) $echo "$progname: invalid tag name: $tagname" 1>&2 exit $EXIT_FAILURE ;; esac case $tagname in CC) # Don't test for the "default" C tag, as we know, it's there, but # not specially marked. ;; *) if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then taglist="$taglist $tagname" # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" else $echo "$progname: ignoring unknown tag $tagname" 1>&2 fi ;; esac ;; *) eval "$prev=\$arg" ;; esac prev= prevopt= continue fi # Have we seen a non-optional argument yet? case $arg in --help) show_help=yes ;; --version) $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" $echo $echo "Copyright (C) 2005 Free Software Foundation, Inc." $echo "This is free software; see the source for copying conditions. There is NO" $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." exit $? ;; --config) ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath # Now print the configurations for the tags. for tagname in $taglist; do ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" done exit $? ;; --debug) $echo "$progname: enabling shell trace mode" set -x preserve_args="$preserve_args $arg" ;; --dry-run | -n) run=: ;; --features) $echo "host: $host" if test "$build_libtool_libs" = yes; then $echo "enable shared libraries" else $echo "disable shared libraries" fi if test "$build_old_libs" = yes; then $echo "enable static libraries" else $echo "disable static libraries" fi exit $? ;; --finish) mode="finish" ;; --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; --preserve-dup-deps) duplicate_deps="yes" ;; --quiet | --silent) show=: preserve_args="$preserve_args $arg" ;; --tag) prevopt="--tag" prev=tag preserve_args="$preserve_args --tag" ;; --tag=*) set tag "$optarg" ${1+"$@"} shift prev=tag preserve_args="$preserve_args --tag" ;; -dlopen) prevopt="-dlopen" prev=execute_dlfiles ;; -*) $echo "$modename: unrecognized option \`$arg'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *) nonopt="$arg" break ;; esac done if test -n "$prevopt"; then $echo "$modename: option \`$prevopt' requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi case $disable_libs in no) ;; shared) build_libtool_libs=no build_old_libs=yes ;; static) build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` ;; esac # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 case $nonopt in *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) mode=link for arg do case $arg in -c) mode=compile break ;; esac done ;; *db | *dbx | *strace | *truss) mode=execute ;; *install*|cp|mv) mode=install ;; *rm) mode=uninstall ;; *) # If we have no mode, but dlfiles were specified, then do execute mode. test -n "$execute_dlfiles" && mode=execute # Just use the default operation mode. if test -z "$mode"; then if test -n "$nonopt"; then $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 else $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 fi fi ;; esac fi # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then $echo "$modename: unrecognized option \`-dlopen'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$modename --help --mode=$mode' for more information." # These modes are in order of execution frequency so that they run quickly. case $mode in # libtool compile mode compile) modename="$modename: compile" # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) if test -n "$libobj" ; then $echo "$modename: you cannot specify \`-o' more than once" 1>&2 exit $EXIT_FAILURE fi arg_mode=target continue ;; -static | -prefer-pic | -prefer-non-pic) later="$later $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac lastarg="$lastarg $arg" done IFS="$save_ifs" lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` # Add the arguments to base_compile. base_compile="$base_compile $lastarg" continue ;; * ) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` case $lastarg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, and some SunOS ksh mistreat backslash-escaping # in scan sets (worked around with variable expansion), # and furthermore cannot handle '|' '&' '(' ')' in scan sets # at all, so we specify them separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac base_compile="$base_compile $lastarg" done # for arg case $arg_mode in arg) $echo "$modename: you must specify an argument for -Xcompile" exit $EXIT_FAILURE ;; target) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit $EXIT_FAILURE ;; *) # Get the name of the library object. [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo xform='[cCFSifmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; *.ads) xform=ads ;; *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.ii) xform=ii ;; *.class) xform=class ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; *.java) xform=java ;; *.obj) xform=obj ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` case $libobj in *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; *) $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 exit $EXIT_FAILURE ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -static) build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` case $qlibobj in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qlibobj="\"$qlibobj\"" ;; esac test "X$libobj" != "X$qlibobj" \ && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir= else xdir=$xdir/ fi lobj=${xdir}$objdir/$objname if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi $run $rm $removelist trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $run ln "$progpath" "$lockfile" 2>/dev/null; do $show "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi $echo "$srcfile" > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` case $qsrcfile in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qsrcfile="\"$qsrcfile\"" ;; esac $run $rm "$libobj" "${libobj}T" # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then $show "$mv $output_obj $lobj" if $run $mv $output_obj $lobj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the PIC object to the libtool object file. test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the non-PIC object the libtool object file. # Only append if the libtool object file exists. test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test ;; *) qarg=$arg ;; esac libtool_args="$libtool_args $qarg" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit $EXIT_FAILURE fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat $save_arg` do # moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$libobjs $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object non_pic_objects="$non_pic_objects $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi done else $echo "$modename: link input file \`$save_arg' does not exist" exit $EXIT_FAILURE fi arg=$save_arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= compile_command="$compile_command $wl$qarg" finalize_command="$finalize_command $wl$qarg" continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; shrext) shrext_cmds="$arg" prev= continue ;; darwin_framework|darwin_framework_skip) test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" prev= continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: more than one -exported-symbols argument is not allowed" exit $EXIT_FAILURE fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework|-arch|-isysroot) case " $CC " in *" ${arg} ${1} "* | *" ${arg} ${1} "*) prev=darwin_framework_skip ;; *) compiler_flags="$compiler_flags $arg" prev=darwin_framework ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; esac continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" notinst_path="$notinst_path $dir" fi dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework deplibs="$deplibs -framework System" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. -model) compile_command="$compile_command $arg" compiler_flags="$compiler_flags $arg" finalize_command="$finalize_command $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" continue ;; -module) module=yes continue ;; # -64, -mips[0-9] enable 64-bit mode on the SGI compiler # -r[0-9][0-9]* specifies the processor on the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler # +DA*, +DD* enable 64-bit mode on the HP compiler # -q* pass through compiler args for the IBM compiler # -m* pass through architecture-specific compiler args for GCC # -m*, -t[45]*, -txscale* pass through architecture-specific # compiler args for GCC # -pg pass through profiling flag for GCC # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ -t[45]*|-txscale*|@*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" compiler_flags="$compiler_flags $arg" continue ;; -shrext) prev=shrext continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # The PATH hackery in wrapper scripts is required on Windows # in order for the loader to find any dlls it needs. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Wl,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $wl$flag" linker_flags="$linker_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; *.$objext) # A standard object. objs="$objs $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$libobjs $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object non_pic_objects="$non_pic_objects $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi oldlibs= # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` if test "X$output_objdir" = "X$output"; then output_objdir="$objdir" else output_objdir="$output_objdir/$objdir" fi # Create the object directory. if test ! -d "$output_objdir"; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then exit $exit_status fi fi # Determine the type of output case $output in "") $echo "$modename: you must specify an output file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac case $host in *cygwin* | *mingw* | *pw32*) # don't eliminate duplications in $postdeps and $predeps duplicate_compiler_generated_deps=yes ;; *) duplicate_compiler_generated_deps=$duplicate_deps ;; esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if test "X$duplicate_deps" = "Xyes" ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$pre_post_deps $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries case $linkmode in lib) passes="conv link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 exit $EXIT_FAILURE ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 continue fi name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then library_names= old_library= case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; *) $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` if eval $echo \"$deplib\" 2>/dev/null \ | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then $echo $echo "*** Warning: Trying to link with static lib archive $deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because the file extensions .$libext of this argument makes me believe" $echo "*** that it is just a static archive that I should not used here." else $echo $echo "*** Warning: Linking the shared library $output against the" $echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 exit $EXIT_FAILURE fi # Check to see that this really is a libtool archive. if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." dlname= dlopen= dlpreopen= libdir= library_names= old_library= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit $EXIT_FAILURE fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 abs_ladir="$ladir" fi ;; esac laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then $echo "$modename: warning: library \`$lib' was moved." 1>&2 dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; *) temp_rpath="$temp_rpath $absdir" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes ; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi # This is a shared library # Warn about portability, can't link against -module's on # some systems (darwin) if test "$shouldnotlink" = yes && test "$pass" = link ; then $echo if test "$linkmode" = prog; then $echo "*** Warning: Linking the executable $output against the loadable module" else $echo "*** Warning: Linking the shared library $output against the loadable module" fi $echo "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names realname="$2" shift; shift libname=`eval \\$echo \"$libname_spec\"` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw*) major=`expr $current - $age` versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" soname=`$echo $soroot | ${SED} -e 's/^.*\///'` newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$extract_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$old_archive_from_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a module then we can not link against # it, someone is ignoring the new warnings I added if /usr/bin/file -L $add 2> /dev/null | $EGREP ": [^:]* bundle" >/dev/null ; then $echo "** Warning, lib $linklib is a module, not a shared library" if test -z "$old_library" ; then $echo $echo "** And there doesn't seem to be a static archive available" $echo "** The link will probably fail, sorry" else add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then $echo "$modename: configuration error: unsupported hardcode properties" exit $EXIT_FAILURE fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && \ test "$hardcode_minus_L" != yes && \ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. $echo $echo "*** Warning: This system can not link to static lib archive $lib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then $echo "*** But as you try to build a module library, libtool will still create " $echo "*** a static module, that should work as long as the dlopening application" $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then $echo $echo "*** However, this would only work if libtool was able to extract symbol" $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" $echo "*** not find such a program. So, this module is probably useless." $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$deplib" && dir="." # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" fi ;; esac if grep "^installed=no" $deplib > /dev/null; then path="$absdir/$objdir" else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi path="$absdir" fi depdepl= case $host in *-*-darwin*) # we do not want to link against static libs, # but need to link against shared eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$path/$depdepl" ; then depdepl="$path/$depdepl" fi # do not add paths which are already there case " $newlib_search_path " in *" $path "*) ;; *) newlib_search_path="$newlib_search_path $path";; esac fi path="" ;; *) path="-L$path" ;; esac ;; -l*) case $host in *-*-darwin*) # Again, we only want to link against shared libraries eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` for tmp in $newlib_search_path ; do if test -f "$tmp/lib$tmp_libs.dylib" ; then eval depdepl="$tmp/lib$tmp_libs.dylib" break fi done path="" ;; *) continue ;; esac ;; *) continue ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac case " $deplibs " in *" $depdepl "*) ;; *) deplibs="$depdepl $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 fi if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 fi # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) if test "$module" = no; then $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit $EXIT_FAILURE else $echo $echo "*** Warning: Linking the shared library $output against the non-libtool" $echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi if test "$dlself" != no; then $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 fi set dummy $rpath if test "$#" -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 fi else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 IFS="$save_ifs" if test -n "$8"; then $echo "$modename: too many parameters to \`-version-info'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$2" number_minor="$3" number_revision="$4" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) current=`expr $number_major + $number_minor` age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) current=`expr $number_major + $number_minor - 1` age="$number_minor" revision="$number_minor" ;; esac ;; no) current="$2" revision="$3" age="$4" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac if test "$age" -gt "$current"; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header major=.`expr $current - $age` versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current"; ;; irix | nonstopux) major=`expr $current - $age + 1` case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" ;; osf) major=.`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. major=`expr $current - $age` versuffix="-$major" ;; *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi if test "$mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$echo "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi removelist="$removelist $p" ;; *) ;; esac done if test -n "$removelist"; then $show "${rm}r $removelist" $run ${rm}r $removelist fi fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. # for path in $notinst_path; do # lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` # deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` # dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` # done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $rm conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ | ${SED} 10q \ | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $echo $echo "*** Warning: linker path does not have real file for library $a_deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $echo "*** with $libname but no candidates were found. (...for file magic test)" else $echo "*** with $libname and none of the candidates passed a file format test" $echo "*** using a file magic. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval $echo \"$potent_lib\" 2>/dev/null \ | ${SED} 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $echo $echo "*** Warning: linker path does not have real file for library $a_deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $echo "*** with $libname but no candidates were found. (...for regex pattern test)" else $echo "*** with $libname and none of the candidates passed a file format test" $echo "*** using a regex pattern. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -e 's/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` done fi if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ | grep . >/dev/null; then $echo if test "X$deplibs_check_method" = "Xnone"; then $echo "*** Warning: inter-library dependencies are not supported in this platform." else $echo "*** Warning: inter-library dependencies are not known to be supported." fi $echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then $echo $echo "*** Warning: libtool could not satisfy all declared inter-library" $echo "*** dependencies of module $libname. Therefore, libtool will create" $echo "*** a static module, that should work as long as the dlopening" $echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then $echo $echo "*** However, this would only work if libtool was able to extract symbol" $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" $echo "*** not find such a program. So, this module is probably useless." $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else $echo "*** The inter-library dependencies that have been dropped here will be" $echo "*** automatically added whenever a program is linked with this library" $echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then $echo $echo "*** Since this library must not contain undefined symbols," $echo "*** because either the platform does not support them or" $echo "*** it was explicitly requested with -no-undefined," $echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" if len=`expr "X$cmd" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then $show "$cmd" $run eval "$cmd" || exit $? skipped_export=false else # The command line is too long to execute in one step. $show "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex"; then $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise. $echo "creating reloadable object files..." # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output output_la=`$echo "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= delfiles= last_robj= k=1 output=$output_objdir/$output_la-${k}.$objext # Loop over the list of objects to be linked. for obj in $save_libobjs do eval test_cmds=\"$reload_cmds $objlist $last_robj\" if test "X$objlist" = X || { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; }; then objlist="$objlist $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext k=`expr $k + 1` output=$output_objdir/$output_la-${k}.$objext objlist=$obj len=1 fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if ${skipped_export-false}; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols libobjs=$output # Append the command to create the export file. eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" fi # Set up a command to remove the reloadable object files # after they are used. i=0 while test "$i" -lt "$k" do i=`expr $i + 1` delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" done $echo "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi # Append the command to remove the reloadable object files # to the just-reset $cmds. eval cmds=\"\$cmds~\$rm $delfiles\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then $show "${rm}r $gentop" $run ${rm}r "$gentop" fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 fi case $output in *.lo) if test -n "$objs$old_deplibs"; then $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 exit $EXIT_FAILURE fi libobj="$output" obj=`$echo "X$output" | $Xsed -e "$lo2o"` ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $run $rm $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $run eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi if test "$preload" = yes; then if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && test "$dlopen_self_static" = unknown; then $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." fi fi case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac case $host in *darwin*) # Don't allow lazy linking, it breaks C++ global constructors if test "$tagname" = CXX ; then compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" fi ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 fi fi if test -n "$dlsyms"; then case $dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${outputname}.nm" $show "$rm $nlist ${nlist}S ${nlist}T" $run $rm "$nlist" "${nlist}S" "${nlist}T" # Parse the name list into a source file. $show "creating $output_objdir/$dlsyms" test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ #ifdef __cplusplus extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ #define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then $show "generating symbol list for \`$output'" test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for arg in $progfiles; do $show "extracting global C symbols from \`$arg'" $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $run $rm $export_symbols $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac else $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac fi fi for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` $run eval '$echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -z "$run"; then # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if grep -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else $echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ #undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ " case $host in *cygwin* | *mingw* ) $echo >> "$output_objdir/$dlsyms" "\ /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs */ struct { " ;; * ) $echo >> "$output_objdir/$dlsyms" "\ const struct { " ;; esac $echo >> "$output_objdir/$dlsyms" "\ const char *name; lt_ptr address; } lt_preloaded_symbols[] = {\ " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" $echo >> "$output_objdir/$dlsyms" "\ {0, (lt_ptr) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " fi pic_flag_for_symtable= case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag";; esac esac # Now compile the dynamic symbol file. $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. case $host in *cygwin* | *mingw* ) if test -f "$output_objdir/${outputname}.def" ; then compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` else compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` fi ;; * ) compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` ;; esac ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 exit $EXIT_FAILURE ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` fi if test "$need_relink" = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" exit_status=$? # Delete the generated files. if test -n "$dlsyms"; then $show "$rm $output_objdir/${outputname}S.${objext}" $run $rm "$output_objdir/${outputname}S.${objext}" fi exit $exit_status fi if test -n "$shlibpath_var"; then # We should set the shlibpath_var rpath= for dir in $temp_rpath; do case $dir in [\\/]* | [A-Za-z]:[\\/]*) # Absolute path. rpath="$rpath$dir:" ;; *) # Relative path: add a thisdir entry. rpath="$rpath\$thisdir/$dir:" ;; esac done temp_rpath="$rpath" fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $run $rm $output # Link the executable and exit $show "$link_command" $run eval "$link_command" || exit $? exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname $show "$link_command" $run eval "$link_command" || exit $? # Now create the wrapper script. $show "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` fi # Quote $echo for shipping. if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then case $progpath in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; esac qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if our run command is non-null. if test -z "$run"; then # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) output_name=`basename $output` output_path=`dirname $output` cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $rm $cwrappersource $cwrapper trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 cat > $cwrappersource <> $cwrappersource<<"EOF" #include #include #include #include #include #include #include #include #include #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) /* -DDEBUG is fairly common in CFLAGS. */ #undef DEBUG #if defined DEBUGWRAPPER # define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) #else # define DEBUG(format, ...) #endif const char *program_name = NULL; void * xmalloc (size_t num); char * xstrdup (const char *string); const char * base_name (const char *name); char * find_executable(const char *wrapper); int check_executable(const char *path); char * strendzap(char *str, const char *pat); void lt_fatal (const char *message, ...); int main (int argc, char *argv[]) { char **newargz; int i; program_name = (char *) xstrdup (base_name (argv[0])); DEBUG("(main) argv[0] : %s\n",argv[0]); DEBUG("(main) program_name : %s\n",program_name); newargz = XMALLOC(char *, argc+2); EOF cat >> $cwrappersource <> $cwrappersource <<"EOF" newargz[1] = find_executable(argv[0]); if (newargz[1] == NULL) lt_fatal("Couldn't find %s", argv[0]); DEBUG("(main) found exe at : %s\n",newargz[1]); /* we know the script has the same name, without the .exe */ /* so make sure newargz[1] doesn't end in .exe */ strendzap(newargz[1],".exe"); for (i = 1; i < argc; i++) newargz[i+1] = xstrdup(argv[i]); newargz[argc+1] = NULL; for (i=0; i> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" return 127; } void * xmalloc (size_t num) { void * p = (void *) malloc (num); if (!p) lt_fatal ("Memory exhausted"); return p; } char * xstrdup (const char *string) { return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL ; } const char * base_name (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ if (isalpha ((unsigned char)name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) if (IS_DIR_SEPARATOR (*name)) base = name + 1; return base; } int check_executable(const char * path) { struct stat st; DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); if ((!path) || (!*path)) return 0; if ((stat (path, &st) >= 0) && ( /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ #if defined (S_IXOTH) ((st.st_mode & S_IXOTH) == S_IXOTH) || #endif #if defined (S_IXGRP) ((st.st_mode & S_IXGRP) == S_IXGRP) || #endif ((st.st_mode & S_IXUSR) == S_IXUSR)) ) return 1; else return 0; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise */ char * find_executable (const char* wrapper) { int has_slash = 0; const char* p; const char* p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char* concat_name; DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char* path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char* q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR(*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen(tmp); concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen(tmp); concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); return NULL; } char * strendzap(char *str, const char *pat) { size_t len, patlen; assert(str != NULL); assert(pat != NULL); len = strlen(str); patlen = strlen(pat); if (patlen <= len) { str += len - patlen; if (strcmp(str, pat) == 0) *str = '\0'; } return str; } static void lt_error_core (int exit_status, const char * mode, const char * message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } EOF # we should really use a build-platform specific compiler # here, but OTOH, the wrappers (shell script and this C one) # are only useful if you want to execute the "real" binary. # Since the "real" binary is built for $host, then this # wrapper might as well be built for $host, too. $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource ;; esac $rm $output trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 $echo > $output "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='${SED} -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variable: notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then echo=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then # Yippee, \$echo works! : else # Restart under the correct shell, and then maybe \$echo will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $mkdir \"\$progdir\" else $rm \"\$progdir/\$file\" fi" $echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit $EXIT_FAILURE fi fi $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $rm \"\$progdir/\$program\"; $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } $rm \"\$progdir/\$file\" fi" else $echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $echo >> $output "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $echo >> $output "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $echo >> $output "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $echo >> $output "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $echo >> $output "\ exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $echo >> $output "\ \$echo \"\$0: cannot exec \$program \$*\" exit $EXIT_FAILURE fi else # The program doesn't exist. \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 $echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit $EXIT_FAILURE fi fi\ " chmod +x $output fi exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do $echo "X$obj" | $Xsed -e 's%^.*/%%' done | sort | sort -uc >/dev/null 2>&1); then : else $echo "copying selected object files to avoid basename conflicts..." if test -z "$gentop"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "$mkdir $gentop" $run $mkdir "$gentop" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$gentop"; then exit $exit_status fi fi save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase counter=`expr $counter + 1` case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" $run ln "$obj" "$gentop/$newobj" || $run cp "$obj" "$gentop/$newobj" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts $echo "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done for obj in $save_oldobjs do oldobjs="$objlist $obj" objlist="$objlist $obj" eval test_cmds=\"$old_archive_cmds\" if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do eval cmd=\"$cmd\" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$generated"; then $show "${rm}r$generated" $run ${rm}r$generated fi # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" $show "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. if test -z "$run"; then for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlfiles="$newdlfiles $libdir/$name" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlprefiles="$newdlprefiles $libdir/$name" done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $rm $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $echo >> $output "\ relink_command=\"$relink_command\"" fi done fi # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? ;; esac exit $EXIT_SUCCESS ;; # libtool install mode install) modename="$modename: install" # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $echo "X$nonopt" | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$arg " arg="$1" shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog$arg" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) case " $install_prog " in *[\\\ /]cp\ *) ;; *) prev=$arg ;; esac ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog $arg" done if test -z "$install_prog"; then $echo "$modename: you must specify an install program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -n "$prev"; then $echo "$modename: the \`$prev' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -z "$files"; then if test -z "$dest"; then $echo "$modename: no file or destination specified" 1>&2 else $echo "$modename: you must specify a destination" 1>&2 fi $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Strip any trailing slash from the destination. dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` test "X$destdir" = "X$dest" && destdir=. destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` # Not a directory, so check to see that there is only one file specified. set dummy $files if test "$#" -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi library_names= old_library= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. if test "$inst_prefix_dir" = "$destdir"; then $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 exit $EXIT_FAILURE fi if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP` else relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP` fi $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 exit $EXIT_FAILURE fi fi # See the names of the shared library. set dummy $library_names if test -n "$2"; then realname="$2" shift shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. $show "$install_prog $dir/$srcname $destdir/$realname" $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$striplib $destdir/$realname" $run eval "$striplib $destdir/$realname" || exit $? fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do if test "$linkname" != "$realname"; then $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" fi done fi # Do each command in the postinstall commands. lib="$destdir/$realname" cmds=$postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' fi exit $lt_exit } done IFS="$save_ifs" fi # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i $show "$install_prog $instname $destdir/$name" $run eval "$install_prog $instname $destdir/$name" || exit $? # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` ;; *.$objext) staticdest="$destfile" destfile= ;; *) $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac # Install the libtool object if requested. if test -n "$destfile"; then $show "$install_prog $file $destfile" $run eval "$install_prog $file $destfile" || exit $? fi # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` $show "$install_prog $staticobj $staticdest" $run eval "$install_prog \$staticobj \$staticdest" || exit $? fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then file=`$echo $file|${SED} 's,.exe$,,'` stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` ;; *) wrapper=$file ;; esac if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit $EXIT_FAILURE fi finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then # If there is no directory component, then add one. case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac fi libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 finalize=no fi done relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then tmpdir=`func_mktempdir` file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP` $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 ${rm}r "$tmpdir" continue fi file="$outputname" else $echo "$modename: warning: cannot relink \`$file'" 1>&2 fi else # Install the binary that we compiled earlier. file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` ;; esac ;; esac $show "$install_prog$stripme $file $destfile" $run eval "$install_prog\$stripme \$file \$destfile" || exit $? test -n "$outputname" && ${rm}r "$tmpdir" ;; esac done for file in $staticlibs; do name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` # Set up the ranlib parameters. oldlib="$destdir/$name" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? if test -n "$stripme" && test -n "$old_striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. cmds=$old_postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$future_libdirs"; then $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 fi if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi ;; # libtool finish mode finish) modename="$modename: finish" libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. cmds=$finish_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" done IFS="$save_ifs" fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $run eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. test "$show" = : && exit $EXIT_SUCCESS $echo "X----------------------------------------------------------------------" | $Xsed $echo "Libraries have been installed in:" for libdir in $libdirs; do $echo " $libdir" done $echo $echo "If you ever happen to want to link against installed libraries" $echo "in a given directory, LIBDIR, you must either use libtool, and" $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" $echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" $echo " during execution" fi if test -n "$runpath_var"; then $echo " - add LIBDIR to the \`$runpath_var' environment variable" $echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi $echo $echo "See any operating system documentation about shared libraries for" $echo "more information, such as the ld(1) and ld.so(8) manual pages." $echo "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS ;; # libtool execute mode execute) modename="$modename: execute" # The first argument is the command name. cmd="$nonopt" if test -z "$cmd"; then $echo "$modename: you must specify a COMMAND" 1>&2 $echo "$help" exit $EXIT_FAILURE fi # Handle -dlopen flags immediately. for file in $execute_dlfiles; do if test ! -f "$file"; then $echo "$modename: \`$file' is not a file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi dir= case $file in *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Read the libtool library. dlname= library_names= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" continue fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 exit $EXIT_FAILURE fi ;; *.lo) # Just add the directory containing the .lo file. dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. ;; *) $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` args="$args \"$file\"" done if test -z "$run"; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi $echo "$cmd$args" exit $EXIT_SUCCESS fi ;; # libtool clean and uninstall mode clean | uninstall) modename="$modename: $mode" rm="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) rm="$rm $arg"; rmforce=yes ;; -*) rm="$rm $arg" ;; *) files="$files $arg" ;; esac done if test -z "$rm"; then $echo "$modename: you must specify an RM program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi rmdirs= origobjdir="$objdir" for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. objdir="$origobjdir" else objdir="$dir/$origobjdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if (test -L "$file") >/dev/null 2>&1 \ || (test -h "$file") >/dev/null 2>&1 \ || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. cmds=$postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. cmds=$old_postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # Read the .lo file . $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" \ && test "$pic_object" != none; then rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" \ && test "$non_pic_object" != none; then rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; then noexename=$name case $file in *.exe) file=`$echo $file|${SED} 's,.exe$,,'` noexename=`$echo $name|${SED} 's,.exe$,,'` # $file with .exe has already been added to rmfiles, # add $file without .exe rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$noexename # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then $show "rmdir $dir" $run rmdir $dir >/dev/null 2>&1 fi done exit $exit_status ;; "") $echo "$modename: you must specify a MODE" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE ;; esac if test -z "$exec_cmd"; then $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE fi fi # test -z "$show_help" if test -n "$exec_cmd"; then eval exec $exec_cmd exit $EXIT_FAILURE fi # We need to display help for each of the modes. case $mode in "") $echo \ "Usage: $modename [OPTION]... [MODE-ARG]... Provide generalized library-building support services. --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --finish same as \`--mode=finish' --help display this help message and exit --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages --tag=TAG use configuration variables from tag TAG --version print version information MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE. Report bugs to ." exit $EXIT_SUCCESS ;; clean) $echo \ "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $echo \ "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $echo \ "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $echo \ "Usage: $modename [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $echo \ "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $echo \ "Usage: $modename [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $echo \ "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac $echo $echo "Try \`$modename --help' for more information about other modes." exit $? # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared disable_libs=shared # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static disable_libs=static # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: ./sqliteodbc-0.992/libtool0100755000076400001440000067622012126210125014127 0ustar chwusers#! /bin/sh # libtoolT - Provide generalized library-building support services. # Generated automatically by (GNU ) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. SED="/bin/sed" # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="/bin/sed -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # The names of the tagged configurations supported by this script. available_tags=" CXX F77" # ### BEGIN LIBTOOL CONFIG # Libtool was configured on host speedy.nodomain: # Shell to use when invoking shell scripts. SHELL="/bin/sh" # Whether or not to build shared libraries. build_libtool_libs=yes # Whether or not to build static libraries. build_old_libs=yes # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=no # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=no # Whether or not to optimize for fast installation. fast_install=yes # The host system. host_alias= host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. echo="echo" # The archiver. AR="ar" AR_FLAGS="cru" # A C compiler. LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. CC="gcc" # Is the compiler the GNU C compiler? with_gcc=yes gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` gcc_ver=`gcc -dumpversion` # An ERE matcher. EGREP="grep -E" # The linker used to build libraries. LD="/usr/i386-linux/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" # A BSD-compatible nm program. NM="/usr/bin/nm -B" # A symbol stripping program STRIP="strip" # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=file # Used on cygwin: DLL creation program. DLLTOOL="dlltool" # Used on cygwin: object dumper. OBJDUMP="objdump" # Used on cygwin: assembler. AS="as" # The name of the directory that contains temporary libtool files. objdir=.libs # How to create reloadable object files. reload_flag=" -r" reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" # How to pass a linker flag through the compiler. wl="-Wl," # Object file suffix (normally "o"). objext="o" # Old archive suffix (normally "a"). libext="a" # Shared library suffix (normally ".so"). shrext_cmds='.so' # Executable file suffix (normally ""). exeext="" # Additional compiler flags for building library objects. pic_flag=" -fPIC -DPIC" pic_mode=default # What is the maximum length of a command? max_cmd_len=32768 # Does compiler simultaneously support -c and -o options? compiler_c_o="yes" # Must we lock files when doing compilation? need_locks="no" # Do we need the lib prefix for modules? need_lib_prefix=no # Do we need a version for libraries? need_version=no # Whether dlopen is supported. dlopen_support=unknown # Whether dlopen of programs is supported. dlopen_self=unknown # Whether dlopen of statically linked programs is supported. dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. link_static_flag="-static" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin -fno-rtti -fno-exceptions" # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec="\${wl}--export-dynamic" # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" # Compiler flag to generate thread-safe objects. thread_safe_flag_spec="" # Library versioning type. version_type=linux # Format of library name prefix. libname_spec="lib\$name" # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" # The coded name of the library, if different from the real name. soname_spec="\${libname}\${release}\${shared_ext}\$major" # Commands used to build and install an old-style archive. RANLIB="ranlib" old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB \$oldlib" old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" old_postuninstall_cmds="" # Create an old-style archive from a shared archive. old_archive_from_new_cmds="" # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds="" # Commands used to build and install a shared archive. archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" archive_expsym_cmds="" postinstall_cmds="" postuninstall_cmds="" # Commands used to build a loadable module (assumed same as above if empty) module_cmds="" module_expsym_cmds="" # Commands to strip libraries. old_striplib="strip --strip-debug" striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. predeps="" # Dependencies to place after the objects being linked to create a # shared library. postdeps="" # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" # Command to use when deplibs_check_method == file_magic. file_magic_cmd="\$MAGIC_CMD" # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag="" # Flag that forces no undefined symbols. no_undefined_flag="" # Commands used to finish a libtool library installation in a directory. finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" # Same as above, but a single script fragment to be evaled but not shown. finish_eval="" # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'" # Transform the output of nm in a proper C declaration global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'" # Transform the output of nm in a C name address pair global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (lt_ptr) \\&\\2},/p'" # This is the shared library runtime path variable. runpath_var=LD_RUN_PATH # This is the shared library path variable. shlibpath_var=LD_LIBRARY_PATH # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=no # How to hardcode a shared library path into an executable. hardcode_action=immediate # Whether we should hardcode library paths into libraries. hardcode_into_libs=yes # Flag to hardcode $libdir into a binary during linking. # This must work even if $libdir does not exist. hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir" # If ld is used when linking, flag to hardcode $libdir into # a binary during linking. This must work even if $libdir does # not exist. hardcode_libdir_flag_spec_ld="" # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator="" # Set to yes if using DIR/libNAME during linking hardcodes DIR into the # resulting binary. hardcode_direct=no # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=no # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=unsupported # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=no # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=unknown # Compile-time system search path for libraries sys_lib_search_path_spec=`echo " /usr/lib/gcc-lib/i386-linux/egcs-2.91.66/ /usr/lib/gcc/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/ /lib/i386-linux/egcs-2.91.66/ /lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib /usr/lib/qt2/lib /lib/gnulibc1 /usr/X11R6/lib/gnulibc1 /usr/openwin/lib/gnulibc1 /usr/lib/gnulibc1 /opt/kde/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" # Set to yes if exported symbols are required. always_export_symbols=no # The commands to list exported symbols. export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds="" # Symbols that should not be listed in the preloaded symbols. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Symbols that must always be exported. include_expsyms="" # ### END LIBTOOL CONFIG # ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. basename="s,^.*/,,g" # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" # The name of this program: progname=`echo "$progpath" | $SED $basename` modename="$progname" # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 PROGRAM=ltmain.sh PACKAGE=libtool VERSION=1.5.22 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi # Check that we have a working $echo. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell, and then maybe $echo will work. exec $SHELL "$progpath" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE fi # Global variables. mode=$default_mode nonopt= prev= prevopt= run= show="$echo" show_help= execute_dlfiles= duplicate_deps=no preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 ##################################### # Shell function definitions: # This seems to be the best place for them # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $mkdir "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || { $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 exit $EXIT_FAILURE } fi $echo "X$my_tmpdir" | $Xsed } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. func_win32_libid () { win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | \ $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $echo $win32_libid_type } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done case "$@ " in " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then $echo "$modename: unable to infer tagged configuration" $echo "$modename: specify a tag with \`--tag'" 1>&2 exit $EXIT_FAILURE # else # $echo "$modename: using $tagname tagged configuration" fi ;; esac fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 exit $EXIT_FAILURE fi } # func_extract_archives gentop oldlib ... func_extract_archives () { my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" my_status="" $show "${rm}r $my_gentop" $run ${rm}r "$my_gentop" $show "$mkdir $my_gentop" $run $mkdir "$my_gentop" my_status=$? if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then exit $my_status fi for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) extracted_serial=`expr $extracted_serial + 1` my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" $show "${rm}r $my_xdir" $run ${rm}r "$my_xdir" $show "$mkdir $my_xdir" $run $mkdir "$my_xdir" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then exit $exit_status fi case $host in *-darwin*) $show "Extracting $my_xabs" # Do not bother doing anything if just a dry run if test -z "$run"; then darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` if test -n "$darwin_arches"; then darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= $show "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we have a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` lipo -create -output "$darwin_file" $darwin_files done # $darwin_filelist ${rm}r unfat-$$ cd "$darwin_orig_dir" else cd "$darwin_orig_dir" func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches fi # $run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # End of Shell function definitions ##################################### # Darwin sucks eval std_shrext=\"$shrext_cmds\" disable_libs=no # Parse our command line options once, thoroughly. while test "$#" -gt 0 do arg="$1" shift case $arg in -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; tag) tagname="$arg" preserve_args="${preserve_args}=$arg" # Check whether tagname contains only valid characters case $tagname in *[!-_A-Za-z0-9,/]*) $echo "$progname: invalid tag name: $tagname" 1>&2 exit $EXIT_FAILURE ;; esac case $tagname in CC) # Don't test for the "default" C tag, as we know, it's there, but # not specially marked. ;; *) if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then taglist="$taglist $tagname" # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" else $echo "$progname: ignoring unknown tag $tagname" 1>&2 fi ;; esac ;; *) eval "$prev=\$arg" ;; esac prev= prevopt= continue fi # Have we seen a non-optional argument yet? case $arg in --help) show_help=yes ;; --version) $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" $echo $echo "Copyright (C) 2005 Free Software Foundation, Inc." $echo "This is free software; see the source for copying conditions. There is NO" $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." exit $? ;; --config) ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath # Now print the configurations for the tags. for tagname in $taglist; do ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" done exit $? ;; --debug) $echo "$progname: enabling shell trace mode" set -x preserve_args="$preserve_args $arg" ;; --dry-run | -n) run=: ;; --features) $echo "host: $host" if test "$build_libtool_libs" = yes; then $echo "enable shared libraries" else $echo "disable shared libraries" fi if test "$build_old_libs" = yes; then $echo "enable static libraries" else $echo "disable static libraries" fi exit $? ;; --finish) mode="finish" ;; --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; --preserve-dup-deps) duplicate_deps="yes" ;; --quiet | --silent) show=: preserve_args="$preserve_args $arg" ;; --tag) prevopt="--tag" prev=tag preserve_args="$preserve_args --tag" ;; --tag=*) set tag "$optarg" ${1+"$@"} shift prev=tag preserve_args="$preserve_args --tag" ;; -dlopen) prevopt="-dlopen" prev=execute_dlfiles ;; -*) $echo "$modename: unrecognized option \`$arg'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *) nonopt="$arg" break ;; esac done if test -n "$prevopt"; then $echo "$modename: option \`$prevopt' requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi case $disable_libs in no) ;; shared) build_libtool_libs=no build_old_libs=yes ;; static) build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` ;; esac # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 case $nonopt in *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) mode=link for arg do case $arg in -c) mode=compile break ;; esac done ;; *db | *dbx | *strace | *truss) mode=execute ;; *install*|cp|mv) mode=install ;; *rm) mode=uninstall ;; *) # If we have no mode, but dlfiles were specified, then do execute mode. test -n "$execute_dlfiles" && mode=execute # Just use the default operation mode. if test -z "$mode"; then if test -n "$nonopt"; then $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 else $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 fi fi ;; esac fi # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then $echo "$modename: unrecognized option \`-dlopen'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$modename --help --mode=$mode' for more information." # These modes are in order of execution frequency so that they run quickly. case $mode in # libtool compile mode compile) modename="$modename: compile" # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) if test -n "$libobj" ; then $echo "$modename: you cannot specify \`-o' more than once" 1>&2 exit $EXIT_FAILURE fi arg_mode=target continue ;; -static | -prefer-pic | -prefer-non-pic) later="$later $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac lastarg="$lastarg $arg" done IFS="$save_ifs" lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` # Add the arguments to base_compile. base_compile="$base_compile $lastarg" continue ;; * ) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` case $lastarg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, and some SunOS ksh mistreat backslash-escaping # in scan sets (worked around with variable expansion), # and furthermore cannot handle '|' '&' '(' ')' in scan sets # at all, so we specify them separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac base_compile="$base_compile $lastarg" done # for arg case $arg_mode in arg) $echo "$modename: you must specify an argument for -Xcompile" exit $EXIT_FAILURE ;; target) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit $EXIT_FAILURE ;; *) # Get the name of the library object. [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo xform='[cCFSifmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; *.ads) xform=ads ;; *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.ii) xform=ii ;; *.class) xform=class ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; *.java) xform=java ;; *.obj) xform=obj ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` case $libobj in *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; *) $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 exit $EXIT_FAILURE ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -static) build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` case $qlibobj in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qlibobj="\"$qlibobj\"" ;; esac test "X$libobj" != "X$qlibobj" \ && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir= else xdir=$xdir/ fi lobj=${xdir}$objdir/$objname if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi $run $rm $removelist trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $run ln "$progpath" "$lockfile" 2>/dev/null; do $show "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi $echo "$srcfile" > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` case $qsrcfile in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qsrcfile="\"$qsrcfile\"" ;; esac $run $rm "$libobj" "${libobj}T" # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then $show "$mv $output_obj $lobj" if $run $mv $output_obj $lobj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the PIC object to the libtool object file. test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the non-PIC object the libtool object file. # Only append if the libtool object file exists. test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test ;; *) qarg=$arg ;; esac libtool_args="$libtool_args $qarg" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit $EXIT_FAILURE fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat $save_arg` do # moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$libobjs $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object non_pic_objects="$non_pic_objects $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi done else $echo "$modename: link input file \`$save_arg' does not exist" exit $EXIT_FAILURE fi arg=$save_arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= compile_command="$compile_command $wl$qarg" finalize_command="$finalize_command $wl$qarg" continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; shrext) shrext_cmds="$arg" prev= continue ;; darwin_framework|darwin_framework_skip) test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" prev= continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: more than one -exported-symbols argument is not allowed" exit $EXIT_FAILURE fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework|-arch|-isysroot) case " $CC " in *" ${arg} ${1} "* | *" ${arg} ${1} "*) prev=darwin_framework_skip ;; *) compiler_flags="$compiler_flags $arg" prev=darwin_framework ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; esac continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" notinst_path="$notinst_path $dir" fi dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework deplibs="$deplibs -framework System" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. -model) compile_command="$compile_command $arg" compiler_flags="$compiler_flags $arg" finalize_command="$finalize_command $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" continue ;; -module) module=yes continue ;; # -64, -mips[0-9] enable 64-bit mode on the SGI compiler # -r[0-9][0-9]* specifies the processor on the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler # +DA*, +DD* enable 64-bit mode on the HP compiler # -q* pass through compiler args for the IBM compiler # -m* pass through architecture-specific compiler args for GCC # -m*, -t[45]*, -txscale* pass through architecture-specific # compiler args for GCC # -pg pass through profiling flag for GCC # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ -t[45]*|-txscale*|@*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" compiler_flags="$compiler_flags $arg" continue ;; -shrext) prev=shrext continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # The PATH hackery in wrapper scripts is required on Windows # in order for the loader to find any dlls it needs. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Wl,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $wl$flag" linker_flags="$linker_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; *.$objext) # A standard object. objs="$objs $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$libobjs $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object non_pic_objects="$non_pic_objects $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi oldlibs= # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` if test "X$output_objdir" = "X$output"; then output_objdir="$objdir" else output_objdir="$output_objdir/$objdir" fi # Create the object directory. if test ! -d "$output_objdir"; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then exit $exit_status fi fi # Determine the type of output case $output in "") $echo "$modename: you must specify an output file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac case $host in *cygwin* | *mingw* | *pw32*) # don't eliminate duplications in $postdeps and $predeps duplicate_compiler_generated_deps=yes ;; *) duplicate_compiler_generated_deps=$duplicate_deps ;; esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if test "X$duplicate_deps" = "Xyes" ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$pre_post_deps $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries case $linkmode in lib) passes="conv link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 exit $EXIT_FAILURE ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 continue fi name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then library_names= old_library= case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; *) $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` if eval $echo \"$deplib\" 2>/dev/null \ | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then $echo $echo "*** Warning: Trying to link with static lib archive $deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because the file extensions .$libext of this argument makes me believe" $echo "*** that it is just a static archive that I should not used here." else $echo $echo "*** Warning: Linking the shared library $output against the" $echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 exit $EXIT_FAILURE fi # Check to see that this really is a libtool archive. if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." dlname= dlopen= dlpreopen= libdir= library_names= old_library= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit $EXIT_FAILURE fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 abs_ladir="$ladir" fi ;; esac laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then $echo "$modename: warning: library \`$lib' was moved." 1>&2 dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; *) temp_rpath="$temp_rpath $absdir" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes ; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi # This is a shared library # Warn about portability, can't link against -module's on # some systems (darwin) if test "$shouldnotlink" = yes && test "$pass" = link ; then $echo if test "$linkmode" = prog; then $echo "*** Warning: Linking the executable $output against the loadable module" else $echo "*** Warning: Linking the shared library $output against the loadable module" fi $echo "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names realname="$2" shift; shift libname=`eval \\$echo \"$libname_spec\"` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw*) major=`expr $current - $age` versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" soname=`$echo $soroot | ${SED} -e 's/^.*\///'` newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$extract_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$old_archive_from_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a module then we can not link against # it, someone is ignoring the new warnings I added if /usr/bin/file -L $add 2> /dev/null | $EGREP ": [^:]* bundle" >/dev/null ; then $echo "** Warning, lib $linklib is a module, not a shared library" if test -z "$old_library" ; then $echo $echo "** And there doesn't seem to be a static archive available" $echo "** The link will probably fail, sorry" else add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then $echo "$modename: configuration error: unsupported hardcode properties" exit $EXIT_FAILURE fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && \ test "$hardcode_minus_L" != yes && \ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. $echo $echo "*** Warning: This system can not link to static lib archive $lib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then $echo "*** But as you try to build a module library, libtool will still create " $echo "*** a static module, that should work as long as the dlopening application" $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then $echo $echo "*** However, this would only work if libtool was able to extract symbol" $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" $echo "*** not find such a program. So, this module is probably useless." $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$deplib" && dir="." # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" fi ;; esac if grep "^installed=no" $deplib > /dev/null; then path="$absdir/$objdir" else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi path="$absdir" fi depdepl= case $host in *-*-darwin*) # we do not want to link against static libs, # but need to link against shared eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$path/$depdepl" ; then depdepl="$path/$depdepl" fi # do not add paths which are already there case " $newlib_search_path " in *" $path "*) ;; *) newlib_search_path="$newlib_search_path $path";; esac fi path="" ;; *) path="-L$path" ;; esac ;; -l*) case $host in *-*-darwin*) # Again, we only want to link against shared libraries eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` for tmp in $newlib_search_path ; do if test -f "$tmp/lib$tmp_libs.dylib" ; then eval depdepl="$tmp/lib$tmp_libs.dylib" break fi done path="" ;; *) continue ;; esac ;; *) continue ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac case " $deplibs " in *" $depdepl "*) ;; *) deplibs="$depdepl $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 fi if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 fi # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) if test "$module" = no; then $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit $EXIT_FAILURE else $echo $echo "*** Warning: Linking the shared library $output against the non-libtool" $echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi if test "$dlself" != no; then $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 fi set dummy $rpath if test "$#" -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 fi else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 IFS="$save_ifs" if test -n "$8"; then $echo "$modename: too many parameters to \`-version-info'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$2" number_minor="$3" number_revision="$4" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) current=`expr $number_major + $number_minor` age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) current=`expr $number_major + $number_minor - 1` age="$number_minor" revision="$number_minor" ;; esac ;; no) current="$2" revision="$3" age="$4" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac if test "$age" -gt "$current"; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header major=.`expr $current - $age` versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current"; ;; irix | nonstopux) major=`expr $current - $age + 1` case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" ;; osf) major=.`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. major=`expr $current - $age` versuffix="-$major" ;; *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi if test "$mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$echo "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi removelist="$removelist $p" ;; *) ;; esac done if test -n "$removelist"; then $show "${rm}r $removelist" $run ${rm}r $removelist fi fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. # for path in $notinst_path; do # lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` # deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` # dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` # done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $rm conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ | ${SED} 10q \ | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $echo $echo "*** Warning: linker path does not have real file for library $a_deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $echo "*** with $libname but no candidates were found. (...for file magic test)" else $echo "*** with $libname and none of the candidates passed a file format test" $echo "*** using a file magic. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval $echo \"$potent_lib\" 2>/dev/null \ | ${SED} 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes $echo $echo "*** Warning: linker path does not have real file for library $a_deplib." $echo "*** I have the capability to make that library automatically link in when" $echo "*** you link to this library. But I can only do this if you have a" $echo "*** shared version of the library, which you do not appear to have" $echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $echo "*** with $libname but no candidates were found. (...for regex pattern test)" else $echo "*** with $libname and none of the candidates passed a file format test" $echo "*** using a regex pattern. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -e 's/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` done fi if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ | grep . >/dev/null; then $echo if test "X$deplibs_check_method" = "Xnone"; then $echo "*** Warning: inter-library dependencies are not supported in this platform." else $echo "*** Warning: inter-library dependencies are not known to be supported." fi $echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then $echo $echo "*** Warning: libtool could not satisfy all declared inter-library" $echo "*** dependencies of module $libname. Therefore, libtool will create" $echo "*** a static module, that should work as long as the dlopening" $echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then $echo $echo "*** However, this would only work if libtool was able to extract symbol" $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" $echo "*** not find such a program. So, this module is probably useless." $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else $echo "*** The inter-library dependencies that have been dropped here will be" $echo "*** automatically added whenever a program is linked with this library" $echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then $echo $echo "*** Since this library must not contain undefined symbols," $echo "*** because either the platform does not support them or" $echo "*** it was explicitly requested with -no-undefined," $echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" if len=`expr "X$cmd" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then $show "$cmd" $run eval "$cmd" || exit $? skipped_export=false else # The command line is too long to execute in one step. $show "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex"; then $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise. $echo "creating reloadable object files..." # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output output_la=`$echo "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= delfiles= last_robj= k=1 output=$output_objdir/$output_la-${k}.$objext # Loop over the list of objects to be linked. for obj in $save_libobjs do eval test_cmds=\"$reload_cmds $objlist $last_robj\" if test "X$objlist" = X || { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; }; then objlist="$objlist $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext k=`expr $k + 1` output=$output_objdir/$output_la-${k}.$objext objlist=$obj len=1 fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if ${skipped_export-false}; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols libobjs=$output # Append the command to create the export file. eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" fi # Set up a command to remove the reloadable object files # after they are used. i=0 while test "$i" -lt "$k" do i=`expr $i + 1` delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" done $echo "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi # Append the command to remove the reloadable object files # to the just-reset $cmds. eval cmds=\"\$cmds~\$rm $delfiles\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then $show "${rm}r $gentop" $run ${rm}r "$gentop" fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 fi case $output in *.lo) if test -n "$objs$old_deplibs"; then $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 exit $EXIT_FAILURE fi libobj="$output" obj=`$echo "X$output" | $Xsed -e "$lo2o"` ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $run $rm $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $run eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi if test "$preload" = yes; then if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && test "$dlopen_self_static" = unknown; then $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." fi fi case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac case $host in *darwin*) # Don't allow lazy linking, it breaks C++ global constructors if test "$tagname" = CXX ; then compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" fi ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 fi fi if test -n "$dlsyms"; then case $dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${outputname}.nm" $show "$rm $nlist ${nlist}S ${nlist}T" $run $rm "$nlist" "${nlist}S" "${nlist}T" # Parse the name list into a source file. $show "creating $output_objdir/$dlsyms" test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ #ifdef __cplusplus extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ #define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then $show "generating symbol list for \`$output'" test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for arg in $progfiles; do $show "extracting global C symbols from \`$arg'" $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $run $rm $export_symbols $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac else $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac fi fi for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` $run eval '$echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -z "$run"; then # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if grep -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else $echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ #undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ " case $host in *cygwin* | *mingw* ) $echo >> "$output_objdir/$dlsyms" "\ /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs */ struct { " ;; * ) $echo >> "$output_objdir/$dlsyms" "\ const struct { " ;; esac $echo >> "$output_objdir/$dlsyms" "\ const char *name; lt_ptr address; } lt_preloaded_symbols[] = {\ " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" $echo >> "$output_objdir/$dlsyms" "\ {0, (lt_ptr) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " fi pic_flag_for_symtable= case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag";; esac esac # Now compile the dynamic symbol file. $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. case $host in *cygwin* | *mingw* ) if test -f "$output_objdir/${outputname}.def" ; then compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` else compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` fi ;; * ) compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` ;; esac ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 exit $EXIT_FAILURE ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` fi if test "$need_relink" = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" exit_status=$? # Delete the generated files. if test -n "$dlsyms"; then $show "$rm $output_objdir/${outputname}S.${objext}" $run $rm "$output_objdir/${outputname}S.${objext}" fi exit $exit_status fi if test -n "$shlibpath_var"; then # We should set the shlibpath_var rpath= for dir in $temp_rpath; do case $dir in [\\/]* | [A-Za-z]:[\\/]*) # Absolute path. rpath="$rpath$dir:" ;; *) # Relative path: add a thisdir entry. rpath="$rpath\$thisdir/$dir:" ;; esac done temp_rpath="$rpath" fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $run $rm $output # Link the executable and exit $show "$link_command" $run eval "$link_command" || exit $? exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname $show "$link_command" $run eval "$link_command" || exit $? # Now create the wrapper script. $show "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` fi # Quote $echo for shipping. if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then case $progpath in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; esac qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if our run command is non-null. if test -z "$run"; then # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) output_name=`basename $output` output_path=`dirname $output` cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $rm $cwrappersource $cwrapper trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 cat > $cwrappersource <> $cwrappersource<<"EOF" #include #include #include #include #include #include #include #include #include #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) /* -DDEBUG is fairly common in CFLAGS. */ #undef DEBUG #if defined DEBUGWRAPPER # define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) #else # define DEBUG(format, ...) #endif const char *program_name = NULL; void * xmalloc (size_t num); char * xstrdup (const char *string); const char * base_name (const char *name); char * find_executable(const char *wrapper); int check_executable(const char *path); char * strendzap(char *str, const char *pat); void lt_fatal (const char *message, ...); int main (int argc, char *argv[]) { char **newargz; int i; program_name = (char *) xstrdup (base_name (argv[0])); DEBUG("(main) argv[0] : %s\n",argv[0]); DEBUG("(main) program_name : %s\n",program_name); newargz = XMALLOC(char *, argc+2); EOF cat >> $cwrappersource <> $cwrappersource <<"EOF" newargz[1] = find_executable(argv[0]); if (newargz[1] == NULL) lt_fatal("Couldn't find %s", argv[0]); DEBUG("(main) found exe at : %s\n",newargz[1]); /* we know the script has the same name, without the .exe */ /* so make sure newargz[1] doesn't end in .exe */ strendzap(newargz[1],".exe"); for (i = 1; i < argc; i++) newargz[i+1] = xstrdup(argv[i]); newargz[argc+1] = NULL; for (i=0; i> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" return 127; } void * xmalloc (size_t num) { void * p = (void *) malloc (num); if (!p) lt_fatal ("Memory exhausted"); return p; } char * xstrdup (const char *string) { return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL ; } const char * base_name (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ if (isalpha ((unsigned char)name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) if (IS_DIR_SEPARATOR (*name)) base = name + 1; return base; } int check_executable(const char * path) { struct stat st; DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); if ((!path) || (!*path)) return 0; if ((stat (path, &st) >= 0) && ( /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ #if defined (S_IXOTH) ((st.st_mode & S_IXOTH) == S_IXOTH) || #endif #if defined (S_IXGRP) ((st.st_mode & S_IXGRP) == S_IXGRP) || #endif ((st.st_mode & S_IXUSR) == S_IXUSR)) ) return 1; else return 0; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise */ char * find_executable (const char* wrapper) { int has_slash = 0; const char* p; const char* p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char* concat_name; DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char* path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char* q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR(*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen(tmp); concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable(concat_name)) return concat_name; XFREE(concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); tmp_len = strlen(tmp); concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable(concat_name)) return concat_name; XFREE(concat_name); return NULL; } char * strendzap(char *str, const char *pat) { size_t len, patlen; assert(str != NULL); assert(pat != NULL); len = strlen(str); patlen = strlen(pat); if (patlen <= len) { str += len - patlen; if (strcmp(str, pat) == 0) *str = '\0'; } return str; } static void lt_error_core (int exit_status, const char * mode, const char * message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } EOF # we should really use a build-platform specific compiler # here, but OTOH, the wrappers (shell script and this C one) # are only useful if you want to execute the "real" binary. # Since the "real" binary is built for $host, then this # wrapper might as well be built for $host, too. $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource ;; esac $rm $output trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 $echo > $output "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='${SED} -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variable: notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then echo=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then # Yippee, \$echo works! : else # Restart under the correct shell, and then maybe \$echo will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $mkdir \"\$progdir\" else $rm \"\$progdir/\$file\" fi" $echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit $EXIT_FAILURE fi fi $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $rm \"\$progdir/\$program\"; $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } $rm \"\$progdir/\$file\" fi" else $echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $echo >> $output "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $echo >> $output "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $echo >> $output "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $echo >> $output "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $echo >> $output "\ exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $echo >> $output "\ \$echo \"\$0: cannot exec \$program \$*\" exit $EXIT_FAILURE fi else # The program doesn't exist. \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 $echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit $EXIT_FAILURE fi fi\ " chmod +x $output fi exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do $echo "X$obj" | $Xsed -e 's%^.*/%%' done | sort | sort -uc >/dev/null 2>&1); then : else $echo "copying selected object files to avoid basename conflicts..." if test -z "$gentop"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "$mkdir $gentop" $run $mkdir "$gentop" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$gentop"; then exit $exit_status fi fi save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase counter=`expr $counter + 1` case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" $run ln "$obj" "$gentop/$newobj" || $run cp "$obj" "$gentop/$newobj" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts $echo "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done for obj in $save_oldobjs do oldobjs="$objlist $obj" objlist="$objlist $obj" eval test_cmds=\"$old_archive_cmds\" if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do eval cmd=\"$cmd\" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$generated"; then $show "${rm}r$generated" $run ${rm}r$generated fi # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" $show "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. if test -z "$run"; then for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlfiles="$newdlfiles $libdir/$name" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlprefiles="$newdlprefiles $libdir/$name" done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $rm $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $echo >> $output "\ relink_command=\"$relink_command\"" fi done fi # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? ;; esac exit $EXIT_SUCCESS ;; # libtool install mode install) modename="$modename: install" # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $echo "X$nonopt" | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$arg " arg="$1" shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog$arg" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) case " $install_prog " in *[\\\ /]cp\ *) ;; *) prev=$arg ;; esac ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog $arg" done if test -z "$install_prog"; then $echo "$modename: you must specify an install program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -n "$prev"; then $echo "$modename: the \`$prev' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -z "$files"; then if test -z "$dest"; then $echo "$modename: no file or destination specified" 1>&2 else $echo "$modename: you must specify a destination" 1>&2 fi $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Strip any trailing slash from the destination. dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` test "X$destdir" = "X$dest" && destdir=. destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` # Not a directory, so check to see that there is only one file specified. set dummy $files if test "$#" -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi library_names= old_library= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. if test "$inst_prefix_dir" = "$destdir"; then $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 exit $EXIT_FAILURE fi if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP` else relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP` fi $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 exit $EXIT_FAILURE fi fi # See the names of the shared library. set dummy $library_names if test -n "$2"; then realname="$2" shift shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. $show "$install_prog $dir/$srcname $destdir/$realname" $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$striplib $destdir/$realname" $run eval "$striplib $destdir/$realname" || exit $? fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do if test "$linkname" != "$realname"; then $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" fi done fi # Do each command in the postinstall commands. lib="$destdir/$realname" cmds=$postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' fi exit $lt_exit } done IFS="$save_ifs" fi # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i $show "$install_prog $instname $destdir/$name" $run eval "$install_prog $instname $destdir/$name" || exit $? # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` ;; *.$objext) staticdest="$destfile" destfile= ;; *) $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac # Install the libtool object if requested. if test -n "$destfile"; then $show "$install_prog $file $destfile" $run eval "$install_prog $file $destfile" || exit $? fi # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` $show "$install_prog $staticobj $staticdest" $run eval "$install_prog \$staticobj \$staticdest" || exit $? fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then file=`$echo $file|${SED} 's,.exe$,,'` stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` ;; *) wrapper=$file ;; esac if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit $EXIT_FAILURE fi finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then # If there is no directory component, then add one. case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac fi libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 finalize=no fi done relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then tmpdir=`func_mktempdir` file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP` $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 ${rm}r "$tmpdir" continue fi file="$outputname" else $echo "$modename: warning: cannot relink \`$file'" 1>&2 fi else # Install the binary that we compiled earlier. file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` ;; esac ;; esac $show "$install_prog$stripme $file $destfile" $run eval "$install_prog\$stripme \$file \$destfile" || exit $? test -n "$outputname" && ${rm}r "$tmpdir" ;; esac done for file in $staticlibs; do name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` # Set up the ranlib parameters. oldlib="$destdir/$name" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? if test -n "$stripme" && test -n "$old_striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. cmds=$old_postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$future_libdirs"; then $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 fi if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi ;; # libtool finish mode finish) modename="$modename: finish" libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. cmds=$finish_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" done IFS="$save_ifs" fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $run eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. test "$show" = : && exit $EXIT_SUCCESS $echo "X----------------------------------------------------------------------" | $Xsed $echo "Libraries have been installed in:" for libdir in $libdirs; do $echo " $libdir" done $echo $echo "If you ever happen to want to link against installed libraries" $echo "in a given directory, LIBDIR, you must either use libtool, and" $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" $echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" $echo " during execution" fi if test -n "$runpath_var"; then $echo " - add LIBDIR to the \`$runpath_var' environment variable" $echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi $echo $echo "See any operating system documentation about shared libraries for" $echo "more information, such as the ld(1) and ld.so(8) manual pages." $echo "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS ;; # libtool execute mode execute) modename="$modename: execute" # The first argument is the command name. cmd="$nonopt" if test -z "$cmd"; then $echo "$modename: you must specify a COMMAND" 1>&2 $echo "$help" exit $EXIT_FAILURE fi # Handle -dlopen flags immediately. for file in $execute_dlfiles; do if test ! -f "$file"; then $echo "$modename: \`$file' is not a file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi dir= case $file in *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Read the libtool library. dlname= library_names= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" continue fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 exit $EXIT_FAILURE fi ;; *.lo) # Just add the directory containing the .lo file. dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. ;; *) $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` args="$args \"$file\"" done if test -z "$run"; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi $echo "$cmd$args" exit $EXIT_SUCCESS fi ;; # libtool clean and uninstall mode clean | uninstall) modename="$modename: $mode" rm="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) rm="$rm $arg"; rmforce=yes ;; -*) rm="$rm $arg" ;; *) files="$files $arg" ;; esac done if test -z "$rm"; then $echo "$modename: you must specify an RM program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi rmdirs= origobjdir="$objdir" for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. objdir="$origobjdir" else objdir="$dir/$origobjdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if (test -L "$file") >/dev/null 2>&1 \ || (test -h "$file") >/dev/null 2>&1 \ || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. cmds=$postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. cmds=$old_postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # Read the .lo file . $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" \ && test "$pic_object" != none; then rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" \ && test "$non_pic_object" != none; then rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; then noexename=$name case $file in *.exe) file=`$echo $file|${SED} 's,.exe$,,'` noexename=`$echo $name|${SED} 's,.exe$,,'` # $file with .exe has already been added to rmfiles, # add $file without .exe rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$noexename # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then $show "rmdir $dir" $run rmdir $dir >/dev/null 2>&1 fi done exit $exit_status ;; "") $echo "$modename: you must specify a MODE" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE ;; esac if test -z "$exec_cmd"; then $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE fi fi # test -z "$show_help" if test -n "$exec_cmd"; then eval exec $exec_cmd exit $EXIT_FAILURE fi # We need to display help for each of the modes. case $mode in "") $echo \ "Usage: $modename [OPTION]... [MODE-ARG]... Provide generalized library-building support services. --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --finish same as \`--mode=finish' --help display this help message and exit --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages --tag=TAG use configuration variables from tag TAG --version print version information MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE. Report bugs to ." exit $EXIT_SUCCESS ;; clean) $echo \ "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $echo \ "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $echo \ "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $echo \ "Usage: $modename [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $echo \ "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $echo \ "Usage: $modename [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $echo \ "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac $echo $echo "Try \`$modename --help' for more information about other modes." exit $? # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared disable_libs=shared # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static disable_libs=static # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # ### BEGIN LIBTOOL TAG CONFIG: CXX # Libtool was configured on host speedy.nodomain: # Shell to use when invoking shell scripts. SHELL="/bin/sh" # Whether or not to build shared libraries. build_libtool_libs=yes # Whether or not to build static libraries. build_old_libs=yes # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=no # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=no # Whether or not to optimize for fast installation. fast_install=yes # The host system. host_alias= host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. echo="echo" # The archiver. AR="ar" AR_FLAGS="cru" # A C compiler. LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. CC="g++" # Is the compiler the GNU C compiler? with_gcc=yes gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` gcc_ver=`gcc -dumpversion` # An ERE matcher. EGREP="grep -E" # The linker used to build libraries. LD="/usr/i386-linux/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" # A BSD-compatible nm program. NM="/usr/bin/nm -B" # A symbol stripping program STRIP="strip" # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=file # Used on cygwin: DLL creation program. DLLTOOL="dlltool" # Used on cygwin: object dumper. OBJDUMP="objdump" # Used on cygwin: assembler. AS="as" # The name of the directory that contains temporary libtool files. objdir=.libs # How to create reloadable object files. reload_flag=" -r" reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" # How to pass a linker flag through the compiler. wl="-Wl," # Object file suffix (normally "o"). objext="o" # Old archive suffix (normally "a"). libext="a" # Shared library suffix (normally ".so"). shrext_cmds='.so' # Executable file suffix (normally ""). exeext="" # Additional compiler flags for building library objects. pic_flag=" -fPIC -DPIC" pic_mode=default # What is the maximum length of a command? max_cmd_len=32768 # Does compiler simultaneously support -c and -o options? compiler_c_o="yes" # Must we lock files when doing compilation? need_locks="no" # Do we need the lib prefix for modules? need_lib_prefix=no # Do we need a version for libraries? need_version=no # Whether dlopen is supported. dlopen_support=unknown # Whether dlopen of programs is supported. dlopen_self=unknown # Whether dlopen of statically linked programs is supported. dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. link_static_flag="" # Compiler flag to turn off builtin functions. no_builtin_flag=" -fno-builtin" # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec="\${wl}--export-dynamic" # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" # Compiler flag to generate thread-safe objects. thread_safe_flag_spec="" # Library versioning type. version_type=linux # Format of library name prefix. libname_spec="lib\$name" # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" # The coded name of the library, if different from the real name. soname_spec="\${libname}\${release}\${shared_ext}\$major" # Commands used to build and install an old-style archive. RANLIB="ranlib" old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB \$oldlib" old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" old_postuninstall_cmds="" # Create an old-style archive from a shared archive. old_archive_from_new_cmds="" # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds="" # Commands used to build and install a shared archive. archive_cmds="\$CC -shared -nostdlib \$predep_objects \$libobjs \$deplibs \$postdep_objects \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" archive_expsym_cmds="\$CC -shared -nostdlib \$predep_objects \$libobjs \$deplibs \$postdep_objects \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-retain-symbols-file \$wl\$export_symbols -o \$lib" postinstall_cmds="" postuninstall_cmds="" # Commands used to build a loadable module (assumed same as above if empty) module_cmds="" module_expsym_cmds="" # Commands to strip libraries. old_striplib="strip --strip-debug" striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. predep_objects=`echo "/usr/lib/crti.o /usr/lib/gcc-lib/i386-linux/egcs-2.91.66/crtbeginS.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=`echo "/usr/lib/gcc-lib/i386-linux/egcs-2.91.66/crtendS.o /usr/lib/crtn.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. predeps="" # Dependencies to place after the objects being linked to create a # shared library. postdeps="-lstdc++ -lm -lgcc -lc -lgcc" # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=`echo "-L/usr/lib/gcc-lib/i386-linux/egcs-2.91.66 -L/usr/i386-linux/lib" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" # Command to use when deplibs_check_method == file_magic. file_magic_cmd="\$MAGIC_CMD" # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag="" # Flag that forces no undefined symbols. no_undefined_flag="" # Commands used to finish a libtool library installation in a directory. finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" # Same as above, but a single script fragment to be evaled but not shown. finish_eval="" # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'" # Transform the output of nm in a proper C declaration global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'" # Transform the output of nm in a C name address pair global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (lt_ptr) \\&\\2},/p'" # This is the shared library runtime path variable. runpath_var=LD_RUN_PATH # This is the shared library path variable. shlibpath_var=LD_LIBRARY_PATH # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=no # How to hardcode a shared library path into an executable. hardcode_action=immediate # Whether we should hardcode library paths into libraries. hardcode_into_libs=yes # Flag to hardcode $libdir into a binary during linking. # This must work even if $libdir does not exist. hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir" # If ld is used when linking, flag to hardcode $libdir into # a binary during linking. This must work even if $libdir does # not exist. hardcode_libdir_flag_spec_ld="" # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator="" # Set to yes if using DIR/libNAME during linking hardcodes DIR into the # resulting binary. hardcode_direct=no # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=no # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=unsupported # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=no # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=unknown # Compile-time system search path for libraries sys_lib_search_path_spec=`echo " /usr/lib/gcc-lib/i386-linux/egcs-2.91.66/ /usr/lib/gcc/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/ /lib/i386-linux/egcs-2.91.66/ /lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib /usr/lib/qt2/lib /lib/gnulibc1 /usr/X11R6/lib/gnulibc1 /usr/openwin/lib/gnulibc1 /usr/lib/gnulibc1 /opt/kde/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" # Set to yes if exported symbols are required. always_export_symbols=no # The commands to list exported symbols. export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds="" # Symbols that should not be listed in the preloaded symbols. exclude_expsyms="" # Symbols that must always be exported. include_expsyms="" # ### END LIBTOOL TAG CONFIG: CXX # ### BEGIN LIBTOOL TAG CONFIG: F77 # Libtool was configured on host speedy.nodomain: # Shell to use when invoking shell scripts. SHELL="/bin/sh" # Whether or not to build shared libraries. build_libtool_libs=yes # Whether or not to build static libraries. build_old_libs=yes # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=no # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=no # Whether or not to optimize for fast installation. fast_install=yes # The host system. host_alias= host=i686-pc-linux-gnu host_os=linux-gnu # The build system. build_alias= build=i686-pc-linux-gnu build_os=linux-gnu # An echo program that does not interpret backslashes. echo="echo" # The archiver. AR="ar" AR_FLAGS="cru" # A C compiler. LTCC="gcc" # LTCC compiler flags. LTCFLAGS="-g -O2" # A language-specific compiler. CC="g77" # Is the compiler the GNU C compiler? with_gcc=yes gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` gcc_ver=`gcc -dumpversion` # An ERE matcher. EGREP="grep -E" # The linker used to build libraries. LD="/usr/i386-linux/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" # A BSD-compatible nm program. NM="/usr/bin/nm -B" # A symbol stripping program STRIP="strip" # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=file # Used on cygwin: DLL creation program. DLLTOOL="dlltool" # Used on cygwin: object dumper. OBJDUMP="objdump" # Used on cygwin: assembler. AS="as" # The name of the directory that contains temporary libtool files. objdir=.libs # How to create reloadable object files. reload_flag=" -r" reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" # How to pass a linker flag through the compiler. wl="-Wl," # Object file suffix (normally "o"). objext="o" # Old archive suffix (normally "a"). libext="a" # Shared library suffix (normally ".so"). shrext_cmds='.so' # Executable file suffix (normally ""). exeext="" # Additional compiler flags for building library objects. pic_flag=" -fPIC" pic_mode=default # What is the maximum length of a command? max_cmd_len=32768 # Does compiler simultaneously support -c and -o options? compiler_c_o="yes" # Must we lock files when doing compilation? need_locks="no" # Do we need the lib prefix for modules? need_lib_prefix=no # Do we need a version for libraries? need_version=no # Whether dlopen is supported. dlopen_support=unknown # Whether dlopen of programs is supported. dlopen_self=unknown # Whether dlopen of statically linked programs is supported. dlopen_self_static=unknown # Compiler flag to prevent dynamic linking. link_static_flag="-static" # Compiler flag to turn off builtin functions. no_builtin_flag="" # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec="\${wl}--export-dynamic" # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" # Compiler flag to generate thread-safe objects. thread_safe_flag_spec="" # Library versioning type. version_type=linux # Format of library name prefix. libname_spec="lib\$name" # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" # The coded name of the library, if different from the real name. soname_spec="\${libname}\${release}\${shared_ext}\$major" # Commands used to build and install an old-style archive. RANLIB="ranlib" old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB \$oldlib" old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib" old_postuninstall_cmds="" # Create an old-style archive from a shared archive. old_archive_from_new_cmds="" # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds="" # Commands used to build and install a shared archive. archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" archive_expsym_cmds="" postinstall_cmds="" postuninstall_cmds="" # Commands used to build a loadable module (assumed same as above if empty) module_cmds="" module_expsym_cmds="" # Commands to strip libraries. old_striplib="strip --strip-debug" striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Dependencies to place before the objects being linked to create a # shared library. predeps="" # Dependencies to place after the objects being linked to create a # shared library. postdeps="" # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" # Command to use when deplibs_check_method == file_magic. file_magic_cmd="\$MAGIC_CMD" # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag="" # Flag that forces no undefined symbols. no_undefined_flag="" # Commands used to finish a libtool library installation in a directory. finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" # Same as above, but a single script fragment to be evaled but not shown. finish_eval="" # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'" # Transform the output of nm in a proper C declaration global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'" # Transform the output of nm in a C name address pair global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (lt_ptr) \\&\\2},/p'" # This is the shared library runtime path variable. runpath_var=LD_RUN_PATH # This is the shared library path variable. shlibpath_var=LD_LIBRARY_PATH # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=no # How to hardcode a shared library path into an executable. hardcode_action=immediate # Whether we should hardcode library paths into libraries. hardcode_into_libs=yes # Flag to hardcode $libdir into a binary during linking. # This must work even if $libdir does not exist. hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir" # If ld is used when linking, flag to hardcode $libdir into # a binary during linking. This must work even if $libdir does # not exist. hardcode_libdir_flag_spec_ld="" # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator="" # Set to yes if using DIR/libNAME during linking hardcodes DIR into the # resulting binary. hardcode_direct=no # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=no # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=unsupported # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=no # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=unknown # Compile-time system search path for libraries sys_lib_search_path_spec=`echo " /usr/lib/gcc-lib/i386-linux/egcs-2.91.66/ /usr/lib/gcc/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/i386-linux/egcs-2.91.66/ /usr/i386-linux/lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/ /lib/i386-linux/egcs-2.91.66/ /lib/ /usr/lib/i386-linux/egcs-2.91.66/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib /usr/lib/qt2/lib /lib/gnulibc1 /usr/X11R6/lib/gnulibc1 /usr/openwin/lib/gnulibc1 /usr/lib/gnulibc1 /opt/kde/lib " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" # Set to yes if exported symbols are required. always_export_symbols=no # The commands to list exported symbols. export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds="" # Symbols that should not be listed in the preloaded symbols. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Symbols that must always be exported. include_expsyms="" # ### END LIBTOOL TAG CONFIG: F77 ./sqliteodbc-0.992/aclocal.m40100644000076400001440000070412511312032604014371 0ustar chwusers# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- ## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 ## Free Software Foundation, Inc. ## Originally by Gordon Matzigkeit , 1996 ## ## This file is free software; the Free Software Foundation gives ## unlimited permission to copy and/or distribute it, with or without ## modifications, as long as this notice is preserved. # serial 48 AC_PROG_LIBTOOL # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) # ----------------------------------------------------------- # If this macro is not defined by Autoconf, define it here. m4_ifdef([AC_PROVIDE_IFELSE], [], [m4_define([AC_PROVIDE_IFELSE], [m4_ifdef([AC_PROVIDE_$1], [$2], [$3])])]) # AC_PROG_LIBTOOL # --------------- AC_DEFUN([AC_PROG_LIBTOOL], [AC_REQUIRE([_AC_PROG_LIBTOOL])dnl dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. AC_PROVIDE_IFELSE([AC_PROG_CXX], [AC_LIBTOOL_CXX], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX ])]) dnl And a similar setup for Fortran 77 support AC_PROVIDE_IFELSE([AC_PROG_F77], [AC_LIBTOOL_F77], [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 ])]) dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [AC_LIBTOOL_GCJ], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [AC_LIBTOOL_GCJ], [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], [AC_LIBTOOL_GCJ], [ifdef([AC_PROG_GCJ], [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) ifdef([A][M_PROG_GCJ], [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) ifdef([LT_AC_PROG_GCJ], [define([LT_AC_PROG_GCJ], defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) ])])# AC_PROG_LIBTOOL # _AC_PROG_LIBTOOL # ---------------- AC_DEFUN([_AC_PROG_LIBTOOL], [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl # Prevent multiple expansion define([AC_PROG_LIBTOOL], []) ])# _AC_PROG_LIBTOOL # AC_LIBTOOL_SETUP # ---------------- AC_DEFUN([AC_LIBTOOL_SETUP], [AC_PREREQ(2.50)dnl AC_REQUIRE([AC_ENABLE_SHARED])dnl AC_REQUIRE([AC_ENABLE_STATIC])dnl AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_LD])dnl AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl AC_REQUIRE([AC_PROG_NM])dnl AC_REQUIRE([AC_PROG_LN_S])dnl AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! AC_REQUIRE([AC_OBJEXT])dnl AC_REQUIRE([AC_EXEEXT])dnl dnl AC_LIBTOOL_SYS_MAX_CMD_LEN AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE AC_LIBTOOL_OBJDIR AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl _LT_AC_PROG_ECHO_BACKSLASH case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e 1s/^X//' [sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] # Same as above, but do not quote variable references. [double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Constants: rm="rm -f" # Global variables: default_ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a ltmain="$ac_aux_dir/ltmain.sh" ofile="$default_ofile" with_gnu_ld="$lt_cv_prog_gnu_ld" AC_CHECK_TOOL(AR, ar, false) AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(STRIP, strip, :) old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru test -z "$AS" && AS=as test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$LD" && LD=ld test -z "$LN_S" && LN_S="ln -s" test -z "$MAGIC_CMD" && MAGIC_CMD=file test -z "$NM" && NM=nm test -z "$SED" && SED=sed test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$RANLIB" && RANLIB=: test -z "$STRIP" && STRIP=: test -z "$ac_objext" && ac_objext=o # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then AC_PATH_MAGIC fi ;; esac AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], enable_win32_dll=yes, enable_win32_dll=no) AC_ARG_ENABLE([libtool-lock], [AC_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes AC_ARG_WITH([pic], [AC_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=default # Use C for the default configuration in the libtool script tagname= AC_LIBTOOL_LANG_C_CONFIG _LT_AC_TAGCONFIG ])# AC_LIBTOOL_SETUP # _LT_AC_SYS_COMPILER # ------------------- AC_DEFUN([_LT_AC_SYS_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_AC_SYS_COMPILER # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. AC_DEFUN([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. AC_DEFUN([_LT_COMPILER_BOILERPLATE], [ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. AC_DEFUN([_LT_LINKER_BOILERPLATE], [ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* ])# _LT_LINKER_BOILERPLATE # _LT_AC_SYS_LIBPATH_AIX # ---------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], [AC_LINK_IFELSE(AC_LANG_PROGRAM,[ aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi],[]) if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_AC_SYS_LIBPATH_AIX # _LT_AC_SHELL_INIT(ARG) # ---------------------- AC_DEFUN([_LT_AC_SHELL_INIT], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) $1 AC_DIVERT_POP ])# _LT_AC_SHELL_INIT # _LT_AC_PROG_ECHO_BACKSLASH # -------------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], [_LT_AC_SHELL_INIT([ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac echo=${ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then # Yippee, $echo works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat </dev/null 2>&1 && unset CDPATH if test -z "$ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if (echo_test_string=`eval $cmd`) 2>/dev/null && echo_test_string=`eval $cmd` && (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null then break fi done fi if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$echo" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. echo='print -r' elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. echo='printf %s\n' if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL echo="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. echo=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. ECHO=$echo if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(ECHO) ])])# _LT_AC_PROG_ECHO_BACKSLASH # _LT_AC_LOCK # ----------- AC_DEFUN([_LT_AC_LOCK], [AC_ARG_ENABLE([libtool-lock], [AC_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) LD="${LD-ld} -64" ;; esac ;; esac fi rm -rf conftest* ;; AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], [*-*-cygwin* | *-*-mingw* | *-*-pw32*) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; ]) esac need_locks="$enable_libtool_lock" ])# _LT_AC_LOCK # AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [AC_REQUIRE([LT_AC_PROG_SED]) AC_CACHE_CHECK([$1], [$2], [$2=no ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $rm conftest* ]) if test x"[$]$2" = xyes; then ifelse([$5], , :, [$5]) else ifelse([$6], , :, [$6]) fi ])# AC_LIBTOOL_COMPILER_OPTION # AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ------------------------------------------------------------ # Check whether the given compiler option works AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" printf "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $rm conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then ifelse([$4], , :, [$4]) else ifelse([$5], , :, [$5]) fi ])# AC_LIBTOOL_LINKER_OPTION # AC_LIBTOOL_SYS_MAX_CMD_LEN # -------------------------- AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [# find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ = "XX$teststring") >/dev/null 2>&1 && new_result=`expr "X$teststring" : ".*" 2>&1` && lt_cv_sys_max_cmd_len=$new_result && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done teststring= # Add a significant safety factor because C++ compilers can tack on massive # amounts of additional arguments before passing them to the linker. # It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi ])# AC_LIBTOOL_SYS_MAX_CMD_LEN # _LT_AC_CHECK_DLFCN # ------------------ AC_DEFUN([_LT_AC_CHECK_DLFCN], [AC_CHECK_HEADERS(dlfcn.h)dnl ])# _LT_AC_CHECK_DLFCN # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # --------------------------------------------------------------------- AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); }] EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_AC_TRY_DLOPEN_SELF # AC_LIBTOOL_DLOPEN_SELF # ---------------------- AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_AC_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_AC_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi ])# AC_LIBTOOL_DLOPEN_SELF # AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) # --------------------------------- # Check to see if options -c and -o are simultaneously supported by compiler AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], [AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $rm -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $rm conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files $rm out/* && rmdir out cd .. rmdir conftest $rm conftest* ]) ])# AC_LIBTOOL_PROG_CC_C_O # AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) # ----------------------------------------- # Check to see if we can do hard links to lock some files if needed AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_REQUIRE([_LT_AC_LOCK])dnl hard_links="nottested" if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi ])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS # AC_LIBTOOL_OBJDIR # ----------------- AC_DEFUN([AC_LIBTOOL_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir ])# AC_LIBTOOL_OBJDIR # AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) # ---------------------------------------------- # Check hardcoding attributes. AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_AC_TAGVAR(hardcode_action, $1)= if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existant directories. if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_AC_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_AC_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_AC_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi ])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH # AC_LIBTOOL_SYS_LIB_STRIP # ------------------------ AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], [striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi ])# AC_LIBTOOL_SYS_LIB_STRIP # AC_LIBTOOL_SYS_DYNAMIC_LINKER # ----------------------------- # PORTME Fill in your ld.so characteristics AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_MSG_CHECKING([dynamic linker characteristics]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` else sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' fi sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; kfreebsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; freebsd*) # from 4.6 on shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix3*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # find out which ABI we are using libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *64-bit*) libsuff=64 sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ;; esac fi rm -rf conftest* ;; esac # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; knetbsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; nto-qnx*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' shlibpath_overrides_runpath=no else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' shlibpath_overrides_runpath=yes case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi ])# AC_LIBTOOL_SYS_DYNAMIC_LINKER # _LT_AC_TAGCONFIG # ---------------- AC_DEFUN([_LT_AC_TAGCONFIG], [AC_ARG_WITH([tags], [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], [include additional configurations @<:@automatic@:>@])], [tagnames="$withval"]) if test -f "$ltmain" && test -n "$tagnames"; then if test ! -f "${ofile}"; then AC_MSG_WARN([output file `$ofile' does not exist]) fi if test -z "$LTCC"; then eval "`$SHELL ${ofile} --config | grep '^LTCC='`" if test -z "$LTCC"; then AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) else AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) fi fi if test -z "$LTCFLAGS"; then eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" fi # Extract list of available tagged configurations in $ofile. # Note that this assumes the entire list is on one line. available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for tagname in $tagnames; do IFS="$lt_save_ifs" # Check whether tagname contains only valid characters case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in "") ;; *) AC_MSG_ERROR([invalid tag name: $tagname]) ;; esac if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null then AC_MSG_ERROR([tag name \"$tagname\" already exists]) fi # Update the list of available tags. if test -n "$tagname"; then echo appending configuration tag \"$tagname\" to $ofile case $tagname in CXX) if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_LIBTOOL_LANG_CXX_CONFIG else tagname="" fi ;; F77) if test -n "$F77" && test "X$F77" != "Xno"; then AC_LIBTOOL_LANG_F77_CONFIG else tagname="" fi ;; GCJ) if test -n "$GCJ" && test "X$GCJ" != "Xno"; then AC_LIBTOOL_LANG_GCJ_CONFIG else tagname="" fi ;; RC) AC_LIBTOOL_LANG_RC_CONFIG ;; *) AC_MSG_ERROR([Unsupported tag name: $tagname]) ;; esac # Append the new tag name to the list of available tags. if test -n "$tagname" ; then available_tags="$available_tags $tagname" fi fi done IFS="$lt_save_ifs" # Now substitute the updated list of available tags. if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then mv "${ofile}T" "$ofile" chmod +x "$ofile" else rm -f "${ofile}T" AC_MSG_ERROR([unable to update list of available tagged configurations.]) fi fi ])# _LT_AC_TAGCONFIG # AC_LIBTOOL_DLOPEN # ----------------- # enable checks for dlopen support AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) ])# AC_LIBTOOL_DLOPEN # AC_LIBTOOL_WIN32_DLL # -------------------- # declare package support for building win32 DLLs AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) ])# AC_LIBTOOL_WIN32_DLL # AC_ENABLE_SHARED([DEFAULT]) # --------------------------- # implement the --enable-shared flag # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. AC_DEFUN([AC_ENABLE_SHARED], [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE([shared], [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]AC_ENABLE_SHARED_DEFAULT) ])# AC_ENABLE_SHARED # AC_DISABLE_SHARED # ----------------- # set the default shared flag to --disable-shared AC_DEFUN([AC_DISABLE_SHARED], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_SHARED(no) ])# AC_DISABLE_SHARED # AC_ENABLE_STATIC([DEFAULT]) # --------------------------- # implement the --enable-static flag # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. AC_DEFUN([AC_ENABLE_STATIC], [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE([static], [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]AC_ENABLE_STATIC_DEFAULT) ])# AC_ENABLE_STATIC # AC_DISABLE_STATIC # ----------------- # set the default static flag to --disable-static AC_DEFUN([AC_DISABLE_STATIC], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_STATIC(no) ])# AC_DISABLE_STATIC # AC_ENABLE_FAST_INSTALL([DEFAULT]) # --------------------------------- # implement the --enable-fast-install flag # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. AC_DEFUN([AC_ENABLE_FAST_INSTALL], [define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE([fast-install], [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) ])# AC_ENABLE_FAST_INSTALL # AC_DISABLE_FAST_INSTALL # ----------------------- # set the default to --disable-fast-install AC_DEFUN([AC_DISABLE_FAST_INSTALL], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_FAST_INSTALL(no) ])# AC_DISABLE_FAST_INSTALL # AC_LIBTOOL_PICMODE([MODE]) # -------------------------- # implement the --with-pic flag # MODE is either `yes' or `no'. If omitted, it defaults to `both'. AC_DEFUN([AC_LIBTOOL_PICMODE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl pic_mode=ifelse($#,1,$1,default) ])# AC_LIBTOOL_PICMODE # AC_PROG_EGREP # ------------- # This is predefined starting with Autoconf 2.54, so this conditional # definition can be removed once we require Autoconf 2.54 or later. m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi]) EGREP=$ac_cv_prog_egrep AC_SUBST([EGREP]) ])]) # AC_PATH_TOOL_PREFIX # ------------------- # find a file program which can recognise shared library AC_DEFUN([AC_PATH_TOOL_PREFIX], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="ifelse([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi ])# AC_PATH_TOOL_PREFIX # AC_PATH_MAGIC # ------------- # find a file program which can recognise a shared library AC_DEFUN([AC_PATH_MAGIC], [AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# AC_PATH_MAGIC # AC_PROG_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([AC_PROG_LD], [AC_ARG_WITH([gnu-ld], [AC_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no]) AC_REQUIRE([LT_AC_PROG_SED])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix3*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; nto-qnx*) lt_cv_deplibs_check_method=unknown ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown ])# AC_DEPLIBS_CHECK_METHOD # AC_PROG_NM # ---------- # find the pathname to a BSD-compatible name lister AC_DEFUN([AC_PROG_NM], [AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi]) NM="$lt_cv_path_NM" ])# AC_PROG_NM # AC_CHECK_LIBM # ------------- # check for math library AC_DEFUN([AC_CHECK_LIBM], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac ])# AC_CHECK_LIBM # AC_LIBLTDL_CONVENIENCE([DIRECTORY]) # ----------------------------------- # sets LIBLTDL to the link flags for the libltdl convenience library and # LTDLINCL to the include flags for the libltdl header and adds # --enable-ltdl-convenience to the configure arguments. Note that # AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, # it is assumed to be `libltdl'. LIBLTDL will be prefixed with # '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' # (note the single quotes!). If your package is not flat and you're not # using automake, define top_builddir and top_srcdir appropriately in # the Makefiles. AC_DEFUN([AC_LIBLTDL_CONVENIENCE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl case $enable_ltdl_convenience in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) # For backwards non-gettext consistent compatibility... INCLTDL="$LTDLINCL" ])# AC_LIBLTDL_CONVENIENCE # AC_LIBLTDL_INSTALLABLE([DIRECTORY]) # ----------------------------------- # sets LIBLTDL to the link flags for the libltdl installable library and # LTDLINCL to the include flags for the libltdl header and adds # --enable-ltdl-install to the configure arguments. Note that # AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, # and an installed libltdl is not found, it is assumed to be `libltdl'. # LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with # '${top_srcdir}/' (note the single quotes!). If your package is not # flat and you're not using automake, define top_builddir and top_srcdir # appropriately in the Makefiles. # In the future, this macro may have to be called after AC_PROG_LIBTOOL. AC_DEFUN([AC_LIBLTDL_INSTALLABLE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_CHECK_LIB(ltdl, lt_dlinit, [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], [if test x"$enable_ltdl_install" = xno; then AC_MSG_WARN([libltdl not installed, but installation disabled]) else enable_ltdl_install=yes fi ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl" LTDLINCL= fi # For backwards non-gettext consistent compatibility... INCLTDL="$LTDLINCL" ])# AC_LIBLTDL_INSTALLABLE # AC_LIBTOOL_CXX # -------------- # enable support for C++ libraries AC_DEFUN([AC_LIBTOOL_CXX], [AC_REQUIRE([_LT_AC_LANG_CXX]) ])# AC_LIBTOOL_CXX # _LT_AC_LANG_CXX # --------------- AC_DEFUN([_LT_AC_LANG_CXX], [AC_REQUIRE([AC_PROG_CXX]) AC_REQUIRE([_LT_AC_PROG_CXXCPP]) _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) ])# _LT_AC_LANG_CXX # _LT_AC_PROG_CXXCPP # ------------------ AC_DEFUN([_LT_AC_PROG_CXXCPP], [ AC_REQUIRE([AC_PROG_CXX]) if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP fi ])# _LT_AC_PROG_CXXCPP # AC_LIBTOOL_F77 # -------------- # enable support for Fortran 77 libraries AC_DEFUN([AC_LIBTOOL_F77], [AC_REQUIRE([_LT_AC_LANG_F77]) ])# AC_LIBTOOL_F77 # _LT_AC_LANG_F77 # --------------- AC_DEFUN([_LT_AC_LANG_F77], [AC_REQUIRE([AC_PROG_F77]) _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) ])# _LT_AC_LANG_F77 # AC_LIBTOOL_GCJ # -------------- # enable support for GCJ libraries AC_DEFUN([AC_LIBTOOL_GCJ], [AC_REQUIRE([_LT_AC_LANG_GCJ]) ])# AC_LIBTOOL_GCJ # _LT_AC_LANG_GCJ # --------------- AC_DEFUN([_LT_AC_LANG_GCJ], [AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) ])# _LT_AC_LANG_GCJ # AC_LIBTOOL_RC # ------------- # enable support for Windows resource files AC_DEFUN([AC_LIBTOOL_RC], [AC_REQUIRE([LT_AC_PROG_RC]) _LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) ])# AC_LIBTOOL_RC # AC_LIBTOOL_LANG_C_CONFIG # ------------------------ # Ensure that the configuration vars for the C compiler are # suitably defined. Those variables are subsequently used by # AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) AC_DEFUN([_LT_AC_LANG_C_CONFIG], [lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_AC_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;\n" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}\n' _LT_AC_SYS_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) AC_LIBTOOL_PROG_COMPILER_PIC($1) AC_LIBTOOL_PROG_CC_C_O($1) AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) AC_LIBTOOL_PROG_LD_SHLIBS($1) AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) AC_LIBTOOL_SYS_LIB_STRIP AC_LIBTOOL_DLOPEN_SELF # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix4* | aix5*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) AC_LIBTOOL_CONFIG($1) AC_LANG_POP CC="$lt_save_CC" ])# AC_LIBTOOL_LANG_C_CONFIG # AC_LIBTOOL_LANG_CXX_CONFIG # -------------------------- # Ensure that the configuration vars for the C compiler are # suitably defined. Those variables are subsequently used by # AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], [AC_LANG_PUSH(C++) AC_REQUIRE([AC_PROG_CXX]) AC_REQUIRE([_LT_AC_PROG_CXXCPP]) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(allow_undefined_flag, $1)= _LT_AC_TAGVAR(always_export_symbols, $1)=no _LT_AC_TAGVAR(archive_expsym_cmds, $1)= _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= _LT_AC_TAGVAR(hardcode_minus_L, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(hardcode_automatic, $1)=no _LT_AC_TAGVAR(module_cmds, $1)= _LT_AC_TAGVAR(module_expsym_cmds, $1)= _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown _LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_AC_TAGVAR(no_undefined_flag, $1)= _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Dependencies to place before and after the object being linked: _LT_AC_TAGVAR(predep_objects, $1)= _LT_AC_TAGVAR(postdep_objects, $1)= _LT_AC_TAGVAR(predeps, $1)= _LT_AC_TAGVAR(postdeps, $1)= _LT_AC_TAGVAR(compiler_lib_search_path, $1)= # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_AC_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;\n" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_AC_SYS_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC _LT_AC_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) # We don't want -fno-exception wen compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration AC_PROG_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ grep 'no-whole-archive' > /dev/null; then _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_AC_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_AC_TAGVAR(archive_cmds, $1)='' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 _LT_AC_TAGVAR(hardcode_direct, $1)=yes else # We have old collect2 _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_AC_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty executable. _LT_AC_SYS_LIBPATH_AIX _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. _LT_AC_SYS_LIBPATH_AIX _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_AC_TAGVAR(always_export_symbols, $1)=no _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[[012]]) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[[012]]) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_automatic, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GXX" = yes ; then lt_int_apple_cc_single_mod=no output_verbose_link_cmd='echo' if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then lt_int_apple_cc_single_mod=yes fi if test "X$lt_int_apple_cc_single_mod" = Xyes ; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' else _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' fi _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds if test "X$lt_int_apple_cc_single_mod" = Xyes ; then _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' fi _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before switch to ELF _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | kfreebsd*-gnu | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_AC_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; hpux9*) _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' ;; *) _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix3*) _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' fi fi _LT_AC_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: ;; linux*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc*) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC*) # Portland Group C++ compiler _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; openbsd2*) # C++ shared libraries are fairly broken _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd='echo' ;; osf3*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; cxx*) _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; cxx*) _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ $rm $lib.exp' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The C++ compiler is used as linker so we must use $wl # flag to pass the commands to the underlying system # linker. We must also pass each convience library through # to the system linker between allextract/defaultextract. # The C++ compiler will combine linker options so we # cannot just pass the convience library names through # without $wl. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac _LT_AC_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | grep -v '^2\.7' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. # So that behaviour is only enabled if SCOABSPATH is set to a # non-empty value in the environment. Most likely only useful for # creating official distributions of packages. # This is a hack until libtool officially supports absolute path # names for shared libraries. _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_AC_TAGVAR(GCC, $1)="$GXX" _LT_AC_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... AC_LIBTOOL_POSTDEP_PREDEP($1) AC_LIBTOOL_PROG_COMPILER_PIC($1) AC_LIBTOOL_PROG_CC_C_O($1) AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) AC_LIBTOOL_PROG_LD_SHLIBS($1) AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) AC_LIBTOOL_CONFIG($1) AC_LANG_POP CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ldcxx=$with_gnu_ld with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld ])# AC_LIBTOOL_LANG_CXX_CONFIG # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) # ------------------------------------ # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" ifelse([$1], [], [#! $SHELL # `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="$SED -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # The names of the tagged configurations supported by this script. available_tags= # ### BEGIN LIBTOOL CONFIG], [# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) # Is the compiler the GNU C compiler? with_gcc=$_LT_AC_TAGVAR(GCC, $1) gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_[]_LT_AC_TAGVAR(LD, $1) # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) # Commands used to build and install a shared archive. archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) # Flag that forces no undefined symbols. no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" # Set to yes if exported symbols are required. always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) # The commands to list exported symbols. export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) # Symbols that must always be exported. include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) ifelse([$1],[], [# ### END LIBTOOL CONFIG], [# ### END LIBTOOL TAG CONFIG: $tagname]) __EOF__ ifelse([$1],[], [ case $host_os in aix3*) cat <<\EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi EOF ;; esac # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || \ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ]) else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ])# AC_LIBTOOL_CONFIG # AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------------------- AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi ])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE # --------------------------------- AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_PROG_NM]) AC_REQUIRE([AC_OBJEXT]) # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Transform an extracted symbol line into a proper C declaration lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32*) symcode='[[ABCDGISTW]]' ;; hpux*) # Its linker distinguishes data from code symbols if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" ;; linux*) if test "$host_cpu" = ia64; then symcode='[[ABCDGIRSTW]]' lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if grep ' nm_test_var$' "$nlist" >/dev/null; then if grep ' nm_test_func$' "$nlist" >/dev/null; then cat < conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' cat <> conftest.$ac_ext #if defined (__STDC__) && __STDC__ # define lt_ptr_t void * #else # define lt_ptr_t char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr_t address; } lt_preloaded_symbols[[]] = { EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext {0, (lt_ptr_t) 0} }; #ifdef __cplusplus } #endif EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -f conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi ]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE # AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) # --------------------------------------- AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], [_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= _LT_AC_TAGVAR(lt_prog_compiler_static, $1)= AC_MSG_CHECKING([for $compiler option to produce PIC]) ifelse([$1],[CXX],[ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | os2* | pw32*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix4* | aix5*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; esac ;; dgux*) case $cc_basename in ec++*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | kfreebsd*-gnu | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; icpc* | ecpc*) # Intel C++ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC*) # Portland Group C++ compiler. _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; vxworks*) ;; *) _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; sysv4*MP*) if test -d /usr/nec; then _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; esac ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; newsos6) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; linux*) case $cc_basename in icc* | ecc*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; esac ;; osf3* | osf4* | osf5*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" ;; esac # # Check to make sure the static flag actually works. # wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) ]) # AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) # ------------------------------------ # See if the linker supports building shared libraries. AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) ifelse([$1],[CXX],[ _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix4* | aix5*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' else _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw*) _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' ;; *) _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ],[ runpath_var= _LT_AC_TAGVAR(allow_undefined_flag, $1)= _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_AC_TAGVAR(archive_cmds, $1)= _LT_AC_TAGVAR(archive_expsym_cmds, $1)= _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_minus_L, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown _LT_AC_TAGVAR(hardcode_automatic, $1)=no _LT_AC_TAGVAR(module_cmds, $1)= _LT_AC_TAGVAR(module_expsym_cmds, $1)= _LT_AC_TAGVAR(always_export_symbols, $1)=no _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_AC_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. _LT_CC_BASENAME([$compiler]) case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_AC_TAGVAR(ld_shlibs, $1)=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>/dev/null` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_AC_TAGVAR(ld_shlibs, $1)=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF fi ;; amigaos*) _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can't use # them. _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_AC_TAGVAR(always_export_symbols, $1)=no _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; interix3*) _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; linux*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then tmp_addflag= case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; esac _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test $supports_anon_versioning = yes; then _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ $echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then _LT_AC_TAGVAR(ld_shlibs, $1)=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_AC_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_AC_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_AC_TAGVAR(always_export_symbols, $1)=yes _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' else _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_AC_TAGVAR(archive_cmds, $1)='' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 _LT_AC_TAGVAR(hardcode_direct, $1)=yes else # We have old collect2 _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_AC_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty executable. _LT_AC_SYS_LIBPATH_AIX _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. _LT_AC_SYS_LIBPATH_AIX _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # see comment about different semantics on the GNU ld section _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; bsdi[[45]]*) _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[[012]]) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[[012]]) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_automatic, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac fi ;; dgux*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | kfreebsd*-gnu | dragonfly*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: _LT_AC_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: _LT_AC_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; openbsd*) _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi ;; os2*) _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' # Both c and cxx compiler support -rpath directly _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' if test "$GCC" = yes; then wlarc='${wl}' _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' else wlarc='' _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine linker options so we # cannot just pass the convience library names through # without $wl, iff we do not link with $LD. # Luckily, gcc supports the same syntax we need for Sun Studio. # Supported since Solaris 2.6 (maybe 2.5.1?) case $wlarc in '') _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; *) _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac ;; esac _LT_AC_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_direct, $1)=yes _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_AC_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_AC_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*) _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_AC_TAGVAR(link_all_deplibs, $1)=yes _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_AC_TAGVAR(ld_shlibs, $1)=no ;; esac fi ]) AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no # # Do we need to explicitly link libc? # case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_AC_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_MSG_CHECKING([whether -lc should be explicitly linked in]) $rm conftest* printf "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) _LT_AC_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) then _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no else _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $rm conftest* AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) ;; esac fi ;; esac ])# AC_LIBTOOL_PROG_LD_SHLIBS # _LT_AC_FILE_LTDLL_C # ------------------- # Be careful that the start marker always follows a newline. AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ # /* ltdll.c starts here */ # #define WIN32_LEAN_AND_MEAN # #include # #undef WIN32_LEAN_AND_MEAN # #include # # #ifndef __CYGWIN__ # # ifdef __CYGWIN32__ # # define __CYGWIN__ __CYGWIN32__ # # endif # #endif # # #ifdef __cplusplus # extern "C" { # #endif # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); # #ifdef __cplusplus # } # #endif # # #ifdef __CYGWIN__ # #include # DECLARE_CYGWIN_DLL( DllMain ); # #endif # HINSTANCE __hDllInstance_base; # # BOOL APIENTRY # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) # { # __hDllInstance_base = hInst; # return TRUE; # } # /* ltdll.c ends here */ ])# _LT_AC_FILE_LTDLL_C # _LT_AC_TAGVAR(VARNAME, [TAGNAME]) # --------------------------------- AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) # old names AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) # This is just to silence aclocal about the macro not being used ifelse([AC_DISABLE_FAST_INSTALL]) AC_DEFUN([LT_AC_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj, no) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS) ]) AC_DEFUN([LT_AC_PROG_RC], [AC_CHECK_TOOL(RC, windres, no) ]) ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ # LT_AC_PROG_SED # -------------- # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. AC_DEFUN([LT_AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ]) ./sqliteodbc-0.992/configure0100755000076400001440000261511112121304476014446 0ustar chwusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` ;; esac echo=${ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then # Yippee, $echo works! : else # Restart under the correct shell. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat </dev/null 2>&1 && unset CDPATH if test -z "$ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if (echo_test_string=`eval $cmd`) 2>/dev/null && echo_test_string=`eval $cmd` && (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null then break fi done fi if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$echo" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. echo='print -r' elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} else # Try using printf. echo='printf %s\n' if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL echo="$CONFIG_SHELL $0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$CONFIG_SHELL $0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "$0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} else # Oops. We lost completely, so just stick with echo. echo=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. ECHO=$echo if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" fi tagnames=${tagnames+${tagnames},}CXX tagnames=${tagnames+${tagnames},}F77 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="sqliteodbc.h" # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CPP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SQLITE_INC SQLITE_LIB SQLITE_LIBVERSION SQLITE_ENCDEC SQLITE_ATOF SQLITE_MPRINTF SQLITE_TRACE SQLITE3_INC SQLITE3_A10N_C SQLITE3_A10N_FLAGS SQLITE3_COLUMNTABLENAME SQLITE3_OVERLOADFUNCTION SQLITE3_PREPARE_V2 SQLITE3_CLEARBINDINGS SQLITE3_CREATEMODULE_V2 SQLITE3_LOADEXTENSION SQLITE3_TABLECOLUMNMETADATA SQLITE3_VFS SQLITE3_PROFILE SQLITE3_STRNICMP EXT_BLOBTOXY EXT_IMPEXP EXT_CSVTABLE EXT_ZIPFILE SQLITE4_INC SQLITE4_A10N_C SQLITE4_A10N_FLAGS XML2_FLAGS XML2_LIBS EXT_XPATH LIB_TARGETS INST_TARGETS UNINST_TARGETS DRVINST_TARGETS DRVUNINST_TARGETS ODBC_FLAGS ODBC_LIB VER_INFO DRVDIR DL_OPTS DL_INITFINI SQLITE3_LIB SQLITE3_A10N_O SQLITE4_A10N_O SPEC_CHANGELOG_TS DEB_CHANGELOG_TS LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP ac_env_CXX_set=${CXX+set} ac_env_CXX_value=$CXX ac_cv_env_CXX_set=${CXX+set} ac_cv_env_CXX_value=$CXX ac_env_CXXFLAGS_set=${CXXFLAGS+set} ac_env_CXXFLAGS_value=$CXXFLAGS ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} ac_cv_env_CXXFLAGS_value=$CXXFLAGS ac_env_CXXCPP_set=${CXXCPP+set} ac_env_CXXCPP_value=$CXXCPP ac_cv_env_CXXCPP_set=${CXXCPP+set} ac_cv_env_CXXCPP_value=$CXXCPP ac_env_F77_set=${F77+set} ac_env_F77_value=$F77 ac_cv_env_F77_set=${F77+set} ac_cv_env_F77_value=$F77 ac_env_FFLAGS_set=${FFLAGS+set} ac_env_FFLAGS_value=$FFLAGS ac_cv_env_FFLAGS_set=${FFLAGS+set} ac_cv_env_FFLAGS_value=$FFLAGS # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-winterface make SQL*W() functions Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-pic try to use only PIC/non-PIC objects [default=use both] --with-tags[=TAGS] include additional configurations [automatic] --with-sqlite=DIR use SQLite header/lib from DIR --with-sqlite3=DIR use SQLite3 hdr/lib from DIR --with-sqlite4=DIR use SQLite4 hdr/src from DIR --with-odbc=DIR use ODBC header/libs from DIR --with-dls dlopen SQLite3/SQLite4 lib Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor F77 Fortran 77 compiler command FFLAGS Fortran 77 compiler flags Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi; # Check whether --enable-static or --disable-static was given. if test "${enable_static+set}" = set; then enableval="$enable_static" p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi; # Check whether --enable-fast-install or --disable-fast-install was given. if test "${enable_fast_install+set}" = set; then enableval="$enable_fast_install" p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi; ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 if test "${lt_cv_path_SED+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done fi SED=$lt_cv_path_SED echo "$as_me:$LINENO: result: $SED" >&5 echo "${ECHO_T}$SED" >&6 echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_prog_egrep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 echo "${ECHO_T}$ac_cv_prog_egrep" >&6 EGREP=$ac_cv_prog_egrep # Check whether --with-gnu-ld or --without-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval="$with_gnu_ld" test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi; ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo "$as_me:$LINENO: checking for ld used by $CC" >&5 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then echo "$as_me:$LINENO: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 else echo "$as_me:$LINENO: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 fi if test "${lt_cv_path_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 echo "${ECHO_T}$LD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 with_gnu_ld=$lt_cv_prog_gnu_ld echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 if test "${lt_cv_ld_reload_flag+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_reload_flag='-r' fi echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 if test "${lt_cv_path_NM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 echo "${ECHO_T}$lt_cv_path_NM" >&6 NM="$lt_cv_path_NM" echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6 fi echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 if test "${lt_cv_deplibs_check_method+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix4* | aix5*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump'. lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | kfreebsd*-gnu | dragonfly*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix3*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; nto-qnx*) lt_cv_deplibs_check_method=unknown ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; esac fi echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check whether --enable-libtool-lock or --disable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then enableval="$enable_libtool_lock" fi; test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line 3073 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 if test "${lt_cv_cc_needs_belf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_cc_needs_belf=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 lt_cv_cc_needs_belf=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) LD="${LD-ld} -64" ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CXX" && break done test -n "$ac_ct_CXX" || ac_ct_CXX="g++" CXX=$ac_ct_CXX fi # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS CXXFLAGS="-g" echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cxx_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi echo "$as_me:$LINENO: result: $CXXCPP" >&5 echo "${ECHO_T}$CXXCPP" >&6 ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi ac_ext=f ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_f77_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_F77+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$F77"; then ac_cv_prog_F77="$F77" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_F77="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi F77=$ac_cv_prog_F77 if test -n "$F77"; then echo "$as_me:$LINENO: result: $F77" >&5 echo "${ECHO_T}$F77" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$F77" && break done fi if test -z "$F77"; then ac_ct_F77=$F77 for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_F77+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_F77"; then ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_F77="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_F77=$ac_cv_prog_ac_ct_F77 if test -n "$ac_ct_F77"; then echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 echo "${ECHO_T}$ac_ct_F77" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_F77" && break done F77=$ac_ct_F77 fi # Provide some information about the compiler. echo "$as_me:4563:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -f a.out # If we don't use `.F' as extension, the preprocessor is not run on the # input file. (Note that this only needs to work for GNU compilers.) ac_save_ext=$ac_ext ac_ext=F echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 if test "${ac_cv_f77_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF program main #ifndef __GNUC__ choke me #endif end _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_f77_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 ac_ext=$ac_save_ext ac_test_FFLAGS=${FFLAGS+set} ac_save_FFLAGS=$FFLAGS FFLAGS= echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_f77_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else FFLAGS=-g cat >conftest.$ac_ext <<_ACEOF program main end _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_f77_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_f77_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 if test "$ac_test_FFLAGS" = set; then FFLAGS=$ac_save_FFLAGS elif test $ac_cv_prog_f77_g = yes; then if test "x$ac_cv_f77_compiler_gnu" = xyes; then FFLAGS="-g -O2" else FFLAGS="-g" fi else if test "x$ac_cv_f77_compiler_gnu" = xyes; then FFLAGS="-O2" else FFLAGS= fi fi G77=`test $ac_compiler_gnu = yes && echo yes` ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! # find the maximum length of command line arguments echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 if test "${lt_cv_sys_max_cmd_len+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ = "XX$teststring") >/dev/null 2>&1 && new_result=`expr "X$teststring" : ".*" 2>&1` && lt_cv_sys_max_cmd_len=$new_result && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done teststring= # Add a significant safety factor because C++ compilers can tack on massive # amounts of additional arguments before passing them to the linker. # It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 else echo "$as_me:$LINENO: result: none" >&5 echo "${ECHO_T}none" >&6 fi # Check for command to grab the raw symbol name followed by C symbol from nm. echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Transform an extracted symbol line into a proper C declaration lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32*) symcode='[ABCDGISTW]' ;; hpux*) # Its linker distinguishes data from code symbols if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" ;; linux*) if test "$host_cpu" = ia64; then symcode='[ABCDGIRSTW]' lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Now try to grab the symbols. nlist=conftest.nm if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if grep ' nm_test_var$' "$nlist" >/dev/null; then if grep ' nm_test_func$' "$nlist" >/dev/null; then cat < conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' cat <> conftest.$ac_ext #if defined (__STDC__) && __STDC__ # define lt_ptr_t void * #else # define lt_ptr_t char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr_t address; } lt_preloaded_symbols[] = { EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext {0, (lt_ptr_t) 0} }; #ifdef __cplusplus } #endif EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then echo "$as_me:$LINENO: result: failed" >&5 echo "${ECHO_T}failed" >&6 else echo "$as_me:$LINENO: result: ok" >&5 echo "${ECHO_T}ok" >&6 fi echo "$as_me:$LINENO: checking for objdir" >&5 echo $ECHO_N "checking for objdir... $ECHO_C" >&6 if test "${lt_cv_objdir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 echo "${ECHO_T}$lt_cv_objdir" >&6 objdir=$lt_cv_objdir case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e 1s/^X//' sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Constants: rm="rm -f" # Global variables: default_ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a ltmain="$ac_aux_dir/ltmain.sh" ofile="$default_ofile" with_gnu_ld="$lt_cv_prog_gnu_ld" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="${ac_tool_prefix}ar" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then echo "$as_me:$LINENO: result: $AR" >&5 echo "${ECHO_T}$AR" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 echo "${ECHO_T}$ac_ct_AR" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi AR=$ac_ct_AR else AR="$ac_cv_prog_AR" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi RANLIB=$ac_ct_RANLIB else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi STRIP=$ac_ct_STRIP else STRIP="$ac_cv_prog_STRIP" fi old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru test -z "$AS" && AS=as test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$LD" && LD=ld test -z "$LN_S" && LN_S="ln -s" test -z "$MAGIC_CMD" && MAGIC_CMD=file test -z "$NM" && NM=nm test -z "$SED" && SED=sed test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$RANLIB" && RANLIB=: test -z "$STRIP" && STRIP=: test -z "$ac_objext" && ac_objext=o # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo "$as_me:$LINENO: checking for file" >&5 echo $ECHO_N "checking for file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi else MAGIC_CMD=: fi fi fi ;; esac enable_dlopen=no enable_win32_dll=no # Check whether --enable-libtool-lock or --disable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then enableval="$enable_libtool_lock" fi; test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Check whether --with-pic or --without-pic was given. if test "${with_pic+set}" = set; then withval="$with_pic" pic_mode="$withval" else pic_mode=default fi; test -z "$pic_mode" && pic_mode=default # Use C for the default configuration in the libtool script tagname= lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;\n" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}\n' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:5630: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:5634: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; *) lt_prog_compiler_pic='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) lt_prog_compiler_pic='-qnocommon' lt_prog_compiler_wl='-Wl,' ;; esac ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; linux*) case $cc_basename in icc* | ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; esac ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 echo "${ECHO_T}$lt_prog_compiler_pic" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:5898: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:5902: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_pic_works=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 if test x"$lt_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 if test "${lt_prog_compiler_static_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" printf "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_static_works=yes fi else lt_prog_compiler_static_works=yes fi fi $rm conftest* LDFLAGS="$save_LDFLAGS" fi echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 if test x"$lt_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o=no $rm -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:6002: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:6006: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $rm conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files $rm out/* && rmdir out cd .. rmdir conftest $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 runpath_var= allow_undefined_flag= enable_shared_with_static_runtimes=no archive_cmds= archive_expsym_cmds= old_archive_From_new_cmds= old_archive_from_expsyms_cmds= export_dynamic_flag_spec= whole_archive_flag_spec= thread_safe_flag_spec= hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no hardcode_shlibpath_var=unsupported link_all_deplibs=unknown hardcode_automatic=no module_cmds= module_expsym_cmds= always_export_symbols=no export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>/dev/null` in *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF fi ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can't use # them. ld_shlibs=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; interix3*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; linux*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then tmp_addflag= case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; esac archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test $supports_anon_versioning = yes; then archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ $echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_libdir_separator=':' link_all_deplibs=yes if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct=yes else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # see comment about different semantics on the GNU ld section ld_shlibs=no ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_From_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[012]) allow_undefined_flag='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[012]) allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported whole_archive_flag_spec='' link_all_deplibs=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) ld_shlibs=no ;; esac fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | kfreebsd*-gnu | dragonfly*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_ld='-rpath $libdir' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; openbsd*) hardcode_direct=yes hardcode_shlibpath_var=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z text' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' else wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine linker options so we # cannot just pass the convience library names through # without $wl, iff we do not link with $LD. # Luckily, gcc supports the same syntax we need for Sun Studio. # Supported since Solaris 2.6 (maybe 2.5.1?) case $wlarc in '') whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; *) whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac fi echo "$as_me:$LINENO: result: $ld_shlibs" >&5 echo "${ECHO_T}$ld_shlibs" >&6 test "$ld_shlibs" = no && can_build_shared=no # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* printf "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc=no else archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $rm conftest* echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 echo "${ECHO_T}$archive_cmds_need_lc" >&6 ;; esac fi ;; esac echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` else sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' fi sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; kfreebsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; freebsd*) # from 4.6 on shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix3*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # find out which ABI we are using libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) echo '#line 7471 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *64-bit*) libsuff=64 sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ;; esac fi rm -rf conftest* ;; esac # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; knetbsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; nto-qnx*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' shlibpath_overrides_runpath=no else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' shlibpath_overrides_runpath=yes case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ test -n "$runpath_var" || \ test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existant directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi echo "$as_me:$LINENO: result: $hardcode_action" >&5 echo "${ECHO_T}$hardcode_action" >&6 if test "$hardcode_action" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi striplib= old_striplib= echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi ;; *) echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 ;; esac fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) echo "$as_me:$LINENO: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define shl_load to an innocuous variant, in case declares shl_load. For example, HP-UX 11i declares gettimeofday. */ #define shl_load innocuous_shl_load /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef shl_load /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_shl_load) || defined (__stub___shl_load) choke me #else char (*f) () = shl_load; #endif #ifdef __cplusplus } #endif int main () { return f != shl_load; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shl_load=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shl_load=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6 if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load (); int main () { shl_load (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_shl_load=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dld_shl_load=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" else echo "$as_me:$LINENO: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define dlopen to an innocuous variant, in case declares dlopen. For example, HP-UX 11i declares gettimeofday. */ #define dlopen innocuous_dlopen /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef dlopen /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_dlopen) || defined (__stub___dlopen) choke me #else char (*f) () = dlopen; #endif #ifdef __cplusplus } #endif int main () { return f != dlopen; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_dlopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6 if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_svld_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_svld_dlopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dld_link (); int main () { dld_link (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_dld_link=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dld_dld_link=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); } EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); exit (status); } EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi # Report which library types will actually be built echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $can_build_shared" >&5 echo "${ECHO_T}$can_build_shared" >&6 echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix4* | aix5*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac echo "$as_me:$LINENO: result: $enable_shared" >&5 echo "${ECHO_T}$enable_shared" >&6 echo "$as_me:$LINENO: checking whether to build static libraries" >&5 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes echo "$as_me:$LINENO: result: $enable_static" >&5 echo "${ECHO_T}$enable_static" >&6 # The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then # See if we are running on zsh, and set the options which allow our commands through # without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ SED SHELL STRIP \ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ deplibs_check_method reload_flag reload_cmds need_locks \ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ old_postinstall_cmds old_postuninstall_cmds \ compiler \ CC \ LD \ lt_prog_compiler_wl \ lt_prog_compiler_pic \ lt_prog_compiler_static \ lt_prog_compiler_no_builtin_flag \ export_dynamic_flag_spec \ thread_safe_flag_spec \ whole_archive_flag_spec \ enable_shared_with_static_runtimes \ old_archive_cmds \ old_archive_from_new_cmds \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ archive_cmds \ archive_expsym_cmds \ postinstall_cmds \ postuninstall_cmds \ old_archive_from_expsyms_cmds \ allow_undefined_flag \ no_undefined_flag \ export_symbols_cmds \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ hardcode_automatic \ module_cmds \ module_expsym_cmds \ lt_cv_prog_compiler_c_o \ exclude_expsyms \ include_expsyms; do case $var in old_archive_cmds | \ old_archive_from_new_cmds | \ archive_cmds | \ archive_expsym_cmds | \ module_cmds | \ module_expsym_cmds | \ old_archive_from_expsyms_cmds | \ export_symbols_cmds | \ extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done case $lt_echo in *'\$0 --fallback-echo"') lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` ;; esac cfgfile="${ofile}T" trap "$rm \"$cfgfile\"; exit 1" 1 2 15 $rm -f "$cfgfile" { echo "$as_me:$LINENO: creating $ofile" >&5 echo "$as_me: creating $ofile" >&6;} cat <<__EOF__ >> "$cfgfile" #! $SHELL # `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: # Originally by Gordon Matzigkeit , 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="$SED -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # The names of the tagged configurations supported by this script. available_tags= # ### BEGIN LIBTOOL CONFIG # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_compiler # Is the compiler the GNU C compiler? with_gcc=$GCC gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_LD # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_predep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_postdep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_predeps # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_compiler_lib_search_path | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$hardcode_automatic # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # ### END LIBTOOL CONFIG __EOF__ case $host_os in aix3*) cat <<\EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi EOF ;; esac # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || \ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" # Check whether --with-tags or --without-tags was given. if test "${with_tags+set}" = set; then withval="$with_tags" tagnames="$withval" fi; if test -f "$ltmain" && test -n "$tagnames"; then if test ! -f "${ofile}"; then { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} fi if test -z "$LTCC"; then eval "`$SHELL ${ofile} --config | grep '^LTCC='`" if test -z "$LTCC"; then { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} else { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} fi fi if test -z "$LTCFLAGS"; then eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" fi # Extract list of available tagged configurations in $ofile. # Note that this assumes the entire list is on one line. available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for tagname in $tagnames; do IFS="$lt_save_ifs" # Check whether tagname contains only valid characters case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in "") ;; *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 echo "$as_me: error: invalid tag name: $tagname" >&2;} { (exit 1); exit 1; }; } ;; esac if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null then { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} { (exit 1); exit 1; }; } fi # Update the list of available tags. if test -n "$tagname"; then echo appending configuration tag \"$tagname\" to $ofile case $tagname in CXX) if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_flag_spec_ld_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;\n" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # We don't want -fno-exception wen compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld or --without-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval="$with_gnu_ld" test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi; ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo "$as_me:$LINENO: checking for ld used by $CC" >&5 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then echo "$as_me:$LINENO: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 else echo "$as_me:$LINENO: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 fi if test "${lt_cv_path_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 echo "${ECHO_T}$LD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ grep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct_CXX=yes else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[012]) allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[012]) allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported whole_archive_flag_spec_CXX='' link_all_deplibs_CXX=yes if test "$GXX" = yes ; then lt_int_apple_cc_single_mod=no output_verbose_link_cmd='echo' if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then lt_int_apple_cc_single_mod=yes fi if test "X$lt_int_apple_cc_single_mod" = Xyes ; then archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' else archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' fi module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds if test "X$lt_int_apple_cc_single_mod" = Xyes ; then archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' fi module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) ld_shlibs_CXX=no ;; esac fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd[12]*) # C++ shared libraries reported to be fairly broken before switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | kfreebsd*-gnu | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) hardcode_libdir_flag_spec_ld_CXX='+b $libdir' ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix3*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: ;; linux*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc*) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC*) # Portland Group C++ compiler archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd='echo' ;; osf3*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ $rm $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The C++ compiler is used as linker so we must use $wl # flag to pass the commands to the underlying system # linker. We must also pass each convience library through # to the system linker between allextract/defaultextract. # The C++ compiler will combine linker options so we # cannot just pass the convience library names through # without $wl. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | grep -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. # So that behaviour is only enabled if SCOABSPATH is set to a # non-empty value in the environment. Most likely only useful for # creating official distributions of packages. # This is a hack until libtool officially supports absolute path # names for shared libraries. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6 test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... cat > conftest.$ac_ext <&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no # The `*' in the case matches for architectures that use `case' in # $output_verbose_cmd can trigger glob expansion during the loop # eval without this substitution. output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` for p in `eval $output_verbose_link_cmd`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" \ || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $rm -f confest.$objext # PORTME: override above test on systems where it is broken case $host_os in interix3*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; solaris*) case $cc_basename in CC*) # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. postdeps_CXX='-lCstd -lCrun' ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | os2* | pw32*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix4* | aix5*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) lt_prog_compiler_pic_CXX='-qnocommon' lt_prog_compiler_wl_CXX='-Wl,' ;; esac ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | kfreebsd*-gnu | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux*) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; icpc* | ecpc*) # Intel C++ lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC*) # Portland Group C++ compiler. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:10815: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:10819: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_pic_works_CXX=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 if test "${lt_prog_compiler_static_works_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" printf "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_static_works_CXX=yes fi else lt_prog_compiler_static_works_CXX=yes fi fi $rm conftest* LDFLAGS="$save_LDFLAGS" fi echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6 if test x"$lt_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o_CXX=no $rm -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:10919: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:10923: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $rm conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files $rm out/* && rmdir out cd .. rmdir conftest $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix4* | aix5*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw*) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6 test "$ld_shlibs_CXX" = no && can_build_shared=no # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* printf "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_CXX=no else archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $rm conftest* echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 ;; esac fi ;; esac echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` else sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' fi sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; kfreebsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; freebsd*) # from 4.6 on shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix3*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # find out which ABI we are using libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) echo '#line 11455 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *64-bit*) libsuff=64 sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ;; esac fi rm -rf conftest* ;; esac # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; knetbsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; nto-qnx*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' shlibpath_overrides_runpath=no else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' shlibpath_overrides_runpath=yes case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || \ test -n "$runpath_var_CXX" || \ test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existant directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 echo "${ECHO_T}$hardcode_action_CXX" >&6 if test "$hardcode_action_CXX" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi # The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then # See if we are running on zsh, and set the options which allow our commands through # without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ SED SHELL STRIP \ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ deplibs_check_method reload_flag reload_cmds need_locks \ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ old_postinstall_cmds old_postuninstall_cmds \ compiler_CXX \ CC_CXX \ LD_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_static_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ export_dynamic_flag_spec_CXX \ thread_safe_flag_spec_CXX \ whole_archive_flag_spec_CXX \ enable_shared_with_static_runtimes_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ postinstall_cmds_CXX \ postuninstall_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ export_symbols_cmds_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_flag_spec_ld_CXX \ hardcode_libdir_separator_CXX \ hardcode_automatic_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ lt_cv_prog_compiler_c_o_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX; do case $var in old_archive_cmds_CXX | \ old_archive_from_new_cmds_CXX | \ archive_cmds_CXX | \ archive_expsym_cmds_CXX | \ module_cmds_CXX | \ module_expsym_cmds_CXX | \ old_archive_from_expsyms_cmds_CXX | \ export_symbols_cmds_CXX | \ extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done case $lt_echo in *'\$0 --fallback-echo"') lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` ;; esac cfgfile="$ofile" cat <<__EOF__ >> "$cfgfile" # ### BEGIN LIBTOOL TAG CONFIG: $tagname # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU C compiler? with_gcc=$GCC_CXX gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_LD_CXX # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds_CXX old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_predep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_postdep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_predeps_CXX # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$hardcode_automatic_CXX # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path_CXX" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # ### END LIBTOOL TAG CONFIG: $tagname __EOF__ else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ldcxx=$with_gnu_ld with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld else tagname="" fi ;; F77) if test -n "$F77" && test "X$F77" != "Xno"; then ac_ext=f ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_f77_compiler_gnu archive_cmds_need_lc_F77=no allow_undefined_flag_F77= always_export_symbols_F77=no archive_expsym_cmds_F77= export_dynamic_flag_spec_F77= hardcode_direct_F77=no hardcode_libdir_flag_spec_F77= hardcode_libdir_flag_spec_ld_F77= hardcode_libdir_separator_F77= hardcode_minus_L_F77=no hardcode_automatic_F77=no module_cmds_F77= module_expsym_cmds_F77= link_all_deplibs_F77=unknown old_archive_cmds_F77=$old_archive_cmds no_undefined_flag_F77= whole_archive_flag_spec_F77= enable_shared_with_static_runtimes_F77=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o objext_F77=$objext # Code to be used in simple compile tests lt_simple_compile_test_code=" subroutine t\n return\n end\n" # Code to be used in simple link tests lt_simple_link_test_code=" program t\n end\n" # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* # Allow CC to be a program name with arguments. lt_save_CC="$CC" CC=${F77-"f77"} compiler=$CC compiler_F77=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $can_build_shared" >&5 echo "${ECHO_T}$can_build_shared" >&6 echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix4* | aix5*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac echo "$as_me:$LINENO: result: $enable_shared" >&5 echo "${ECHO_T}$enable_shared" >&6 echo "$as_me:$LINENO: checking whether to build static libraries" >&5 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes echo "$as_me:$LINENO: result: $enable_static" >&5 echo "${ECHO_T}$enable_static" >&6 GCC_F77="$G77" LD_F77="$LD" lt_prog_compiler_wl_F77= lt_prog_compiler_pic_F77= lt_prog_compiler_static_F77= echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_static_F77='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_F77='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_F77='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_F77='-fno-common' ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared_F77=no enable_shared=no ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_F77=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_F77='-fPIC' ;; esac ;; *) lt_prog_compiler_pic_F77='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl_F77='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_F77='-Bstatic' else lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' fi ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) lt_prog_compiler_pic_F77='-qnocommon' lt_prog_compiler_wl_F77='-Wl,' ;; esac ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_F77='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl_F77='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_F77='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static_F77='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl_F77='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static_F77='-non_shared' ;; newsos6) lt_prog_compiler_pic_F77='-KPIC' lt_prog_compiler_static_F77='-Bstatic' ;; linux*) case $cc_basename in icc* | ecc*) lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_pic_F77='-KPIC' lt_prog_compiler_static_F77='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_pic_F77='-fpic' lt_prog_compiler_static_F77='-Bstatic' ;; ccc*) lt_prog_compiler_wl_F77='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static_F77='-non_shared' ;; esac ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl_F77='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static_F77='-non_shared' ;; solaris*) lt_prog_compiler_pic_F77='-KPIC' lt_prog_compiler_static_F77='-Bstatic' case $cc_basename in f77* | f90* | f95*) lt_prog_compiler_wl_F77='-Qoption ld ';; *) lt_prog_compiler_wl_F77='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl_F77='-Qoption ld ' lt_prog_compiler_pic_F77='-PIC' lt_prog_compiler_static_F77='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_pic_F77='-KPIC' lt_prog_compiler_static_F77='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic_F77='-Kconform_pic' lt_prog_compiler_static_F77='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_pic_F77='-KPIC' lt_prog_compiler_static_F77='-Bstatic' ;; unicos*) lt_prog_compiler_wl_F77='-Wl,' lt_prog_compiler_can_build_shared_F77=no ;; uts4*) lt_prog_compiler_pic_F77='-pic' lt_prog_compiler_static_F77='-Bstatic' ;; *) lt_prog_compiler_can_build_shared_F77=no ;; esac fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_F77"; then echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works_F77+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_pic_works_F77=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_F77" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:12513: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:12517: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_pic_works_F77=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 if test x"$lt_prog_compiler_pic_works_F77" = xyes; then case $lt_prog_compiler_pic_F77 in "" | " "*) ;; *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; esac else lt_prog_compiler_pic_F77= lt_prog_compiler_can_build_shared_F77=no fi fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_F77= ;; *) lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" ;; esac # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\" echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 if test "${lt_prog_compiler_static_works_F77+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_static_works_F77=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" printf "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_static_works_F77=yes fi else lt_prog_compiler_static_works_F77=yes fi fi $rm conftest* LDFLAGS="$save_LDFLAGS" fi echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5 echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6 if test x"$lt_prog_compiler_static_works_F77" = xyes; then : else lt_prog_compiler_static_F77= fi echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o_F77=no $rm -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:12617: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:12621: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_F77=yes fi fi chmod u+w . 2>&5 $rm conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files $rm out/* && rmdir out cd .. rmdir conftest $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 runpath_var= allow_undefined_flag_F77= enable_shared_with_static_runtimes_F77=no archive_cmds_F77= archive_expsym_cmds_F77= old_archive_From_new_cmds_F77= old_archive_from_expsyms_cmds_F77= export_dynamic_flag_spec_F77= whole_archive_flag_spec_F77= thread_safe_flag_spec_F77= hardcode_libdir_flag_spec_F77= hardcode_libdir_flag_spec_ld_F77= hardcode_libdir_separator_F77= hardcode_direct_F77=no hardcode_minus_L_F77=no hardcode_shlibpath_var_F77=unsupported link_all_deplibs_F77=unknown hardcode_automatic_F77=no module_cmds_F77= module_expsym_cmds_F77= always_export_symbols_F77=no export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms_F77= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs_F77=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_F77='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_F77= fi supports_anon_versioning=no case `$LD -v 2>/dev/null` in *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs_F77=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF fi ;; amigaos*) archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_minus_L_F77=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can't use # them. ld_shlibs_F77=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_F77=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_F77=no fi ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_F77='-L$libdir' allow_undefined_flag_F77=unsupported always_export_symbols_F77=no enable_shared_with_static_runtimes_F77=yes export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_F77=no fi ;; interix3*) hardcode_direct_F77=no hardcode_shlibpath_var_F77=no hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' export_dynamic_flag_spec_F77='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; linux*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then tmp_addflag= case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; esac archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test $supports_anon_versioning = yes; then archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ $echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi else ld_shlibs_F77=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs_F77=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs_F77=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs_F77=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' else ld_shlibs_F77=no fi ;; esac ;; sunos4*) archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct_F77=yes hardcode_shlibpath_var_F77=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs_F77=no fi ;; esac if test "$ld_shlibs_F77" = no; then runpath_var= hardcode_libdir_flag_spec_F77= export_dynamic_flag_spec_F77= whole_archive_flag_spec_F77= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag_F77=unsupported always_export_symbols_F77=yes archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L_F77=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct_F77=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_F77='' hardcode_direct_F77=yes hardcode_libdir_separator_F77=':' link_all_deplibs_F77=yes if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct_F77=yes else # We have old collect2 hardcode_direct_F77=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_F77=yes hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_libdir_separator_F77= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols_F77=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_F77='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF program main end _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_F77="-z nodefs" archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF program main end _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_F77=' ${wl}-bernotok' allow_undefined_flag_F77=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_F77='$convenience' archive_cmds_need_lc_F77=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_minus_L_F77=yes # see comment about different semantics on the GNU ld section ld_shlibs_F77=no ;; bsdi[45]*) export_dynamic_flag_spec_F77=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_F77=' ' allow_undefined_flag_F77=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_From_new_cmds_F77='true' # FIXME: Should let the user specify the lib program. old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path_F77='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes_F77=yes ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[012]) allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[012]) allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac archive_cmds_need_lc_F77=no hardcode_direct_F77=no hardcode_automatic_F77=yes hardcode_shlibpath_var_F77=unsupported whole_archive_flag_spec_F77='' link_all_deplibs_F77=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) ld_shlibs_F77=no ;; esac fi ;; dgux*) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_shlibpath_var_F77=no ;; freebsd1*) ld_shlibs_F77=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec_F77='-R$libdir' hardcode_direct_F77=yes hardcode_shlibpath_var_F77=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_F77=yes hardcode_minus_L_F77=yes hardcode_shlibpath_var_F77=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | kfreebsd*-gnu | dragonfly*) archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec_F77='-R$libdir' hardcode_direct_F77=yes hardcode_shlibpath_var_F77=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' hardcode_libdir_separator_F77=: hardcode_direct_F77=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_F77=yes export_dynamic_flag_spec_F77='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' hardcode_libdir_separator_F77=: hardcode_direct_F77=yes export_dynamic_flag_spec_F77='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_F77=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' hardcode_libdir_separator_F77=: case $host_cpu in hppa*64*|ia64*) hardcode_libdir_flag_spec_ld_F77='+b $libdir' hardcode_direct_F77=no hardcode_shlibpath_var_F77=no ;; *) hardcode_direct_F77=yes export_dynamic_flag_spec_F77='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_F77=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' fi hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_F77=: link_all_deplibs_F77=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec_F77='-R$libdir' hardcode_direct_F77=yes hardcode_shlibpath_var_F77=no ;; newsos6) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_F77=yes hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_F77=: hardcode_shlibpath_var_F77=no ;; openbsd*) hardcode_direct_F77=yes hardcode_shlibpath_var_F77=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' export_dynamic_flag_spec_F77='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_F77='-R$libdir' ;; *) archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' ;; esac fi ;; os2*) hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_minus_L_F77=yes allow_undefined_flag_F77=unsupported archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag_F77=' -expect_unresolved \*' archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_F77=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' else allow_undefined_flag_F77=' -expect_unresolved \*' archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec_F77='-rpath $libdir' fi hardcode_libdir_separator_F77=: ;; solaris*) no_undefined_flag_F77=' -z text' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' else wlarc='' archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' fi hardcode_libdir_flag_spec_F77='-R$libdir' hardcode_shlibpath_var_F77=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine linker options so we # cannot just pass the convience library names through # without $wl, iff we do not link with $LD. # Luckily, gcc supports the same syntax we need for Sun Studio. # Supported since Solaris 2.6 (maybe 2.5.1?) case $wlarc in '') whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; *) whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac ;; esac link_all_deplibs_F77=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_direct_F77=yes hardcode_minus_L_F77=yes hardcode_shlibpath_var_F77=no ;; sysv4) case $host_vendor in sni) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_F77=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds_F77='$CC -r -o $output$reload_objs' hardcode_direct_F77=no ;; motorola) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var_F77=no ;; sysv4.3*) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var_F77=no export_dynamic_flag_spec_F77='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var_F77=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs_F77=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) no_undefined_flag_F77='${wl}-z,text' archive_cmds_need_lc_F77=no hardcode_shlibpath_var_F77=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_F77='${wl}-z,text' allow_undefined_flag_F77='${wl}-z,nodefs' archive_cmds_need_lc_F77=no hardcode_shlibpath_var_F77=no hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator_F77=':' link_all_deplibs_F77=yes export_dynamic_flag_spec_F77='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_F77='-L$libdir' hardcode_shlibpath_var_F77=no ;; *) ld_shlibs_F77=no ;; esac fi echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 echo "${ECHO_T}$ld_shlibs_F77" >&6 test "$ld_shlibs_F77" = no && can_build_shared=no # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_F77" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_F77=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_F77 in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* printf "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_F77 pic_flag=$lt_prog_compiler_pic_F77 compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_F77 allow_undefined_flag_F77= if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_F77=no else archive_cmds_need_lc_F77=yes fi allow_undefined_flag_F77=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $rm conftest* echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 ;; esac fi ;; esac echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` else sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' fi sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; kfreebsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; freebsd*) # from 4.6 on shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix3*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # find out which ABI we are using libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) echo '#line 14066 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *64-bit*) libsuff=64 sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ;; esac fi rm -rf conftest* ;; esac # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; knetbsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; nto-qnx*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' shlibpath_overrides_runpath=no else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' shlibpath_overrides_runpath=yes case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action_F77= if test -n "$hardcode_libdir_flag_spec_F77" || \ test -n "$runpath_var_F77" || \ test "X$hardcode_automatic_F77" = "Xyes" ; then # We can hardcode non-existant directories. if test "$hardcode_direct_F77" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && test "$hardcode_minus_L_F77" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_F77=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_F77=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_F77=unsupported fi echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 echo "${ECHO_T}$hardcode_action_F77" >&6 if test "$hardcode_action_F77" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi # The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then # See if we are running on zsh, and set the options which allow our commands through # without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ SED SHELL STRIP \ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ deplibs_check_method reload_flag reload_cmds need_locks \ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ old_postinstall_cmds old_postuninstall_cmds \ compiler_F77 \ CC_F77 \ LD_F77 \ lt_prog_compiler_wl_F77 \ lt_prog_compiler_pic_F77 \ lt_prog_compiler_static_F77 \ lt_prog_compiler_no_builtin_flag_F77 \ export_dynamic_flag_spec_F77 \ thread_safe_flag_spec_F77 \ whole_archive_flag_spec_F77 \ enable_shared_with_static_runtimes_F77 \ old_archive_cmds_F77 \ old_archive_from_new_cmds_F77 \ predep_objects_F77 \ postdep_objects_F77 \ predeps_F77 \ postdeps_F77 \ compiler_lib_search_path_F77 \ archive_cmds_F77 \ archive_expsym_cmds_F77 \ postinstall_cmds_F77 \ postuninstall_cmds_F77 \ old_archive_from_expsyms_cmds_F77 \ allow_undefined_flag_F77 \ no_undefined_flag_F77 \ export_symbols_cmds_F77 \ hardcode_libdir_flag_spec_F77 \ hardcode_libdir_flag_spec_ld_F77 \ hardcode_libdir_separator_F77 \ hardcode_automatic_F77 \ module_cmds_F77 \ module_expsym_cmds_F77 \ lt_cv_prog_compiler_c_o_F77 \ exclude_expsyms_F77 \ include_expsyms_F77; do case $var in old_archive_cmds_F77 | \ old_archive_from_new_cmds_F77 | \ archive_cmds_F77 | \ archive_expsym_cmds_F77 | \ module_cmds_F77 | \ module_expsym_cmds_F77 | \ old_archive_from_expsyms_cmds_F77 | \ export_symbols_cmds_F77 | \ extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done case $lt_echo in *'\$0 --fallback-echo"') lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` ;; esac cfgfile="$ofile" cat <<__EOF__ >> "$cfgfile" # ### BEGIN LIBTOOL TAG CONFIG: $tagname # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_F77 # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_compiler_F77 # Is the compiler the GNU C compiler? with_gcc=$GCC_F77 gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_LD_F77 # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_F77 # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_F77 pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_F77 # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds_F77 old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds_F77 archive_expsym_cmds=$lt_archive_expsym_cmds_F77 postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_module_cmds_F77 module_expsym_cmds=$lt_module_expsym_cmds_F77 # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_predep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_postdep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_predeps_F77 # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_postdeps_F77 # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_F77 # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_F77 # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_F77 # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct_F77 # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L_F77 # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$hardcode_automatic_F77 # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_F77 # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path_F77" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols_F77 # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_F77 # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_F77 # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_F77 # ### END LIBTOOL TAG CONFIG: $tagname __EOF__ else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" else tagname="" fi ;; GCJ) if test -n "$GCJ" && test "X$GCJ" != "Xno"; then # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o objext_GCJ=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}\n" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* # Allow CC to be a program name with arguments. lt_save_CC="$CC" CC=${GCJ-"gcj"} compiler=$CC compiler_GCJ=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # GCJ did not exist at the time GCC didn't implicitly link libc in. archive_cmds_need_lc_GCJ=no old_archive_cmds_GCJ=$old_archive_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... lt_prog_compiler_no_builtin_flag_GCJ= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:14848: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:14852: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl_GCJ= lt_prog_compiler_pic_GCJ= lt_prog_compiler_static_GCJ= echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_static_GCJ='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_GCJ='-Bstatic' fi ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' ;; beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_GCJ='-fno-common' ;; interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared_GCJ=no enable_shared=no ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_GCJ=-Kconform_pic fi ;; hpux*) # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_GCJ='-fPIC' ;; esac ;; *) lt_prog_compiler_pic_GCJ='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl_GCJ='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_GCJ='-Bstatic' else lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' fi ;; darwin*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files case $cc_basename in xlc*) lt_prog_compiler_pic_GCJ='-qnocommon' lt_prog_compiler_wl_GCJ='-Wl,' ;; esac ;; mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl_GCJ='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_GCJ='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl_GCJ='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static_GCJ='-non_shared' ;; newsos6) lt_prog_compiler_pic_GCJ='-KPIC' lt_prog_compiler_static_GCJ='-Bstatic' ;; linux*) case $cc_basename in icc* | ecc*) lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_pic_GCJ='-KPIC' lt_prog_compiler_static_GCJ='-static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_pic_GCJ='-fpic' lt_prog_compiler_static_GCJ='-Bstatic' ;; ccc*) lt_prog_compiler_wl_GCJ='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static_GCJ='-non_shared' ;; esac ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl_GCJ='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static_GCJ='-non_shared' ;; solaris*) lt_prog_compiler_pic_GCJ='-KPIC' lt_prog_compiler_static_GCJ='-Bstatic' case $cc_basename in f77* | f90* | f95*) lt_prog_compiler_wl_GCJ='-Qoption ld ';; *) lt_prog_compiler_wl_GCJ='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl_GCJ='-Qoption ld ' lt_prog_compiler_pic_GCJ='-PIC' lt_prog_compiler_static_GCJ='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_pic_GCJ='-KPIC' lt_prog_compiler_static_GCJ='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic_GCJ='-Kconform_pic' lt_prog_compiler_static_GCJ='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_pic_GCJ='-KPIC' lt_prog_compiler_static_GCJ='-Bstatic' ;; unicos*) lt_prog_compiler_wl_GCJ='-Wl,' lt_prog_compiler_can_build_shared_GCJ=no ;; uts4*) lt_prog_compiler_pic_GCJ='-pic' lt_prog_compiler_static_GCJ='-Bstatic' ;; *) lt_prog_compiler_can_build_shared_GCJ=no ;; esac fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_GCJ"; then echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_pic_works_GCJ=no ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_GCJ" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:15116: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:15120: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_pic_works_GCJ=yes fi fi $rm conftest* fi echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then case $lt_prog_compiler_pic_GCJ in "" | " "*) ;; *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; esac else lt_prog_compiler_pic_GCJ= lt_prog_compiler_can_build_shared_GCJ=no fi fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_GCJ= ;; *) lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" ;; esac # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\" echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_prog_compiler_static_works_GCJ=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" printf "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_prog_compiler_static_works_GCJ=yes fi else lt_prog_compiler_static_works_GCJ=yes fi fi $rm conftest* LDFLAGS="$save_LDFLAGS" fi echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5 echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6 if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then : else lt_prog_compiler_static_GCJ= fi echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_compiler_c_o_GCJ=no $rm -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out printf "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:15220: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:15224: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_GCJ=yes fi fi chmod u+w . 2>&5 $rm conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files $rm out/* && rmdir out cd .. rmdir conftest $rm conftest* fi echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 runpath_var= allow_undefined_flag_GCJ= enable_shared_with_static_runtimes_GCJ=no archive_cmds_GCJ= archive_expsym_cmds_GCJ= old_archive_From_new_cmds_GCJ= old_archive_from_expsyms_cmds_GCJ= export_dynamic_flag_spec_GCJ= whole_archive_flag_spec_GCJ= thread_safe_flag_spec_GCJ= hardcode_libdir_flag_spec_GCJ= hardcode_libdir_flag_spec_ld_GCJ= hardcode_libdir_separator_GCJ= hardcode_direct_GCJ=no hardcode_minus_L_GCJ=no hardcode_shlibpath_var_GCJ=unsupported link_all_deplibs_GCJ=unknown hardcode_automatic_GCJ=no module_cmds_GCJ= module_expsym_cmds_GCJ= always_export_symbols_GCJ=no export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms_GCJ= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= # Just being paranoid about ensuring that cc_basename is set. for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs_GCJ=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_GCJ= fi supports_anon_versioning=no case `$LD -v 2>/dev/null` in *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs_GCJ=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF fi ;; amigaos*) archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_minus_L_GCJ=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can't use # them. ld_shlibs_GCJ=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_GCJ=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_GCJ=no fi ;; cygwin* | mingw* | pw32*) # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_GCJ='-L$libdir' allow_undefined_flag_GCJ=unsupported always_export_symbols_GCJ=no enable_shared_with_static_runtimes_GCJ=yes export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_GCJ=no fi ;; interix3*) hardcode_direct_GCJ=no hardcode_shlibpath_var_GCJ=no hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' export_dynamic_flag_spec_GCJ='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; linux*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then tmp_addflag= case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; esac archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test $supports_anon_versioning = yes; then archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ $echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi else ld_shlibs_GCJ=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs_GCJ=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs_GCJ=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs_GCJ=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' else ld_shlibs_GCJ=no fi ;; esac ;; sunos4*) archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs_GCJ=no fi ;; esac if test "$ld_shlibs_GCJ" = no; then runpath_var= hardcode_libdir_flag_spec_GCJ= export_dynamic_flag_spec_GCJ= whole_archive_flag_spec_GCJ= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag_GCJ=unsupported always_export_symbols_GCJ=yes archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L_GCJ=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct_GCJ=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | grep 'GNU' > /dev/null; then export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_GCJ='' hardcode_direct_GCJ=yes hardcode_libdir_separator_GCJ=':' link_all_deplibs_GCJ=yes if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct_GCJ=yes else # We have old collect2 hardcode_direct_GCJ=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_GCJ=yes hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_libdir_separator_GCJ= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols_GCJ=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_GCJ='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_GCJ="-z nodefs" archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'`; fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_GCJ=' ${wl}-bernotok' allow_undefined_flag_GCJ=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_GCJ='$convenience' archive_cmds_need_lc_GCJ=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_minus_L_GCJ=yes # see comment about different semantics on the GNU ld section ld_shlibs_GCJ=no ;; bsdi[45]*) export_dynamic_flag_spec_GCJ=-rdynamic ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_GCJ=' ' allow_undefined_flag_GCJ=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_From_new_cmds_GCJ='true' # FIXME: Should let the user specify the lib program. old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`' enable_shared_with_static_runtimes_GCJ=yes ;; darwin* | rhapsody*) case $host_os in rhapsody* | darwin1.[012]) allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' ;; *) # Darwin 1.3 on if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' else case ${MACOSX_DEPLOYMENT_TARGET} in 10.[012]) allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' ;; esac fi ;; esac archive_cmds_need_lc_GCJ=no hardcode_direct_GCJ=no hardcode_automatic_GCJ=yes hardcode_shlibpath_var_GCJ=unsupported whole_archive_flag_spec_GCJ='' link_all_deplibs_GCJ=yes if test "$GCC" = yes ; then output_verbose_link_cmd='echo' archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else case $cc_basename in xlc*) output_verbose_link_cmd='echo' archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' ;; *) ld_shlibs_GCJ=no ;; esac fi ;; dgux*) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_shlibpath_var_GCJ=no ;; freebsd1*) ld_shlibs_GCJ=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec_GCJ='-R$libdir' hardcode_direct_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_GCJ=yes hardcode_minus_L_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | kfreebsd*-gnu | dragonfly*) archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec_GCJ='-R$libdir' hardcode_direct_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' hardcode_libdir_separator_GCJ=: hardcode_direct_GCJ=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_GCJ=yes export_dynamic_flag_spec_GCJ='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' hardcode_libdir_separator_GCJ=: hardcode_direct_GCJ=yes export_dynamic_flag_spec_GCJ='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_GCJ=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' hardcode_libdir_separator_GCJ=: case $host_cpu in hppa*64*|ia64*) hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' hardcode_direct_GCJ=no hardcode_shlibpath_var_GCJ=no ;; *) hardcode_direct_GCJ=yes export_dynamic_flag_spec_GCJ='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L_GCJ=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' fi hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_GCJ=: link_all_deplibs_GCJ=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec_GCJ='-R$libdir' hardcode_direct_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; newsos6) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_GCJ=yes hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_GCJ=: hardcode_shlibpath_var_GCJ=no ;; openbsd*) hardcode_direct_GCJ=yes hardcode_shlibpath_var_GCJ=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' export_dynamic_flag_spec_GCJ='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_GCJ='-R$libdir' ;; *) archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' ;; esac fi ;; os2*) hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_minus_L_GCJ=yes allow_undefined_flag_GCJ=unsupported archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag_GCJ=' -expect_unresolved \*' archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_GCJ=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' else allow_undefined_flag_GCJ=' -expect_unresolved \*' archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec_GCJ='-rpath $libdir' fi hardcode_libdir_separator_GCJ=: ;; solaris*) no_undefined_flag_GCJ=' -z text' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' else wlarc='' archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' fi hardcode_libdir_flag_spec_GCJ='-R$libdir' hardcode_shlibpath_var_GCJ=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine linker options so we # cannot just pass the convience library names through # without $wl, iff we do not link with $LD. # Luckily, gcc supports the same syntax we need for Sun Studio. # Supported since Solaris 2.6 (maybe 2.5.1?) case $wlarc in '') whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; *) whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; esac ;; esac link_all_deplibs_GCJ=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_direct_GCJ=yes hardcode_minus_L_GCJ=yes hardcode_shlibpath_var_GCJ=no ;; sysv4) case $host_vendor in sni) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_GCJ=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds_GCJ='$CC -r -o $output$reload_objs' hardcode_direct_GCJ=no ;; motorola) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var_GCJ=no ;; sysv4.3*) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var_GCJ=no export_dynamic_flag_spec_GCJ='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var_GCJ=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs_GCJ=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) no_undefined_flag_GCJ='${wl}-z,text' archive_cmds_need_lc_GCJ=no hardcode_shlibpath_var_GCJ=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_GCJ='${wl}-z,text' allow_undefined_flag_GCJ='${wl}-z,nodefs' archive_cmds_need_lc_GCJ=no hardcode_shlibpath_var_GCJ=no hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator_GCJ=':' link_all_deplibs_GCJ=yes export_dynamic_flag_spec_GCJ='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec_GCJ='-L$libdir' hardcode_shlibpath_var_GCJ=no ;; *) ld_shlibs_GCJ=no ;; esac fi echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 echo "${ECHO_T}$ld_shlibs_GCJ" >&6 test "$ld_shlibs_GCJ" = no && can_build_shared=no # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_GCJ" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_GCJ=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_GCJ in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* printf "$lt_simple_compile_test_code" > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_GCJ pic_flag=$lt_prog_compiler_pic_GCJ compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ allow_undefined_flag_GCJ= if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_GCJ=no else archive_cmds_need_lc_GCJ=yes fi allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $rm conftest* echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 ;; esac fi ;; esac echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. if test "$GCC" = yes; then sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` else sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' fi sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; kfreebsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; freebsd*) # from 4.6 on shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix3*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # find out which ABI we are using libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) echo '#line 16689 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *64-bit*) libsuff=64 sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ;; esac fi rm -rf conftest* ;; esac # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; knetbsd*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='GNU ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; nto-qnx*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' shlibpath_overrides_runpath=no else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' shlibpath_overrides_runpath=yes case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action_GCJ= if test -n "$hardcode_libdir_flag_spec_GCJ" || \ test -n "$runpath_var_GCJ" || \ test "X$hardcode_automatic_GCJ" = "Xyes" ; then # We can hardcode non-existant directories. if test "$hardcode_direct_GCJ" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && test "$hardcode_minus_L_GCJ" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_GCJ=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_GCJ=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_GCJ=unsupported fi echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 echo "${ECHO_T}$hardcode_action_GCJ" >&6 if test "$hardcode_action_GCJ" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi # The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then # See if we are running on zsh, and set the options which allow our commands through # without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ SED SHELL STRIP \ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ deplibs_check_method reload_flag reload_cmds need_locks \ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ old_postinstall_cmds old_postuninstall_cmds \ compiler_GCJ \ CC_GCJ \ LD_GCJ \ lt_prog_compiler_wl_GCJ \ lt_prog_compiler_pic_GCJ \ lt_prog_compiler_static_GCJ \ lt_prog_compiler_no_builtin_flag_GCJ \ export_dynamic_flag_spec_GCJ \ thread_safe_flag_spec_GCJ \ whole_archive_flag_spec_GCJ \ enable_shared_with_static_runtimes_GCJ \ old_archive_cmds_GCJ \ old_archive_from_new_cmds_GCJ \ predep_objects_GCJ \ postdep_objects_GCJ \ predeps_GCJ \ postdeps_GCJ \ compiler_lib_search_path_GCJ \ archive_cmds_GCJ \ archive_expsym_cmds_GCJ \ postinstall_cmds_GCJ \ postuninstall_cmds_GCJ \ old_archive_from_expsyms_cmds_GCJ \ allow_undefined_flag_GCJ \ no_undefined_flag_GCJ \ export_symbols_cmds_GCJ \ hardcode_libdir_flag_spec_GCJ \ hardcode_libdir_flag_spec_ld_GCJ \ hardcode_libdir_separator_GCJ \ hardcode_automatic_GCJ \ module_cmds_GCJ \ module_expsym_cmds_GCJ \ lt_cv_prog_compiler_c_o_GCJ \ exclude_expsyms_GCJ \ include_expsyms_GCJ; do case $var in old_archive_cmds_GCJ | \ old_archive_from_new_cmds_GCJ | \ archive_cmds_GCJ | \ archive_expsym_cmds_GCJ | \ module_cmds_GCJ | \ module_expsym_cmds_GCJ | \ old_archive_from_expsyms_cmds_GCJ | \ export_symbols_cmds_GCJ | \ extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done case $lt_echo in *'\$0 --fallback-echo"') lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` ;; esac cfgfile="$ofile" cat <<__EOF__ >> "$cfgfile" # ### BEGIN LIBTOOL TAG CONFIG: $tagname # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_GCJ # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_compiler_GCJ # Is the compiler the GNU C compiler? with_gcc=$GCC_GCJ gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_LD_GCJ # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_GCJ # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_GCJ pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_GCJ # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds_GCJ old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds_GCJ archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_module_cmds_GCJ module_expsym_cmds=$lt_module_expsym_cmds_GCJ # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_predep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_postdep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_predeps_GCJ # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_postdeps_GCJ # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_GCJ # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_GCJ # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_GCJ # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct_GCJ # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L_GCJ # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$hardcode_automatic_GCJ # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_GCJ # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path_GCJ" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols_GCJ # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_GCJ # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_GCJ # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_GCJ # ### END LIBTOOL TAG CONFIG: $tagname __EOF__ else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" else tagname="" fi ;; RC) # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o objext_RC=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext printf "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $rm conftest* ac_outfile=conftest.$ac_objext printf "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $rm conftest* # Allow CC to be a program name with arguments. lt_save_CC="$CC" CC=${RC-"windres"} compiler=$CC compiler_RC=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` lt_cv_prog_compiler_c_o_RC=yes # The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then # See if we are running on zsh, and set the options which allow our commands through # without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ SED SHELL STRIP \ libname_spec library_names_spec soname_spec extract_expsyms_cmds \ old_striplib striplib file_magic_cmd finish_cmds finish_eval \ deplibs_check_method reload_flag reload_cmds need_locks \ lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ old_postinstall_cmds old_postuninstall_cmds \ compiler_RC \ CC_RC \ LD_RC \ lt_prog_compiler_wl_RC \ lt_prog_compiler_pic_RC \ lt_prog_compiler_static_RC \ lt_prog_compiler_no_builtin_flag_RC \ export_dynamic_flag_spec_RC \ thread_safe_flag_spec_RC \ whole_archive_flag_spec_RC \ enable_shared_with_static_runtimes_RC \ old_archive_cmds_RC \ old_archive_from_new_cmds_RC \ predep_objects_RC \ postdep_objects_RC \ predeps_RC \ postdeps_RC \ compiler_lib_search_path_RC \ archive_cmds_RC \ archive_expsym_cmds_RC \ postinstall_cmds_RC \ postuninstall_cmds_RC \ old_archive_from_expsyms_cmds_RC \ allow_undefined_flag_RC \ no_undefined_flag_RC \ export_symbols_cmds_RC \ hardcode_libdir_flag_spec_RC \ hardcode_libdir_flag_spec_ld_RC \ hardcode_libdir_separator_RC \ hardcode_automatic_RC \ module_cmds_RC \ module_expsym_cmds_RC \ lt_cv_prog_compiler_c_o_RC \ exclude_expsyms_RC \ include_expsyms_RC; do case $var in old_archive_cmds_RC | \ old_archive_from_new_cmds_RC | \ archive_cmds_RC | \ archive_expsym_cmds_RC | \ module_cmds_RC | \ module_expsym_cmds_RC | \ old_archive_from_expsyms_cmds_RC | \ export_symbols_cmds_RC | \ extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done case $lt_echo in *'\$0 --fallback-echo"') lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` ;; esac cfgfile="$ofile" cat <<__EOF__ >> "$cfgfile" # ### BEGIN LIBTOOL TAG CONFIG: $tagname # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_RC # Whether or not to disallow shared libs when runtime libs are static allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # A C compiler. LTCC=$lt_LTCC # LTCC compiler flags. LTCFLAGS=$lt_LTCFLAGS # A language-specific compiler. CC=$lt_compiler_RC # Is the compiler the GNU C compiler? with_gcc=$GCC_RC gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\` gcc_ver=\`gcc -dumpversion\` # An ERE matcher. EGREP=$lt_EGREP # The linker used to build libraries. LD=$lt_LD_RC # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_RC # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Shared library suffix (normally ".so"). shrext_cmds='$shrext_cmds' # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_RC pic_mode=$pic_mode # What is the maximum length of a command? max_cmd_len=$lt_cv_sys_max_cmd_len # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC # Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_RC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds_RC old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds_RC archive_expsym_cmds=$lt_archive_expsym_cmds_RC postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands used to build a loadable module (assumed same as above if empty) module_cmds=$lt_module_cmds_RC module_expsym_cmds=$lt_module_expsym_cmds_RC # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Dependencies to place before the objects being linked to create a # shared library. predep_objects=\`echo $lt_predep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place after the objects being linked to create a # shared library. postdep_objects=\`echo $lt_postdep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Dependencies to place before the objects being linked to create a # shared library. predeps=$lt_predeps_RC # Dependencies to place after the objects being linked to create a # shared library. postdeps=$lt_postdeps_RC # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_RC # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_RC # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_RC # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC # If ld is used when linking, flag to hardcode \$libdir into # a binary during linking. This must work even if \$libdir does # not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC # Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct_RC # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L_RC # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_RC # Set to yes if building a shared library automatically hardcodes DIR into the library # and all subsequent libraries and executables linked against it. hardcode_automatic=$hardcode_automatic_RC # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_RC # Compile-time system search path for libraries sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\` # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path_RC" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols_RC # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_RC # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_RC # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_RC # ### END LIBTOOL TAG CONFIG: $tagname __EOF__ else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` if test -f "$ltmain_in"; then test -f Makefile && make "$ltmain" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ;; *) { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 echo "$as_me: error: Unsupported tag name: $tagname" >&2;} { (exit 1); exit 1; }; } ;; esac # Append the new tag name to the list of available tags. if test -n "$tagname" ; then available_tags="$available_tags $tagname" fi fi done IFS="$lt_save_ifs" # Now substitute the updated list of available tags. if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then mv "${ofile}T" "$ofile" chmod +x "$ofile" else rm -f "${ofile}T" { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 echo "$as_me: error: unable to update list of available tagged configurations." >&2;} { (exit 1); exit 1; }; } fi fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' # Prevent multiple expansion # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' CC=${CC:-cc} VER_INFO=`cat VERSION` ########## # Find SQLite header file and library # # Check whether --with-sqlite or --without-sqlite was given. if test "${with_sqlite+set}" = set; then withval="$with_sqlite" SQLITE_DIR=$withval fi; if test -n "$SQLITE_DIR" ; then if test ! -d "$SQLITE_DIR" ; then { { echo "$as_me:$LINENO: error: SQLite directory $SQLITE_DIR does not exist" >&5 echo "$as_me: error: SQLite directory $SQLITE_DIR does not exist" >&2;} { (exit 1); exit 1; }; } fi fi SQLITE_INC=UNKNOWN SQLITE_LIB=UNKNOWN if test -z "$SQLITE_DIR" ; then if test -r "$includedir/sqlite.h" -a -r "$libdir/libsqlite.la" ; then SQLITE_INC="$includedir" SQLITE_LIB="$libdir/libsqlite.la" SQLITE_LIBDIR="$libdir" SQLITE_DIR="" else SQLITE_DIR="../sqlite /usr /usr/local /opt" fi fi echo "$as_me:$LINENO: checking for SQLite header and library" >&5 echo $ECHO_N "checking for SQLite header and library... $ECHO_C" >&6 for i in $SQLITE_DIR ; do if test -r "$i/sqlite.h" ; then if test -r "$i/libsqlite.la" ; then SQLITE_INC="$i" SQLITE_LIB="$i/libsqlite.la" SQLITE_LIBDIR=$i break fi elif test -r "$i/include/sqlite.h" ; then SQLITE_INC="$i/include" if test -r "$i/lib/libsqlite.la" ; then SQLITE_LIB="$i/lib/libsqlite.la" SQLITE_LIBDIR="$i/lib" break elif test -d "$i/lib" ; then SQLITE_LIB="-lsqlite" SQLITE_LIBDIR="$i/lib" break fi fi done if test "$SQLITE_INC" = "UNKNOWN" -o "$SQLITE_LIB" = "UNKNOWN" ; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 { echo "$as_me:$LINENO: WARNING: SQLite header files and/or library not found" >&5 echo "$as_me: WARNING: SQLite header files and/or library not found" >&2;} else echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 fi # test for availability of sqlite_libversion() et.al. if test -n "$SQLITE_LIBDIR" ; then SQLITE_LIBDIR="-L$SQLITE_LIBDIR" fi saved_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$SQLITE_INC" saved_LIBS=$LIBS LIBS="$LIBS $SQLITE_LIBDIR" echo "$as_me:$LINENO: checking for sqlite_libversion in -lsqlite" >&5 echo $ECHO_N "checking for sqlite_libversion in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqlite_libversion+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite_libversion (); int main () { sqlite_libversion (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqlite_libversion=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqlite_libversion=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_libversion" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_libversion" >&6 if test $ac_cv_lib_sqlite_sqlite_libversion = yes; then SQLITE_LIBVERSION=1 else SQLITE_LIBVERSION=0 fi echo "$as_me:$LINENO: checking for sqlite_compile in -lsqlite" >&5 echo $ECHO_N "checking for sqlite_compile in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqlite_compile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite_compile (); int main () { sqlite_compile (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqlite_compile=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqlite_compile=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_compile" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_compile" >&6 if test $ac_cv_lib_sqlite_sqlite_compile = yes; then SQLITE_COMPILE=1 else SQLITE_COMPILE=0 fi echo "$as_me:$LINENO: checking for sqlite_encode_binary in -lsqlite" >&5 echo $ECHO_N "checking for sqlite_encode_binary in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqlite_encode_binary+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite_encode_binary (); int main () { sqlite_encode_binary (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqlite_encode_binary=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqlite_encode_binary=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_encode_binary" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_encode_binary" >&6 if test $ac_cv_lib_sqlite_sqlite_encode_binary = yes; then SQLITE_ENCDEC=1 else SQLITE_ENCDEC=0 fi echo "$as_me:$LINENO: checking for sqliteAtoF in -lsqlite" >&5 echo $ECHO_N "checking for sqliteAtoF in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqliteAtoF+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqliteAtoF (); int main () { sqliteAtoF (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqliteAtoF=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqliteAtoF=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqliteAtoF" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqliteAtoF" >&6 if test $ac_cv_lib_sqlite_sqliteAtoF = yes; then SQLITE_ATOF=1 else SQLITE_ATOF=0 fi echo "$as_me:$LINENO: checking for sqlite_mprintf in -lsqlite" >&5 echo $ECHO_N "checking for sqlite_mprintf in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqlite_mprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite_mprintf (); int main () { sqlite_mprintf (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqlite_mprintf=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqlite_mprintf=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_mprintf" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_mprintf" >&6 if test $ac_cv_lib_sqlite_sqlite_mprintf = yes; then SQLITE_MPRINTF=1 else SQLITE_MPRINTF=0 fi echo "$as_me:$LINENO: checking for sqlite_trace in -lsqlite" >&5 echo $ECHO_N "checking for sqlite_trace in -lsqlite... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite_sqlite_trace+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite_trace (); int main () { sqlite_trace (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite_sqlite_trace=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite_sqlite_trace=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_trace" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_trace" >&6 if test $ac_cv_lib_sqlite_sqlite_trace = yes; then SQLITE_TRACE=1 else SQLITE_TRACE=0 fi LIBS=$saved_LIBS CFLAGS=$saved_CFLAGS if test "$SQLITE_COMPILE" = "0" ; then { echo "$as_me:$LINENO: WARNING: SQLite library too old, need 2.8.0 or later" >&5 echo "$as_me: WARNING: SQLite library too old, need 2.8.0 or later" >&2;} else LIB_TARGETS="$LIB_TARGETS libsqliteodbc.la" INST_TARGETS="$INST_TARGETS install-2" UNINST_TARGETS="$UNINST_TARGETS uninstall-2" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-2" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-2" fi ########## # Find SQLite3 header file and library # # Check whether --with-sqlite3 or --without-sqlite3 was given. if test "${with_sqlite3+set}" = set; then withval="$with_sqlite3" SQLITE3_DIR=$withval fi; if test -n "$SQLITE3_DIR" ; then if test ! -d "$SQLITE3_DIR" ; then { echo "$as_me:$LINENO: WARNING: SQLite3 directory $SQLITE3_DIR does not exist" >&5 echo "$as_me: WARNING: SQLite3 directory $SQLITE3_DIR does not exist" >&2;} fi fi SQLITE3_INC=UNKNOWN SQLITE3_LIB=UNKNOWN if test -z "$SQLITE3_DIR" ; then if test -r "$includedir/sqlite3.h" -a -r "$libdir/libsqlite3.la" ; then SQLITE3_INC="$includedir" SQLITE3_LIB="$libdir/libsqlite3.la" SQLITE3_LIBDIR="$libdir" SQLITE3_DIR="" else SQLITE3_DIR="../sqlite /usr /usr/local /opt" fi fi echo "$as_me:$LINENO: checking for SQLite3 header and library" >&5 echo $ECHO_N "checking for SQLite3 header and library... $ECHO_C" >&6 for i in $SQLITE3_DIR ; do if test -r "$i/sqlite3.h" ; then if test -r "$i/sqlite3.c" ; then SQLITE3_INC="$i" SQLITE3_LIB="unknown" SQLITE3_LIBDIR="" SQLITE3_A10N_C="$i/sqlite3.c" SQLITE3_A10N_O="sqlite3.lo" break elif test -r "$i/libsqlite3.la" ; then SQLITE3_INC="$i" SQLITE3_LIB="$i/libsqlite3.la" SQLITE3_LIBDIR=$i break fi elif test -r "$i/include/sqlite3.h" ; then SQLITE3_INC="$i/include" if test -r "$i/lib/libsqlite3.la" ; then SQLITE3_LIB="$i/lib/libsqlite3.la" SQLITE3_LIBDIR="$i/lib" break elif test -d "$i/lib" ; then SQLITE3_LIB="-lsqlite3" SQLITE3_LIBDIR="$i/lib" break fi fi done if test "$SQLITE3_INC" = "UNKNOWN" -o "$SQLITE3_LIB" = "UNKNOWN" ; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 { echo "$as_me:$LINENO: WARNING: SQLite3 header files and/or library not found" >&5 echo "$as_me: WARNING: SQLite3 header files and/or library not found" >&2;} else echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 LIB_TARGETS="$LIB_TARGETS libsqlite3odbc.la" INST_TARGETS="$INST_TARGETS install-3" UNINST_TARGETS="$UNINST_TARGETS uninstall-3" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-3" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-3" if test -n "$SQLITE3_A10N_C" ; then SQLITE3_LIB="" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_DLL=1 -DSQLITE_SOUNDEX=1" SQLITE3_A10N_FLAGS="$SQLITE3_A10N_FLAGS -DSQLITE_THREADSAFE=1" fi fi # test for availability of some sqlite3_*() funcs if test -n "$SQLITE3_LIBDIR" ; then SQLITE3_LIBDIR="-L$SQLITE3_LIBDIR" fi if test -n "$SQLITE3_A10N_C" ; then SQLITE3_LOADEXTENSION=1 SQLITE3_COLUMNTABLENAME=1 SQLITE3_OVERLOADFUNCTION=1 SQLITE3_PREPARE_V2=1 SQLITE3_CLEARBINDINGS=1 SQLITE3_CREATEMODULE_V2=1 SQLITE3_VFS=1 SQLITE3_TABLECOLUMNMETADATA=1 SQLITE3_PROFILE=1 SQLITE3_STRNICMP=1 else saved_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$SQLITE3_INC" saved_LIBS=$LIBS LIBS="$LIBS $SQLITE3_LIBDIR" echo "$as_me:$LINENO: checking for sqlite3_load_extension in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_load_extension in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_load_extension+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_load_extension (); int main () { sqlite3_load_extension (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_load_extension=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_load_extension=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_load_extension" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_load_extension" >&6 if test $ac_cv_lib_sqlite3_sqlite3_load_extension = yes; then SQLITE3_LOADEXTENSION=1 else SQLITE3_LOADEXTENSION=0 fi if test "$SQLITE3_LOADEXTENSION" = "0" ; then unset ac_cv_lib_sqlite3_sqlite3_load_extension # try again with -ldl LIBS="$LIBS -ldl $SQLITE3_LIBDIR" echo "$as_me:$LINENO: checking for sqlite3_load_extension in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_load_extension in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_load_extension+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_load_extension (); int main () { sqlite3_load_extension (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_load_extension=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_load_extension=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_load_extension" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_load_extension" >&6 if test $ac_cv_lib_sqlite3_sqlite3_load_extension = yes; then SQLITE3_LOADEXTENSION=1 else SQLITE3_LOADEXTENSION=0 fi if test "$SQLITE3_LOADEXTENSION" = "1" ; then SQLITE3_LIB="$SQLITE3_LIB -ldl" fi fi echo "$as_me:$LINENO: checking for sqlite3_column_table_name in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_column_table_name in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_column_table_name+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_column_table_name (); int main () { sqlite3_column_table_name (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_column_table_name=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_column_table_name=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_column_table_name" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_column_table_name" >&6 if test $ac_cv_lib_sqlite3_sqlite3_column_table_name = yes; then SQLITE3_COLUMNTABLENAME=1 else SQLITE3_COLUMNTABLENAME=0 fi echo "$as_me:$LINENO: checking for sqlite3_overload_function in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_overload_function in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_overload_function+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_overload_function (); int main () { sqlite3_overload_function (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_overload_function=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_overload_function=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_overload_function" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_overload_function" >&6 if test $ac_cv_lib_sqlite3_sqlite3_overload_function = yes; then SQLITE3_OVERLOADFUNCTION=1 else SQLITE3_OVERLOADFUNCTION=0 fi echo "$as_me:$LINENO: checking for sqlite3_prepare_v2 in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_prepare_v2 in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_prepare_v2+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_prepare_v2 (); int main () { sqlite3_prepare_v2 (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_prepare_v2=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_prepare_v2=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_prepare_v2" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_prepare_v2" >&6 if test $ac_cv_lib_sqlite3_sqlite3_prepare_v2 = yes; then SQLITE3_PREPARE_V2=1 else SQLITE3_PREPARE_V2=0 fi echo "$as_me:$LINENO: checking for sqlite3_clear_bindings in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_clear_bindings in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_clear_bindings+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_clear_bindings (); int main () { sqlite3_clear_bindings (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_clear_bindings=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_clear_bindings=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_clear_bindings" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_clear_bindings" >&6 if test $ac_cv_lib_sqlite3_sqlite3_clear_bindings = yes; then SQLITE3_CLEARBINDINGS=1 else SQLITE3_CLEARBINDINGS=0 fi echo "$as_me:$LINENO: checking for sqlite3_create_module_v2 in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_create_module_v2 in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_create_module_v2+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_create_module_v2 (); int main () { sqlite3_create_module_v2 (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_create_module_v2=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_create_module_v2=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_create_module_v2" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_create_module_v2" >&6 if test $ac_cv_lib_sqlite3_sqlite3_create_module_v2 = yes; then SQLITE3_CREATEMODULE_V2=1 else SQLITE3_CREATEMODULE_V2=0 fi echo "$as_me:$LINENO: checking for sqlite3_vfs_register in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_vfs_register in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_vfs_register+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_vfs_register (); int main () { sqlite3_vfs_register (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_vfs_register=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_vfs_register=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_vfs_register" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_vfs_register" >&6 if test $ac_cv_lib_sqlite3_sqlite3_vfs_register = yes; then SQLITE3_VFS=1 else SQLITE3_VFS=0 fi echo "$as_me:$LINENO: checking for sqlite3_table_column_metadata in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_table_column_metadata in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_table_column_metadata+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_table_column_metadata (); int main () { sqlite3_table_column_metadata (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_table_column_metadata=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_table_column_metadata=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_table_column_metadata" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_table_column_metadata" >&6 if test $ac_cv_lib_sqlite3_sqlite3_table_column_metadata = yes; then SQLITE3_TABLECOLUMNMETADATA=1 else SQLITE3_TABLECOLUMNMETADATA=0 fi echo "$as_me:$LINENO: checking for sqlite3_profile in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_profile in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_profile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_profile (); int main () { sqlite3_profile (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_profile=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_profile=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_profile" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_profile" >&6 if test $ac_cv_lib_sqlite3_sqlite3_profile = yes; then SQLITE3_PROFILE=1 else SQLITE3_PROFILE=0 fi echo "$as_me:$LINENO: checking for sqlite3_strnicmp in -lsqlite3" >&5 echo $ECHO_N "checking for sqlite3_strnicmp in -lsqlite3... $ECHO_C" >&6 if test "${ac_cv_lib_sqlite3_sqlite3_strnicmp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqlite3_strnicmp (); int main () { sqlite3_strnicmp (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_sqlite3_sqlite3_strnicmp=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_sqlite3_sqlite3_strnicmp=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_strnicmp" >&5 echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_strnicmp" >&6 if test $ac_cv_lib_sqlite3_sqlite3_strnicmp = yes; then SQLITE3_STRNICMP=1 else SQLITE3_STRNICMP=0 fi LIBS=$saved_LIBS CFLAGS=$saved_CFLAGS fi ######### # Find zlib for zipfile module # LIBZ_OK=no if test "$SQLITE3_LOADEXTENSION" = "1" ; then echo "$as_me:$LINENO: checking for library containing zlibVersion" >&5 echo $ECHO_N "checking for library containing zlibVersion... $ECHO_C" >&6 if test "${ac_cv_search_zlibVersion+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_zlibVersion=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char zlibVersion (); int main () { zlibVersion (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_zlibVersion="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_zlibVersion" = no; then for ac_lib in z; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char zlibVersion (); int main () { zlibVersion (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_zlibVersion="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_zlibVersion" >&5 echo "${ECHO_T}$ac_cv_search_zlibVersion" >&6 if test "$ac_cv_search_zlibVersion" != no; then test "$ac_cv_search_zlibVersion" = "none required" || LIBS="$ac_cv_search_zlibVersion $LIBS" for ac_header in zlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF LIBZ_OK=yes fi done fi fi ######### # Add extensions to build # if test "$SQLITE3_LOADEXTENSION" = "1" ; then EXT_BLOBTOXY=libsqlite3_mod_blobtoxy.la EXT_IMPEXP=libsqlite3_mod_impexp.la EXT_CSVTABLE=libsqlite3_mod_csvtable.la EXT_ZIPFILE="" LIB_TARGETS="$LIB_TARGETS $EXT_BLOBTOXY $EXT_IMPEXP $EXT_CSVTABLE" if test "$LIBZ_OK" = "yes" ; then EXT_ZIPFILE=libsqlite3_mod_zipfile.la LIB_TARGETS="$LIB_TARGETS $EXT_ZIPFILE" fi else EXT_BLOBTOXY="" EXT_IMPEXP="" EXT_CSVTABLE="" EXT_ZIPFILE="" fi ########## # Find SQLite4 header file and library # # Check whether --with-sqlite4 or --without-sqlite4 was given. if test "${with_sqlite4+set}" = set; then withval="$with_sqlite4" SQLITE4_DIR=$withval fi; if test -n "$SQLITE4_DIR" ; then if test ! -d "$SQLITE4_DIR" ; then { echo "$as_me:$LINENO: WARNING: SQLite4 directory $SQLITE4_DIR does not exist" >&5 echo "$as_me: WARNING: SQLite4 directory $SQLITE4_DIR does not exist" >&2;} fi fi SQLITE4_INC=UNKNOWN if test -n "$SQLITE4_DIR" ; then echo "$as_me:$LINENO: checking for SQLite4 header and library" >&5 echo $ECHO_N "checking for SQLite4 header and library... $ECHO_C" >&6 for i in $SQLITE4_DIR ; do if test -r "$i/sqlite4.h" ; then if test -r "$i/sqlite4.c" ; then SQLITE4_INC="$i" SQLITE4_A10N_C="$i/sqlite4.c" SQLITE4_A10N_O="sqlite4.lo" break fi fi done fi if test "$SQLITE4_INC" = "UNKNOWN" ; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 { echo "$as_me:$LINENO: WARNING: SQLite4 header file and source not found" >&5 echo "$as_me: WARNING: SQLite4 header file and source not found" >&2;} else echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 LIB_TARGETS="$LIB_TARGETS libsqlite4odbc.la" INST_TARGETS="$INST_TARGETS install-4" UNINST_TARGETS="$UNINST_TARGETS uninstall-4" DRVINST_TARGETS="$DRVINST_TARGETS drvinst-4" DRVUNINST_TARGETS="$DRVUNINST_TARGETS drvuninst-4" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_ENABLE_COLUMN_METADATA=1" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_SOUNDEX=1" SQLITE4_A10N_FLAGS="$SQLITE4_A10N_FLAGS -DSQLITE4_THREADSAFE=1" fi ######### # libxml2 support for XPath virtual table module XML2_FLAGS="" XML2_LIBS="" EXT_XPATH="" if test "$SQLITE3_LOADEXTENSION" = "1" ; then echo "$as_me:$LINENO: checking for libxml2 header and library" >&5 echo $ECHO_N "checking for libxml2 header and library... $ECHO_C" >&6 XML2_CONFIG="`which xml2-config 2>/dev/null`" if test -n "$XML2_CONFIG" ; then XML2_FLAGS="`xml2-config --cflags`" XML2_LIBS="`xml2-config --libs`" EXT_XPATH=libsqlite3_mod_xpath.la LIB_TARGETS="$LIB_TARGETS $EXT_XPATH" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi ######### # Any SQLite to be done ? if test "X$LIB_TARGETS" = "X" ; then { { echo "$as_me:$LINENO: error: No usable SQLite header/library on this system" >&5 echo "$as_me: error: No usable SQLite header/library on this system" >&2;} { (exit 1); exit 1; }; } fi ######### # Find ODBC headers and libraries # # Check whether --with-odbc or --without-odbc was given. if test "${with_odbc+set}" = set; then withval="$with_odbc" ODBC_DIR=$withval fi; if test -n "$ODBC_DIR" ; then if test ! -d "$ODBC_DIR" ; then { { echo "$as_me:$LINENO: error: ODBC directory $ODBC_DIR does not exist" >&5 echo "$as_me: error: ODBC directory $ODBC_DIR does not exist" >&2;} { (exit 1); exit 1; }; } fi fi ODBC_FLAGS=UNKNOWN ODBC_LIB=UNKNOWN if test -z "$ODBC_DIR" ; then if test -r "$includedir/sql.h" -a -r "$includedir/iodbcinst.h" -a -r "$libdir/libiodbcinst.la" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$includedir" ODBC_LIB="$libdir/libiodbcinst.la" ODBC_DIR="" elif test -r "$includedir/iodbc/sql.h" -a -r "$includedir/iodbc/iodbcinst.h" -a -r "$libdir/libiodbcinst.la" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$includedir/iodbc" ODBC_LIB="$libdir/libiodbcinst.la" ODBC_DIR="" elif test -r "$includedir/sql.h" -a -r "$includedir/odbcinst.h" -a -r "$libdir/libodbcinst.la" ; then ODBC_FLAGS="-DHAVE_UNIXODBC=1 -I$includedir" ODBC_LIB="$libdir/libodbcinst.la" if test -r "$includedir/odbcinstext.h" ; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_ODBCINSTEXT_H=1 -Imissing" fi else ODBC_DIR="/usr /usr/local /opt" fi fi echo "$as_me:$LINENO: checking for ODBC headers and libraries" >&5 echo $ECHO_N "checking for ODBC headers and libraries... $ECHO_C" >&6 for i in $ODBC_DIR ; do if test -r "$i/include/iodbc/sql.h" -o -r "$i/include/sql.h" ; then if test -r "$i/include/iodbc/iodbcinst.h" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$i/include/iodbc" if test -r "$i/lib/libiodbcinst.la" ; then ODBC_LIB="$i/lib/libiodbcinst.la" else ODBC_LIB=-liodbcinst fi break elif test -r "$i/include/iodbcinst.h" ; then ODBC_FLAGS="-DHAVE_IODBC=1 -I$i/include" if test -r "$i/lib/libiodbcinst.la" ; then ODBC_LIB="$i/lib/libiodbcinst.la" else ODBC_LIB=-liodbcinst fi break elif test -r "$i/include/odbcinst.h" ; then ODBC_FLAGS="-DHAVE_UNIXODBC=1 -I$i/include" if test -r "$i/lib/libodbcinst.la" ; then ODBC_LIB="$i/lib/libodbcinst.la" else ODBC_LIB=-lodbcinst fi if test -r "$i/include/odbcinstext.h" ; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_ODBCINSTEXT_H=1" if test -r "$i/include/log.h" -a -r "$i/include/ini.h" ; then : no need for replacements else ODBC_FLAGS="$ODBC_FLAGS -Imissing" fi fi break fi fi done if test "$ODBC_FLAGS" = "UNKNOWN" -o "$ODBC_LIB" = "UNKNOWN" ; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 { { echo "$as_me:$LINENO: error: ODBC header files and/or libraries not found" >&5 echo "$as_me: error: ODBC header files and/or libraries not found" >&2;} { (exit 1); exit 1; }; } else echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 fi ########## # Test ODBC features. # SAVED_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ODBC_FLAGS" echo "$as_me:$LINENO: checking for SQLLEN availability" >&5 echo $ECHO_N "checking for SQLLEN availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLLEN len = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLLEN=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLULEN availability" >&5 echo $ECHO_N "checking for SQLULEN availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLULEN len = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLULEN=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLROWCOUNT availability" >&5 echo $ECHO_N "checking for SQLROWCOUNT availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLROWCOUNT rc = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWCOUNT=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLSETPOSIROW availability" >&5 echo $ECHO_N "checking for SQLSETPOSIROW availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLSETPOSIROW rc = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLSETPOSIROW=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLROWOFFSET availability" >&5 echo $ECHO_N "checking for SQLROWOFFSET availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLROWOFFSET rc = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWOFFSET=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLROWSETSIZE availability" >&5 echo $ECHO_N "checking for SQLROWSETSIZE availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLROWSETSIZE rc = 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLROWSETSIZE=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLColAttribute signature has SQLLEN" >&5 echo $ECHO_N "checking for SQLColAttribute signature has SQLLEN... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #define ODBCVER 0x0300 #include #include #include int main () { SQLHSTMT stmt = SQL_NULL_HSTMT; SQLSMALLINT valLen; SQLLEN val2; extern SQLRETURN SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT col, SQLUSMALLINT id, SQLPOINTER charattr, SQLSMALLINT buflen, SQLSMALLINT *slen, SQLLEN *numattr); SQLColAttribute(stmt, 1, 0, NULL, 0, &valLen, &val2); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DCOLATTRIBUTE_LAST_ARG_TYPE=SQLLEN_PTR" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLSetStmtOption signature has SQLULEN" >&5 echo $ECHO_N "checking for SQLSetStmtOption signature has SQLULEN... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #define ODBCVER 0x0300 #include #include #include int main () { SQLHSTMT stmt = SQL_NULL_HSTMT; extern SQLRETURN SQLSetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT option, SQLULEN value); SQLSetStmtOption(stmt, 1, 2); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DSETSTMTOPTION_LAST_ARG_TYPE=SQLULEN" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLWCHAR availability" >&5 echo $ECHO_N "checking for SQLWCHAR availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLWCHAR thisiswchar; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_SQLWCHAR=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for SQLBIGINT availability" >&5 echo $ECHO_N "checking for SQLBIGINT availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { SQLBIGINT thisisbig; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LONG_LONG=1" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: checking for ptrdiff_t availability" >&5 echo $ECHO_N "checking for ptrdiff_t availability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { ptrdiff_t apdt = 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 ODBC_FLAGS="$ODBC_FLAGS -DPTRDIFF_T=ptrdiff_t" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 ODBC_FLAGS="$ODBC_FLAGS -DPTRDIFF_T=int" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$SAVED_CFLAGS" ########## # Experimental: dlopen for resolving SQLGetPrivateProfileString dynamically # echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then DLOPENFORGPPS=1 else DLOPENFORGPPS=0 fi if test "$DLOPENFORGPPS" = "1" ; then echo "$as_me:$LINENO: checking for SQLGetPrivateProfileString via dlopen" >&5 echo $ECHO_N "checking for SQLGetPrivateProfileString via dlopen... $ECHO_C" >&6 saved_LIBS=$LIBS LIBS="$LIBS -ldl" if test "$cross_compiling" = yes; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main(int argc, char **argv) { void *lib; int (*gpps)(); lib = dlopen("libodbcinst.so", RTLD_LAZY); if (!lib) { lib = dlopen("libiodbcinst.so", RTLD_LAZY); } if (lib) { gpps = (int (*)()) dlsym(lib, "SQLGetPrivateProfileString"); exit(0); } exit(1); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ODBC_FLAGS="$ODBC_FLAGS -DUSE_DLOPEN_FOR_GPPS" ODBC_LIB="-ldl" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi LIBS=$saved_LIBS fi ########## # Find out if char ptr array can be passed in place of # a va_list (needed for sqlite_exec_vprintf() and # sqlite_vmprintf()) # echo "$as_me:$LINENO: checking va_list usage" >&5 echo $ECHO_N "checking va_list usage... $ECHO_C" >&6 if test "$cross_compiling" = yes; then USE_VFUNCS=0 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include static int vatest(char **x, ...) { va_list ap; char *y; int ret; va_start(ap, x); y = va_arg(ap, char *); x = (char **) &x + 1; ret = (y != *x); va_end(ap); return ret; } int main(int argc, char **argv) { exit(vatest(NULL, vatest, 0.0, 0, NULL)); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then USE_VFUNCS=1 else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) USE_VFUNCS=0 fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$USE_VFUNCS" = "1" ; then echo "$as_me:$LINENO: result: using sqlite_exec_vprintf/sqlite_vmprintf" >&5 echo "${ECHO_T}using sqlite_exec_vprintf/sqlite_vmprintf" >&6 else echo "$as_me:$LINENO: result: NOT using sqlite_exec_vprintf/sqlite_vmprintf" >&5 echo "${ECHO_T}NOT using sqlite_exec_vprintf/sqlite_vmprintf" >&6 ODBC_FLAGS="$ODBC_FLAGS -DCANT_PASS_VALIST_AS_CHARPTR=1" fi ########## # Check for usleep() and nanosleep() # echo "$as_me:$LINENO: checking for usleep" >&5 echo $ECHO_N "checking for usleep... $ECHO_C" >&6 if test "${ac_cv_func_usleep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define usleep to an innocuous variant, in case declares usleep. For example, HP-UX 11i declares gettimeofday. */ #define usleep innocuous_usleep /* System header to define __stub macros and hopefully few prototypes, which can conflict with char usleep (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef usleep /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char usleep (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_usleep) || defined (__stub___usleep) choke me #else char (*f) () = usleep; #endif #ifdef __cplusplus } #endif int main () { return f != usleep; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_usleep=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_usleep=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_usleep" >&5 echo "${ECHO_T}$ac_cv_func_usleep" >&6 if test $ac_cv_func_usleep = yes; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_USLEEP=1" fi echo "$as_me:$LINENO: checking for nanosleep" >&5 echo $ECHO_N "checking for nanosleep... $ECHO_C" >&6 if test "${ac_cv_func_nanosleep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define nanosleep to an innocuous variant, in case declares nanosleep. For example, HP-UX 11i declares gettimeofday. */ #define nanosleep innocuous_nanosleep /* System header to define __stub macros and hopefully few prototypes, which can conflict with char nanosleep (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef nanosleep /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char nanosleep (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_nanosleep) || defined (__stub___nanosleep) choke me #else char (*f) () = nanosleep; #endif #ifdef __cplusplus } #endif int main () { return f != nanosleep; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_nanosleep=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_nanosleep=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_nanosleep" >&5 echo "${ECHO_T}$ac_cv_func_nanosleep" >&6 if test $ac_cv_func_nanosleep = yes; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_NANOSLEEP=1" fi ########## # Check for localeconv() # echo "$as_me:$LINENO: checking for localeconv" >&5 echo $ECHO_N "checking for localeconv... $ECHO_C" >&6 if test "${ac_cv_func_localeconv+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define localeconv to an innocuous variant, in case declares localeconv. For example, HP-UX 11i declares gettimeofday. */ #define localeconv innocuous_localeconv /* System header to define __stub macros and hopefully few prototypes, which can conflict with char localeconv (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef localeconv /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char localeconv (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_localeconv) || defined (__stub___localeconv) choke me #else char (*f) () = localeconv; #endif #ifdef __cplusplus } #endif int main () { return f != localeconv; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_localeconv=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_localeconv=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_localeconv" >&5 echo "${ECHO_T}$ac_cv_func_localeconv" >&6 if test $ac_cv_func_localeconv = yes; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LOCALECONV=1" fi ########## # Check for localtime_r() # echo "$as_me:$LINENO: checking for localtime_r" >&5 echo $ECHO_N "checking for localtime_r... $ECHO_C" >&6 if test "${ac_cv_func_localtime_r+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define localtime_r to an innocuous variant, in case declares localtime_r. For example, HP-UX 11i declares gettimeofday. */ #define localtime_r innocuous_localtime_r /* System header to define __stub macros and hopefully few prototypes, which can conflict with char localtime_r (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef localtime_r /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char localtime_r (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_localtime_r) || defined (__stub___localtime_r) choke me #else char (*f) () = localtime_r; #endif #ifdef __cplusplus } #endif int main () { return f != localtime_r; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_localtime_r=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_localtime_r=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_localtime_r" >&5 echo "${ECHO_T}$ac_cv_func_localtime_r" >&6 if test $ac_cv_func_localtime_r = yes; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_LOCALTIME_R=1" fi ########## # Check for gmtime_r() # echo "$as_me:$LINENO: checking for gmtime_r" >&5 echo $ECHO_N "checking for gmtime_r... $ECHO_C" >&6 if test "${ac_cv_func_gmtime_r+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define gmtime_r to an innocuous variant, in case declares gmtime_r. For example, HP-UX 11i declares gettimeofday. */ #define gmtime_r innocuous_gmtime_r /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gmtime_r (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef gmtime_r /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gmtime_r (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gmtime_r) || defined (__stub___gmtime_r) choke me #else char (*f) () = gmtime_r; #endif #ifdef __cplusplus } #endif int main () { return f != gmtime_r; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_gmtime_r=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_gmtime_r=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_gmtime_r" >&5 echo "${ECHO_T}$ac_cv_func_gmtime_r" >&6 if test $ac_cv_func_gmtime_r = yes; then ODBC_FLAGS="$ODBC_FLAGS -DHAVE_GMTIME_R=1" fi ########## # Allow omission of SQL*W() functions for SQLITE_UTF8 encoding # # Check whether --enable-winterface or --disable-winterface was given. if test "${enable_winterface+set}" = set; then enableval="$enable_winterface" test $enable_winterface = "no" && ODBC_FLAGS="$ODBC_FLAGS -DWITHOUT_WINTERFACE=1" else ODBC_FLAGS="$ODBC_FLAGS -DWITHOUT_WINTERFACE=1" fi; ######### # Install directory (on Debian $libdir/odbc) if test -r /etc/debian_version ; then DRVDIR="/odbc" else DRVDIR="" fi ########## # Experimental: dlopen for resolving SQLite3/SQLite4 symbols # # Check whether --with-dls or --without-dls was given. if test "${with_dls+set}" = set; then withval="$with_dls" WITH_DLS=1 else WITH_DLS=0 fi; if test "$DLOPENFORGPPS" = "1" ; then if test "$WITH_DLS" = "1" ; then DL_OPTS="-DSQLITE_DYNLOAD=1" SQLITE3_LIB="" SQLITE3_A10N_O="" SQLITE4_A10N_O="" DL_INITFINI="-Wl,-init,dls_init -Wl,-fini,dls_fini" fi fi ######### # Generate the output files. # SPEC_CHANGELOG_TS=`LANG=C date -u "+%a %b %d %Y"` DEB_CHANGELOG_TS=`LANG=C date "+%a, %d %b %Y %X %z"` ac_config_files="$ac_config_files Makefile sqliteodbc.spec debian/changelog" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then we branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. cat >confdef2opt.sed <<\_ACEOF t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote d : quote s,[ `~#$^&*(){}\\|;'"<>?],\\&,g s,\[,\\&,g s,\],\\&,g s,\$,$$,g p _ACEOF # We use echo to avoid assuming a particular line-breaking character. # The extra dot is to prevent the shell from consuming trailing # line-breaks from the sub-command output. A line-break within # single-quotes doesn't work because, if this script is created in a # platform that uses two characters for line-breaks (e.g., DOS), tr # would break. ac_LF_and_DOT=`echo; echo .` DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` rm -f confdef2opt.sed ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir INSTALL="$INSTALL" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "sqliteodbc.spec" ) CONFIG_FILES="$CONFIG_FILES sqliteodbc.spec" ;; "debian/changelog" ) CONFIG_FILES="$CONFIG_FILES debian/changelog" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@SED@,$SED,;t t s,@EGREP@,$EGREP,;t t s,@LN_S@,$LN_S,;t t s,@ECHO@,$ECHO,;t t s,@AR@,$AR,;t t s,@ac_ct_AR@,$ac_ct_AR,;t t s,@RANLIB@,$RANLIB,;t t s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t s,@STRIP@,$STRIP,;t t s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t s,@CPP@,$CPP,;t t s,@CXX@,$CXX,;t t s,@CXXFLAGS@,$CXXFLAGS,;t t s,@ac_ct_CXX@,$ac_ct_CXX,;t t s,@CXXCPP@,$CXXCPP,;t t s,@F77@,$F77,;t t s,@FFLAGS@,$FFLAGS,;t t s,@ac_ct_F77@,$ac_ct_F77,;t t s,@LIBTOOL@,$LIBTOOL,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@SQLITE_INC@,$SQLITE_INC,;t t s,@SQLITE_LIB@,$SQLITE_LIB,;t t s,@SQLITE_LIBVERSION@,$SQLITE_LIBVERSION,;t t s,@SQLITE_ENCDEC@,$SQLITE_ENCDEC,;t t s,@SQLITE_ATOF@,$SQLITE_ATOF,;t t s,@SQLITE_MPRINTF@,$SQLITE_MPRINTF,;t t s,@SQLITE_TRACE@,$SQLITE_TRACE,;t t s,@SQLITE3_INC@,$SQLITE3_INC,;t t s,@SQLITE3_A10N_C@,$SQLITE3_A10N_C,;t t s,@SQLITE3_A10N_FLAGS@,$SQLITE3_A10N_FLAGS,;t t s,@SQLITE3_COLUMNTABLENAME@,$SQLITE3_COLUMNTABLENAME,;t t s,@SQLITE3_OVERLOADFUNCTION@,$SQLITE3_OVERLOADFUNCTION,;t t s,@SQLITE3_PREPARE_V2@,$SQLITE3_PREPARE_V2,;t t s,@SQLITE3_CLEARBINDINGS@,$SQLITE3_CLEARBINDINGS,;t t s,@SQLITE3_CREATEMODULE_V2@,$SQLITE3_CREATEMODULE_V2,;t t s,@SQLITE3_LOADEXTENSION@,$SQLITE3_LOADEXTENSION,;t t s,@SQLITE3_TABLECOLUMNMETADATA@,$SQLITE3_TABLECOLUMNMETADATA,;t t s,@SQLITE3_VFS@,$SQLITE3_VFS,;t t s,@SQLITE3_PROFILE@,$SQLITE3_PROFILE,;t t s,@SQLITE3_STRNICMP@,$SQLITE3_STRNICMP,;t t s,@EXT_BLOBTOXY@,$EXT_BLOBTOXY,;t t s,@EXT_IMPEXP@,$EXT_IMPEXP,;t t s,@EXT_CSVTABLE@,$EXT_CSVTABLE,;t t s,@EXT_ZIPFILE@,$EXT_ZIPFILE,;t t s,@SQLITE4_INC@,$SQLITE4_INC,;t t s,@SQLITE4_A10N_C@,$SQLITE4_A10N_C,;t t s,@SQLITE4_A10N_FLAGS@,$SQLITE4_A10N_FLAGS,;t t s,@XML2_FLAGS@,$XML2_FLAGS,;t t s,@XML2_LIBS@,$XML2_LIBS,;t t s,@EXT_XPATH@,$EXT_XPATH,;t t s,@LIB_TARGETS@,$LIB_TARGETS,;t t s,@INST_TARGETS@,$INST_TARGETS,;t t s,@UNINST_TARGETS@,$UNINST_TARGETS,;t t s,@DRVINST_TARGETS@,$DRVINST_TARGETS,;t t s,@DRVUNINST_TARGETS@,$DRVUNINST_TARGETS,;t t s,@ODBC_FLAGS@,$ODBC_FLAGS,;t t s,@ODBC_LIB@,$ODBC_LIB,;t t s,@VER_INFO@,$VER_INFO,;t t s,@DRVDIR@,$DRVDIR,;t t s,@DL_OPTS@,$DL_OPTS,;t t s,@DL_INITFINI@,$DL_INITFINI,;t t s,@SQLITE3_LIB@,$SQLITE3_LIB,;t t s,@SQLITE3_A10N_O@,$SQLITE3_A10N_O,;t t s,@SQLITE4_A10N_O@,$SQLITE4_A10N_O,;t t s,@SPEC_CHANGELOG_TS@,$SPEC_CHANGELOG_TS,;t t s,@DEB_CHANGELOG_TS@,$DEB_CHANGELOG_TS,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi ./sqliteodbc-0.992/sqliteodbcos2.rc0100644000076400001440000000707510145661773015656 0ustar chwusers /* OS/2 Warp 4.0 Resource Script File - Created by Universal Resource Editor */ #define INCL_WINSYS #define INCL_WINBIDI #define INCL_WINSTDDLGS #define INCL_WINSTDSPIN #define INCL_NLS #define INCL_SW #include #include "resourceos2.h" DLGTEMPLATE DLG_SQLITEODBCCONFIGURATION MOVEABLE DISCARDABLE BEGIN DIALOG "SQLite ODBC Configuation",DLG_SQLITEODBCCONFIGURATION,8,30,238,111, FS_NOBYTEALIGN | FS_BORDER | WS_CLIPSIBLINGS | WS_SAVEBITS | WS_VISIBLE, FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans" PRESPARAMS PP_USER, "12.System Proportional" BEGIN CONTROL "OK", DID_OK, 5, 5, 38, 12, WC_BUTTON, BS_PUSHBUTTON | BS_DEFAULT | WS_GROUP | WS_TABSTOP | WS_VISIBLE CONTROL "Cancel", DID_CANCEL, 48, 5, 38, 12, WC_BUTTON, BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE CONTROL "Data source name", ST_DATASOURCENAME, 6, 96, 47, 7, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | WS_GROUP | WS_VISIBLE CONTROL "Description", ST_DESCRIPTION, 6, 84, 41, 7, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | WS_GROUP | WS_VISIBLE CONTROL "Database name", ST_DATABASENAME, 6, 70, 38, 7, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | WS_GROUP | WS_VISIBLE CONTROL "Timeout", ST_TIMEOUT, 6, 55, 38, 6, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | WS_GROUP | WS_VISIBLE CONTROL "", EF_DSNNAME, 62, 96, 95, 7, WC_ENTRYFIELD, ES_MARGIN | ES_ANY | WS_TABSTOP | WS_VISIBLE CTLDATA 8, 32, 0, 0 CONTROL "", EF_DSNDESC, 62, 83, 141, 7, WC_ENTRYFIELD, ES_MARGIN | ES_ANY | WS_TABSTOP | WS_VISIBLE CTLDATA 8, 32, 0, 0 CONTROL "", EF_DATABASE, 62, 69, 125, 7, WC_ENTRYFIELD, ES_MARGIN | ES_ANY | WS_TABSTOP | WS_VISIBLE CTLDATA 8, 32, 0, 0 CONTROL "", EF_TIMEOUT, 62, 54, 47, 7, WC_ENTRYFIELD, ES_MARGIN | ES_ANY | WS_TABSTOP | WS_VISIBLE CTLDATA 8, 32, 0, 0 CONTROL "Browse", IDC_BROWSE, 197, 67, 38, 12, WC_BUTTON, BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE CONTROL "No ~Wide character", IDC_NOWCHAR, 62, 38, 57, 8, WC_BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE CONTROL "~Step API", IDC_STEPAPI, 136, 37, 38, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE END END ./sqliteodbc-0.992/sqliteodbcos2.def0100644000076400001440000000210510466721335015772 0ustar chwusersLIBRARY SQLLODBC DESCRIPTION 'SQLite ODBC Driver ' EXPORTS SQLBulkOperations SQLDataSources SQLDrivers SQLBrowseConnect SQLPutData SQLBindParameter SQLBindParam SQLNumParams SQLParamData SQLDescribeParam SQLSetParam SQLParamOptions SQLTablePrivileges SQLColumnPrivileges SQLPrimaryKeys SQLSpecialColumns SQLForeignKeys SQLEndTran SQLTransact SQLNativeSql SQLProcedures SQLProcedureColumns SQLGetEnvAttr SQLSetEnvAttr SQLGetDiagRec SQLGetDiagField SQLGetStmtOption SQLSetStmtOption SQLSetPos SQLSetScrollOptions SQLGetInfo SQLGetFunctions SQLGetConnectAttr SQLSetConnectAttr SQLGetConnectOption SQLSetConnectOption SQLConnect SQLDisconnect SQLDriverConnect SQLCancel SQLGetCursorName SQLSetCursorName SQLCloseCursor SQLBindCol SQLTables SQLColumns SQLGetTypeInfo SQLStatistics SQLGetData SQLFetch SQLFetchScroll SQLExtendedFetch SQLRowCount SQLNumResultCols SQLDescribeCol SQLColAttributes SQLColAttribute SQLError SQLMoreResults SQLPrepare SQLExecute SQLExecDirect SQLAllocHandle SQLFreeHandle SQLGetStmtAttr SQLSetStmtAttr SQLAllocStmt SQLFreeStmt SQLAllocConnect SQLFreeConnect ConfigDSN ./sqliteodbc-0.992/makefile.os20100644000076400001440000000277610145423640014745 0ustar chwusers# # os/2 makfile # # change these to point to your installation directories # location of the sqlite.h and sqlite.lib SQLITELIB=../sqliteodbc/sqlitelib #location of the unixodbc odbcinst directory UNIXODBCROOT=/uodbc/unixodbc #location to copy the sqlite sqllodbc.dll file KITDLL=\uodbc\dll CC = gcc CCFLAGS = -Zomf -c LINKFLAGS = -Zomf -Zdll -Wall DEFINEITS = -D_POSIX_SOURCE \ -DHAVE_STDLIB_H \ -DHAVE_SQL_H -DHAVE_SQLEXT_H \ -DHAVE_SQLGETPRIVATEPROFILESTRING -DHAVE_ODBCINST_H -DHAVE_STRCASECMP \ -DHAVE_PWD_H \ -DUNIXODBC \ -D_UNIX_ \ -DWITH_UNIXODBC \ -DHAVE_UNIXODBC \ -DHAVE_DIRENT_H \ -D__OS2__ -DOS2 \ -DHAVE_ULONG \ -DHAVE_LIBVERSION=1 \ -DHAVE_MEMCPY -DHAVE_MEMMOVE -DHAVE_STRNLEN DEFFILE = sqliteodbcos2.def .SUFFIXES: .c .obj .dll LIBADD = \ $(UNIXODBCROOT)/odbcinst/odbccp.lib \ $(SQLITELIB)/sqlite.lib INCLUDES = -I $(UNIXODBCROOT)/include \ -I $(UNIXODBCROOT)/odbcinst \ -I $(SQLITELIB) RESOURCEFILES = sqliteodbcos2.rc HEADERS = \ sqliteodbc.h \ resourceos2.h DEPENDENCIES = $(HEADERS) $(RESOURCEFILES) SOURCES = \ sqliteodbc.c OBJECTS = \ sqliteodbc.obj all: sqllodbc.dll sqllodbc.dll: $(OBJECTS) $(DEPENDENCIES) @echo Linking sqllite.DLL $(CC) $(LINKFLAGS) -o sqllODBC.dll $(OBJECTS) $(LIBADD) $(DEFFILE) @rc -p sqliteodbcos2.rc sqllODBC.dll @copy sqllODBC.dll $(KITDLL) .c.obj: @echo Compiling $< $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINEITS) -o $@ $< clean: @del *.obj @del *.dll ./sqliteodbc-0.992/resourceos2.h0100644000076400001440000000056410377272311015164 0ustar chwusers#define DLG_SQLITEODBCCONFIGURATION 256 #define ST_DATASOURCENAME 258 #define ST_DESCRIPTION 259 #define ST_DATABASENAME 260 #define ST_TIMEOUT 261 #define EF_DSNNAME 262 #define EF_DSNDESC 263 #define EF_DATABASE 264 #define EF_TIMEOUT 265 #define IDC_BROWSE 266 #define IDC_NOWCHAR 267 #define IDC_STEPAPI 268 #define IDC_NOTXN 269 #define IDC_LONGNAM 270 ./sqliteodbc-0.992/README.OS20100644000076400001440000000153510145425372014021 0ustar chwusersThe OS/2 port of the sqlite ODBC driver is compiled with the GCC 3.2.2 compiler. The makefile is set up to use the unixODBC header files for common definitions of the ODBC driver manager. The port uses the SQLite 2.8.15 OS/2 port package done by Andrew MacIntyre email: andymac@bullseye.apana.org.au, or andymac@pcug.org.au web: http://www.andymac.org/ The build file requires the presence of of a subdirectory containing sqlite.h and sqlite.lib from the SQLite-2.8.15 package. There are three variables at the beginning of the make file for OS/2 that have to set for your environment SQLITELIB - location of the SQLite.h and SQLite.lib files UNIXODBCROOT - root directory of the unixodbc source tree this is used to locate the 'include' and 'odbcinst' directories KITDLL - location to copy the SQLLODBC.DLL file after it is built ./sqliteodbc-0.992/README.ic0100644000076400001440000000354410466643215014017 0ustar chwusers------------------------------------------------------------------ How to compile Win32 SQLite3 ODBC driver with the Intel-Compiler ------------------------------------------------------------------ This HOWTO was written by Gunter Hinrichsen Read first the README section "Build instructions for MS Visual C++ 6.0:". Some easy changes have to be made to compile SQLite3 ODBC driver under Intel- Compiler environment. You have to replace some options in the two make files. Of course you can add at advanced Intel-Compiler optimize options, too. sqlite3.mak: ------------ - Replace in "BCC" the "cl" by "icl". Old: "BCC = cl -Gs -GX -D_WIN32 -nologo -Zi" New: "BCC = icl -Gs -GX -D_WIN32 -nologo -Zi" - Replace in "TCC" the "cl" by "icl". Old: "TCC = cl -Gs -GX -D_WIN32 -DOS_WIN=1 -nologo -Zi" New: "TCC = icl -Gs -GX -D_WIN32 -DOS_WIN=1 -nologo -Zi" - Replace in the "sqlite3.dll:" section "link" by "xilink". Old: "xilink -release -nodefaultlib -dll msvcrt.lib kernel32.lib \" New: "link -release -nodefaultlib -dll msvcrt.lib kernel32.lib \" - Add in the "xilink" comando line the lib "libircmt.lib". Old: "xilink -release -nodefaultlib -dll msvcrt.lib kernel32.lib \" New: "link -release -nodefaultlib -dll msvcrt.lib kernel32.lib libircmt.lib \" sqlite3odbc.mak: ---------------- - Replace in "CC" the "cl" by "icl". Old: "CC=cl" New: "CC=icl" - Replace in "LN" the "link" by "xilink". Old: "LN=link" New: "LN=xilink" - Add in "DLLLIBS" the lib "libircmt.lib". Old: "DLLLIBS= msvcrt.lib odbccp32.lib kernel32.lib \" New: "DLLLIBS= msvcrt.lib odbccp32.lib kernel32.lib libircmt.lib \" ------------------------------------- Start the Intel Environment. You can find the Environment in the start-menu: "Intel(R) Software Development Tools/Intel(R) C++ Compiler 9.1/Build Environment for IA-32 applications" Now compile with: nmake -f sqlite3odbc.mak ./sqliteodbc-0.992/drvdsninst.sh0100755000076400001440000000212710434531122015262 0ustar chwusers#!/bin/sh # # Install ODBC driver and system DSN # $1 driver name # $2 DSN name # $3 libtool .la file # $4 directory where libtool installs shared library which odbcinst > /dev/null || { echo >&2 "no usable odbcinst program" exit 1 } DRVNAME=$1 DRVNAME_BR='['"$1"']' DSNNAME=$2 DSNNAME_BR='['"$2"']' . $3 || exit 1 for n in $library_names ; do true done if [ -z "$n" ] ; then echo >&2 "no shared library name for driver $DRVNAME in $3" exit 1 fi DRVSHLIB="$4/$n" if [ ! -r "$DRVSHLIB" ] ; then echo >&2 "no shared library for driver $DRVNAME in $4" exit 1 fi cat > /tmp/drvinst.$$ << __EOD__ $DRVNAME_BR Description=$DRVNAME Driver=$DRVSHLIB Setup=$DRVSHLIB FileUsage=1 __EOD__ odbcinst -q -d -n "$DRVNAME" | fgrep "$DRVNAME_BR" > /dev/null || { odbcinst -i -d -n "$DRVNAME" -f /tmp/drvinst.$$ || true } rm -f /tmp/drvinst.$$ cat > /tmp/dsninst.$$ << __EOD__ $DSNNAME_BR Driver=$DRVNAME __EOD__ odbcinst -q -s -n "$DSNNAME" | fgrep "$DSNNAME_BR" > /dev/null || { odbcinst -i -l -s -n "$DSNNAME" -f /tmp/dsninst.$$ || true } rm -f /tmp/dsninst.$$ ./sqliteodbc-0.992/drvdsnuninst.sh0100755000076400001440000000036610402540203015623 0ustar chwusers#!/bin/sh # # Uninstall ODBC driver and system DSN # $1 driver name # $2 DSN name which odbcinst > /dev/null || { echo >&2 "no usable odbcinst program" exit 1 } odbcinst -u -d -n "$1" || true odbcinst -u -l -s -n "$2" || true ./sqliteodbc-0.992/Makefile.mingw-cross0100644000076400001440000002041212107272323016435 0ustar chwusers# Makefile for SQLite ODBC Drivers # using MinGW cross compiler MINGW = /opt/mingw64/bin/x86_64-w64-mingw32- CC = $(MINGW)gcc -m32 -march=i386 -mtune=i386 STRIP = $(MINGW)strip RC = $(MINGW)windres -F pe-i386 MAKENSIS = makensis DRV_VER= $(shell cat VERSION) CFLAGS= -O2 -Wall -DNDEBUG=1 -DDRIVER_VER_INFO=\"$(DRV_VER)\" SQLITE_INC = sqlite SQLITE_LIB = sqlite/libsqlite.a SQLITE_FLAGS = -DHAVE_LIBVERSION=1 \ -DHAVE_ENCDEC=1 \ -DHAVE_SQLITEATOF=1 \ -DHAVE_SQLITEMPRINTF=1 \ -DHAVE_SQLITETRACE=1 SQLITE3_INC = sqlite3 SQLITE3_SRC = sqlite3/src SQLITE3_LIB = sqlite3/libsqlite3.a SQLITE3_FLAGS= -DHAVE_SQLITE3COLUMNTABLENAME=1 \ -DHAVE_SQLITE3LOADEXTENSION=1 \ -DHAVE_SQLITE3PREPAREV2=1 \ -DHAVE_SQLITE3VFS=1 \ -DHAVE_SQLITE3PROFILE=1 SQLITE3_A10N = sqlite3/sqlite3.c SQLITE3_A10N_FLAGS = \ -DWIN32=1 -DNDEBUG=1 -DNO_TCL -DTHREADSAFE=1 \ -DSQLITE_ENABLE_COLUMN_METADATA=1 \ -DSQLITE_DLL=1 \ -DSQLITE_THREADSAFE=1 \ -DSQLITE_OS_WIN=1 \ -DSQLITE_ASCII=1 \ -DSQLITE_SOUNDEX=1 \ -DSQLITE_OMIT_EXPLAIN=1 TCC_INC = TCC/libtcc TCC_LIB = TCC/libtcc/libtcc.a ODBC_FLAGS = -DHAVE_LONG_LONG=1 -DHAVE_SQLROWOFFSET=1 ODBC_LIB = -lodbc all: sqliteodbc.dll sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ sqlite.exe \ inst.exe instq.exe uninst.exe uninstq.exe \ adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe \ SQLiteODBCInstaller.exe $(SQLITE3_EXE) $(SQLITE_TCC_DLL) all_no2: sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ inst.exe instq.exe uninst.exe uninstq.exe \ adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe \ SQLiteODBCInstaller.exe $(SQLITE3_EXE) $(SQLITE_TCC_DLL) sqliteodbc.o: sqliteodbc.c sqliteodbc.h resource.h $(CC) $(CFLAGS) -mdll -c -I$(SQLITE_INC) $(ODBC_FLAGS) \ $(SQLITE_FLAGS) $(ADD_CFLAGS) sqliteodbc.c sqliteodbcu.o: sqliteodbc.c sqliteodbc.h resource.h $(CC) $(CFLAGS) -mdll -c -I$(SQLITE_INC) $(ODBC_FLAGS) \ $(SQLITE_FLAGS) $(ADD_CFLAGS) -o sqliteodbcu.o sqliteodbc.c sqliteodbc.dll: sqliteodbc.o sqliteodbcres.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqliteodbc.a -Wl,--strip-all \ -o sqliteodbc.dll \ sqliteodbc.o sqliteodbcres.o \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE_LIB) sqlite.exe: sqliteodbc.dll sqlite/src/minshell.c sqlite/sqlite.h \ sqliteres.o $(CC) $(CFLAGS) $(SQLITE_FLAGS) -Isqlite -o sqlite.exe \ sqlite/src/minshell.c sqliteres.o -L. -lsqliteodbc \ $(SQLITE_LIB) $(STRIP) sqlite.exe sqliteodbcu.dll: sqliteodbcu.o sqliteodbcures.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqliteodbcu.a -Wl,--strip-all \ -o sqliteodbcu.dll \ sqliteodbcu.o sqliteodbcures.o \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE_LIB) sqliteu.exe: sqliteodbcu.dll sqlite/src/minshell.c sqlite/sqlite.h \ sqliteres.o $(CC) $(CFLAGS) -Isqlite -o sqliteu.exe \ sqlite/src/minshell.c sqliteres.o -L. -lsqliteodbcu \ $(SQLITE_LIB) $(STRIP) sqliteu.exe sqliteodbcres.o: sqliteodbc.rc resource.h $(RC) -o sqliteodbcres.o -I$(SQLITE_INC) sqliteodbc.rc sqliteodbcures.o: sqliteodbc.rc resource.h $(RC) -o sqliteodbcures.o -I$(SQLITE_INC) sqliteodbc.rc resource.h: resource.h.in VERS=`cat VERSION` ;\ VERS_C=`echo $$VERS | sed -e 's/\([0-9]\+\)[.]\([0-9]\+\).*/\1,\2/g'` ;\ sed -e 's/--VERS_C--/'$$VERS_C'/g' < resource.h.in | \ sed -e 's/--VERS--/'$$VERS'/g' > resource.h sqlite3a10n.o: $(SQLITE3_A10N) $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(SQLITE3_A10N_FLAGS) \ $(ADD_CFLAGS) -o sqlite3a10n.o $(SQLITE3_A10N) sqlite3odbc.o: sqlite3odbc.c sqlite3odbc.h resource3.h $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(ODBC_FLAGS) \ $(SQLITE3_FLAGS) $(ADD_CFLAGS) sqlite3odbc.c sqlite3odbcnw.o: sqlite3odbc.c sqlite3odbc.h resource3.h $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(ODBC_FLAGS) \ $(SQLITE3_FLAGS) $(ADD_CFLAGS) -DWITHOUT_WINTERFACE=1 \ -o sqlite3odbcnw.o sqlite3odbc.c sqlite3odbc$(SEEEXT).dll: sqlite3odbc.o sqlite3odbcres.o $(SQLITE3_A10N_O) $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3odbc.a -Wl,--strip-all \ -o sqlite3odbc$(SEEEXT).dll \ sqlite3odbc.o sqlite3odbcres.o $(SQLITE3_A10N_O) \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE3_DLL) $(STRIP) sqlite3odbc$(SEEEXT).dll sqlite3odbc$(SEEEXT)nw.dll: sqlite3odbcnw.o sqlite3odbcres.o $(SQLITE3_A10N_O) $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3odbcnw.a -Wl,--strip-all \ -o sqlite3odbc$(SEEEXT)nw.dll \ sqlite3odbcnw.o sqlite3odbcres.o $(SQLITE3_A10N_O) \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE3_DLL) $(STRIP) sqlite3odbc$(SEEEXT)nw.dll sqlite3.exe: sqlite3odbc$(SEEEXT).dll sqlite3/src/minshell.c \ sqliteres.o $(CC) $(CFLAGS) $(SQLITE3_FLAGS) -Isqlite3 -o sqlite3.exe \ sqlite3/src/minshell.c sqliteres.o \ -L. -lsqlite3odbc$(SEEEXT) $(STRIP) sqlite3.exe sqlite3odbcres.o: sqlite3odbc.rc resource3.h $(RC) -o sqlite3odbcres.o -I$(SQLITE3_INC) sqlite3odbc.rc resource3.h: resource.h.in VERS=`cat VERSION` ;\ VERS_C=`echo $$VERS | sed -e 's/\([0-9]\+\)[.]\([0-9]\+\).*/\1,\2/g'` ;\ sed -e 's/--VERS_C--/'$$VERS_C'/g' < resource.h.in | \ sed -e 's/--VERS--/'$$VERS'/g' > resource3.h sqliteres.rc: @echo "ico ICON sqlite.ico" > sqliteres.rc sqliteres.o: sqliteres.rc $(RC) -o sqliteres.o sqliteres.rc instres.o: inst.rc $(RC) -o instres.o -I$(SQLITE3_INC) inst.rc inst.exe: inst.c instres.o $(CC) $(CFLAGS) $(ADD_CFLAGS) -mwindows -o inst.exe \ inst.c instres.o -lodbc32 -lodbccp32 -lkernel32 \ -luser32 $(STRIP) inst.exe instq.exe: inst.exe cp -p inst.exe instq.exe uninst.exe: inst.exe cp -p inst.exe uninst.exe uninstq.exe: inst.exe cp -p inst.exe uninstq.exe adddsnres.o: adddsn.rc $(RC) -o adddsnres.o -I$(SQLITE3_INC) adddsn.rc adddsn.exe: adddsn.c adddsnres.o $(CC) $(CFLAGS) $(ADD_CFLAGS) -mwindows -o adddsn.exe \ adddsn.c adddsnres.o -lodbc32 -lodbccp32 -lkernel32 \ -luser32 $(STRIP) adddsn.exe remdsn.exe: adddsn.exe cp -p adddsn.exe remdsn.exe addsysdsn.exe: adddsn.exe cp -p adddsn.exe addsysdsn.exe remsysdsn.exe: adddsn.exe cp -p adddsn.exe remsysdsn.exe SQLiteODBCInstaller.exe: SQLiteODBCInstaller.c sqliteres.o $(CC) $(CFLAGS) $(ADD_CFLAGS) -o SQLiteODBCInstaller.exe \ SQLiteODBCInstaller.c sqliteres.o -lkernel32 -luser32 $(STRIP) SQLiteODBCInstaller.exe blobtoxyres.o: blobtoxy.rc resource3.h $(RC) -o blobtoxyres.o -I$(SQLITE3_INC) blobtoxy.rc blobtoxy.o: blobtoxy.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ blobtoxy.c sqlite3_mod_blobtoxy.dll: blobtoxy.o blobtoxyres.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_blobtoxy.dll \ blobtoxy.o blobtoxyres.o impexp.o: impexp.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ impexp.c sqlite3_mod_impexp.dll: impexp.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_impexp.dll \ impexp.o -lcomdlg32 csvtable.o: csvtable.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ csvtable.c sqlite3_mod_csvtable.dll: csvtable.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_csvtable.dll \ csvtable.o zipfile.o: zipfile.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ -Izlib zipfile.c sqlite3_mod_zipfile.dll: zipfile.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_zipfile.dll \ zipfile.o -Lzlib -lz sqlite+tcc.o: sqlite+tcc.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ -I$(TCC_INC) sqlite+tcc.c sqlite+tcc.dll: sqlite+tcc.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite+tcc.dll \ sqlite+tcc.o $(TCC_LIB) clean: rm -f *.o sqliteodbc*.dll sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ sqlite+tcc.dll \ *inst.exe *dsn.exe sqlite*.exe sqliteres.rc *~ \ core core.* rm -f resource.h resource3.h ./sqliteodbc-0.992/Makefile.mingw64-cross0100644000076400001440000001736612064611440016624 0ustar chwusers# Makefile for SQLite3 ODBC Drivers # using MinGW WIN64 cross compiler MINGW = /opt/mingw64/bin/x86_64-w64-mingw32- CC = $(MINGW)gcc STRIP = $(MINGW)strip RC = $(MINGW)windres MAKENSIS = makensis DRV_VER= $(shell cat VERSION) CFLAGS= -O2 -Wall -DNDEBUG=1 -DDRIVER_VER_INFO=\"$(DRV_VER)\" SQLITE_INC = sqlite SQLITE_LIB = sqlite/libsqlite.a SQLITE_FLAGS = -DHAVE_LIBVERSION=1 \ -DHAVE_ENCDEC=1 \ -DHAVE_SQLITEATOF=1 \ -DHAVE_SQLITEMPRINTF=1 \ -DHAVE_SQLITETRACE=1 SQLITE3_INC = sqlite3 SQLITE3_SRC = sqlite3/src SQLITE3_LIB = sqlite3/libsqlite3.a SQLITE3_FLAGS= -DHAVE_SQLITE3COLUMNTABLENAME=1 \ -DHAVE_SQLITE3LOADEXTENSION=1 \ -DHAVE_SQLITE3PREPAREV2=1 \ -DHAVE_SQLITE3VFS=1 \ -DHAVE_SQLITE3PROFILE=1 SQLITE3_A10N = sqlite3/sqlite3.c SQLITE3_A10N_FLAGS = \ -DWIN32=1 -DNDEBUG=1 -DNO_TCL -DTHREADSAFE=1 \ -DSQLITE_ENABLE_COLUMN_METADATA=1 \ -DSQLITE_DLL=1 \ -DSQLITE_THREADSAFE=1 \ -DSQLITE_OS_WIN=1 \ -DSQLITE_ASCII=1 \ -DSQLITE_SOUNDEX=1 \ -DSQLITE_OMIT_SHARED_CACHE=1 \ -DSQLITE_OMIT_EXPLAIN=1 ODBC_FLAGS = -DHAVE_LONG_LONG=1 -DHAVE_SQLROWOFFSET=1 -DHAVE_SQLLEN=1 \ -DHAVE_SQLULEN=1 -DHAVE_SQLROWCOUNT=1 -DHAVE_SQLSETPOSIROW=1 \ -DPTRDIFF_T=ptrdiff_t ODBC_LIB = -lodbc all: sqliteodbc.dll sqlite.exe \ sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ inst.exe instq.exe uninst.exe uninstq.exe \ adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe $(SQLITE3_EXE) all_no2: sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ inst.exe instq.exe uninst.exe uninstq.exe \ adddsn.exe remdsn.exe \ addsysdsn.exe remsysdsn.exe $(SQLITE3_EXE) sqliteodbc.o: sqliteodbc.c sqliteodbc.h resource.h $(CC) $(CFLAGS) -mdll -c -I$(SQLITE_INC) $(ODBC_FLAGS) \ $(SQLITE_FLAGS) $(ADD_CFLAGS) sqliteodbc.c sqliteodbcu.o: sqliteodbc.c sqliteodbc.h resource.h $(CC) $(CFLAGS) -mdll -c -I$(SQLITE_INC) $(ODBC_FLAGS) \ $(SQLITE_FLAGS) $(ADD_CFLAGS) -o sqliteodbcu.o sqliteodbc.c sqliteodbc.dll: sqliteodbc.o sqliteodbcres.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqliteodbc.a -Wl,--strip-all \ -o sqliteodbc.dll \ sqliteodbc.o sqliteodbcres.o \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE_LIB) sqlite.exe: sqliteodbc.dll sqlite/src/minshell.c sqlite/sqlite.h \ sqliteres.o $(CC) $(CFLAGS) $(SQLITE_FLAGS) -o sqlite.exe \ sqlite/src/minshell.c sqliteres.o -L. -lsqliteodbc \ $(SQLITE_LIB) $(STRIP) sqlite.exe sqliteodbcu.dll: sqliteodbcu.o sqliteodbcures.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqliteodbcu.a -Wl,--strip-all \ -o sqliteodbcu.dll \ sqliteodbcu.o sqliteodbcures.o \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE_LIB) sqliteu.exe: sqliteodbc.dll sqlite/src/minshell.c sqlite/sqlite.h \ sqliteres.o $(CC) $(CFLAGS) $(SQLITE_FLAGS) -o sqliteu.exe \ sqlite/src/minshell.c sqliteres.o -L. -lsqliteodbcu \ $(SQLITE_LIB) $(STRIP) sqliteu.exe sqliteodbcres.o: sqliteodbc.rc resource.h $(RC) -o sqliteodbcres.o -I$(SQLITE_INC) sqliteodbc.rc sqliteodbcures.o: sqliteodbc.rc resource.h $(RC) -o sqliteodbcures.o -I$(SQLITE_INC) sqliteodbc.rc resource.h: resource.h.in VERS=`cat VERSION` ;\ VERS_C=`echo $$VERS | sed -e 's/\([0-9]\+\)[.]\([0-9]\+\).*/\1,\2/g'` ;\ sed -e 's/--VERS_C--/'$$VERS_C'/g' < resource.h.in | \ sed -e 's/--VERS--/'$$VERS'/g' > resource.h sqlite3a10n.o: $(SQLITE3_A10N) $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(SQLITE3_A10N_FLAGS) \ $(ADD_CFLAGS) -o sqlite3a10n.o $(SQLITE3_A10N) sqlite3odbc.o: sqlite3odbc.c sqlite3odbc.h resource3.h $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(ODBC_FLAGS) \ $(SQLITE3_FLAGS) $(ADD_CFLAGS) sqlite3odbc.c sqlite3odbcnw.o: sqlite3odbc.c sqlite3odbc.h resource3.h $(CC) $(CFLAGS) -c -I$(SQLITE3_INC) $(ODBC_FLAGS) \ $(SQLITE3_FLAGS) $(ADD_CFLAGS) -DWITHOUT_WINTERFACE=1 \ -o sqlite3odbcnw.o sqlite3odbc.c sqlite3odbc$(SEEEXT).dll: sqlite3odbc.o sqlite3odbcres.o \ $(SQLITE3_A10N_O) $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3odbc.a -Wl,--strip-all \ -o sqlite3odbc$(SEEEXT).dll \ sqlite3odbc.o sqlite3odbcres.o $(SQLITE3_A10N_O) \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE3_DLL) $(STRIP) sqlite3odbc$(SEEEXT).dll sqlite3odbc$(SEEEXT)nw.dll: sqlite3odbcnw.o sqlite3odbcres.o \ $(SQLITE3_A10N_O) $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3odbcnw.a -Wl,--strip-all \ -o sqlite3odbc$(SEEEXT)nw.dll \ sqlite3odbcnw.o sqlite3odbcres.o $(SQLITE3_A10N_O) \ -lodbc32 -lodbccp32 -lcomdlg32 \ -lkernel32 -luser32 -lmsvcrt $(SQLITE3_DLL) $(STRIP) sqlite3odbc$(SEEEXT)nw.dll sqlite3.exe: sqlite3odbc$(SEEEXT).dll sqlite3/src/minshell.c \ sqliteres.o $(CC) $(CFLAGS) $(SQLITE3_FLAGS) -Isqlite3 -o sqlite3.exe \ sqlite3/src/minshell.c sqliteres.o \ -L. -lsqlite3odbc$(SEEEXT) $(STRIP) sqlite3.exe sqlite3odbcres.o: sqlite3odbc.rc resource3.h $(RC) -o sqlite3odbcres.o -I$(SQLITE3_INC) sqlite3odbc.rc resource3.h: resource.h.in VERS=`cat VERSION` ;\ VERS_C=`echo $$VERS | sed -e 's/\([0-9]\+\)[.]\([0-9]\+\).*/\1,\2/g'` ;\ sed -e 's/--VERS_C--/'$$VERS_C'/g' < resource.h.in | \ sed -e 's/--VERS--/'$$VERS'/g' > resource3.h sqliteres.rc: @echo "ico ICON sqlite.ico" > sqliteres.rc sqliteres.o: sqliteres.rc $(RC) -o sqliteres.o sqliteres.rc instres.o: inst.rc $(RC) -o instres.o -I$(SQLITE3_INC) inst.rc inst.exe: inst.c instres.o $(CC) $(CFLAGS) $(ADD_CFLAGS) -mwindows -o inst.exe \ inst.c instres.o -lodbc32 -lodbccp32 -lkernel32 \ -luser32 $(STRIP) inst.exe instq.exe: inst.exe cp -p inst.exe instq.exe uninst.exe: inst.exe cp -p inst.exe uninst.exe uninstq.exe: inst.exe cp -p inst.exe uninstq.exe adddsnres.o: adddsn.rc $(RC) -o adddsnres.o -I$(SQLITE3_INC) adddsn.rc adddsn.exe: adddsn.c adddsnres.o $(CC) $(CFLAGS) $(ADD_CFLAGS) -mwindows -o adddsn.exe \ adddsn.c adddsnres.o -lodbc32 -lodbccp32 -lkernel32 \ -luser32 $(STRIP) adddsn.exe remdsn.exe: adddsn.exe cp -p adddsn.exe remdsn.exe addsysdsn.exe: adddsn.exe cp -p adddsn.exe addsysdsn.exe remsysdsn.exe: adddsn.exe cp -p adddsn.exe remsysdsn.exe blobtoxyres.o: blobtoxy.rc resource3.h $(RC) -o blobtoxyres.o -I$(SQLITE3_INC) blobtoxy.rc blobtoxy.o: blobtoxy.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ blobtoxy.c sqlite3_mod_blobtoxy.dll: blobtoxy.o blobtoxyres.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_blobtoxy.dll \ blobtoxy.o blobtoxyres.o impexp.o: impexp.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ impexp.c sqlite3_mod_impexp.dll: impexp.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_impexp.dll \ impexp.o -lcomdlg32 csvtable.o: csvtable.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ csvtable.c sqlite3_mod_csvtable.dll: csvtable.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_csvtable.dll \ csvtable.o zipfile.o: zipfile.c $(CC) $(CFLAGS) -mdll -c -I$(SQLITE3_INC) -I$(SQLITE3_SRC) \ -Izlib zipfile.c sqlite3_mod_zipfile.dll: zipfile.o $(CC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--strip-all -o sqlite3_mod_zipfile.dll \ zipfile.o -Lzlib -lz clean: rm -f *.o sqliteodbc*.dll sqlite3odbc$(SEEEXT).dll \ sqlite3_mod_blobtoxy.dll \ sqlite3_mod_impexp.dll \ sqlite3_mod_csvtable.dll \ sqlite3_mod_zipfile.dll \ *inst.exe *dsn.exe sqlite*.exe sqliteres.rc *~ \ core core.* rm -f resource.h resource3.h ./sqliteodbc-0.992/mf-sqlite.mingw-cross0100644000076400001440000000735512107272220016630 0ustar chwusers#!/usr/make # # Makefile for SQLITE, use in conjunction with mingw-cross-build.sh # since some patches are needed (libshell.c etc.) #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DTHREADSAFE=1 #THREADSAFE = -DTHREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1 # to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DMEMORY_DEBUG=2 #OPTS = -DMEMORY_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_SOUNDEX=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 -march=i386 -mtune=i386 \ -O2 -DNO_TCL -DNO_OLDNAMES -D_off_t="long long" -D_OFF_T_=1 #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Should the database engine assume text is coded as UTF-8 or iso8859? # # ENCODING = UTF8 ENCODING = ISO8859 #### Special libshell target LIBOBJ += libshell.o libshell.o: $(TOP)/src/libshell.c sqlite.h $(TCCX) -c $(TOP)/src/libshell.c # You should not have to change anything below this line ############################################################################### include $(TOP)/main.mk sqlite.dll: $(LIBOBJ) rm -f libsqlite.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite.a -Wl,--strip-all \ -o sqlite.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt sqliteu.dll: $(LIBOBJ) rm -f libsqlite.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite.a -Wl,--strip-all \ -o sqliteu.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt ./sqliteodbc-0.992/mf-sqlite.mingw64-cross0100644000076400001440000000731611737055571017017 0ustar chwusers#!/usr/make # # Makefile for SQLITE, use in conjunction with mingw-cross-build.sh # since some patches are needed (libshell.c etc.) #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DTHREADSAFE=1 #THREADSAFE = -DTHREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1 # to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DMEMORY_DEBUG=2 #OPTS = -DMEMORY_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_SOUNDEX=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -O2 -DNO_TCL \ -DNO_OLDNAMES -D_off_t="long long" -D_OFF_T_=1 #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Should the database engine assume text is coded as UTF-8 or iso8859? # # ENCODING = UTF8 ENCODING = ISO8859 #### Special libshell target LIBOBJ += libshell.o libshell.o: $(TOP)/src/libshell.c sqlite.h $(TCCX) -c $(TOP)/src/libshell.c # You should not have to change anything below this line ############################################################################### include $(TOP)/main.mk sqlite.dll: $(LIBOBJ) rm -f libsqlite.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite.a -Wl,--strip-all \ -o sqlite.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt sqliteu.dll: $(LIBOBJ) rm -f libsqlite.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite.a -Wl,--strip-all \ -o sqliteu.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt ./sqliteodbc-0.992/mf-sqlite3.mingw-cross0100644000076400001440000000740512107272231016711 0ustar chwusers#!/usr/make # # Makefile for SQLITE, use in conjunction with mingw-cross-build.sh # since some patches are needed (libshell.c etc.) #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = -lcomdlg32 #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SOUNDEX=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 -march=i386 -mtune=i386 \ -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk #### Special libshell target LIBOBJ += libshell.o libshell.o: $(TOP)/src/libshell.c sqlite3.h $(TCCX) -c $(TOP)/src/libshell.c SRC += $(TOP)/src/libshell.c # You should not have to change anything below this line ############################################################################### include $(TOP)/main.mk sqlite3.dll: $(LIBOBJ) rm -f libsqlite3.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3.a -Wl,--strip-all \ -o sqlite3.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt ./sqliteodbc-0.992/mf-sqlite3.mingw64-cross0100644000076400001440000000734211706776072017103 0ustar chwusers#!/usr/make # # Makefile for SQLITE, use in conjunction with mingw64-cross-build.sh # since some patches are needed (libshell.c etc.) #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = -lcomdlg32 #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SOUNDEX=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk #### Special libshell target LIBOBJ += libshell.o libshell.o: $(TOP)/src/libshell.c sqlite3.h $(TCCX) -c $(TOP)/src/libshell.c SRC += $(TOP)/src/libshell.c # You should not have to change anything below this line ############################################################################### include $(TOP)/main.mk sqlite3.dll: $(LIBOBJ) rm -f libsqlite3.a $(TCC) $(CFLAGS) -shared -Wl,--kill-at \ -Wl,--out-implib,libsqlite3.a -Wl,--strip-all \ -o sqlite3.dll $(LIBOBJ) \ -lcomdlg32 -lkernel32 -luser32 -lmsvcrt ./sqliteodbc-0.992/mf-sqlite3extfunc.mingw-cross0100644000076400001440000000205112107272242020300 0ustar chwusers#!/usr/make # # Makefile for SQLITE3 extension functions, use in conjunction with # mingw-cross-build.sh #### C Compile and options for use in building executables that # will run on the target platform. # TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 -march=i386 -mtune=i386 \ -O2 -DNO_TCL # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -Isqlite3 -Isqlite3/src # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # all: sqlite3_mod_extfunc.$(SO) # Rules to build individual files # extfunc.o: extfunc.c $(TCCX) -c extfunc.c sqlite3_mod_extfunc.$(SO): extfunc.o $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3extfunc.a -Wl,--strip-all \ -o sqlite3_mod_extfunc.$(SO) extfunc.o clean: rm -f extfunc.o libsqlite3extfunc.a sqlite3_mod_extfunc.$(SO) semiclean: rm -f extfunc.o libsqlite3extfunc.a ./sqliteodbc-0.992/mf-sqlite3extfunc.mingw64-cross0100644000076400001440000000200611706775456020475 0ustar chwusers#!/usr/make # # Makefile for SQLITE3 extension functions, use in conjunction with # mingw64-cross-build.sh #### C Compile and options for use in building executables that # will run on the target platform. # TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -O2 -DNO_TCL # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -Isqlite3 -Isqlite3/src # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # all: sqlite3_mod_extfunc.$(SO) # Rules to build individual files # extfunc.o: extfunc.c $(TCCX) -c extfunc.c sqlite3_mod_extfunc.$(SO): extfunc.o $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3extfunc.a -Wl,--strip-all \ -o sqlite3_mod_extfunc.$(SO) extfunc.o clean: rm -f extfunc.o libsqlite3extfunc.a sqlite3_mod_extfunc.$(SO) semiclean: rm -f extfunc.o libsqlite3extfunc.a ./sqliteodbc-0.992/mf-sqlite3fts.mingw-cross0100644000076400001440000001771512107272251017435 0ustar chwusers#!/usr/make # # Makefile for SQLITE FTS extensions, use in conjunction with # mingw-cross-build.sh #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_FTS3=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 -march=i386 -mtune=i386 \ -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll SHPREFIX = #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP) -I$(TOP)/src # Object files for FTS1 # FTS1OBJ+= fts1.o fts1_hash.o fts1_porter.o fts1_tokenizer1.o # Object files for FTS2 # FTS2OBJ+= fts2.o fts2_hash.o fts2_porter.o fts2_tokenizer1.o # Object files for FTS3 # FTS3OBJ+= fts3.o fts3_hash.o fts3_porter.o fts3_tokenizer.o fts3_tokenizer1.o \ fts3_expr.o fts3_icu.o fts3_snippet.o fts3_write.o fts3_aux.o # FTS1 source code files. # FTS1SRC += \ $(TOP)/ext/fts1/fts1.c \ $(TOP)/ext/fts1/fts1.h \ $(TOP)/ext/fts1/fts1_hash.c \ $(TOP)/ext/fts1/fts1_hash.h \ $(TOP)/ext/fts1/fts1_porter.c \ $(TOP)/ext/fts1/fts1_tokenizer.h \ $(TOP)/ext/fts1/fts1_tokenizer1.c # FTS2 source code files. # FTS2SRC += \ $(TOP)/ext/fts2/fts2.c \ $(TOP)/ext/fts2/fts2.h \ $(TOP)/ext/fts2/fts2_hash.c \ $(TOP)/ext/fts2/fts2_hash.h \ $(TOP)/ext/fts2/fts2_porter.c \ $(TOP)/ext/fts2/fts2_tokenizer.h \ $(TOP)/ext/fts2/fts2_tokenizer1.c # FTS3 source code files. # FTS3SRC += \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3_hash.c \ $(TOP)/ext/fts3/fts3_hash.h \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ $(TOP)/ext/fts3/fts3_expr.c \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_snippet.c \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/fts3/fts3_aux.c # Common headers HDR += $(TOP)/sqlite3.h \ $(TOP)/src/sqlite3ext.h # Header files used by FTS1 # FTS1HDR += \ $(TOP)/ext/fts1/fts1.h \ $(TOP)/ext/fts1/fts1_hash.h \ $(TOP)/ext/fts1/fts1_tokenizer.h # Header files used by FTS2 # FTS1HDR += \ $(TOP)/ext/fts2/fts2.h \ $(TOP)/ext/fts2/fts2_hash.h \ $(TOP)/ext/fts2/fts2_tokenizer.h # Header files used by FTS3 # FTS3HDR += \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3_hash.h \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3Int.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # # SQLite 3.4.* #all: sqlite3_mod_fts1.$(SO) sqlite3_mod_fts2.$(SO) # SQLite 3.5.* all: sqlite3_mod_fts3.$(SO) # Rules to build individual files # fts1.o: $(TOP)/ext/fts1/fts1.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1.c fts1_hash.o: $(TOP)/ext/fts1/fts1_hash.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_hash.c fts1_porter.o: $(TOP)/ext/fts1/fts1_porter.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_porter.c fts1_tokenizer1.o: $(TOP)/ext/fts1/fts1_tokenizer1.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_tokenizer1.c sqlite3_mod_fts1.$(SO): $(FTS1OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts1.a -Wl,--strip-all \ -o sqlite3_mod_fts1.$(SO) $(FTS1OBJ) fts2.o: $(TOP)/ext/fts2/fts2.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2.c fts2_hash.o: $(TOP)/ext/fts2/fts2_hash.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_hash.c fts2_porter.o: $(TOP)/ext/fts2/fts2_porter.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_porter.c fts2_tokenizer1.o: $(TOP)/ext/fts2/fts2_tokenizer1.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_tokenizer1.c sqlite3_mod_fts2.$(SO): $(FTS2OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts2.a -Wl,--strip-all \ -o sqlite3_mod_fts2.$(SO) $(FTS2OBJ) fts3.o: $(TOP)/ext/fts3/fts3.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3.c fts3_hash.o: $(TOP)/ext/fts3/fts3_hash.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_hash.c fts3_porter.o: $(TOP)/ext/fts2/fts2_porter.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_porter.c fts3_tokenizer.o: $(TOP)/ext/fts3/fts3_tokenizer.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_tokenizer.c fts3_tokenizer1.o: $(TOP)/ext/fts3/fts3_tokenizer1.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_tokenizer1.c fts3_expr.o: $(TOP)/ext/fts3/fts3_expr.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_expr.c fts3_icu.o: $(TOP)/ext/fts3/fts3_icu.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_icu.c fts3_write.o: $(TOP)/ext/fts3/fts3_write.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_write.c fts3_snippet.o: $(TOP)/ext/fts3/fts3_snippet.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_snippet.c fts3_aux.o: $(TOP)/ext/fts3/fts3_aux.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_aux.c sqlite3_mod_fts3.$(SO): $(FTS3OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts3.a -Wl,--strip-all \ -o sqlite3_mod_fts3.$(SO) $(FTS3OBJ) clean: rm -f $(FTS1OBJ) libsqlite3fts1.a sqlite3_mod_fts1.$(SO) rm -f $(FTS2OBJ) libsqlite3fts2.a sqlite3_mod_fts2.$(SO) rm -f $(FTS3OBJ) libsqlite3fts3.a sqlite3_mod_fts3.$(SO) ./sqliteodbc-0.992/mf-sqlite3fts.mingw64-cross0100644000076400001440000001765211706775655017633 0ustar chwusers#!/usr/make # # Makefile for SQLITE FTS extensions, use in conjunction with # mingw64-cross-build.sh #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_FTS3=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll SHPREFIX = #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP) -I$(TOP)/src # Object files for FTS1 # FTS1OBJ+= fts1.o fts1_hash.o fts1_porter.o fts1_tokenizer1.o # Object files for FTS2 # FTS2OBJ+= fts2.o fts2_hash.o fts2_porter.o fts2_tokenizer1.o # Object files for FTS3 # FTS3OBJ+= fts3.o fts3_hash.o fts3_porter.o fts3_tokenizer.o fts3_tokenizer1.o \ fts3_expr.o fts3_icu.o fts3_snippet.o fts3_write.o fts3_aux.o # FTS1 source code files. # FTS1SRC += \ $(TOP)/ext/fts1/fts1.c \ $(TOP)/ext/fts1/fts1.h \ $(TOP)/ext/fts1/fts1_hash.c \ $(TOP)/ext/fts1/fts1_hash.h \ $(TOP)/ext/fts1/fts1_porter.c \ $(TOP)/ext/fts1/fts1_tokenizer.h \ $(TOP)/ext/fts1/fts1_tokenizer1.c # FTS2 source code files. # FTS2SRC += \ $(TOP)/ext/fts2/fts2.c \ $(TOP)/ext/fts2/fts2.h \ $(TOP)/ext/fts2/fts2_hash.c \ $(TOP)/ext/fts2/fts2_hash.h \ $(TOP)/ext/fts2/fts2_porter.c \ $(TOP)/ext/fts2/fts2_tokenizer.h \ $(TOP)/ext/fts2/fts2_tokenizer1.c # FTS3 source code files. # FTS3SRC += \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3_hash.c \ $(TOP)/ext/fts3/fts3_hash.h \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ $(TOP)/ext/fts3/fts3_expr.c \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_snippet.c \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/fts3/fts3_aux.c # Common headers HDR += $(TOP)/sqlite3.h \ $(TOP)/src/sqlite3ext.h # Header files used by FTS1 # FTS1HDR += \ $(TOP)/ext/fts1/fts1.h \ $(TOP)/ext/fts1/fts1_hash.h \ $(TOP)/ext/fts1/fts1_tokenizer.h # Header files used by FTS2 # FTS1HDR += \ $(TOP)/ext/fts2/fts2.h \ $(TOP)/ext/fts2/fts2_hash.h \ $(TOP)/ext/fts2/fts2_tokenizer.h # Header files used by FTS3 # FTS3HDR += \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3_hash.h \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3Int.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # # SQLite 3.4.* #all: sqlite3_mod_fts1.$(SO) sqlite3_mod_fts2.$(SO) # SQLite 3.5.* all: sqlite3_mod_fts3.$(SO) # Rules to build individual files # fts1.o: $(TOP)/ext/fts1/fts1.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1.c fts1_hash.o: $(TOP)/ext/fts1/fts1_hash.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_hash.c fts1_porter.o: $(TOP)/ext/fts1/fts1_porter.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_porter.c fts1_tokenizer1.o: $(TOP)/ext/fts1/fts1_tokenizer1.c $(FTS1HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts1/fts1_tokenizer1.c sqlite3_mod_fts1.$(SO): $(FTS1OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts1.a -Wl,--strip-all \ -o sqlite3_mod_fts1.$(SO) $(FTS1OBJ) fts2.o: $(TOP)/ext/fts2/fts2.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2.c fts2_hash.o: $(TOP)/ext/fts2/fts2_hash.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_hash.c fts2_porter.o: $(TOP)/ext/fts2/fts2_porter.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_porter.c fts2_tokenizer1.o: $(TOP)/ext/fts2/fts2_tokenizer1.c $(FTS2HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts2/fts2_tokenizer1.c sqlite3_mod_fts2.$(SO): $(FTS2OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts2.a -Wl,--strip-all \ -o sqlite3_mod_fts2.$(SO) $(FTS2OBJ) fts3.o: $(TOP)/ext/fts3/fts3.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3.c fts3_hash.o: $(TOP)/ext/fts3/fts3_hash.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_hash.c fts3_porter.o: $(TOP)/ext/fts2/fts2_porter.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_porter.c fts3_tokenizer.o: $(TOP)/ext/fts3/fts3_tokenizer.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_tokenizer.c fts3_tokenizer1.o: $(TOP)/ext/fts3/fts3_tokenizer1.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_tokenizer1.c fts3_expr.o: $(TOP)/ext/fts3/fts3_expr.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_expr.c fts3_icu.o: $(TOP)/ext/fts3/fts3_icu.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_icu.c fts3_write.o: $(TOP)/ext/fts3/fts3_write.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_write.c fts3_snippet.o: $(TOP)/ext/fts3/fts3_snippet.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_snippet.c fts3_aux.o: $(TOP)/ext/fts3/fts3_aux.c $(FTS3HDR) $(HDR) $(TCCX) -c $(TOP)/ext/fts3/fts3_aux.c sqlite3_mod_fts3.$(SO): $(FTS3OBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3fts3.a -Wl,--strip-all \ -o sqlite3_mod_fts3.$(SO) $(FTS3OBJ) clean: rm -f $(FTS1OBJ) libsqlite3fts1.a sqlite3_mod_fts1.$(SO) rm -f $(FTS2OBJ) libsqlite3fts2.a sqlite3_mod_fts2.$(SO) rm -f $(FTS3OBJ) libsqlite3fts3.a sqlite3_mod_fts3.$(SO) ./sqliteodbc-0.992/mf-sqlite3rtree.mingw-cross0100644000076400001440000001034412107272261017752 0ustar chwusers#!/usr/make # # Makefile for SQLITE rtree extensions, use in conjunction with # mingw-cross-build.sh #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_RTREE=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 -march=i386 -mtune=i386 \ -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll SHPREFIX = #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP) -I$(TOP)/src # Object files for rtree # RTREEOBJ+= rtree.o # rtree source code files. # RTREESRC += \ $(TOP)/ext/rtree/rtree.h \ $(TOP)/ext/rtree/rtree.c # Common headers HDR += $(TOP)/sqlite3.h \ $(TOP)/src/sqlite3ext.h # Header files used by rtree # RTREEHDR += \ $(TOP)/ext/rtree/rtree.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # all: sqlite3_mod_rtree.$(SO) # Rules to build individual files # sqlite3_mod_rtree.$(SO): $(RTREEOBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3rtree.a -Wl,--strip-all \ -o sqlite3_mod_rtree.$(SO) $(RTREEOBJ) rtree.o: $(TOP)/ext/rtree/rtree.c $(RTREEHDR) $(HDR) $(TCCX) -c $(TOP)/ext/rtree/rtree.c clean: rm -f $(RTREEOBJ) libsqlite3rtree.a sqlite3_mod_rtree.$(SO) ./sqliteodbc-0.992/mf-sqlite3rtree.mingw64-cross0100644000076400001440000001030111706776252020132 0ustar chwusers#!/usr/make # # Makefile for SQLITE rtree extensions, use in conjunction with # mingw64-cross-build.sh #### The toplevel directory of the source tree. This is the directory # that contains this "Makefile.in" and the "configure.in" script. # TOP = ../sqlite3 #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system # call, then define the HAVE_USLEEP macro for all C modules. # USLEEP = #USLEEP = -DHAVE_USLEEP=1 #### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro # appropriately: # THREADSAFE = -DSQLITE_THREADSAFE=1 #THREADSAFE = -DSQLITE_THREADSAFE=0 #### Specify any extra linker options needed to make the library # thread safe # #THREADLIB = -lpthread THREADLIB = #### Specify any extra libraries needed to access required functions. # #TLIBS = -lrt # fdatasync on Solaris 8 TLIBS = #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all # malloc()s and free()s in order to track down memory leaks. # # SQLite uses some expensive assert() statements in the inner loop. # You can make the library go almost twice as fast if you compile # with -DNDEBUG=1 # #OPTS = -DSQLITE_DEBUG=2 #OPTS = -DSQLITE_DEBUG=1 #OPTS = OPTS = -DNDEBUG=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_RTREE=1 \ -DSQLITE_ENABLE_MEMSYS5=1 \ -DWIN32=1 -DSQLITE_OS_WIN=1 $(THREADSAFE) #OPTS += -DHAVE_FDATASYNC=1 #### The suffix to add to executable files. ".exe" for windows. # Nothing for unix. # EXE = .exe #EXE = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -O2 -DNO_TCL #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. # #AR = ar cr AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar cr #RANLIB = ranlib RANLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ranlib # MKSHLIB = gcc -shared # SO = so # SHPREFIX = lib MKSHLIB = /opt/mingw64/bin/x86_64-w64-mingw32-ar -shared SO = dll SHPREFIX = #### Extra compiler options needed for programs that use the TCL library. # TCL_FLAGS = #TCL_FLAGS = -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.4linux #TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux #### Linker options needed to link against the TCL library. # LIBTCL = #LIBTCL = -ltcl -lm -ldl #LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl #LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc #### Compiler options needed for programs that use the readline() library. # READLINE_FLAGS = #READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline #### Linker options needed by programs using readline() must link against. # LIBREADLINE = #LIBREADLINE = -static -lreadline -ltermcap #### Which "awk" program provides nawk compatibilty # # NAWK = nawk NAWK = awk # This is how we compile # TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP) -I$(TOP)/src # Object files for rtree # RTREEOBJ+= rtree.o # rtree source code files. # RTREESRC += \ $(TOP)/ext/rtree/rtree.h \ $(TOP)/ext/rtree/rtree.c # Common headers HDR += $(TOP)/sqlite3.h \ $(TOP)/src/sqlite3ext.h # Header files used by rtree # RTREEHDR += \ $(TOP)/ext/rtree/rtree.h # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # all: sqlite3_mod_rtree.$(SO) # Rules to build individual files # sqlite3_mod_rtree.$(SO): $(RTREEOBJ) $(TCCX) -shared -Wl,--kill-at \ -Wl,-out-implib,libsqlite3rtree.a -Wl,--strip-all \ -o sqlite3_mod_rtree.$(SO) $(RTREEOBJ) rtree.o: $(TOP)/ext/rtree/rtree.c $(RTREEHDR) $(HDR) $(TCCX) -c $(TOP)/ext/rtree/rtree.c clean: rm -f $(RTREEOBJ) libsqlite3rtree.a sqlite3_mod_rtree.$(SO) ./sqliteodbc-0.992/mf-zlib.mingw-cross0100644000076400001440000000212512107272270016262 0ustar chwusersSTATICLIB = libz.a CC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc -m32 CFLAGS = -march=i386 -mtune=i386 -O2 LD = $(CC) LDFLAGS = AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar ARFLAGS = rcs OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o \ zutil.o all: $(STATICLIB) .c.o: $(CC) $(CFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) clean: -$(RM) $(STATICLIB) -$(RM) *.o adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h gzclose.o: zlib.h zconf.h gzguts.h gzlib.o: zlib.h zconf.h gzguts.h gzread.o: zlib.h zconf.h gzguts.h gzwrite.o: zlib.h zconf.h gzguts.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h ./sqliteodbc-0.992/mf-zlib.mingw64-cross0100644000076400001440000000207012025431663016435 0ustar chwusersSTATICLIB = libz.a CC = /opt/mingw64/bin/x86_64-w64-mingw32-gcc CFLAGS = -O2 LD = $(CC) LDFLAGS = AR = /opt/mingw64/bin/x86_64-w64-mingw32-ar ARFLAGS = rcs OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o \ zutil.o all: $(STATICLIB) .c.o: $(CC) $(CFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) clean: -$(RM) $(STATICLIB) -$(RM) *.o adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h gzclose.o: zlib.h zconf.h gzguts.h gzlib.o: zlib.h zconf.h gzguts.h gzread.o: zlib.h zconf.h gzguts.h gzwrite.o: zlib.h zconf.h gzguts.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h ./sqliteodbc-0.992/mingw-cross-build.sh0100755000076400001440000015362712125472517016460 0ustar chwusers#!/bin/sh # # Build script for cross compiling and packaging SQLite # ODBC drivers and tools for Win32 using MinGW and NSIS. # Tested on Fedora Core 3/5/8, Debian Etch, RHEL 5/6 # # Cross toolchain and NSIS for Linux/i386/x86_64 can be fetched from # http://www.ch-werner.de/xtools/crossmingw64-0.3-1.i386.rpm # http://www.ch-werner.de/xtools/crossmingw64-0.3-1.x86_64.rpm # http://www.ch-werner.de/xtools/nsis-2.37-1.i386.rpm # or # http://www.ch-werner.de/xtools/crossmingw64-0.3.i386.tar.bz2 # http://www.ch-werner.de/xtools/crossmingw64-0.3.x86_64.tar.bz2 # http://www.ch-werner.de/xtools/nsis-2.37-1_i386.tar.gz # Some aspects of the build process can be controlled by shell variables: # # NO_SQLITE2=1 omit building SQLite 2 and drivers for it # NO_TCCEXT=1 omit building TCC extension # WITH_SOURCES=1 add source directory to NSIS installer # SQLITE_DLLS=1 build and package drivers with SQLite 2/3 DLLs # SQLITE_DLLS=2 build drivers with refs to SQLite 2/3 DLLs # SQLite3 driver can use System.Data.SQlite.dll set -e VER2=2.8.17 VER3=3.7.16.1 VER3X=3071601 VERZ=1.2.7 TCCVER=0.9.25 nov2=false if test -n "$NO_SQLITE2" ; then nov2=true ADD_NSIS="-DWITHOUT_SQLITE2" fi notcc=false if test -n "$NO_TCCEXT" ; then notcc=true ADD_NSIS="$ADD_NSIS -DWITHOUT_TCCEXT" else export SQLITE_TCC_DLL="sqlite+tcc.dll" fi if test -f "$WITH_SEE" ; then export SEEEXT=see ADD_NSIS="$ADD_NSIS -DWITH_SEE=$SEEEXT" if test "$SQLITE_DLLS" = "2" ; then SQLITE_DLLS=1 fi fi if test "$SQLITE_DLLS" = "2" ; then # turn on -DSQLITE_DYNLOAD in sqlite3odbc.c export ADD_CFLAGS="-DWITHOUT_SHELL=1 -DWITH_SQLITE_DLLS=2" ADD_NSIS="$ADD_NSIS -DWITHOUT_SQLITE3_EXE" elif test -n "$SQLITE_DLLS" ; then export ADD_CFLAGS="-DWITHOUT_SHELL=1 -DWITH_SQLITE_DLLS=1" export SQLITE3_DLL="-Lsqlite3 -lsqlite3" export SQLITE3_EXE="sqlite3.exe" ADD_NSIS="$ADD_NSIS -DWITH_SQLITE_DLLS" else export SQLITE3_A10N_O="sqlite3a10n.o" export SQLITE3_EXE="sqlite3.exe" fi if test -n "$WITH_SOURCES" ; then ADD_NSIS="$ADD_NSIS -DWITH_SOURCES" fi echo "==================" echo "Preparing zlib ..." echo "==================" test -r zlib-${VERZ}.tar.gz || \ wget -c http://zlib.net/zlib-${VERZ}.tar.gz || exit 1 rm -rf zlib-${VERZ} tar xzf zlib-${VERZ}.tar.gz ln -sf zlib-${VERZ} zlib echo "====================" echo "Preparing sqlite ..." echo "====================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || test -r sqlite-${VER2}.tar.gz || \ wget -c http://www.sqlite.org/sqlite-${VER2}.tar.gz $nov2 || test -r sqlite-${VER2}.tar.gz || exit 1 $nov2 || rm -f sqlite $nov2 || tar xzf sqlite-${VER2}.tar.gz $nov2 || ln -sf sqlite-${VER2} sqlite # enable sqlite_encode_binary et.al. $nov2 || patch sqlite/main.mk <<'EOD' --- sqlite.orig/main.mk 2005-04-24 00:43:23.000000000 +0200 +++ sqlite/main.mk 2006-03-16 14:29:55.000000000 +0100 @@ -55,7 +55,7 @@ # Object files for the SQLite library. # LIBOBJ = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \ - expr.o func.o hash.o insert.o \ + expr.o func.o hash.o insert.o encode.o \ main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \ select.o table.o tokenize.o trigger.o update.o util.o \ vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o EOD # display encoding $nov2 || patch sqlite/src/shell.c <<'EOD' --- sqlite.orig/src/shell.c 2005-04-24 00:43:22.000000000 +0200 +++ sqlite/src/shell.c 2006-05-23 08:22:01.000000000 +0200 @@ -1180,6 +1180,7 @@ " -separator 'x' set output field separator (|)\n" " -nullvalue 'text' set text string for NULL values\n" " -version show SQLite version\n" + " -encoding show SQLite encoding\n" " -help show this text, also show dot-commands\n" ; static void usage(int showDetail){ @@ -1297,7 +1298,10 @@ }else if( strcmp(z,"-echo")==0 ){ data.echoOn = 1; }else if( strcmp(z,"-version")==0 ){ - printf("%s\n", sqlite_version); + printf("%s\n", sqlite_libversion()); + return 1; + }else if( strcmp(z,"-encoding")==0 ){ + printf("%s\n", sqlite_libencoding()); return 1; }else if( strcmp(z,"-help")==0 ){ usage(1); @@ -1330,9 +1334,9 @@ char *zHome; char *zHistory = 0; printf( - "SQLite version %s\n" + "SQLite version %s encoding %s\n" "Enter \".help\" for instructions\n", - sqlite_version + sqlite_libversion(), sqlite_libencoding() ); zHome = find_home_dir(); if( zHome && (zHistory = malloc(strlen(zHome)+20))!=0 ){ EOD # use open file dialog when no database name given # need to link with -lcomdlg32 when enabled true || patch sqlite/src/shell.c <<'EOD' --- sqlite.orig/src/shell.c 2006-07-23 11:18:13.000000000 +0200 +++ sqlite/src/shell.c 2006-07-23 11:30:26.000000000 +0200 @@ -20,6 +20,10 @@ #include "sqlite.h" #include +#if defined(_WIN32) && defined(DRIVER_VER_INFO) +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) # include # include @@ -1246,6 +1250,17 @@ if( i +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) # include # include @@ -1205,7 +1209,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1246,6 +1250,17 @@ if( i #include +#if defined(_WIN32) && defined(DRIVER_VER_INFO) +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) # include # include @@ -1676,6 +1676,17 @@ if( inRef++; } int sqlite3_mutex_try(sqlite3_mutex *p){ + /* The TryEnterCriticalSection() interface is not available on all + ** windows systems. Since sqlite3_mutex_try() is only used as an + ** optimization, we can skip it on windows. */ + return SQLITE_BUSY; + +#if 0 /* Not Available */ int rc; assert( p ); assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) ); @@ -152,6 +158,7 @@ rc = SQLITE_BUSY; } return rc; +#endif } /* EOD # same but new module libshell.c cp -p sqlite3/src/shell.c sqlite3/src/libshell.c test "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch sqlite3/src/libshell.c <<'EOD' --- sqlite3.orig/src/libshell.c 2007-01-08 23:40:05.000000000 +0100 +++ sqlite3/src/libshell.c 2007-01-10 18:35:43.000000000 +0100 @@ -21,6 +21,10 @@ #include #include +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) # include # include @@ -1774,7 +1778,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1816,6 +1820,17 @@ if( i #include +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) # include # include @@ -1774,7 +1778,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1816,6 +1820,17 @@ if( i #include +#ifdef _WIN32 +#include +#endif + #if !defined(_WIN32) && !defined(WIN32) # include # if !defined(__RTP__) && !defined(_WRS_KERNEL) @@ -2894,7 +2898,7 @@ return argv[i]; } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -2996,6 +3000,17 @@ } } if( data.zDbFilename==0 ){ +#if defined(_WIN32) && !defined(__TINYC__) + static OPENFILENAME ofn; + static char zDbFn[1024]; + ofn.lStructSize = sizeof(ofn); + ofn.lpstrFile = (LPTSTR) zDbFn; + ofn.nMaxFile = sizeof(zDbFn); + ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR; + if( GetOpenFileName(&ofn) ){ + data.zDbFilename = zDbFn; + } else +#endif #ifndef SQLITE_OMIT_MEMORYDB data.zDbFilename = ":memory:"; #else EOD rm -f sqlite3/src/minshell.c touch sqlite3/src/minshell.c patch sqlite3/src/minshell.c <<'EOD' --- sqlite3.orig/src/minshell.c 2007-01-10 18:46:47.000000000 +0100 +++ sqlite3/src/minshell.c 2007-01-10 18:46:47.000000000 +0100 @@ -0,0 +1,20 @@ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement the "sqlite" command line +** utility for accessing SQLite databases. +*/ + +int sqlite3_main(int argc, char **argv); + +int main(int argc, char **argv){ + return sqlite3_main(argc, argv); +} EOD # amalgamation: add libshell.c test "$VER3" != "3.5.6" && test -r sqlite3/tool/mksqlite3c.tcl && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/tool/mksqlite3c.tcl 2007-04-02 14:20:10.000000000 +0200 +++ sqlite3/tool/mksqlite3c.tcl 2007-04-03 09:42:03.000000000 +0200 @@ -194,6 +194,7 @@ where.c parse.c + libshell.c tokenize.c complete.c EOD test "$VER3" = "3.5.6" && test -r sqlite3/tool/mksqlite3c.tcl && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/tool/mksqlite3c.tcl 2007-04-02 14:20:10.000000000 +0200 +++ sqlite3/tool/mksqlite3c.tcl 2007-04-03 09:42:03.000000000 +0200 @@ -200,6 +200,7 @@ main.c + libshell.c fts3.c fts3_hash.c fts3_porter.c EOD # patch: parse foreign key constraints on virtual tables test "$VER3" != "3.6.15" -a "$VER3" != "3.6.16" -a "$VER3" != "3.6.17" \ -a "$VER3" != "3.6.18" -a "$VER3" != "3.6.19" -a "$VER3" != "3.6.20" \ -a "$VER3" != "3.6.21" -a "$VER3" != "3.6.22" -a "$VER3" != "3.6.23" \ -a "$VER3" != "3.6.23.1" -a "$VER3" != "3.7.0" -a "$VER3" != "3.7.0.1" \ -a "$VER3" != "3.7.1" -a "$VER3" != "3.7.2" -a "$VER3" != "3.7.3" \ -a "$VER3" != "3.7.4" -a "$VER3" != "3.7.5" -a "$VER3" != "3.7.6" \ -a "$VER3" != "3.7.6.1" -a "$VER3" != "3.7.6.2" -a "$VER3" != "3.7.6.3" \ -a "$VER3" != "3.7.7" -a "$VER3" != "3.7.7.1" -a "$VER3" != "3.7.8" \ -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" -a "$VER3" != "3.7.11" \ -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" -a "$VER3" != "3.7.13" \ -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" \ -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' diff -u sqlite3.orig/src/build.c sqlite3/src/build.c --- sqlite3.orig/src/build.c 2007-01-09 14:53:04.000000000 +0100 +++ sqlite3/src/build.c 2007-01-30 08:14:41.000000000 +0100 @@ -2063,7 +2063,7 @@ char *z; assert( pTo!=0 ); - if( p==0 || pParse->nErr || IN_DECLARE_VTAB ) goto fk_end; + if( p==0 || pParse->nErr ) goto fk_end; if( pFromCol==0 ){ int iCol = p->nCol-1; if( iCol<0 ) goto fk_end; diff -u sqlite3.orig/src/pragma.c sqlite3/src/pragma.c --- sqlite3.orig/src/pragma.c 2007-01-27 03:24:56.000000000 +0100 +++ sqlite3/src/pragma.c 2007-01-30 09:19:30.000000000 +0100 @@ -589,6 +589,9 @@ pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); +#ifndef SQLITE_OMIT_VIRTUAL_TABLE + if( pTab->pVtab ) sqlite3ViewGetColumnNames(pParse, pTab); +#endif pFK = pTab->pFKey; if( pFK ){ int i = 0; diff -u sqlite3.orig/src/vtab.c sqlite3/src/vtab.c --- sqlite3.orig/src/vtab.c 2007-01-09 15:01:14.000000000 +0100 +++ sqlite3/src/vtab.c 2007-01-30 08:23:22.000000000 +0100 @@ -540,6 +540,9 @@ int rc = SQLITE_OK; Table *pTab = db->pVTab; char *zErr = 0; +#ifndef SQLITE_OMIT_FOREIGN_KEYS + FKey *pFKey; +#endif sqlite3_mutex_enter(db->mutex); pTab = db->pVTab; @@ -568,6 +571,15 @@ } sParse.declareVtab = 0; +#ifndef SQLITE_OMIT_FOREIGN_KEYS + assert( pTab->pFKey==0 ); + pTab->pFKey = sParse.pNewTable->pFKey; + sParse.pNewTable->pFKey = 0; + for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ + pFKey->pFrom=pTab; + } +#endif + if( sParse.pVdbe ){ sqlite3VdbeFinalize(sParse.pVdbe); } EOD # patch: re-enable NO_TCL in tclsqlite.c (3.3.15) patch -d sqlite3 -p1 <<'EOD' diff -u sqlite3.orig/src/tclsqlite.c sqlite3/src/tclsqlite.c --- sqlite3.orig/src/tclsqlite.c 2007-04-06 17:02:14.000000000 +0200 +++ sqlite3/src/tclsqlite.c 2007-04-10 07:47:49.000000000 +0200 @@ -14,6 +14,7 @@ ** ** $Id: mingw-cross-build.sh,v 1.76 2013/03/30 05:16:56 chw Exp chw $ */ +#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "tcl.h" /* @@ -2264,3 +2265,5 @@ return 0; } #endif /* TCLSH */ + +#endif /* !defined(NO_TCL) */ EOD # patch: Win32 locking and pager unlock, for SQLite3 < 3.4.0 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2007-04-11 19:52:04.000000000 +0200 +++ sqlite3/src/os_win.c 2007-05-08 06:57:06.000000000 +0200 @@ -1237,8 +1237,8 @@ ** the PENDING_LOCK byte is temporary. */ newLocktype = pFile->locktype; - if( pFile->locktype==NO_LOCK - || (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK) + if( locktype==SHARED_LOCK + || (locktype==EXCLUSIVE_LOCK && pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -1289,6 +1289,18 @@ newLocktype = EXCLUSIVE_LOCK; }else{ OSTRACE2("error-code = %d\n", GetLastError()); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -1362,6 +1374,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: Win32 locking and pager unlock, for SQLite3 >= 3.5.4 && <= 3.6.10 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2007-12-13 22:38:58.000000000 +0100 +++ sqlite3/src/os_win.c 2008-01-18 10:01:48.000000000 +0100 @@ -855,8 +855,8 @@ ** the PENDING_LOCK byte is temporary. */ newLocktype = pFile->locktype; - if( pFile->locktype==NO_LOCK - || (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK) + if( locktype==SHARED_LOCK + || (locktype==EXCLUSIVE_LOCK && pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -907,7 +907,18 @@ newLocktype = EXCLUSIVE_LOCK; }else{ OSTRACE2("error-code = %d\n", GetLastError()); - getReadLock(pFile); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -982,6 +993,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: Win32 locking and pager unlock, for SQLite3 >= 3.6.11 && < 3.7.0 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2009-02-15 14:07:09.000000000 +0100 +++ sqlite3/src/os_win.c 2009-02-20 16:39:48.000000000 +0100 @@ -922,7 +922,7 @@ newLocktype = pFile->locktype; if( (pFile->locktype==NO_LOCK) || ( (locktype==EXCLUSIVE_LOCK) - && (pFile->locktype==RESERVED_LOCK)) + && (pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -981,7 +981,18 @@ }else{ error = GetLastError(); OSTRACE2("error-code = %d\n", error); - getReadLock(pFile); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -1057,6 +1068,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: compile fix for FTS3 as extension module test "$VER3" != "3.6.21" -a "$VER3" != "3.6.22" -a "$VER3" != "3.6.23" \ -a "$VER3" != "3.6.23.1" -a "$VER3" != "3.7.0" -a "$VER3" != "3.7.0.1" \ -a "$VER3" != "3.7.1" -a "$VER3" != "3.7.2" -a "$VER3" != "3.7.3" \ -a "$VER3" != "3.7.4" -a "$VER3" != "3.7.5" -a "$VER3" != "3.7.6" \ -a "$VER3" != "3.7.6.1" -a "$VER3" != "3.7.6.2" -a "$VER3" != "3.7.6.3" \ -a "$VER3" != "3.7.7" -a "$VER3" != "3.7.7.1" -a "$VER3" != "3.7.8" \ -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" -a "$VER3" != "3.7.11" \ -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" -a "$VER3" != "3.7.13" \ -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" \ -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2008-02-02 17:24:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2008-03-16 11:29:02.000000000 +0100 @@ -274,10 +274,6 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -6389,7 +6385,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD test "$VER3" = "3.6.21" -o "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" \ -o "$VER3" = "3.6.23.1" -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2008-02-02 17:24:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2008-03-16 11:29:02.000000000 +0100 @@ -274,10 +274,6 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include "fts3Int.h" #include @@ -6389,7 +6385,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_porter.c 2008-02-01 16:40:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3_porter.c 2008-03-16 11:34:50.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" /* --- sqlite3.orig/ext/fts3/fts3_tokenizer1.c 2007-11-23 18:31:18.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer1.c 2008-03-16 11:35:37.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" typedef struct simple_tokenizer { EOD test "$VER3" != "3.7.8" -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" \ -a "$VER3" != "3.7.11" -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" \ -a "$VER3" != "3.7.13" -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" \ -a "$VER3" != "3.7.15" -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" \ -a "$VER3" != "3.7.16" -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_hash.c 2007-11-24 01:41:52.000000000 +0100 +++ sqlite3/ext/fts3/fts3_hash.c 2008-03-16 11:39:57.000000000 +0100 @@ -29,6 +29,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "sqlite3.h" #include "fts3_hash.h" EOD test "$VER3" = "3.6.21" && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2009-12-03 20:39:06.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-01-05 07:59:27.000000000 +0100 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include EOD test "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" -o "$VER3" = "3.6.23.1" \ -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2010-01-05 09:42:19.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-01-05 09:55:25.000000000 +0100 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include @@ -2226,7 +2230,7 @@ if( !zVal ){ return SQLITE_NOMEM; - }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ + }else if( nVal==8 && 0==strnicmp(zVal, "optimize", 8) ){ rc = fts3SegmentMerge(p, -1); if( rc==SQLITE_DONE ){ rc = SQLITE_OK; @@ -2234,10 +2238,10 @@ sqlite3Fts3PendingTermsClear(p); } #ifdef SQLITE_TEST - }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ + }else if( nVal>9 && 0==strnicmp(zVal, "nodesize=", 9) ){ p->nNodeSize = atoi(&zVal[9]); rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ + }else if( nVal>11 && 0==strnicmp(zVal, "maxpending=", 9) ){ p->nMaxPendingData = atoi(&zVal[11]); rc = SQLITE_OK; #endif EOD test "$VER3" = "3.7.6" -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" \ -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2011-04-12 11:44:56.000000000 +0200 +++ sqlite3/ext/fts3/fts3_write.c 2011-04-13 08:00:51.000000000 +0200 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include @@ -2450,7 +2454,7 @@ if( !zVal ){ return SQLITE_NOMEM; - }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ + }else if( nVal==8 && 0==strnicmp(zVal, "optimize", 8) ){ rc = fts3SegmentMerge(p, FTS3_SEGCURSOR_ALL); if( rc==SQLITE_DONE ){ rc = SQLITE_OK; @@ -2458,10 +2462,10 @@ sqlite3Fts3PendingTermsClear(p); } #ifdef SQLITE_TEST - }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ + }else if( nVal>9 && 0==strnicmp(zVal, "nodesize=", 9) ){ p->nNodeSize = atoi(&zVal[9]); rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ + }else if( nVal>11 && 0==strnicmp(zVal, "maxpending=", 9) ){ p->nMaxPendingData = atoi(&zVal[11]); rc = SQLITE_OK; #endif --- sqlite3.orig/ext/fts3/fts3_aux.c 2011-04-12 11:44:56.000000000 +0200 +++ sqlite3/ext/fts3/fts3_aux.c 2011-04-13 08:16:17.000000000 +0200 @@ -15,6 +15,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.6.21" -o "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" \ -o "$VER3" = "3.6.23.1" -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_snippet.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_snippet.c 2010-01-05 08:03:51.000000000 +0100 @@ -14,6 +14,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2010-01-05 08:06:10.000000000 +0100 @@ -17,6 +17,11 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS @@ -445,7 +450,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = (int)strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = (int)((zInput - z) + nStr + 1); --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2009-12-07 17:38:46.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2010-01-05 08:12:50.000000000 +0100 @@ -27,7 +27,7 @@ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" @@ -166,7 +166,7 @@ if( !z ){ zCopy = sqlite3_mprintf("simple"); }else{ - if( sqlite3_strnicmp(z, "tokenize", 8) || fts3IsIdChar(z[8])){ + if( strnicmp(z, "tokenize", 8) || fts3IsIdChar(z[8])){ return SQLITE_OK; } zCopy = sqlite3_mprintf("%s", &z[8]); EOD test "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_snippet.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_snippet.c 2010-01-05 08:03:51.000000000 +0100 @@ -14,6 +14,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2009-12-07 17:38:46.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2010-01-05 08:12:50.000000000 +0100 @@ -27,7 +27,7 @@ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2010-01-05 08:06:10.000000000 +0100 @@ -17,6 +17,11 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS @@ -445,7 +450,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = (int)strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = (int)((zInput - z) + nStr + 1); --- sqlite3.orig/ext/fts3/fts3.c 2010-12-07 16:14:36.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2010-12-16 11:59:02.000000000 +0100 @@ -702,8 +698,8 @@ sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */ assert( strlen(argv[0])==4 ); - assert( (sqlite3_strnicmp(argv[0], "fts4", 4)==0 && isFts4) - || (sqlite3_strnicmp(argv[0], "fts3", 4)==0 && !isFts4) + assert( (strnicmp(argv[0], "fts4", 4)==0 && isFts4) + || (strnicmp(argv[0], "fts3", 4)==0 && !isFts4) ); nDb = (int)strlen(argv[1]) + 1; @@ -732,7 +728,7 @@ /* Check if this is a tokenizer specification */ if( !pTokenizer && strlen(z)>8 - && 0==sqlite3_strnicmp(z, "tokenize", 8) + && 0==strnicmp(z, "tokenize", 8) && 0==sqlite3Fts3IsIdChar(z[8]) ){ rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr); @@ -744,8 +740,8 @@ rc = SQLITE_NOMEM; goto fts3_init_out; } - if( nKey==9 && 0==sqlite3_strnicmp(z, "matchinfo", 9) ){ - if( strlen(zVal)==4 && 0==sqlite3_strnicmp(zVal, "fts3", 4) ){ + if( nKey==9 && 0==strnicmp(z, "matchinfo", 9) ){ + if( strlen(zVal)==4 && 0==strnicmp(zVal, "fts3", 4) ){ bNoDocsize = 1; }else{ *pzErr = sqlite3_mprintf("unrecognized matchinfo: %s", zVal); --- sqlite3.orig/ext/fts3/fts3_write.c 2010-12-16 12:08:45.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-12-16 12:48:30.000000000 +0100 @@ -868,16 +868,16 @@ assert( pnBlob); if( p->pSegments ){ - rc = sqlite3_blob_reopen(p->pSegments, iBlockid); - }else{ - if( 0==p->zSegmentsTbl ){ - p->zSegmentsTbl = sqlite3_mprintf("%s_segments", p->zName); - if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM; - } - rc = sqlite3_blob_open( - p->db, p->zDb, p->zSegmentsTbl, "block", iBlockid, 0, &p->pSegments - ); + sqlite3_blob_close(p->pSegments); + p->pSegments = 0; } + if( 0==p->zSegmentsTbl ){ + p->zSegmentsTbl = sqlite3_mprintf("%s_segments", p->zName); + if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM; + } + rc = sqlite3_blob_open( + p->db, p->zDb, p->zSegmentsTbl, "block", iBlockid, 0, &p->pSegments + ); if( rc==SQLITE_OK ){ int nByte = sqlite3_blob_bytes(p->pSegments); EOD # patch: FTS3 again, for SQLite3 >= 3.6.8 test "$VER3" = "3.6.8" -o "$VER3" = "3.6.9" -o "$VER3" = "3.6.10" \ -o "$VER3" = "3.6.11" -o "$VER3" = "3.6.12" -o "$VER3" = "3.6.13" \ -o "$VER3" = "3.6.14" -o "$VER3" = "3.6.14.1" -o "$VER3" = "3.6.14.2" \ -o "$VER3" = "3.6.15" -o "$VER3" = "3.6.16" -o "$VER3" = "3.6.17" \ -o "$VER3" = "3.6.18" -o "$VER3" = "3.6.19" -o "$VER3" = "3.6.20" && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-01-01 15:06:13.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2009-01-14 09:55:13.000000000 +0100 @@ -57,6 +57,12 @@ #define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10 #include "fts3_expr.h" + +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "sqlite3.h" #include #include EOD test "$VER3" = "3.6.17" -o "$VER3" = "3.6.18" -o "$VER3" = "3.6.19" \ -o "$VER3" = "3.6.20" && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-01-01 15:06:13.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2009-01-14 09:55:13.000000000 +0100 @@ -428,7 +428,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = ((zInput - z) + nStr + 1); EOD # patch: compile fix for rtree as extension module patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/rtree/rtree.c 2008-07-16 16:43:35.000000000 +0200 +++ sqlite3/ext/rtree/rtree.c 2008-07-17 08:59:53.000000000 +0200 @@ -2812,7 +2812,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD # patch: compile fix for rtree as extension module test "$VER3" = "3.7.3" -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" \ -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ -o "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/rtree/rtree.c 2010-10-16 10:53:54.000000000 +0200 +++ sqlite3/ext/rtree/rtree.c 2010-10-16 11:12:32.000000000 +0200 @@ -3193,6 +3193,8 @@ return rc; } +#ifdef SQLITE_CORE + /* ** A version of sqlite3_free() that can be used as a callback. This is used ** in two places - as the destructor for the blob value returned by the @@ -3257,6 +3259,8 @@ ); } +#endif + #ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, EOD # patch: .read shell command test "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ -o "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/shell.c 2011-05-19 15:34:57.000000000 +0200 +++ sqlite3/src/shell.c 2011-06-09 13:36:13.000000000 +0200 @@ -1957,6 +1957,7 @@ }else{ rc = process_input(p, alt); fclose(alt); + if( rc ) rc = 1; } }else EOD # patch: FTS3 for 3.7.7 plus missing APIs in sqlite3ext.h/loadext.c test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_aux.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_aux.c 2011-06-25 06:44:08.000000000 +0200 @@ -14,6 +14,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3.c 2011-06-25 06:48:49.000000000 +0200 @@ -295,10 +295,6 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -3136,7 +3132,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD test "$VER3" = "3.7.8" -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" \ -o "$VER3" = "3.7.11" -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" \ -o "$VER3" = "3.7.13" -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ -o "$VER3" = "3.7.15" -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" \ -o "$VER3" = "3.7.16" -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2011-09-19 20:46:52.000000000 +0200 +++ sqlite3/ext/fts3/fts3.c 2011-09-20 09:47:40.000000000 +0200 @@ -295,10 +295,6 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -4826,7 +4822,7 @@ } } -#if !SQLITE_CORE +#ifndef SQLITE_CORE /* ** Initialize API pointer table, if required. */ EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_expr.c 2011-06-25 06:47:00.000000000 +0200 @@ -18,6 +18,11 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS --- sqlite3.orig/ext/fts3/fts3_snippet.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_snippet.c 2011-06-25 06:45:47.000000000 +0200 @@ -13,7 +13,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) - +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2011-06-25 06:50:19.000000000 +0200 @@ -25,7 +25,7 @@ */ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" --- sqlite3.orig/ext/fts3/fts3_write.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_write.c 2011-06-25 06:45:05.000000000 +0200 @@ -20,6 +20,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/src/sqlite3ext.h 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/src/sqlite3ext.h 2011-06-25 07:28:06.000000000 +0200 @@ -212,6 +212,9 @@ int (*wal_autocheckpoint)(sqlite3*,int); int (*wal_checkpoint)(sqlite3*,const char*); void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); + int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); + int (*vtab_config)(sqlite3*,int op,...); + int (*vtab_on_conflict)(sqlite3*); }; /* @@ -412,6 +415,9 @@ #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint #define sqlite3_wal_hook sqlite3_api->wal_hook +#define sqlite3_blob_reopen sqlite3_api->blob_reopen +#define sqlite3_vtab_config sqlite3_api->vtab_config +#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; --- sqlite3.orig/src/loadext.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/src/loadext.c 2011-06-25 07:29:59.000000000 +0200 @@ -84,6 +84,8 @@ # define sqlite3_create_module 0 # define sqlite3_create_module_v2 0 # define sqlite3_declare_vtab 0 +# define sqlite3_vtab_config 0 +# define sqlite3_vtab_on_conflict 0 #endif #ifdef SQLITE_OMIT_SHARED_CACHE @@ -107,6 +109,7 @@ #define sqlite3_blob_open 0 #define sqlite3_blob_read 0 #define sqlite3_blob_write 0 +#define sqlite3_blob_reopen 0 #endif /* @@ -372,6 +375,18 @@ 0, 0, #endif +#ifndef SQLITE_OMIT_INCRBLOB + sqlite3_blob_reopen, +#else + 0, +#endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + sqlite3_vtab_config, + sqlite3_vtab_on_conflict, +#else + 0, + 0, +#endif }; /* EOD test "$VER3" = "3.7.11" -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" \ -o "$VER3" = "3.7.13" -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ -o "$VER3" = "3.7.15" -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/sqlite3ext.h 2012-03-22 20:13:33.000000000 +0100 +++ sqlite3/src/sqlite3ext.h 2012-03-22 20:13:57.000000000 +0100 @@ -236,6 +236,7 @@ int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); int (*vtab_config)(sqlite3*,int op,...); int (*vtab_on_conflict)(sqlite3*); + int (*stricmp)(const char*,const char*); }; /* @@ -439,6 +440,7 @@ #define sqlite3_blob_reopen sqlite3_api->blob_reopen #define sqlite3_vtab_config sqlite3_api->vtab_config #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict +#define sqlite3_stricmp sqlite3_api->stricmp #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; --- sqlite3.orig/src/loadext.c 2012-03-20 15:20:13.000000000 +0100 +++ sqlite3/src/loadext.c 2012-03-22 20:16:24.000000000 +0100 @@ -378,6 +378,7 @@ sqlite3_blob_reopen, sqlite3_vtab_config, sqlite3_vtab_on_conflict, + sqlite3_stricmp, }; /* EOD echo "====================" echo "Preparing TinyCC ..." echo "====================" ( $notcc && echo '*** skipped (NO_TCCEXT)' ) || true $notcc || test -r tcc-${TCCVER}.tar.bz2 || \ wget -c http://download.savannah.nongnu.org/releases/tinycc/tcc-${TCCVER}.tar.bz2 $notcc || test -r tcc-${TCCVER}.tar.bz2 || exit 1 $notcc || rm -rf tcc tcc-${TCCVER} $notcc || tar xjf tcc-${TCCVER}.tar.bz2 $notcc || ln -sf tcc-${TCCVER} tcc $notcc || patch -d tcc -p1 < tcc-${TCCVER}.patch echo "========================" echo "Cleanup before build ..." echo "========================" make -f Makefile.mingw-cross clean $notv2 || make -C sqlite -f ../mf-sqlite.mingw-cross clean make -C sqlite3 -f ../mf-sqlite3.mingw-cross clean make -C sqlite3 -f ../mf-sqlite3fts.mingw-cross clean make -C sqlite3 -f ../mf-sqlite3rtree.mingw-cross clean make -f mf-sqlite3extfunc.mingw-cross clean echo "=============================" echo "Building SQLite 2 ... ISO8859" echo "=============================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -C sqlite -f ../mf-sqlite.mingw-cross all if test -n "$SQLITE_DLLS" ; then $nov2 || make -C sqlite -f ../mf-sqlite.mingw-cross sqlite.dll fi echo "=================" echo "Building zlib ..." echo "=================" make -C zlib -f ../mf-zlib.mingw-cross all echo "=====================" echo "Building SQLite 3 ..." echo "=====================" make -C sqlite3 -f ../mf-sqlite3.mingw-cross all test -r sqlite3/tool/mksqlite3c.tcl && \ make -C sqlite3 -f ../mf-sqlite3.mingw-cross sqlite3.c if test -r sqlite3/sqlite3.c -a -f "$WITH_SEE" ; then cat sqlite3/sqlite3.c "$WITH_SEE" >sqlite3.c ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_HAS_CODEC=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_ACTIVATION_KEY=\\\"$SEE_KEY\\\"" ADD_CFLAGS="$ADD_CFLAGS -DSEEEXT=\\\"$SEEEXT\\\"" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_API=static -DWIN32=1 -DNDEBUG=1 -DNO_TCL" ADD_CFLAGS="$ADD_CFLAGS -DTHREADSAFE=1 -DSQLITE_OMIT_EXPLAIN=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_DLL=1 -DSQLITE_TRHEADSAFE=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_OS_WIN=1 -DSQLITE_ASCII=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_SOUNDEX=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1" ADD_CFLAGS="$ADD_CFLAGS -DWITHOUT_SHELL=1" export ADD_CFLAGS ADD_NSIS="$ADD_NSIS -DWITHOUT_SQLITE3_EXE" unset SQLITE3_A10N_O unset SQLITE3_EXE fi if test -n "$SQLITE_DLLS" ; then make -C sqlite3 -f ../mf-sqlite3.mingw-cross sqlite3.dll fi echo "===================" echo "Building TinyCC ..." echo "===================" ( $notcc && echo '*** skipped (NO_TCCEXT)' ) || true $notcc || ( cd tcc ; sh mingw-cross-build.sh ) # copy SQLite headers into TCC install include directory $notcc || $nov2 || cp -p sqlite/sqlite.h TCC/include $notcc || cp -p sqlite3/sqlite3.h sqlite3/src/sqlite3ext.h TCC/include # copy LGPL to TCC install doc directory $notcc || cp -p tcc-${TCCVER}/COPYING TCC/doc $notcc || cp -p tcc-${TCCVER}/README TCC/doc/readme.txt echo "===============================" echo "Building ODBC drivers and utils" echo "===============================" if $nov2 ; then make -f Makefile.mingw-cross all_no2 else make -f Makefile.mingw-cross fi make -f Makefile.mingw-cross sqlite3odbc${SEEEXT}nw.dll echo "==========================" echo "Building SQLite 2 ... UTF8" echo "==========================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -C sqlite -f ../mf-sqlite.mingw-cross clean $nov2 || make -C sqlite -f ../mf-sqlite.mingw-cross ENCODING=UTF8 all if test -n "$SQLITE_DLLS" ; then $nov2 || \ make -C sqlite -f ../mf-sqlite.mingw-cross ENCODING=UTF8 sqliteu.dll fi echo "=========================" echo "Building drivers ... UTF8" echo "=========================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -f Makefile.mingw-cross sqliteodbcu.dll sqliteu.exe echo "===================================" echo "Building SQLite3 FTS extensions ..." echo "===================================" make -C sqlite3 -f ../mf-sqlite3fts.mingw-cross clean all mv sqlite3/sqlite3_mod_fts*.dll . echo "=====================================" echo "Building SQLite3 rtree extensions ..." echo "=====================================" make -C sqlite3 -f ../mf-sqlite3rtree.mingw-cross clean all mv sqlite3/sqlite3_mod_rtree.dll . echo "========================================" echo "Building SQLite3 extension functions ..." echo "========================================" make -f mf-sqlite3extfunc.mingw-cross clean all echo "============================" echo "Building DLL import defs ..." echo "============================" # requires wine: create .def files with tiny_impdef.exe # for all .dll files which provide SQLite ( $notcc && echo '*** skipped (NO_TCCEXT)' ) || true $notcc || $nov2 || wine TCC/tiny_impdef.exe \ sqliteodbc.dll -o TCC/lib/sqlite.def $notcc || $nov2 || wine TCC/tiny_impdef.exe \ sqliteodbcu.dll -o TCC/lib/sqliteu.def $notcc || wine TCC/tiny_impdef.exe sqlite3odbc.dll -o TCC/lib/sqlite3.def if test -n "$SQLITE_DLLS" ; then $nov2 || mv sqlite/sqlite.dll . $nov2 || mv sqlite/sqliteu.dll . mv sqlite3/sqlite3.dll . fi if test -n "$SQLITE_DLLS" ; then $notcc || $nov2 || wine TCC/tiny_impdef.exe \ sqlite.dll -o TCC/lib/sqlite.def $notcc || $nov2 || wine TCC/tiny_impdef.exe \ sqliteu.dll -o TCC/lib/sqliteu.def $notcc || wine TCC/tiny_impdef.exe sqlite3.dll -o TCC/lib/sqlite3.def fi echo "=======================" echo "Cleanup after build ..." echo "=======================" $nov2 || make -C sqlite -f ../mf-sqlite.mingw-cross clean $nov2 || rm -f sqlite/sqlite.exe mv sqlite3/sqlite3.c sqlite3/sqlite3.amalg make -C sqlite3 -f ../mf-sqlite3.mingw-cross clean rm -f sqlite3/sqlite3.exe make -C sqlite3 -f ../mf-sqlite3fts.mingw-cross clean make -C sqlite3 -f ../mf-sqlite3rtree.mingw-cross clean mv sqlite3/sqlite3.amalg sqlite3/sqlite3.c make -f mf-sqlite3extfunc.mingw-cross semiclean echo "===========================" echo "Creating NSIS installer ..." echo "===========================" cp -p README readme.txt unix2dos < license.terms > license.txt || todos < license.terms > license.txt $notcc || unix2dos -k TCC/doc/COPYING || unix2dos -p TCC/doc/COPYING || \ todos -p TCC/doc/COPYING $notcc || unix2dos -k TCC/doc/readme.txt || unix2dos -p TCC/doc/readme.txt || \ todos -p TCC/doc/readme.txt makensis $ADD_NSIS sqliteodbc.nsi ./sqliteodbc-0.992/mingw64-cross-build.sh0100755000076400001440000015166512125472520016624 0ustar chwusers#!/bin/sh # # Build script for cross compiling and packaging SQLite 3 # ODBC drivers and tools for Win32 using MinGW and NSIS. # Tested on Fedora Core 3/5/8, Debian Etch, RHEL 5/6. # # Cross toolchain and NSIS for Linux/i386/x86_64 can be fetched from # http://www.ch-werner.de/xtools/crossmingw64-0.3-1.i386.rpm # http://www.ch-werner.de/xtools/crossmingw64-0.3-1.x86_64.rpm # http://www.ch-werner.de/xtools/nsis-2.37-1.i386.rpm # or # http://www.ch-werner.de/xtools/crossmingw64-0.3.i386.tar.bz2 # http://www.ch-werner.de/xtools/crossmingw64-0.3.x86_64.tar.bz2 # http://www.ch-werner.de/xtools/nsis-2.37-1_i386.tar.gz # Some aspects of the build process can be controlled by shell variables: # # NO_SQLITE2=1 omit building SQLite 2 and drivers for it # SQLITE_DLLS=1 build and package driver with sqlite3.dll # SQLITE_DLLS=2 build driver with refs to sqlite3.dll # driver can use System.Data.SQLite.dll instead set -e VER2=2.8.17 VER3=3.7.16.1 VER3X=3071601 VERZ=1.2.7 nov2=false if test -n "$NO_SQLITE2" ; then nov2=true ADD_NSIS="-DWITHOUT_SQLITE2" fi if test -f "$WITH_SEE" ; then export SEEEXT=see ADD_NSIS="-DWITH_SEE=$SEEEXT" if test "$SQLITE_DLLS" = "2" ; then SQLITE_DLLS=1 fi fi if test "$SQLITE_DLLS" = "2" ; then # turn on -DSQLITE_DYNLOAD in sqlite3odbc.c export ADD_CFLAGS="-DWITHOUT_SHELL=1 -DWITH_SQLITE_DLLS=2" ADD_NSIS="$ADD_NSIS -DWITHOUT_SQLITE3_EXE" elif test -n "$SQLITE_DLLS" ; then export ADD_CFLAGS="-DWITHOUT_SHELL=1 -DWITH_SQLITE_DLLS=1" export SQLITE3_DLL="-Lsqlite3 -lsqlite3" export SQLITE3_EXE="sqlite3.exe" ADD_NSIS="$ADD_NSIS -DWITH_SQLITE_DLLS" else export SQLITE3_A10N_O="sqlite3a10n.o" export SQLITE3_EXE="sqlite3.exe" fi if test -n "$WITH_SOURCES" ; then ADD_NSIS="$ADD_NSIS -DWITH_SOURCES" fi echo "==================" echo "Preparing zlib ..." echo "==================" test -r zlib-${VERZ}.tar.gz || \ wget -c http://zlib.net/zlib-${VERZ}.tar.gz || exit 1 rm -rf zlib-${VERZ} tar xzf zlib-${VERZ}.tar.gz ln -sf zlib-${VERZ} zlib echo "====================" echo "Preparing sqlite ..." echo "====================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || test -r sqlite-${VER2}.tar.gz || \ wget -c http://www.sqlite.org/sqlite-${VER2}.tar.gz $nov2 || test -r sqlite-${VER2}.tar.gz || exit 1 $nov2 || rm -f sqlite $nov2 || tar xzf sqlite-${VER2}.tar.gz $nov2 || ln -sf sqlite-${VER2} sqlite # enable sqlite_encode_binary et.al. $nov2 || patch sqlite/main.mk <<'EOD' --- sqlite.orig/main.mk 2005-04-24 00:43:23.000000000 +0200 +++ sqlite/main.mk 2006-03-16 14:29:55.000000000 +0100 @@ -55,7 +55,7 @@ # Object files for the SQLite library. # LIBOBJ = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \ - expr.o func.o hash.o insert.o \ + expr.o func.o hash.o insert.o encode.o \ main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \ select.o table.o tokenize.o trigger.o update.o util.o \ vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o EOD # display encoding $nov2 || patch sqlite/src/shell.c <<'EOD' --- sqlite.orig/src/shell.c 2005-04-24 00:43:22.000000000 +0200 +++ sqlite/src/shell.c 2006-05-23 08:22:01.000000000 +0200 @@ -1180,6 +1180,7 @@ " -separator 'x' set output field separator (|)\n" " -nullvalue 'text' set text string for NULL values\n" " -version show SQLite version\n" + " -encoding show SQLite encoding\n" " -help show this text, also show dot-commands\n" ; static void usage(int showDetail){ @@ -1297,7 +1298,10 @@ }else if( strcmp(z,"-echo")==0 ){ data.echoOn = 1; }else if( strcmp(z,"-version")==0 ){ - printf("%s\n", sqlite_version); + printf("%s\n", sqlite_libversion()); + return 1; + }else if( strcmp(z,"-encoding")==0 ){ + printf("%s\n", sqlite_libencoding()); return 1; }else if( strcmp(z,"-help")==0 ){ usage(1); @@ -1330,9 +1334,9 @@ char *zHome; char *zHistory = 0; printf( - "SQLite version %s\n" + "SQLite version %s encoding %s\n" "Enter \".help\" for instructions\n", - sqlite_version + sqlite_libversion(), sqlite_libencoding() ); zHome = find_home_dir(); if( zHome && (zHistory = malloc(strlen(zHome)+20))!=0 ){ EOD # use open file dialog when no database name given # need to link with -lcomdlg32 when enabled true || patch sqlite/src/shell.c <<'EOD' --- sqlite.orig/src/shell.c 2006-07-23 11:18:13.000000000 +0200 +++ sqlite/src/shell.c 2006-07-23 11:30:26.000000000 +0200 @@ -20,6 +20,10 @@ #include "sqlite.h" #include +#if defined(_WIN32) && defined(DRIVER_VER_INFO) +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) # include # include @@ -1246,6 +1250,17 @@ if( i +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__MACOS__) # include # include @@ -1205,7 +1209,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1246,6 +1250,17 @@ if( i #include +#if defined(_WIN32) && defined(DRIVER_VER_INFO) +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) # include # include @@ -1676,6 +1676,17 @@ if( inRef++; } int sqlite3_mutex_try(sqlite3_mutex *p){ + /* The TryEnterCriticalSection() interface is not available on all + ** windows systems. Since sqlite3_mutex_try() is only used as an + ** optimization, we can skip it on windows. */ + return SQLITE_BUSY; + +#if 0 /* Not Available */ int rc; assert( p ); assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) ); @@ -152,6 +158,7 @@ rc = SQLITE_BUSY; } return rc; +#endif } /* EOD # same but new module libshell.c cp -p sqlite3/src/shell.c sqlite3/src/libshell.c test "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" \ -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch sqlite3/src/libshell.c <<'EOD' --- sqlite3.orig/src/libshell.c 2007-01-08 23:40:05.000000000 +0100 +++ sqlite3/src/libshell.c 2007-01-10 18:35:43.000000000 +0100 @@ -21,6 +21,10 @@ #include #include +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) # include # include @@ -1774,7 +1778,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1816,6 +1820,17 @@ if( i #include +#ifdef _WIN32 +# include +#endif + #if !defined(_WIN32) && !defined(WIN32) # include # include @@ -1774,7 +1778,7 @@ strcpy(continuePrompt," ...> "); } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -1816,6 +1820,17 @@ if( i #include +#ifdef _WIN32 +#include +#endif + #if !defined(_WIN32) && !defined(WIN32) # include # if !defined(__RTP__) && !defined(_WRS_KERNEL) @@ -2894,7 +2898,7 @@ return argv[i]; } -int main(int argc, char **argv){ +int sqlite3_main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; @@ -2996,6 +3000,17 @@ } } if( data.zDbFilename==0 ){ +#if defined(_WIN32) && !defined(__TINYC__) + static OPENFILENAME ofn; + static char zDbFn[1024]; + ofn.lStructSize = sizeof(ofn); + ofn.lpstrFile = (LPTSTR) zDbFn; + ofn.nMaxFile = sizeof(zDbFn); + ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR; + if( GetOpenFileName(&ofn) ){ + data.zDbFilename = zDbFn; + } else +#endif #ifndef SQLITE_OMIT_MEMORYDB data.zDbFilename = ":memory:"; #else EOD rm -f sqlite3/src/minshell.c touch sqlite3/src/minshell.c patch sqlite3/src/minshell.c <<'EOD' --- sqlite3.orig/src/minshell.c 2007-01-10 18:46:47.000000000 +0100 +++ sqlite3/src/minshell.c 2007-01-10 18:46:47.000000000 +0100 @@ -0,0 +1,20 @@ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement the "sqlite" command line +** utility for accessing SQLite databases. +*/ + +int sqlite3_main(int argc, char **argv); + +int main(int argc, char **argv){ + return sqlite3_main(argc, argv); +} EOD # amalgamation: add libshell.c test "$VER3" != "3.5.6" && test -r sqlite3/tool/mksqlite3c.tcl && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/tool/mksqlite3c.tcl 2007-04-02 14:20:10.000000000 +0200 +++ sqlite3/tool/mksqlite3c.tcl 2007-04-03 09:42:03.000000000 +0200 @@ -194,6 +194,7 @@ where.c parse.c + libshell.c tokenize.c complete.c EOD test "$VER3" = "3.5.6" && test -r sqlite3/tool/mksqlite3c.tcl && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/tool/mksqlite3c.tcl 2007-04-02 14:20:10.000000000 +0200 +++ sqlite3/tool/mksqlite3c.tcl 2007-04-03 09:42:03.000000000 +0200 @@ -200,6 +200,7 @@ main.c + libshell.c fts3.c fts3_hash.c fts3_porter.c EOD # patch: parse foreign key constraints on virtual tables test "$VER3" != "3.6.15" -a "$VER3" != "3.6.16" -a "$VER3" != "3.6.17" \ -a "$VER3" != "3.6.18" -a "$VER3" != "3.6.19" -a "$VER3" != "3.6.20" \ -a "$VER3" != "3.6.21" -a "$VER3" != "3.6.22" -a "$VER3" != "3.6.23" \ -a "$VER3" != "3.6.23.1" -a "$VER3" != "3.7.0" -a "$VER3" != "3.7.0.1" \ -a "$VER3" != "3.7.1" -a "$VER3" != "3.7.2" -a "$VER3" != "3.7.3" \ -a "$VER3" != "3.7.4" -a "$VER3" != "3.7.5" -a "$VER3" != "3.7.6" \ -a "$VER3" != "3.7.6.1" -a "$VER3" != "3.7.6.2" -a "$VER3" != "3.7.6.3" \ -a "$VER3" != "3.7.7" -a "$VER3" != "3.7.7.1" -a "$VER3" != "3.7.8" \ -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" -a "$VER3" != "3.7.11" \ -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" -a "$VER3" != "3.7.13" \ -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" \ -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' diff -u sqlite3.orig/src/build.c sqlite3/src/build.c --- sqlite3.orig/src/build.c 2007-01-09 14:53:04.000000000 +0100 +++ sqlite3/src/build.c 2007-01-30 08:14:41.000000000 +0100 @@ -2063,7 +2063,7 @@ char *z; assert( pTo!=0 ); - if( p==0 || pParse->nErr || IN_DECLARE_VTAB ) goto fk_end; + if( p==0 || pParse->nErr ) goto fk_end; if( pFromCol==0 ){ int iCol = p->nCol-1; if( iCol<0 ) goto fk_end; diff -u sqlite3.orig/src/pragma.c sqlite3/src/pragma.c --- sqlite3.orig/src/pragma.c 2007-01-27 03:24:56.000000000 +0100 +++ sqlite3/src/pragma.c 2007-01-30 09:19:30.000000000 +0100 @@ -589,6 +589,9 @@ pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); +#ifndef SQLITE_OMIT_VIRTUAL_TABLE + if( pTab->pVtab ) sqlite3ViewGetColumnNames(pParse, pTab); +#endif pFK = pTab->pFKey; if( pFK ){ int i = 0; diff -u sqlite3.orig/src/vtab.c sqlite3/src/vtab.c --- sqlite3.orig/src/vtab.c 2007-01-09 15:01:14.000000000 +0100 +++ sqlite3/src/vtab.c 2007-01-30 08:23:22.000000000 +0100 @@ -540,6 +540,9 @@ int rc = SQLITE_OK; Table *pTab = db->pVTab; char *zErr = 0; +#ifndef SQLITE_OMIT_FOREIGN_KEYS + FKey *pFKey; +#endif sqlite3_mutex_enter(db->mutex); pTab = db->pVTab; @@ -568,6 +571,15 @@ } sParse.declareVtab = 0; +#ifndef SQLITE_OMIT_FOREIGN_KEYS + assert( pTab->pFKey==0 ); + pTab->pFKey = sParse.pNewTable->pFKey; + sParse.pNewTable->pFKey = 0; + for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ + pFKey->pFrom=pTab; + } +#endif + if( sParse.pVdbe ){ sqlite3VdbeFinalize(sParse.pVdbe); } EOD # patch: re-enable NO_TCL in tclsqlite.c (3.3.15) patch -d sqlite3 -p1 <<'EOD' diff -u sqlite3.orig/src/tclsqlite.c sqlite3/src/tclsqlite.c --- sqlite3.orig/src/tclsqlite.c 2007-04-06 17:02:14.000000000 +0200 +++ sqlite3/src/tclsqlite.c 2007-04-10 07:47:49.000000000 +0200 @@ -14,6 +14,7 @@ ** ** $Id: mingw64-cross-build.sh,v 1.37 2013/03/30 05:16:56 chw Exp chw $ */ +#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "tcl.h" /* @@ -2264,3 +2265,5 @@ return 0; } #endif /* TCLSH */ + +#endif /* !defined(NO_TCL) */ EOD # patch: Win32 locking and pager unlock, for SQLite3 < 3.4.0 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2007-04-11 19:52:04.000000000 +0200 +++ sqlite3/src/os_win.c 2007-05-08 06:57:06.000000000 +0200 @@ -1237,8 +1237,8 @@ ** the PENDING_LOCK byte is temporary. */ newLocktype = pFile->locktype; - if( pFile->locktype==NO_LOCK - || (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK) + if( locktype==SHARED_LOCK + || (locktype==EXCLUSIVE_LOCK && pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -1289,6 +1289,18 @@ newLocktype = EXCLUSIVE_LOCK; }else{ OSTRACE2("error-code = %d\n", GetLastError()); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -1362,6 +1374,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: Win32 locking and pager unlock, for SQLite3 >= 3.5.4 && <= 3.6.10 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2007-12-13 22:38:58.000000000 +0100 +++ sqlite3/src/os_win.c 2008-01-18 10:01:48.000000000 +0100 @@ -855,8 +855,8 @@ ** the PENDING_LOCK byte is temporary. */ newLocktype = pFile->locktype; - if( pFile->locktype==NO_LOCK - || (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK) + if( locktype==SHARED_LOCK + || (locktype==EXCLUSIVE_LOCK && pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -907,7 +907,18 @@ newLocktype = EXCLUSIVE_LOCK; }else{ OSTRACE2("error-code = %d\n", GetLastError()); - getReadLock(pFile); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -982,6 +993,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: Win32 locking and pager unlock, for SQLite3 >= 3.6.11 && < 3.7.0 true || patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/os_win.c 2009-02-15 14:07:09.000000000 +0100 +++ sqlite3/src/os_win.c 2009-02-20 16:39:48.000000000 +0100 @@ -922,7 +922,7 @@ newLocktype = pFile->locktype; if( (pFile->locktype==NO_LOCK) || ( (locktype==EXCLUSIVE_LOCK) - && (pFile->locktype==RESERVED_LOCK)) + && (pFile->locktype0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){ @@ -981,7 +981,18 @@ }else{ error = GetLastError(); OSTRACE2("error-code = %d\n", error); - getReadLock(pFile); + if( !getReadLock(pFile) ){ + /* This should never happen. We should always be able to + ** reacquire the read lock */ + OSTRACE1("could not re-get a SHARED lock.\n"); + if( newLocktype==PENDING_LOCK || pFile->locktype==PENDING_LOCK ){ + UnlockFile(pFile->h, PENDING_BYTE, 0, 1, 0); + } + if( pFile->locktype==RESERVED_LOCK ){ + UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); + } + newLocktype = NO_LOCK; + } } } @@ -1057,6 +1068,7 @@ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = SQLITE_IOERR_UNLOCK; + locktype = NO_LOCK; } } if( type>=RESERVED_LOCK ){ EOD # patch: compile fix for FTS3 as extension module test "$VER3" != "3.6.21" -a "$VER3" != "3.6.22" -a "$VER3" != "3.6.23" \ -a "$VER3" != "3.6.23.1" -a "$VER3" != "3.7.0" -a "$VER3" != "3.7.0.1" \ -a "$VER3" != "3.7.1" -a "$VER3" != "3.7.2" -a "$VER3" != "3.7.3" \ -a "$VER3" != "3.7.4" -a "$VER3" != "3.7.5" -a "$VER3" != "3.7.6" \ -a "$VER3" != "3.7.6.1" -a "$VER3" != "3.7.6.2" -a "$VER3" != "3.7.6.3" \ -a "$VER3" != "3.7.7" -a "$VER3" != "3.7.7.1" -a "$VER3" != "3.7.8" \ -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" -a "$VER3" != "3.7.11" \ -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" -a "$VER3" != "3.7.13" \ -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" -a "$VER3" != "3.7.15" \ -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" -a "$VER3" != "3.7.16" \ -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2008-02-02 17:24:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2008-03-16 11:29:02.000000000 +0100 @@ -274,10 +274,6 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -6389,7 +6385,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, --- sqlite3.orig/ext/fts3/fts3_porter.c 2008-02-01 16:40:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3_porter.c 2008-03-16 11:34:50.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" /* --- sqlite3.orig/ext/fts3/fts3_tokenizer1.c 2007-11-23 18:31:18.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer1.c 2008-03-16 11:35:37.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" typedef struct simple_tokenizer { --- sqlite3.orig/ext/fts3/fts3_hash.c 2007-11-24 01:41:52.000000000 +0100 +++ sqlite3/ext/fts3/fts3_hash.c 2008-03-16 11:39:57.000000000 +0100 @@ -29,6 +29,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "sqlite3.h" #include "fts3_hash.h" --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2008-06-24 03:29:58.000000000 +0200 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2008-07-17 08:38:24.000000000 +0200 @@ -27,7 +27,7 @@ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3_hash.h" EOD test "$VER3" = "3.6.21" -o "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" \ -o "$VER3" = "3.6.23.1" -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" -o "$VER3" = "3.7.5" \ -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2008-02-02 17:24:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2008-03-16 11:29:02.000000000 +0100 @@ -274,10 +274,6 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include "fts3Int.h" #include @@ -6389,7 +6385,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_porter.c 2008-02-01 16:40:34.000000000 +0100 +++ sqlite3/ext/fts3/fts3_porter.c 2008-03-16 11:34:50.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" /* --- sqlite3.orig/ext/fts3/fts3_tokenizer1.c 2007-11-23 18:31:18.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer1.c 2008-03-16 11:35:37.000000000 +0100 @@ -31,6 +31,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "fts3_tokenizer.h" typedef struct simple_tokenizer { EOD test "$VER3" != "3.7.8" -a "$VER3" != "3.7.9" -a "$VER3" != "3.7.10" \ -a "$VER3" != "3.7.11" -a "$VER3" != "3.7.12" -a "$VER3" != "3.7.12.1" \ -a "$VER3" != "3.7.13" -a "$VER3" != "3.7.14" -a "$VER3" != "3.7.14.1" \ -a "$VER3" != "3.7.15" -a "$VER3" != "3.7.15.1" -a "$VER3" != "3.7.15.2" \ -a "$VER3" != "3.7.16" -a "$VER3" != "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_hash.c 2007-11-24 01:41:52.000000000 +0100 +++ sqlite3/ext/fts3/fts3_hash.c 2008-03-16 11:39:57.000000000 +0100 @@ -29,6 +29,11 @@ #include #include +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "sqlite3.h" #include "fts3_hash.h" EOD test "$VER3" = "3.6.21" && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2009-12-03 20:39:06.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-01-05 07:59:27.000000000 +0100 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include EOD test "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" -o "$VER3" = "3.6.23.1" \ -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2010-01-05 09:42:19.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-01-05 09:55:25.000000000 +0100 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include @@ -2226,7 +2230,7 @@ if( !zVal ){ return SQLITE_NOMEM; - }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ + }else if( nVal==8 && 0==strnicmp(zVal, "optimize", 8) ){ rc = fts3SegmentMerge(p, -1); if( rc==SQLITE_DONE ){ rc = SQLITE_OK; @@ -2234,10 +2238,10 @@ sqlite3Fts3PendingTermsClear(p); } #ifdef SQLITE_TEST - }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ + }else if( nVal>9 && 0==strnicmp(zVal, "nodesize=", 9) ){ p->nNodeSize = atoi(&zVal[9]); rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ + }else if( nVal>11 && 0==strnicmp(zVal, "maxpending=", 9) ){ p->nMaxPendingData = atoi(&zVal[11]); rc = SQLITE_OK; #endif EOD test "$VER3" = "3.7.6"\ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_write.c 2011-04-12 11:44:56.000000000 +0200 +++ sqlite3/ext/fts3/fts3_write.c 2011-04-13 08:00:51.000000000 +0200 @@ -20,6 +20,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include @@ -2450,7 +2454,7 @@ if( !zVal ){ return SQLITE_NOMEM; - }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ + }else if( nVal==8 && 0==strnicmp(zVal, "optimize", 8) ){ rc = fts3SegmentMerge(p, FTS3_SEGCURSOR_ALL); if( rc==SQLITE_DONE ){ rc = SQLITE_OK; @@ -2458,10 +2462,10 @@ sqlite3Fts3PendingTermsClear(p); } #ifdef SQLITE_TEST - }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ + }else if( nVal>9 && 0==strnicmp(zVal, "nodesize=", 9) ){ p->nNodeSize = atoi(&zVal[9]); rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ + }else if( nVal>11 && 0==strnicmp(zVal, "maxpending=", 9) ){ p->nMaxPendingData = atoi(&zVal[11]); rc = SQLITE_OK; #endif --- sqlite3.orig/ext/fts3/fts3_aux.c 2011-04-12 11:44:56.000000000 +0200 +++ sqlite3/ext/fts3/fts3_aux.c 2011-04-13 08:16:17.000000000 +0200 @@ -15,6 +15,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.6.21" -o "$VER3" = "3.6.22" -o "$VER3" = "3.6.23" \ -o "$VER3" = "3.6.23.1" -o "$VER3" = "3.7.0" -o "$VER3" = "3.7.0.1" \ -o "$VER3" = "3.7.1" -o "$VER3" = "3.7.2" -o "$VER3" = "3.7.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_snippet.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_snippet.c 2010-01-05 08:03:51.000000000 +0100 @@ -14,6 +14,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2010-01-05 08:06:10.000000000 +0100 @@ -17,6 +17,11 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS @@ -445,7 +450,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = (int)strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = (int)((zInput - z) + nStr + 1); --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2009-12-07 17:38:46.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2010-01-05 08:12:50.000000000 +0100 @@ -27,7 +27,7 @@ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" @@ -166,7 +166,7 @@ if( !z ){ zCopy = sqlite3_mprintf("simple"); }else{ - if( sqlite3_strnicmp(z, "tokenize", 8) || fts3IsIdChar(z[8])){ + if( strnicmp(z, "tokenize", 8) || fts3IsIdChar(z[8])){ return SQLITE_OK; } zCopy = sqlite3_mprintf("%s", &z[8]); EOD test "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_snippet.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_snippet.c 2010-01-05 08:03:51.000000000 +0100 @@ -14,6 +14,10 @@ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "fts3Int.h" +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2009-12-07 17:38:46.000000000 +0100 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2010-01-05 08:12:50.000000000 +0100 @@ -27,7 +27,7 @@ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-12-03 12:33:32.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2010-01-05 08:06:10.000000000 +0100 @@ -17,6 +17,11 @@ */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS @@ -445,7 +450,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = (int)strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = (int)((zInput - z) + nStr + 1); --- sqlite3.orig/ext/fts3/fts3.c 2010-12-07 16:14:36.000000000 +0100 +++ sqlite3/ext/fts3/fts3.c 2010-12-16 11:59:02.000000000 +0100 @@ -702,8 +698,8 @@ sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */ assert( strlen(argv[0])==4 ); - assert( (sqlite3_strnicmp(argv[0], "fts4", 4)==0 && isFts4) - || (sqlite3_strnicmp(argv[0], "fts3", 4)==0 && !isFts4) + assert( (strnicmp(argv[0], "fts4", 4)==0 && isFts4) + || (strnicmp(argv[0], "fts3", 4)==0 && !isFts4) ); nDb = (int)strlen(argv[1]) + 1; @@ -732,7 +728,7 @@ /* Check if this is a tokenizer specification */ if( !pTokenizer && strlen(z)>8 - && 0==sqlite3_strnicmp(z, "tokenize", 8) + && 0==strnicmp(z, "tokenize", 8) && 0==sqlite3Fts3IsIdChar(z[8]) ){ rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr); @@ -744,8 +740,8 @@ rc = SQLITE_NOMEM; goto fts3_init_out; } - if( nKey==9 && 0==sqlite3_strnicmp(z, "matchinfo", 9) ){ - if( strlen(zVal)==4 && 0==sqlite3_strnicmp(zVal, "fts3", 4) ){ + if( nKey==9 && 0==strnicmp(z, "matchinfo", 9) ){ + if( strlen(zVal)==4 && 0==strnicmp(zVal, "fts3", 4) ){ bNoDocsize = 1; }else{ *pzErr = sqlite3_mprintf("unrecognized matchinfo: %s", zVal); --- sqlite3.orig/ext/fts3/fts3_write.c 2010-12-16 12:08:45.000000000 +0100 +++ sqlite3/ext/fts3/fts3_write.c 2010-12-16 12:48:30.000000000 +0100 @@ -868,16 +868,16 @@ assert( pnBlob); if( p->pSegments ){ - rc = sqlite3_blob_reopen(p->pSegments, iBlockid); - }else{ - if( 0==p->zSegmentsTbl ){ - p->zSegmentsTbl = sqlite3_mprintf("%s_segments", p->zName); - if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM; - } - rc = sqlite3_blob_open( - p->db, p->zDb, p->zSegmentsTbl, "block", iBlockid, 0, &p->pSegments - ); + sqlite3_blob_close(p->pSegments); + p->pSegments = 0; } + if( 0==p->zSegmentsTbl ){ + p->zSegmentsTbl = sqlite3_mprintf("%s_segments", p->zName); + if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM; + } + rc = sqlite3_blob_open( + p->db, p->zDb, p->zSegmentsTbl, "block", iBlockid, 0, &p->pSegments + ); if( rc==SQLITE_OK ){ int nByte = sqlite3_blob_bytes(p->pSegments); EOD # patch: FTS3 again, for SQLite3 >= 3.6.8 test "$VER3" = "3.6.8" -o "$VER3" = "3.6.9" -o "$VER3" = "3.6.10" \ -o "$VER3" = "3.6.11" -o "$VER3" = "3.6.12" -o "$VER3" = "3.6.13" \ -o "$VER3" = "3.6.14" -o "$VER3" = "3.6.14.1" -o "$VER3" = "3.6.14.2" \ -o "$VER3" = "3.6.15" -o "$VER3" = "3.6.16" -o "$VER3" = "3.6.17" \ -o "$VER3" = "3.6.18" -o "$VER3" = "3.6.19" -o "$VER3" = "3.6.20" && \ patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-01-01 15:06:13.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2009-01-14 09:55:13.000000000 +0100 @@ -57,6 +57,12 @@ #define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10 #include "fts3_expr.h" + +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + #include "sqlite3.h" #include #include EOD test "$VER3" = "3.6.17" -o "$VER3" = "3.6.18" -o "$VER3" = "3.6.19" \ -o "$VER3" = "3.6.20" && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2009-01-01 15:06:13.000000000 +0100 +++ sqlite3/ext/fts3/fts3_expr.c 2009-01-14 09:55:13.000000000 +0100 @@ -428,7 +428,7 @@ const char *zStr = pParse->azCol[ii]; int nStr = strlen(zStr); if( nInput>nStr && zInput[nStr]==':' - && sqlite3_strnicmp(zStr, zInput, nStr)==0 + && memcmp(zStr, zInput, nStr)==0 ){ iCol = ii; iColLen = ((zInput - z) + nStr + 1); EOD # patch: compile fix for rtree as extension module patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/rtree/rtree.c 2008-07-16 16:43:35.000000000 +0200 +++ sqlite3/ext/rtree/rtree.c 2008-07-17 08:59:53.000000000 +0200 @@ -2812,7 +2812,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD # patch: compile fix for rtree as extension module test "$VER3" = "3.7.3" -o "$VER3" = "3.7.4" -o "$VER3" = "3.7.5" \ -o "$VER3" = "3.7.6" \ -o "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ -o "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/rtree/rtree.c 2010-10-16 10:53:54.000000000 +0200 +++ sqlite3/ext/rtree/rtree.c 2010-10-16 11:12:32.000000000 +0200 @@ -3193,6 +3193,8 @@ return rc; } +#ifdef SQLITE_CORE + /* ** A version of sqlite3_free() that can be used as a callback. This is used ** in two places - as the destructor for the blob value returned by the @@ -3257,6 +3259,8 @@ ); } +#endif + #ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, EOD # patch: .read shell command test "$VER3" = "3.7.6.1" -o "$VER3" = "3.7.6.2" -o "$VER3" = "3.7.6.3" \ -o "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/shell.c 2011-05-19 15:34:57.000000000 +0200 +++ sqlite3/src/shell.c 2011-06-09 13:36:13.000000000 +0200 @@ -1957,6 +1957,7 @@ }else{ rc = process_input(p, alt); fclose(alt); + if( rc ) rc = 1; } }else EOD # patch: FTS3 for 3.7.7 plus missing APIs in sqlite3ext.h/loadext.c test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_aux.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_aux.c 2011-06-25 06:44:08.000000000 +0200 @@ -14,6 +14,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3.c 2011-06-25 06:48:49.000000000 +0200 @@ -295,10 +295,6 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -3136,7 +3132,7 @@ return rc; } -#if !SQLITE_CORE +#ifndef SQLITE_CORE int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, EOD test "$VER3" = "3.7.8" -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" \ -o "$VER3" = "3.7.11" -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" \ -o "$VER3" = "3.7.13" -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ -o "$VER3" = "3.7.15" -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" \ -o "$VER3" = "3.7.16" -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3.c 2011-09-19 20:46:52.000000000 +0200 +++ sqlite3/ext/fts3/fts3.c 2011-09-20 09:47:40.000000000 +0200 @@ -295,10 +295,6 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) -#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) -# define SQLITE_CORE 1 -#endif - #include #include #include @@ -4826,7 +4822,7 @@ } } -#if !SQLITE_CORE +#ifndef SQLITE_CORE /* ** Initialize API pointer table, if required. */ EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" -o "$VER3" = "3.7.8" \ -o "$VER3" = "3.7.9" -o "$VER3" = "3.7.10" -o "$VER3" = "3.7.11" \ -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" -o "$VER3" = "3.7.13" \ -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" -o "$VER3" = "3.7.15" \ -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" -o "$VER3" = "3.7.16" \ -o "$VER3" = "3.7.16.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_expr.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_expr.c 2011-06-25 06:47:00.000000000 +0200 @@ -18,6 +18,11 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif + /* ** By default, this module parses the legacy syntax that has been ** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS --- sqlite3.orig/ext/fts3/fts3_snippet.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_snippet.c 2011-06-25 06:45:47.000000000 +0200 @@ -13,7 +13,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) - +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include EOD test "$VER3" = "3.7.7" -o "$VER3" = "3.7.7.1" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/ext/fts3/fts3_tokenizer.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_tokenizer.c 2011-06-25 06:50:19.000000000 +0200 @@ -25,7 +25,7 @@ */ #include "sqlite3ext.h" #ifndef SQLITE_CORE - SQLITE_EXTENSION_INIT1 +extern const sqlite3_api_routines *sqlite3_api; #endif #include "fts3Int.h" --- sqlite3.orig/ext/fts3/fts3_write.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/ext/fts3/fts3_write.c 2011-06-25 06:45:05.000000000 +0200 @@ -20,6 +20,10 @@ #include "fts3Int.h" #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) +#include "sqlite3ext.h" +#ifndef SQLITE_CORE +extern const sqlite3_api_routines *sqlite3_api; +#endif #include #include #include --- sqlite3.orig/src/sqlite3ext.h 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/src/sqlite3ext.h 2011-06-25 07:28:06.000000000 +0200 @@ -212,6 +212,9 @@ int (*wal_autocheckpoint)(sqlite3*,int); int (*wal_checkpoint)(sqlite3*,const char*); void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); + int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); + int (*vtab_config)(sqlite3*,int op,...); + int (*vtab_on_conflict)(sqlite3*); }; /* @@ -412,6 +415,9 @@ #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint #define sqlite3_wal_hook sqlite3_api->wal_hook +#define sqlite3_blob_reopen sqlite3_api->blob_reopen +#define sqlite3_vtab_config sqlite3_api->vtab_config +#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; --- sqlite3.orig/src/loadext.c 2011-06-24 09:06:08.000000000 +0200 +++ sqlite3/src/loadext.c 2011-06-25 07:29:59.000000000 +0200 @@ -84,6 +84,8 @@ # define sqlite3_create_module 0 # define sqlite3_create_module_v2 0 # define sqlite3_declare_vtab 0 +# define sqlite3_vtab_config 0 +# define sqlite3_vtab_on_conflict 0 #endif #ifdef SQLITE_OMIT_SHARED_CACHE @@ -107,6 +109,7 @@ #define sqlite3_blob_open 0 #define sqlite3_blob_read 0 #define sqlite3_blob_write 0 +#define sqlite3_blob_reopen 0 #endif /* @@ -372,6 +375,18 @@ 0, 0, #endif +#ifndef SQLITE_OMIT_INCRBLOB + sqlite3_blob_reopen, +#else + 0, +#endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + sqlite3_vtab_config, + sqlite3_vtab_on_conflict, +#else + 0, + 0, +#endif }; /* EOD test "$VER3" = "3.7.11" -o "$VER3" = "3.7.12" -o "$VER3" = "3.7.12.1" \ -o "$VER3" = "3.7.13" -o "$VER3" = "3.7.14" -o "$VER3" = "3.7.14.1" \ -o "$VER3" = "3.7.15" -o "$VER3" = "3.7.15.1" -o "$VER3" = "3.7.15.2" \ && patch -d sqlite3 -p1 <<'EOD' --- sqlite3.orig/src/sqlite3ext.h 2012-03-22 20:13:33.000000000 +0100 +++ sqlite3/src/sqlite3ext.h 2012-03-22 20:13:57.000000000 +0100 @@ -236,6 +236,7 @@ int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); int (*vtab_config)(sqlite3*,int op,...); int (*vtab_on_conflict)(sqlite3*); + int (*stricmp)(const char*,const char*); }; /* @@ -439,6 +440,7 @@ #define sqlite3_blob_reopen sqlite3_api->blob_reopen #define sqlite3_vtab_config sqlite3_api->vtab_config #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict +#define sqlite3_stricmp sqlite3_api->stricmp #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; --- sqlite3.orig/src/loadext.c 2012-03-20 15:20:13.000000000 +0100 +++ sqlite3/src/loadext.c 2012-03-22 20:16:24.000000000 +0100 @@ -378,6 +378,7 @@ sqlite3_blob_reopen, sqlite3_vtab_config, sqlite3_vtab_on_conflict, + sqlite3_stricmp, }; /* EOD echo "========================" echo "Cleanup before build ..." echo "========================" make -f Makefile.mingw64-cross clean $notv2 || make -C sqlite -f ../mf-sqlite.mingw64-cross clean make -C sqlite3 -f ../mf-sqlite3.mingw64-cross clean make -C sqlite3 -f ../mf-sqlite3fts.mingw64-cross clean make -C sqlite3 -f ../mf-sqlite3rtree.mingw64-cross clean make -f mf-sqlite3extfunc.mingw64-cross clean echo "=============================" echo "Building SQLite 2 ... ISO8859" echo "=============================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -C sqlite -f ../mf-sqlite.mingw64-cross all if test -n "$SQLITE_DLLS" ; then $nov2 || make -C sqlite -f ../mf-sqlite.mingw64-cross sqlite.dll fi echo "=================" echo "Building zlib ..." echo "=================" make -C zlib -f ../mf-zlib.mingw64-cross all echo "==========================" echo "Building SQLite 2 ... UTF8" echo "==========================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -C sqlite -f ../mf-sqlite.mingw64-cross clean $nov2 || make -C sqlite -f ../mf-sqlite.mingw64-cross ENCODING=UTF8 all if test -n "$SQLITE_DLLS" ; then $nov2 || \ make -C sqlite -f ../mf-sqlite.mingw64-cross ENCODING=UTF8 sqliteu.dll fi echo "=====================" echo "Building SQLite 3 ..." echo "=====================" make -C sqlite3 -f ../mf-sqlite3.mingw64-cross all test -r sqlite3/tool/mksqlite3c.tcl && \ make -C sqlite3 -f ../mf-sqlite3.mingw64-cross sqlite3.c if test -r sqlite3/sqlite3.c -a -f "$WITH_SEE" ; then cat sqlite3/sqlite3.c "$WITH_SEE" > sqlite3.c ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_HAS_CODEC=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_ACTIVATION_KEY=\\\"$SEE_KEY\\\"" ADD_CFLAGS="$ADD_CFLAGS -DSEEEXT=\\\"$SEEEXT\\\"" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_API=static -DWIN32=1 -DNDEBUG=1 -DNO_TCL" ADD_CFLAGS="$ADD_CFLAGS -DTHREADSAFE=1 -DSQLITE_OMIT_EXPLAIN=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_DLL=1 -DSQLITE_THREADSAFE=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_OS_WIN=1 -DSQLITE_ASCII=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_SOUNDEX=1" ADD_CFLAGS="$ADD_CFLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1" ADD_CFLAGS="$ADD_CFLAGS -DWITHOUT_SHELL=1" export ADD_CFLAGS ADD_NSIS="$ADD_NSIS -DWITHOUT_SQLITE3_EXE" unset SQLITE3_A10N_O unset SQLITE3_EXE fi if test -n "$SQLITE_DLLS" ; then make -C sqlite3 -f ../mf-sqlite3.mingw64-cross sqlite3.dll fi echo "===============================" echo "Building ODBC drivers and utils" echo "===============================" if $nov2 ; then make -f Makefile.mingw64-cross all_no2 else make -f Makefile.mingw64-cross fi make -f Makefile.mingw64-cross sqlite3odbc${SEEEXT}nw.dll echo "===================================" echo "Building SQLite3 FTS extensions ..." echo "===================================" make -C sqlite3 -f ../mf-sqlite3fts.mingw64-cross clean all mv sqlite3/sqlite3_mod_fts*.dll . echo "=====================================" echo "Building SQLite3 rtree extensions ..." echo "=====================================" make -C sqlite3 -f ../mf-sqlite3rtree.mingw64-cross clean all mv sqlite3/sqlite3_mod_rtree.dll . echo "========================================" echo "Building SQLite3 extension functions ..." echo "========================================" make -f mf-sqlite3extfunc.mingw64-cross clean all echo "=========================" echo "Building drivers ... UTF8" echo "=========================" ( $nov2 && echo '*** skipped (NO_SQLITE2)' ) || true $nov2 || make -f Makefile.mingw64-cross sqliteodbcu.dll sqliteu.exe echo "=======================" echo "Cleanup after build ..." echo "=======================" $nov2 || make -C sqlite -f ../mf-sqlite.mingw64-cross clean $nov2 || rm -f sqlite/sqlite.exe make -C sqlite3 -f ../mf-sqlite3.mingw64-cross clean make -C sqlite3 -f ../mf-sqlite3fts.mingw64-cross clean make -C sqlite3 -f ../mf-sqlite3rtree.mingw64-cross clean make -f mf-sqlite3extfunc.mingw64-cross semiclean echo "===========================" echo "Creating NSIS installer ..." echo "===========================" cp -p README readme.txt unix2dos < license.terms > license.txt || todos < license.terms > license.txt makensis $ADD_NSIS sqliteodbc_w64.nsi ./sqliteodbc-0.992/sqlite.ico0100644000076400001440000007234610551172501014536 0ustar chwusers 00hĈ è.è (ŝ 00¨& ¨ÎÈv$h>+00 ¨%Ĥ0  ¨NV ˆ öf h~p(0`@€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙ˆ†hw‚€xhwĝr€w˙ˆh÷ƒwv ˆˆ€w€xˆc€xhh‡ˆc€‡ĝr€wˆ†€xwxhwˆ‚ˆˆxwˆ`‡ˆ€ˆˆxwx†€xaw€ˆ€wx(x`ˆ†€†‡‡vw‡†c€ˆ‚€xxwv(x‡ˆ€xx†ˆh‡wv8‡wx€x‡pˆˆ÷ˆ(‡rXxˆ‡‚wˆ†ˆ€‚€x(‡wx€€w€€xhˆ‡€€xc€w†€ˆ‡€€x€xˆ‚xbˆ€€x€€wˆˆ‡ˆˆ‡‚ˆx†€px`ˆ†(xˆ8x€xˆxˆwx€x€xˆxpx€w†6†ˆhˆ€wˆˆxxxw‡‡‡˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙˙˙ƒ˙˙˙˙˙˙˙˙˙˙˙˙˙˙€˙˙˙˙˙˙˙€˙˙˙˙˙˙À?˙˙˙˙˙˙à?˙˙˙˙˙˙˙˙˙˙˙ĝ˙˙˙˙˙ü˙˙˙˙˙ŝ˙˙˙˙˙˙À?˙˙˙˙˙x˙˙˙˙ü˙˙˙˙ĝx˙˙˙˙ĝp˙˙˙ĝÀ˙˙˙ü€˙˙˙˙€€?˙˙˙˙à˙˙˙˙ĝ˙˙˙˙˙˙˙˙˙˙Á`˙˙˙˙ÀÀ˙˙˙˙˙˙˙˙ŭ˙˙˙˙˙€0a˙˙˙˙˙à?q˙˙˙˙˙ü ˙˙˙˙˙˙˙˙˙˙˙˙À?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @À€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙hwx`÷ˆwx€÷hˆˆ‡vˆˆ8wˆ‡†ˆ‡x`ˆc€ˆˆ‡ƒ€xˆ€ˆˆwcˆ†ˆˆˆ†ˆwhˆxˆˆˆˆˆwc‡…xˆˆˆˆ€x(ˆˆ€xhxˆxhˆˆˆˆˆxxˆ†8ˆ‡ˆˆˆˆ†‡ˆˆx€‡ˆ€€€ˆhˆ‡px‡‡˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙ƒ˙˙˙Á˙˙˙à˙˙˙˙ĝ˙˙ĝ˙˙˙à˙ĝ˙ŝ˙˙ ?˙à€˙˙˙˙˙Ù˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0À€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙€‡†ĝ€w€ˆvˆhwˆwˆ€ˆx`ˆ€x€‡† xcˆˆwx8x€ˆˆ‡ˆˆ€ˆgˆ€x€ˆhˆx€xˆˆˆˆˆ€ˆ€w€xˆˆˆxp˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙‡˙˙˙Ç˙˙˙à?˙˙˙˙c˙˙ì1˙˙à˙˙ĝ˙˙˙˙ˆG˙˙à ˙˙ĝ}˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( €€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙xw€xˆ€‡ˆˆ€ˆˆˆˆˆˆxˆ€xhˆˆpxˆˆˆ€ˆˆˆ‡xˆp˙˙˙˙˙˙˙˙˙˙˙˙?˙˙˙˙˙˙˙˙˙À˙˙À?˙˙À˙˙˙˙ü˙˙˙˙˙˙Á˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0`€†‰¨˘ŒŠİħ ıżĵ‰–†UYZ:<<]aVĦĴŠ‘–ŠknmâċÚéìĴ´“™œfia°·£Ÿİ‰Ĥ™Ĥ‰š‚˘İ’…‰…]`YJLMim`lqbmqe•|ʽ@BAĴ²İ´şħx{qHJE}‚„qtu465<==ĥ½½tx{699“œ~>ABÈÎş™žœ–œ‰RUMuzl޳•š˘Œ8::…Šµşĥ‘–™˘¨•Ĥ•°ĥĞFIE²ıWZ\~„q¨²’´½˘ĥ½µ˘ĤĦMPGĤ°ad]¤QTUZ\Xuzj‰‘yşÂİĊDED|ƒmĞħİôġñ†ŒŽ˜ …œĤ…ĥ˘ŻĥĤ ¨Žeik,.-˜¤~lprZ\U˘ĴŒ—]ab°¸œŸ–ùúĝħ¸¸µğĵ޲žqth¤rvx685NPR<>@£ĴŽ³ğ œ¨„¤­“› £sxhŞ´”­ĥ™ħ¸´aeg– ‚°ÇÍıBD>EH>‚†€‚†…]_W£Œ Ğˆ İ‹ Ş‹°‘§ħ“§²’…ˆ‚ac^df^Żĥ³Ĵ³´ŻµĥħıĦħı˘³ğ£žİ…¨†žİ†ŸŞ†•†twuÔÙÉ×Ü͙Ÿ˜Ĥ­ ¤ŞĤŻ‘_ceħş²ğŸżĊ³ĵÀĥİ­Ĥħ¸ĞµğĴ^`_ċèŜşıÀżĵÁ½ƒˆx‡‹~–š”ƒ”›…А“““Ž”—UWPĦ œ˘¤ž¤ĤŒ…\_YZ]^PRKRUKPROIKHILJ022342355£Ğ˜¤ĞœĤœ£’›Ħ—|‚pƒwíïéhjcjmgkpa•˜‹“}Ĵµ—ĵЁ†v„‰w›£‰DEAACEBDE:<;@<üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüĥ\üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüÜ,üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü˜M…î)7üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü–RœTö7üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüC÷úcB-(SüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüC4ùcäjüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüCsRAXÔüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüCsĈ P6üÊ+&›üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü^ì‘@Z¨] üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü‰H/¤ P%‘Ğó SüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüĤXBFpZ+üV2!ßüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüï5x×BwĠYüüġWmT !kßüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü3 /y^2üüüüQ1n_g=£vüüüüüüüüüüüüüüüüüüüüüüüüüSÈ;Œ|FaÖhÄ)­üüüŸÇ{Şħüüüüüüüüüüüüüüüüüüüüüüüü²’†üüüü€/MT˙ûüüüĦAĴEĵ?üüüüüüüüüüüüüüüüüüüüüüü"wJüüü9ğ ƒa 4É,üühšÏ°OüüüüüüüüüüüüüüüüüüüüCU%l\üL ñf€Ny;El&üü0 ÍxxGüüüüüüüüüüüüüüüüüüüüü"ÁKOJ]&üDp / ;ˆ,+0nÜŬMËüüüüüüüüüüüüüüüüüüüüüüüüŜh1NX)ü$‚F•ëşI9e<269üüüüüüüüüüüüüüüüüüüüüüüüü* [ #jçHmĊ~7üüWĴÑüüüüüüüüüüüüüüüüüüüüüüüüüüÛA´k _lü*"éU½üüü>4r +üüüüüüüüüüüüüüüüüüüüüüüüüüü˘ o `üüü#K6&üüdVÓüüüüüüüüüüüüüüüüüüüüüüüüüüšAU·?üüüĉ}üŻüü8z.üüüüüüüüüüüüüüüüüüüüüüüüüèH[oĝüü>E—,\üüufG 'üüüüüüüüüüüüüüüüüüüüüüüüü<â íiYċL! b3 vü‹Ĝê3ı?üüüüüüüüüüüüüüüüüüüüüüüüüŠüİ=(-¸.quÀ“‡I+üüQtrÒüüüüüüüüüüüüüüüüüüüüüüüüüüüٍ;@ga[Î?üüŭÚ8D”üüdŽ$iüüüüüüüüüüüüüüüüüüüüüüüüüüüü§ż„Ìüüüüüüeüüüïáüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüeôµ!››››`'àüž'üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüŝtò:: qüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü#55:b™³üüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙˙˙ƒ˙˙˙˙˙˙˙˙˙˙˙˙˙˙€˙˙˙˙˙˙˙€˙˙˙˙˙˙À?˙˙˙˙˙˙à?˙˙˙˙˙˙˙˙˙˙˙ĝ˙˙˙˙˙ü˙˙˙˙˙ŝ˙˙˙˙˙˙À?˙˙˙˙˙x˙˙˙˙ü˙˙˙˙ĝx˙˙˙˙ĝp˙˙˙ĝÀ˙˙˙ü€˙˙˙˙€€?˙˙˙˙à˙˙˙˙ĝ˙˙˙˙˙˙˙˙˙˙Á`˙˙˙˙ÀÀ˙˙˙˙˙˙˙˙ŭ˙˙˙˙˙€0a˙˙˙˙˙à?q˙˙˙˙˙ü ˙˙˙˙˙˙˙˙˙˙˙˙À?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @€¨İjmijniÁÈħÁȲ˘Ş—£Ş—PRMQRMin^in_ıÁ¨ıÁİš˘Žš˘ĦݘĦİ™Y\^Y]^MPPNPQ`eU`fV §š Ĥ›—‚–ƒ‘–™‘—šGIFFIG‰‘yŠ’yž¤˘Ÿ˘rvpswp”œ”‚hm^im_lrbmrcz~€z{ŸİŠŸ¨Œ€‡q€†s…q…sš˘Š›£‹Z]]”ˆ•ŠŒŠŒ’‹­³²Ĵ²³^aX_bYĦ¨˘İœ}‚„ƒ„ĤĴ¨§­İy~my}oPTMRUM•›œ”š•›ž]`\^a^be_cg^€…ˆ‚‡‰„t„wx|z~~­”§Ż–•ŸĤ•Ÿ§–wzzv{}£Ğ˜}€}~‚}~‚ƒ‰t‚ˆwfjheik]a`_ba^ab_bbkpclrd¤Ĵ‘ĤŻ’š˘™ Žš ŽşÂ¨ğŞìîçîêhm\fjlPSSQTQRUU ¨”…Œz…‰}‡Œ}А““–{{ž¤™xi£İĞ˘­‹ İŽ£Œ†Œw{€‚„†`eY{y…Šˆ‡gm`ehf’šƒ’š„”›†”œ…Ğħħ´³Żµĥ’Œ™¤œ§ƒ™˘‡•˜twpqtv•›’˜—•š–X[XZ]Y³ğ ³ı·ż›  ŸĤÄ˵ĊÌ·UYNĤ‹˘İĦ¤ĞĦ§­£§­Ĥ‰‘w˜||p|€t[`TÌÒÀÔÙÉŻĥĦĴ²ŻĦސptityiAD@GIJLNK§ħ‘¨°—­µŸÀǰÈÏĵħ´Ż·ĵĴ„‰‡‹ˆ‹Š’—“˜œœˆy’—Ž˜Ÿ`cdkobcgiĦ§¤rwyY\SWZ\²ğŸäçŬ°·´Š’inplppšŸ =@@ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬœŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ7µwŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ„Äİ4ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ¸uĥƒŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬÂtŞ4fŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬÂ×rÑDÛÏŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ{·Ĥ~†)ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬZs3ŜÜBĴ RŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬǤİ! ŬŬ­dQh/ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŒğÎ<şXI.Ŭ–È@`ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬÒ"eŬŬW5ÖĵŬ_(,yiLŬŬŬŬŬŬŬŬŬŬŬŬŬĜ'*˘‘½Êş ÔĠ€;Y…0ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬE”qÌڍH1Ĉ£aĊ}ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ>šO:2xm³?]ŬF“ VŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬıĦ@²ĞŽŬA6vgŬŬGzMŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ­n™JŠŬ9ԝSž$pk8ÙŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ—\À%-b› ż|´j‰ UNÓŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŻl cħK°ÍÉC¨TÓŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ=[Á‡ˆ^ŬŬŬŬŬ‚ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ˜+‹P&˕#ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬo’Ÿ§ŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬŬ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙ƒ˙˙˙Á˙˙˙à˙˙˙˙ĝ˙˙ĝ˙˙˙à˙ĝ˙ŝ˙˙ ?˙à€˙˙˙˙˙Ù˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0 qweqwfTXZUXZĤŻ—§Ż—†y‡yu{pv{pX\XY\XrxhsxhšĦŠšĦ‹]`^\`_¨°—¨ħ˜€†ˆ†‰kpdlqd²ş ³şĦpttqtu’˜‰“™‰x}tx|u^b`_c`„‹u…Œtš˘ŒpumptoĦ§” Ĥ•VXSUYTĞħİаЭ´µ¤lppnrpĦݘ£Ğ™^abÀĈ´ÁÈħ”˜˜–›™qxetzg{€‚~‚ƒ|‚„€…|€†~‚‡А’Ž’‘ad`dgbħ¸Ğ³şŻnrtfj`dhekobhlfħ¸¸ĥğı‰y‹”y‰|şÁŞĵÄŻzp‚‡z’˜œ³ı·ĥ½µ§­Ħ¤ŞĤtzktym–Š[^] ŞˆĦݏrvp³ğ§~„s~ƒ{vzw„‰|‡Œİħ ­µĦıÀ§¤Ĵš§Żœˆ‘tœĦš –£•žĤ”•Š£˜mqnĥİĞ²ŻŻĥĴ ¨“¤Ğ—}„oĦ§İŻ żĊ³ıÀżħ·³ıżĵħ·Ĥ•””™˜Ÿ’ÊÑRUR‚‡…†‹†ˆŽ…†ŒŽ‰ŽŒx}lÌÒÀÚŜÑdijhlny}yGHHäèß²ğŸŽ•€ˆŒ´³kop8::ei_[_a˜ž ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜nŽ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜X„—˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜W5’#0˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜WRy™G•˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜aŒ9T‰˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜}36Fj"˜˜˜˜˜˜˜˜˜˜˜˜˜˜dewi*A,mJ <˜˜˜˜˜˜˜˜˜˜˜YN†˜@›Ek'‘˜˜˜˜˜˜˜˜˜W\ZCP1x(&r“_`˜˜˜˜˜˜˜˜˜˜˜M/:8pQSDœqK˜˜˜˜˜˜˜˜˜˜˜˜v`O…~‹+=tb]U˜˜˜˜˜˜˜˜˜˜˜˜gl ˜šŠI2[!˜˜˜˜˜˜˜˜˜˜˜˜hƒ‡s$Hˆ?;{f ˜˜˜˜˜˜˜˜˜˜˜˜˜u€”^ ˜V-7Lo4˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜–‚ >cB|˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜.%)z˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙‡˙˙˙Ç˙˙˙à?˙˙˙˙c˙˙ì1˙˙à˙˙ĝ˙˙˙˙ˆG˙˙à ˙˙ĝ}˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @„~…~~„t~…tw{yw|x}‚y|‚z—œ™—œ›‘—‹–Œy~qx}r~…v~„|„Šw‚ˆxˆŽ‹ŠŽtxpuzpv{rƒwlpkosn°·´³ş·˜ž‰™ŸŽzurxitynŒ’‘•–™ ›£ž¤Ÿ¨§­”𛓙œ•›–œŸ{€}|~Ħ¨’¤Ĵž‡Œ€Ÿ¨“qvgswlzo“š‘‘˜‡“™svr|ƒn°·ŸĴ³µgm^œ£ É·ÓĜËAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'AAAAAAAAAAAAAA@AAAAAAAAAAAAAA? *AAAAAAAAAAA>;- AAAAAAAAA4$7 9AAAAAAAA !5/1AAAAAAAAA0=6&,AAAAAAAAA23.#AAAAAAAAA%:" )8+AAAAAAAAAA( ?<İš¤ƒŭ—˙ı†ˆƒBž¤£ĦĞŒîœĤ†˙nrcŝ--+ô ›/997˘¨•“޳•ùsyhŝ!! ×i//. vvu2WWU=³ı§á[_Sûimaŭœ¨„˙]aUû‡ RTM&ĤĞš” ¨è İ‹˙v{kŭ%%#Ŭ_{tH޲˜×ŸİŒ˙[]Uĝ¸D ,-*Ÿ§ŽıĤŻ‘˙¨²“˙œ§„˙MOHĝlpe¨mqf˙dh[ôĴ² ïWXU2I##"Ÿ£•{Ħޏ܌”|ŭ:<5´Z***ž¤’Фġ˜¤~˙¨„˙lqbŭŞ Ğħ°Ÿİ‰˙MPFü ÉZ…xĤgk_÷Îu$’—ˆi­“Ó§­˜ù`bZùÂp0 qsm3¤Ş—¤Ş³–ó˘­‹˙lnfÑ000~ D›Ħ޳›Ĥƒú‰‘x˙562èNOJÁ–ˆÏв›òuylüσC rtlI˘¨•§˘¨“ïw{mŭDEBç"xxw,dg^E&&%3ğż²Á‡‹}ü784äĵMOGڒ›}˙Ĥˆ˙ORHĝ°897O—›Žrš ŒÄ•†ŭY[Uìžj4MNJ1™Ÿ‹˜­ĥ™üsxhŭğ888~ƒsa°¸žê§Ż•˙~„r˙qti˙°¸˙™¤˙†vŝ ™›•O”˜Š°İ§ž šŬTUQ·-}wK²ş íx|oüm***²µŞˆ™Ħ‡ĊĤ°‘ġžİ…˙›Ĥ˙Ĵµ—ŝ)*)µ! !!!‹Œ‹NHIFLݰš˙ħ  ```*–—’[sxjbjleWYSò'(%Ġğ“…………ˆHIG­KKJ‰HHH.ÄŻâ887˜ Ğ\­ĥ™ù£Œ˙Ĥˆ˙Ž—|˙—ž‡˙ Ĥ“˙˘¨•˙£¨–˙£‘úĦ¤šÈ888O†‡„"111]_Y/ĤĞ›“žĤÌ™|ϐ™|Ϙ †Ï’˜ƒÀ‡‹Œ896I ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙?˙˙˙˙˙˙€˙˙˙˙˙˙À˙˙˙˙˙à˙˙˙˙˙˙˙˙˙˙ĝ˙˙˙˙˙ü?˙˙˙˙ŝ˙˙˙˙ü˙˙˙˙ĝ˙˙˙˙ĝ˙˙˙?˙˙˙?˙˙˙ĝ?˙˙˙ü˙˙˙˙€˙˙˙˙à˙˙˙˙ĝ˙˙˙˙€˙˙˙˙€˙˙˙˙À˙˙˙˙˙˙˙˙˙˙˙˙˙˙À˙˙˙˙˙à˙˙˙˙˙ŝ˙˙˙˙˙˙˙˙˙˙˙˙À˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @ €H7STP=™ĦˆôTXKî@@?EÉÏĵŝÄ˵˙~„pû ”bd_&­´œċîê˙ÌÒÀ˙w~hû ”_a[9޲™ċìîç˙ĊÌ·˙~„pû …_a\8޲™ċäçŬ˙şÂ¨˙]cRö€998‚,-*–›E YZW.—Ÿ„ÌÔÙÉ˙·ż˙`eUŭ—‚ŝƒˆx İûejZö²F ;<9•}¸ÁȲ˙ğŞ˙€†s˙ şCC@X‘˜‚œˆôfk[ġ³[ AC:–ƒü³ğ ˙Ä˵˙‰‘yŝ½7EFC/ƒ‰vŠ–‡ĉ‚ˆvüVZOá230²(((z ^bV·ima썔|Íqui­ž§ŠêÀǰ˙­”˙BE=c†‰c‰~ökob˙^aXüdf`ż%rvjrŠ’yŝ=?:²!?@<ykë²ğŸ˙ıÁİ˙rwgĝŞ7_bYMš˘‰Ê”‚ŭko`÷572ΙB‹‚a“›€ùeiZô;<7ɐ—~,.)ÜadY…ž§ŠèıÁ¨˙³ı˙PSIë Jpsh­§Ż–˙˘­‹˙ŸİŠ˙Y[SŻ KLJ0|€sr–†”œ„ûš Ž˙ˆyŝxFHBƒy}oŝŸ¨ŒüÁÈħ˙·ĵĴ˙afXîBD>Ñ]`W°¨ŞĦ·…‰}ŭ²$ jleJšĦˆÌœ§ƒ˙BD?É|r€‡qŝħ•ħ£Ğĝ|p˙^aXŭPPOĞ#~‚tp’™ƒó;=6Ùf‡‹my|t£WZP쏘|˙MQEîR3512ˆŽyš˜ ‡ófkZù()&İ$UXP>˜ ‡Çx}kù$%#ĥ@ €‡s…ĤŻ‘ĝ™¤˙GJAé]|ożY\Sŝjmdf%%$ˆNmqer–ej[î))(ŻOmogF’™§ħ‘ŭ[]UÇuEG?— „óhm\ú:;6Ŭ€†rêvzmìbLOGm‘–…·y~oêGICÒm &6653›Ÿĥfk\íLMGôƒ‰t˙‰‘wŝ-.*Ô9:8Z‘–†–‡‹Òklhm340F“šƒ¸~ƒrùm ~v\’™ż§Ż”ó£Œ˙…‹vúh!"./-;‡ˆƒv(-”ƒıBC>ğ *** -.*;uyn´jp_ĝVZMçNQHĠWYSÓWYSÒ_bXÍqqo‹nqgQorivklh$‰{‘—|̆r˜Î}ƒp­XZSf ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙€˙˙À˙˙à˙˙˙˙à˙à˙à˙à˙ü˙˙À˙à˙ĝ˙˙˙˙À˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0 ` fi]:_cUÀH–œŠdËÑ˙…Œwĝdž˘“&żĊħäċèß˙ƒŠrĝd˜)ĵ­äÛßÒ˙{‚lġJ-:Ħ¤˜'Ż·žÌÒÀ˙nt`ó†w÷”‚èjo]ê')%„–™šĦ‰ÄÁÈħ˙†wü{™žY™˘‡żkp_è682’><=9W{qណìıÁ§ŭšĦŠŭ9;5§~v4š Žñknbŭnqiá@A?Ssvk7‡vöDE@Y ^bVŽ”ï³ğ˘˙]bTŬ Q‡}7Ÿ§ŽÈms`óKMDħižĦ•)•}Ġkq`äAC<˘ƒŠtç451™•‚”³ğĦŭ Ĥ”üUXNÂV•…Á²ğŸ˙ĦޏŝIKEnƒ…}&˘Ş‘‘ĤŻ”ġntaîac[gjn`ġ“›‚ĊşÁŞŭz~pŝUVPÙKKJJ‰Ž€µFI@ĵ1•šŠ1’€“_bY΋”zŝ)*%–Œ‘‚=›¤‰İv{iö;=6İžŽvx~lê-.*‹‰{8¤­‘߇sŭ/2+” ˆŽ{Ġ]`UêKMGs571ŠDF@J—€–hl^Ü/0-Š(hje Ħ¨‘r|‚o’kne²=?9‚Šqô]aTèmqc°knbÀSVNĞ\‰Ž}~~ƒsŜ46/štxj§˜˘Š‘{î Şˆ˙di[“ˆ6˜š”jPQNQNOJ“™†Í JOOO ƒ†|/‚†xğho\^cSĊimaÂhk`Ádfa“˘§—N3320UWR œ˘ŽZˆ‘um”~hjme5˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙€˙˙À˙˙à˙˙À˙˙À˙À˙à˙ü˙˙˙˙€˙˙˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(  @—œ‹˘txiŬ4‹WÔÙËù{oĉ-†‹zZÉĥôhm\âhl_Ĉ^bSşHY^Pd°·Ÿŝ{€oò?A9Žx~kŻ]aTÂ>@9r %NPH*ei[Úej[wŠ‘|ߗˆù791Žhka‚{oòOQI³=txmtyhŞ`eVÍx}löV[MİĦ¨’ŝ€…wĉMOG·“™…ßkoaÙKLG•{™_bXÌafVîpvd˜{oĉGJBŸpufz]aSÄGeiZ*“œ€ÄafWĈILCotd÷FH@´ILD˜[_RĞ[_TŞ)*'Zw|n†…qíy€jġ=?9mdf_|<=:]{€o­&'$OZ\ULpvdÔkp`Ĝ`dYħ^_[Aac\! ˙˙˙˙˙˙˙˙?˙˙˙˙˙˙˙˙˙€˙˙˙À?˙˙€˙˙€˙˙à˙˙ĝ˙˙ü˙˙˙€˙˙˙˙˙˙˙˙˙˙˙˙˙./sqliteodbc-0.992/sqliteodbc.ico0100644000076400001440000006224610551174416015373 0ustar chwusers 00hĈ è.è (ŝ 00¨& ¨ÎÈv$h>+00¨Ĥ0 ¨ NMHöYh>a(0`€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙ˆ†hw‚€xhwĝr€w˙ˆh÷ƒwv ˆˆ€w€xˆc€xhh‡ˆc€‡ĝr€wˆ†€xwxhwˆ‚ˆˆxwˆ`‡ˆ€ˆˆxwx†€xaw€ˆ€wx(x`ˆ†€†‡‡vw‡†c€ˆ‚€xxwv(x‡ˆ€xx†ˆh‡wv8‡wx€x‡pˆˆ÷ˆ(‡rXxˆ‡‚wˆ†ˆ€‚€x(‡wx€€w€€xhˆ‡€€xc€w†€ˆ‡€€x€xˆ‚xbˆ€€x€€wˆˆ‡ˆˆ‡‚ˆx†€px`ˆ†(xˆ8x€xˆxˆwx€x€xˆxpx€w†6†ˆhˆ€wˆˆxxxw‡‡‡˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙ƒ˙ùŒs˙˙öµ­˙€˙öµŻ˙€ö´o˙À?öµŻ˙à?öµ­˙yŒs˙ĝ˙˙˙ü˙˙˙ŝ˙˙˙˙À?˙˙˙x˙˙ü˙˙ĝx˙˙ĝp˙ĝÀ˙ü€˙˙€€?˙˙à˙˙ĝ˙˙˙˙˙˙Á`˙˙ÀÀ˙˙˙˙ŭ˙˙˙€0a˙˙˙à?q˙˙˙ü ˙˙˙˙˙˙˙˙À?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @€€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙hwx`÷ˆwx€÷hˆˆ‡vˆˆ8wˆ‡†ˆ‡x`ˆc€ˆˆ‡ƒ€xˆ€ˆˆwcˆ†ˆˆˆ†ˆwhˆxˆˆˆˆˆwc‡…xˆˆˆˆ€x(ˆˆ€xhxˆxhˆˆˆˆˆxxˆ†8ˆ‡ˆˆˆˆ†‡ˆˆx€‡ˆ€€€ˆhˆ‡px‡‡˙˙˙˙˙˙˙˙˙óç˙ík[˙ík_żíhߏík_ík[ƒóçÁ˙˙˙à˙˙˙˙ĝ˙˙ĝ˙˙˙à˙ĝ˙ŝ˙˙ ?˙à€˙˙˙˙˙Ù˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0€€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙€‡†ĝ€w€ˆvˆhwˆwˆ€ˆx`ˆ€x€‡† xcˆˆwx8x€ˆˆ‡ˆˆ€ˆgˆ€x€ˆhˆx€xˆˆˆˆˆ€ˆ€w€xˆˆˆxp˙˙˙˙³;˙UU˙U7żUU³;‡˙˙Ç˙˙à?˙˙c˙ì1˙à˙ĝ˙˙ˆG˙à ˙ĝ}˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( À€€€€€€€€€ÀÀÀ€€€˙˙˙˙˙˙˙˙˙˙˙˙xw€xˆ€‡ˆˆ€ˆˆˆˆˆˆxˆ€xhˆˆpxˆˆˆ€ˆˆˆ‡xˆp˙˙˙˙˙˙?˙˙˙ÀÀ?Àü˙˙Á˙˙˙˙˙˙(0`€ †‰¨˘ŒŠİħ ıżĵ‰–†UYZ:<<]aVĦĴŠ‘–ŠknmâċÚéìĴ´“™œfia°·£Ÿİ‰Ĥ™Ĥ‰š‚˘İ’…‰…]`YJLMim`lqbmqe•|ʽ@BAĴ²İ´şħx{qHJE}‚„qtu465<==ĥ½½tx{699“œ~>ABÈÎş™žœ–œ‰RUMuzl޳•š˘Œ8::…Šµşĥ‘–™˘¨•Ĥ•°ĥĞFIE²ıWZ\~„q¨²’´½˘ĥ½µ˘ĤĦMPGĤ°ad]¤QTUZ\Xuzj‰‘yşÂİĊDED|ƒmĞħİôġñ†ŒŽ˜ …œĤ…ĥ˘ŻĥĤ ¨Žeik,.-˜¤~lprZ\U˘ĴŒ—]ab°¸œŸ–ùúĝħ¸¸µğĵ޲žqth¤rvx685NPR<>@£ĴŽ³ğ œ¨„¤­“› £sxhŞ´”­ĥ™ħ¸´aeg– ‚°ÇÍıBD>EH>‚†€‚†…]_W£Œ Ğˆ İ‹ Ş‹°‘§ħ“§²’…ˆ‚ac^df^Żĥ³Ĵ³´ŻµĥħıĦħı˘³ğ£žİ…¨†žİ†ŸŞ†•†twuÔÙÉ×Ü͙Ÿ˜Ĥ­ ¤ŞĤŻ‘_ceħş²ğŸżĊ³ĵÀĥİ­Ĥħ¸ĞµğĴ^`_ċèŜşıÀżĵÁ½ƒˆx‡‹~–š”ƒ”›…А“““Ž”—UWPĦ œ˘¤ž¤ĤŒ…\_YZ]^PRKRUKPROIKHILJ022342355£Ğ˜¤ĞœĤœ£’›Ħ—|‚pƒwíïéhjcjmgkpa•˜‹“}Ĵµ—ĵЁ†v„‰w›£‰DEAACEBDE:<;@<ĥ\Ü,˜M…î)7–RœTö7C÷úcB-(SC4ùcäjCsRAXÔCsĈ P6Ê+&›^ì‘@Z¨] ‰H/¤ P%‘Ğó SĤXBFpZ+V2!ßï5x×BwĠYġWmT !kß3 /y^2Q1n_g=£vSÈ;Œ|FaÖhÄ)­ŸÇ{Şħ²’†€/MT˙ûĦAĴEĵ?"wJ9ğ ƒa 4É,hšÏ°OCU%l\L ñf€Ny;El&0 ÍxxG"ÁKOJ]&Dp / ;ˆ,+0nÜŬMËŜh1NX)$‚F•ëşI9e<269* [ #jçHmĊ~7WĴÑÛA´k _l*"éU½>4r +˘ o `#K6&dVÓšAU·?ĉ}Ż8z.èH[oĝ>E—,\ufG '<â íiYċL! b3 v‹Ĝê3ı?Šİ=(-¸.quÀ“‡I+QtrÒٍ;@ga[Î?ŭÚ8D”dŽ$i§ż„Ìeïáeôµ!››››`'àž'ŝtò:: q#55:b™³˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙ƒ˙ŝc˙˙ŭ­k€˙ŭ­k˙€ŭ­˙À?ŭ­k˙à?ŭ­k~c˙ĝ˙˙˙ü˙˙˙ŝ˙˙˙˙À?˙˙˙x˙˙ü˙˙ĝx˙˙ĝp˙ĝÀ˙ü€˙˙€€?˙˙à˙˙ĝ˙˙˙˙˙˙Á`˙˙ÀÀ˙˙˙˙ŭ˙˙˙€0a˙˙˙à?q˙˙˙ü ˙˙˙˙˙˙˙˙À?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @€¨İjmijniÁÈħÁȲ˘Ş—£Ş—PRMQRMin^in_ıÁ¨ıÁİš˘Žš˘ĦݘĦİ™Y\^Y]^MPPNPQ`eU`fV §š Ĥ›—‚–ƒ‘–™‘—šGIFFIG‰‘yŠ’yž¤˘Ÿ˘rvpswp”œ”‚hm^im_lrbmrcz~€z{ŸİŠŸ¨Œ€‡q€†s…q…sš˘Š›£‹Z]]”ˆ•ŠŒŠŒ’‹­³²Ĵ²³^aX_bYĦ¨˘İœ}‚„ƒ„ĤĴ¨§­İy~my}oPTMRUM•›œ”š•›ž]`\^a^be_cg^€…ˆ‚‡‰„t„wx|z~~­”§Ż–•ŸĤ•Ÿ§–wzzv{}£Ğ˜}€}~‚}~‚ƒ‰t‚ˆwfjheik]a`_ba^ab_bbkpclrd¤Ĵ‘ĤŻ’š˘™ Žš ŽşÂ¨ğŞìîçîêhm\fjlPSSQTQRUU ¨”…Œz…‰}‡Œ}А““–{{ž¤™xi£İĞ˘­‹ İŽ£Œ†Œw{€‚„†`eY{y…Šˆ‡gm`ehf’šƒ’š„”›†”œ…Ğħħ´³Żµĥ’Œ™¤œ§ƒ™˘‡•˜twpqtv•›’˜—•š–X[XZ]Y³ğ ³ı·ż›  ŸĤÄ˵ĊÌ·UYNĤ‹˘İĦ¤ĞĦ§­£§­Ĥ‰‘w˜||p|€t[`TÌÒÀÔÙÉŻĥĦĴ²ŻĦސptityiAD@GIJLNK§ħ‘¨°—­µŸÀǰÈÏĵħ´Ż·ĵĴ„‰‡‹ˆ‹Š’—“˜œœˆy’—Ž˜Ÿ`cdkobcgiĦ§¤rwyY\SWZ\²ğŸäçŬ°·´Š’inplppšŸ =@@œ7µw„Äİ4¸uĥƒÂtŞ4fÂ×rÑDÛÏ{·Ĥ~†)Zs3ŜÜBĴ RǤİ! ­dQh/ŒğÎ<şXI.–È@`Ò"eW5Öĵ_(,yiLĜ'*˘‘½Êş ÔĠ€;Y…0E”qÌڍH1Ĉ£aĊ}>šO:2xm³?]F“ VıĦ@²ĞŽA6vgGzM­n™JŠ9ԝSž$pk8ٗ\À%-b› ż|´j‰ UNÓŻl cħK°ÍÉC¨TÓ=[Á‡ˆ^‚˜+‹P&˕#o’Ÿ§˙˙˙˙˙˙˙˙˙óç˙ík[˙ík_żíhߏík_ík[ƒóçÁ˙˙˙à˙˙˙˙ĝ˙˙ĝ˙˙˙à˙ĝ˙ŝ˙˙ ?˙à€˙˙˙˙˙Ù˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0 qweqwfTXZUXZĤŻ—§Ż—†y‡yu{pv{pX\XY\XrxhsxhšĦŠšĦ‹]`^\`_¨°—¨ħ˜€†ˆ†‰kpdlqd²ş ³şĦpttqtu’˜‰“™‰x}tx|u^b`_c`„‹u…Œtš˘ŒpumptoĦ§” Ĥ•VXSUYTĞħİаЭ´µ¤lppnrpĦݘ£Ğ™^abÀĈ´ÁÈħ”˜˜–›™qxetzg{€‚~‚ƒ|‚„€…|€†~‚‡А’Ž’‘ad`dgbħ¸Ğ³şŻnrtfj`dhekobhlfħ¸¸ĥğı‰y‹”y‰|şÁŞĵÄŻzp‚‡z’˜œ³ı·ĥ½µ§­Ħ¤ŞĤtzktym–Š[^] ŞˆĦݏrvp³ğ§~„s~ƒ{vzw„‰|‡Œİħ ­µĦıÀ§¤Ĵš§Żœˆ‘tœĦš –£•žĤ”•Š£˜mqnĥİĞ²ŻŻĥĴ ¨“¤Ğ—}„oĦ§İŻ żĊ³ıÀżħ·³ıżĵħ·Ĥ•””™˜Ÿ’ÊÑRUR‚‡…†‹†ˆŽ…†ŒŽ‰ŽŒx}lÌÒÀÚŜÑdijhlny}yGHHäèß²ğŸŽ•€ˆŒ´³kop8::ei_[_a˜ž nŽX„—W5’#0WRy™G•aŒ9T‰}36Fj"dewi*A,mJ <YN†@›Ek'‘W\ZCP1x(&r“_`M/:8pQSDœqKv`O…~‹+=tb]Ugl šŠI2[!hƒ‡s$Hˆ?;{f u€”^ V-7Lo4–‚ >cB|.%)z˙˙˙˙³;˙UU˙U7żUU³;‡˙˙Ç˙˙à?˙˙c˙ì1˙à˙ĝ˙˙ˆG˙à ˙ĝ}˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @„~…~~„t~…tw{yw|x}‚y|‚z—œ™—œ›‘—‹–Œy~qx}r~…v~„|„Šw‚ˆxˆŽ‹ŠŽtxpuzpv{rƒwlpkosn°·´³ş·˜ž‰™ŸŽzurxitynŒ’‘•–™ ›£ž¤Ÿ¨§­”𛓙œ•›–œŸ{€}|~Ħ¨’¤Ĵž‡Œ€Ÿ¨“qvgswlzo“š‘‘˜‡“™svr|ƒn°·ŸĴ³µgm^œ£ É·ÓĜË'@? *>;- 4$7 9 !5/10=6&,23.#%:" )8+( <˙˙˙˙˙˙?˙˙˙ÀÀ?Àü˙˙Á˙˙˙˙˙˙(0`€‡Œ|³ĵ im` ›˘Žğާ²’˜Ÿˆ+,* ”×ÜÍôġñħş˜Ħ…')%а Ż¸›ñóîùúĝµ½˘”%'#а Ş³”îêúúù²ğŸ˜Ħƒ()&аĦŞ´•êíċġöòݳ“Ħݏ##"Ĵħ˘Ş´”ĉÜíï颭‹|ƒm ݳĤĦĴ‹ÙŜèëâžİ†…p §Ğlpd‚‡v–‡VXP‚‡w£­ÈÏğċèŜĦĴŠ}„nIKD­ĥœvxq­´žİ†”ƒRUMœŸ–›¤…µ£áäÙĤħ¤­“''%§ŞĦвš¨…–ž„OQI 783™ ŠĤ°ĜŬδ½Ħ– ‚24/{~s§—˘ĞŒ˜ †\`U()'im^uzk°·ĦĦĴŠÈÎşÇÍı˘ĴŒPSIXYT–šŒ•›‡³ğĦ‘—‚osf:<7JJI'''QSLfib­“ħı jmcĤ°°ıœÒ×Ĉ¤Ž|‚p!!!ş½ħnrghjcDG=“—‹£§™~€|564’šŸŞ†tvnPRKİħ™ ĞˆÉÏğşÂİ™Ħ†683?@?Ĥ­˜¨²’”›…KNE–›‹— ‚SUO450…x°°ıœËÑżŞ³—jo`žĦ˜¤Ĵ“¤ĤŻ‘„‰wPRK**)ĤŞœœ§…mqc9;7¤Š‘zsun˘Ş ĞˆżĈŻÇÍıĤ–HKCmoj’—ˆĵа°›£‰RTM‚„~—‰žĤŽ²ğŸž§‹uzj785NPK›§‚WZRGGFw{l­’˘­‹ÈÎşÊĵĤ­–bd\ori³ğ ³ĵ ·żşÂİ‹“|Z\U˘›Ĵ³œ¤ŻŽ•œˆĊ ¨ŽKLGxzradYŸİ‰§ħÔÙÉÎÓÂĦ¨’lqa<=9 ž›Ż³ĤSVM Ÿ˘™§Ż•ĦĴ‰™Y\R³˘Ÿİˆ+,)GGF£Ż£ĴŽƒw]_Wmqd‰Š…///€~¨Ż˜”›…;<7vvvĦ§”¨ħ“„ˆ{>?<š¤ƒ—†ˆƒž¤ĦĞŒœĤ†nrc--+ 997˘¨•޳•syh!! //.vvuWWU³ı§[_Simaœ¨„]aURTMĤĞš ¨ İ‹v{k%%#{t޲˜ŸİŒ[]U,-*Ÿ§ŽĤŻ‘¨²“œ§„MOHlpemqfdh[Ĵ² WXU##"Ÿ£•ĦޏŒ”|:<5***ž¤’¤˜¤~¨„lqbĞħŸİ‰MPF …xgk_’—ˆ­“§­˜`bZqsm¤Ş—޳–˘­‹lnf000 ›ĦŽ›Ĥƒ‰‘x562NOJ–ˆĞ²›uylrtl˘¨•˘¨“w{mDEBxxwdg^&&%ğż²‡‹}784MOG’›}ĤˆORH897—›Žš Œ•†Y[UMNJ™Ÿ‹­ĥ™sxh888~ƒs°¸ž§Ż•~„rqti°¸™¤†v™›•”˜Š°İž šTUQ}w²ş x|o***²µŞ™Ħ‡Ĥ°‘žİ…›ĤĴµ—)*)!!!‹Œ‹HIFݰš```–—’sxjjleWYS'(%HIGKKJHHHÄŻ887Ğ­ĥ™£ŒĤˆŽ—|—ž‡ Ĥ“˘¨•£¨–£‘Ħ¤š888†‡„111]_YĤĞ›žĤ™|™|˜ †’˜ƒ‡‹896˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ï˙˙˙˙˙˙ùŒs˙˙öµ­˙˙öµŻ˙ö´o˙?öµŻ˙€öµ­˙ÀyŒs˙à˙˙˙˙˙˙ĝ˙˙˙ü?˙˙ŝ˙˙ü˙˙ĝ˙˙ĝ˙?˙?˙ĝ?˙ü˙˙€˙˙à˙˙ĝ˙˙€˙˙€˙˙À˙˙˙˙˙˙˙˙À˙˙˙à˙˙˙ŝ˙˙˙˙˙˙˙˙À˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @€ STP™ĦˆTXK@@?ÉÏĵÄ˵~„p bd_­´œîêÌÒÀw~h _a[޲™ìîçĊÌ·~„p _a\޲™äçŬşÂ¨]cR998,-*YZW—Ÿ„ÔÙÉ·ż`eU—‚ƒˆx İejZ;<9•}ÁÈ²ğŞ€†s CC@‘˜‚œˆfk[AC:–ƒ³ğ Ä˵‰‘yEFCƒ‰v–‡‚ˆvVZO230(((^bVima”|quiž§ŠÀǰ­”BE=†‰‰~kob^aXdf`rvjŠ’y=?:?@]`W¨ŞĦ…‰}jlešĦˆœ§ƒBD?|r€‡q•£Ğ|p^aXPPO~‚t’™ƒ;=6‡‹y|tWZP˜|MQE351ˆŽy˜ ‡fkZ()&UXP˜ ‡x}k$%#€‡sĤŻ‘™¤GJA|oY\Sjmd%%$mqe–ej[))(mog’™§ħ‘[]UEG?— „hm\:;6€†rvzmLOG‘–…y~oGIC665›Ÿfk\LMGƒ‰t‰‘w-.*9:8‘–†‡‹klh340“šƒ~ƒr~v’™§Ż”£Œ…‹v./-‡ˆƒ”ƒBC>***-.*uynjp_VZMNQHWYSWYS_bXqqonqgoriklh‰{—|†r˜}ƒpXZS˙˙˙˙˙˙˙˙˙óç˙ík[˙ík_íhßík_ík[óç€˙˙À˙˙à˙˙˙˙à˙à˙à˙à˙ü˙˙À˙à˙ĝ˙˙˙˙À˙˙ĝ˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙(0 fi]_cU–œŠËхŒwž˘“żĊħċè߃Šr˜ĵ­ÛßÒ{‚lĦ¤˜Ż·žÌÒÀnt`†w”‚jo]')%–™šĦ‰ÁÈħ†w™ž™˘‡kp_682<=9{qžŽıÁ§šĦŠ9;5~vš Žknbnqi@A?svk‡vDE@^bV”³ğ˘]bT ‡}Ÿ§Žms`KMDžĦ••}kq`AC<ƒŠt451•‚³ğĦ Ĥ”UXN•…²ğŸĦޏIKEƒ…}˘Ş‘ĤŻ”ntaac[jn`“›‚şÁŞz~pUVPKKJ‰Ž€FI@•šŠ’€_bY‹”z)*%Œ‘‚›¤‰v{i;=6žŽx~l-.*‰{¤­‘‡s/2+ˆŽ{]`UKMG571DF@—€hl^/0-hjeĦ¨‘|‚okne=?9‚Šq]aTmqcknbSVN‰Ž}~ƒs46/txj§˜Š‘{ Şˆdi[“ˆ˜š”PQNNOJ“™† OOOƒ†|‚†xho\^cSimahk`dfa˘§—332UWRœ˘Žˆ‘u”~jme˙˙˙˙³;˙UUżU7UU³;˙˙€˙À˙à˙À˙ÀÀàü˙˙€˙˙ü˙˙˙˙˙˙˙˙˙˙˙˙˙˙( @—œ‹txi‹ÔÙË{o†‹zÉĥhm\hl_^bSY^P°·Ÿ{€o?A9x~k]aT>@9 NPHei[ej[Š‘|—ˆ791hka{oOQItxmtyh`eVx}lV[MĦ¨’€…wMOG“™…koaKLG•{_bXafVpvd{oGJBpuf]aSeiZ“œ€afWILCotdFH@ILD[_R[_T)*'w|n…qy€j=?9df_<=:{€o&'$Z\Upvdkp``dY^_[ac\˙˙˙˙?˙˙˙€˙À?€€àĝü˙€˙˙˙˙˙./sqliteodbc-0.992/sqliteodbc.nsi0100644000076400001440000002052612062622025015376 0ustar chwusers; NSIS Config (http://nsis.sf.net) ; ; Run it with ; ; .../makensis [-DWITH_SOURCES] [-DWITH_SQLITE_DLLS] this-file.nsi ; ; to create the installer sqliteodbc.exe ; ; If -DWITH_SOURCES is specified, source code is included. ; If -DWITH_SQLITE_DLLS is specified, separate SQLite DLLs ; are packaged which allows to exchange these independently ; of the ODBC drivers in the Win32 system folder. ; ------------------------------- ; Start BrandingText " " !ifdef WITH_SEE Name "SQLite ODBC Driver (SEE)" !else Name "SQLite ODBC Driver" !endif !ifdef WITH_SEE !define PROD_NAME "SQLite ODBC Driver (SEE)" !define PROD_NAME0 "SQLite ODBC Driver (SEE)" !else !define PROD_NAME "SQLite ODBC Driver" !define PROD_NAME0 "SQLite ODBC Driver" !endif CRCCheck On !include "MUI.nsh" !include "Sections.nsh" ;-------------------------------- ; General OutFile "sqliteodbc.exe" ;-------------------------------- ; Folder selection page InstallDir "$PROGRAMFILES\${PROD_NAME0}" ;-------------------------------- ; Modern UI Configuration !define MUI_ICON "sqliteodbc.ico" !define MUI_UNICON "sqliteodbc.ico" !define MUI_WELCOMEPAGE_TITLE "SQLite ODBC Installation" !define MUI_WELCOMEPAGE_TEXT "This program will guide you through the \ installation of SQLite ODBC Driver.\r\n\r\n$_CLICK" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "license.txt" !insertmacro MUI_PAGE_DIRECTORY !ifndef WITHOUT_TCCEXT !insertmacro MUI_PAGE_COMPONENTS !endif !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_TITLE "SQLite ODBC Installation" !define MUI_FINISHPAGE_TEXT "The installation of SQLite ODBC Driver is complete.\ \r\n\r\n$_CLICK" !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ; Language !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ; Installer Sections Section "-Main (required)" InstallationInfo ; Add files SetOutPath "$INSTDIR" !ifdef WITH_SEE File "sqlite3odbc${WITH_SEE}.dll" !else File "sqlite3odbc.dll" !endif ; unsupported non-WCHAR driver for SQLite3 !ifdef WITH_SEE File "sqlite3odbc${WITH_SEE}nw.dll" !else File "sqlite3odbcnw.dll" !endif !ifndef WITHOUT_SQLITE3_EXE File "sqlite3.exe" !endif File "inst.exe" File "instq.exe" File "uninst.exe" File "uninstq.exe" File "adddsn.exe" File "remdsn.exe" File "addsysdsn.exe" File "remsysdsn.exe" ; File "SQLiteODBCInstaller.exe" ; SQLite 3.4.* ; File "sqlite3_mod_fts1.dll" ; File "sqlite3_mod_fts2.dll" ; SQLite 3.5.* File "sqlite3_mod_fts3.dll" File "sqlite3_mod_blobtoxy.dll" File "sqlite3_mod_impexp.dll" File "sqlite3_mod_csvtable.dll" ; SQLite 3.6.* File "sqlite3_mod_rtree.dll" File "sqlite3_mod_extfunc.dll" File "sqlite3_mod_zipfile.dll" File "license.terms" File "license.txt" File "README" File "readme.txt" !ifdef WITH_SQLITE_DLLS File "sqlite3.dll" !endif ; Shortcuts SetOutPath "$SMPROGRAMS\${PROD_NAME0}" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Re-install ODBC Drivers.lnk" \ "$INSTDIR\inst.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Remove ODBC Drivers.lnk" \ "$INSTDIR\uninst.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Uninstall.lnk" \ "$INSTDIR\uninstall.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\View README.lnk" \ "$INSTDIR\readme.txt" SetOutPath "$SMPROGRAMS\${PROD_NAME0}\Shells" !ifndef WITHOUT_SQLITE3_EXE CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 3.lnk" \ "$INSTDIR\sqlite3.exe" !endif ; Write uninstall information to the registry WriteRegStr HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" \ "DisplayName" "${PROD_NAME} (remove only)" WriteRegStr HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" \ "UninstallString" "$INSTDIR\Uninstall.exe" SetOutPath "$INSTDIR" WriteUninstaller "$INSTDIR\Uninstall.exe" ExecWait '"$INSTDIR\instq.exe"' SectionEnd !ifndef WITHOUT_SQLITE2 Section /o "SQLite 2 Drivers" Sqlite2Install SetOutPath "$INSTDIR" File "sqliteodbc.dll" File "sqliteodbcu.dll" File "sqlite.exe" File "sqliteu.exe" !ifdef WITH_SQLITE_DLLS File "sqlite.dll" File "sqliteu.dll" !endif CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 2.lnk" \ "$INSTDIR\sqlite.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 2 (UTF-8).lnk" \ "$INSTDIR\sqliteu.exe" ExecWait '"$INSTDIR\instq.exe"' SectionEnd !endif !ifdef WITH_SOURCES Section /o "Source Code" SourceInstall SetOutPath "$INSTDIR\source" File "source\README" File "source\VERSION" File "source\ChangeLog" File "source\license.terms" File "source\header.html" File "source\footer.html" File "source\stylesheet.css" File "source\doxygen.conf" File "source\adddsn.c" File "source\inst.c" File "source\fixup.c" File "source\mkopc.c" File "source\mkopc3.c" File "source\sqliteodbc.c" File "source\sqliteodbc.h" File "source\sqliteodbc.rc" File "source\sqliteodbc.mak" File "source\sqliteodbc.def" File "source\sqliteodbcu.def" File "source\sqliteodbc.spec" File "source\sqliteodbc.spec.in" File "source\sqlite3odbc.c" File "source\sqlite3odbc.h" File "source\sqlite3odbc.rc" File "source\sqlite3odbc.mak" File "source\sqlite3odbc.def" File "source\sqlite.mak" File "source\sqlite3.mak" File "source\resource.h.in" File "source\install-sh" File "source\Makefile.in" File "source\configure.in" File "source\config.guess" File "source\config.sub" File "source\ltmain.sh" File "source\libtool" File "source\aclocal.m4" File "source\configure" File "source\sqliteodbcos2.rc" File "source\sqliteodbcos2.def" File "source\makefile.os2" File "source\resourceos2.h" File "source\README.OS2" File "source\README.ic" File "source\drvdsninst.sh" File "source\drvdsnuninst.sh" File "source\Makefile.mingw-cross" File "source\mf-sqlite.mingw-cross" File "source\mf-sqlite3.mingw-cross" File "source\mf-sqlite3fts.mingw-cross" File "source\mf-sqlite3rtree.mingw-cross" File "source\mingw-cross-build.sh" File "source\sqliteodbc.nsi" ; File "source\SQLiteODBCInstaller.c" File "source\blobtoxy.c" File "source\blobtoxy.rc" File "source\impexp.c" File "source\sqlite.ico" File "source\sqliteodbc.ico" File "source\tcc-0.9.23.patch" File "source\tcc-0.9.24.patch" File "source\sqlite+tcc.c" File "source\strict_typing.sql" File "source\README.sqlite+tcc" SetOutPath "$INSTDIR\source\missing" File "source\missing/ini.h" File "source\missing/log.h" SetOutPath "$INSTDIR\source\tccex" File "source\tccex\README.bench" File "source\tccex\obench.c" File "source\tccex\sbench.c" File "source\tccex\sqlite.c" File "source\tccex\sqlite3.c" File "source\tccex\samplext.c" SetOutPath "$INSTDIR\source\tccex\a10n" File "source\tccex\a10n\README.txt" SectionEnd !endif !ifndef WITHOUT_TCCEXT Section /o "SQLite+TCC" TccInstall SetOutPath "$INSTDIR\TCC" File "README.sqlite+tcc" File "sqlite+tcc.dll" File "strict_typing.sql" File "TCC\tcc.exe" File "TCC\tiny_impdef.exe" File "TCC\tiny_libmaker.exe" File /r "TCC\doc" File /r "TCC\include" File /r "TCC\lib" File /r "TCC\libtcc" SetOutPath "$INSTDIR\TCC\samples" File "tccex/samplext.c" File "tccex/sqlite.c" File "tccex/sqlite3.c" File "tccex/obench.c" File "tccex/sbench.c" File "tccex/README.bench" SetOutPath "$INSTDIR\TCC\samples\a10n" File "sqlite3/sqlite3.c" File "sqlite3/src/test_vfstrace.c" ; deprecated as of 3.5.1 ; File "sqlite3/sqlite3internal.h" File "tccex/a10n/README.txt" SectionEnd !endif !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !ifndef WITHOUT_SQLITE2 !insertmacro MUI_DESCRIPTION_TEXT ${Sqlite2Install} \ "Drivers and utilities for SQLite Version 2" !endif !ifdef WITH_SOURCES !insertmacro MUI_DESCRIPTION_TEXT ${SourceInstall} \ "Source code" !endif !ifndef WITHOUT_TCCEXT !insertmacro MUI_DESCRIPTION_TEXT ${TccInstall} \ "Experimental combination of SQLite and TinyCC" !endif !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ; Uninstaller Section Section "Uninstall" ExecWait '"$INSTDIR\uninstq.exe"' ; Delete Files RMDir /r "$INSTDIR\*" RMDir /r "$INSTDIR\*.*" ; Remove the installation directory RMDir /r "$INSTDIR" ; Remove start menu/program files subdirectory RMDir /r "$SMPROGRAMS\${PROD_NAME0}" ; Delete Uninstaller And Unistall Registry Entries DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PROD_NAME0}" DeleteRegKey HKEY_LOCAL_MACHINE \ "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" SectionEnd ;-------------------------------- ; EOF ./sqliteodbc-0.992/sqliteodbc_w64.nsi0100644000076400001440000001145412062622035016077 0ustar chwusers; NSIS Config (http://nsis.sf.net) ; for Win64 drivers ; ; Run it with ; ; .../makensis [-DWITH_SQLITE_DLLS] this-file.nsi ; ; to create the installer sqliteodbc_w64.exe ; ; If -DWITH_SQLITE_DLLS is specified, separate SQLite DLLs ; are packaged which allows to exchange these independently ; of the ODBC drivers in the Win64 system folder. ; ------------------------------- ; Start BrandingText " " !ifdef WITH_SEE Name "SQLite3 ODBC Driver (SEE) for Win64" !else Name "SQLite3 ODBC Driver for Win64" !endif !ifdef WITH_SEE !define PROD_NAME "SQLite ODBC Driver (SEE) for Win64" !define PROD_NAME0 "SQLite ODBC Driver (SEE) for Win64" !else !define PROD_NAME "SQLite ODBC Driver for Win64" !define PROD_NAME0 "SQLite ODBC Driver for Win64" !endif CRCCheck On !include "MUI.nsh" !include "Sections.nsh" ;-------------------------------- ; General OutFile "sqliteodbc_w64.exe" ;-------------------------------- ; Folder selection page InstallDir "$PROGRAMFILES64\${PROD_NAME0}" ;-------------------------------- ; Modern UI Configuration !define MUI_ICON "sqliteodbc.ico" !define MUI_UNICON "sqliteodbc.ico" !define MUI_WELCOMEPAGE_TITLE "SQLite ODBC for Win64 Installation" !define MUI_WELCOMEPAGE_TEXT "This program will guide you through the \ installation of SQLite ODBC Driver.\r\n\r\n$_CLICK" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "license.txt" !insertmacro MUI_PAGE_DIRECTORY !ifndef WITHOUT_SQLITE2 !insertmacro MUI_PAGE_COMPONENTS !endif !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_TITLE "SQLite ODBC for Win64 Installation" !define MUI_FINISHPAGE_TEXT "The installation of SQLite ODBC Driver is complete.\ \r\n\r\n$_CLICK" !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ; Language !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ; Installer Sections Section "-Main (required)" InstallationInfo ; Add files SetOutPath "$INSTDIR" !ifdef WITH_SEE File "sqlite3odbc${WITH_SEE}.dll" !else File "sqlite3odbc.dll" !endif ; unsupported non-WCHAR driver for SQLite3 !ifdef WITH_SEE File "sqlite3odbc${WITH_SEE}nw.dll" !else File "sqlite3odbcnw.dll" !endif !ifndef WITHOUT_SQLITE3_EXE File "sqlite3.exe" !endif File "inst.exe" File "instq.exe" File "uninst.exe" File "uninstq.exe" File "adddsn.exe" File "remdsn.exe" File "addsysdsn.exe" File "remsysdsn.exe" File "sqlite3_mod_fts3.dll" File "sqlite3_mod_blobtoxy.dll" File "sqlite3_mod_impexp.dll" File "sqlite3_mod_csvtable.dll" File "sqlite3_mod_rtree.dll" File "sqlite3_mod_extfunc.dll" File "sqlite3_mod_zipfile.dll" File "license.terms" File "license.txt" File "README" File "readme.txt" !ifdef WITH_SQLITE_DLLS File "sqlite3.dll" !endif ; Shortcuts SetOutPath "$SMPROGRAMS\${PROD_NAME0}" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Re-install ODBC Drivers.lnk" \ "$INSTDIR\inst.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Remove ODBC Drivers.lnk" \ "$INSTDIR\uninst.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Uninstall.lnk" \ "$INSTDIR\uninstall.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\View README.lnk" \ "$INSTDIR\readme.txt" SetOutPath "$SMPROGRAMS\${PROD_NAME0}\Shells" !ifndef WITHOUT_SQLITE3_EXE CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 3.lnk" \ "$INSTDIR\sqlite3.exe" !endif ; Write uninstall information to the registry WriteRegStr HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" \ "DisplayName" "${PROD_NAME} (remove only)" WriteRegStr HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" \ "UninstallString" "$INSTDIR\Uninstall.exe" SetOutPath "$INSTDIR" WriteUninstaller "$INSTDIR\Uninstall.exe" ExecWait '"$INSTDIR\instq.exe"' SectionEnd !ifndef WITHOUT_SQLITE2 Section /o "SQLite 2 Drivers" Sqlite2Install SetOutPath "$INSTDIR" File "sqliteodbc.dll" File "sqliteodbcu.dll" File "sqlite.exe" File "sqliteu.exe" !ifdef WITH_SQLITE_DLLS File "sqlite.dll" File "sqliteu.dll" !endif CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 2.lnk" \ "$INSTDIR\sqlite.exe" CreateShortCut "$SMPROGRAMS\${PROD_NAME0}\Shells\SQLite 2 (UTF-8).lnk" \ "$INSTDIR\sqliteu.exe" ExecWait '"$INSTDIR\instq.exe"' SectionEnd !endif ;-------------------------------- ; Uninstaller Section Section "Uninstall" ExecWait '"$INSTDIR\uninstq.exe"' ; Delete Files RMDir /r "$INSTDIR\*" RMDir /r "$INSTDIR\*.*" ; Remove the installation directory RMDir /r "$INSTDIR" ; Remove start menu/program files subdirectory RMDir /r "$SMPROGRAMS\${PROD_NAME0}" ; Delete Uninstaller And Unistall Registry Entries DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PROD_NAME0}" DeleteRegKey HKEY_LOCAL_MACHINE \ "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROD_NAME0}" SectionEnd ;-------------------------------- ; EOF ./sqliteodbc-0.992/SQLiteODBCInstaller.c0100644000076400001440000006226711733002772016362 0ustar chwusers/* SQLiteODBCInstaller: -------------------- Installs SQLiteODBC Driver. Contact: Fjord-e-design GmbH, Kanzleistr. 91-93, D-24943 Flensburg Telephone: +49 (0)461/480897-80, (Germany) Fax: +49 (0)461/480897-81 (Germany) EMail: hinrichsen@fjord-e-design.com WWW: http://www.fjord-e-design.com ----------------------------------------------------------------------- - History -------------------------------------------------------------- Version 1.0: 2006-08-11 by fjord-e-design GmbH - Initial release. Version 1.1: 2006-08-14 by fjord-e-design GmbH - Change license from GNU to BSD. - Replaced rundll32 to direct DLL access. ----------------------------------------------------------------------- - LICENSE ------------------------------------------------------------- Copyright (c) 2006, fjord-e-design GmbH All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the fjord-e-design nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------- */ #include "stdio.h" #include "direct.h" #include "string.h" #include "windows.h" // Version of Installer #define SQLINST_VERSION "1.2" // Known Argument Types #define SQLINST_ARGID_COUNT 9 #define SQLINST_ARGID_UNKNOWN (-1) #define SQLINST_ARGID_HELP (0) #define SQLINST_ARGID_VERSION (1) #define SQLINST_ARGID_INSTALL (2) #define SQLINST_ARGID_UNINSTALL (3) #define SQLINST_ARGID_ALL (4) #define SQLINST_ARGID_DRIVER (5) #define SQLINST_ARGID_QUIET (6) #define SQLINST_ARGID_SHOW_MSG_BOX (7) #define SQLINST_ARGID_DLL (8) // Some internel values.... #define SQLINST_MAX_BUFFER (1024) #define SQLINST_MAX_ARG_VALUE (5) #define SQLINST_MAX_ARGS (10) // Known driver #define SQLINST_DRIVER_COUNT (4) #define SQLINST_DRIVER_SQL2 (0x01) #define SQLINST_DRIVER_SQL2_UTF (0x02) #define SQLINST_DRIVER_SQL3 (0x04) #define SQLINST_DRIVER_DLL (0x08) // Actions: What have I todo? #define SQLINST_ACTION_NOT_KNOWN (0) #define SQLINST_ACTION_PRINT_HELP (1) #define SQLINST_ACTION_INSTALL (2) #define SQLINST_ACTION_UNINSTALL (3) // DLL-Function typedef UINT (CALLBACK* InstallFunc)(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow); typedef UINT (CALLBACK* UnInstallFunc)(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow); struct SQLiteDriverData_Struct { // Name for Argument const char *pArgOptionName; // SQLINST_DRIVER_* const unsigned char ArgFlag; // DriverName const char *pDriverName; // DSN-Name const char *pDSNName; // DLL-Name const char *pDLLName; }; // Define availably Driver (SQLINST_DRIVER_DLL = use given DLL) static const struct SQLiteDriverData_Struct g_SQLiteDriverData[SQLINST_DRIVER_COUNT] = \ { { "sql2" , SQLINST_DRIVER_SQL2 , "SQLite ODBC Driver" , "SQLite Datasource" , "sqliteodbc.dll" }, { "sql2u" , SQLINST_DRIVER_SQL2_UTF , "SQLite ODBC (UTF-8) Driver" , "SQLite UTF-8 Datasource" , "sqliteodbcu.dll" }, { "sql3" , SQLINST_DRIVER_SQL3 , "SQLite3 ODBC Driver" , "SQLite3 Datasource" , "sqlite3odbc.dll" }, { "" , SQLINST_DRIVER_DLL , "" , "" , "" } }; struct ArgData_Struct { // Name of the Arg const char *pArgName; // The id const char ArgID; // Commet const char *pArgComment; }; static const struct ArgData_Struct g_ArgData[SQLINST_ARGID_COUNT] =\ { { "h", SQLINST_ARGID_HELP , "-h = print help" }, { "v", SQLINST_ARGID_VERSION , "-v = print version" }, { "i", SQLINST_ARGID_INSTALL , "-i = install" }, { "u", SQLINST_ARGID_UNINSTALL , "-u = uninstall" }, { "a", SQLINST_ARGID_ALL , "-a = (un)install all driver (default)" }, { "d", SQLINST_ARGID_DRIVER , "-d = (un)install only given driver" }, { "l", SQLINST_ARGID_DLL , "-l = (un)install given dll. (full path and dll name)" }, { "q", SQLINST_ARGID_QUIET , "-q = quiet" }, { "m", SQLINST_ARGID_SHOW_MSG_BOX , "-m = show errors in windows messageboxes!" } }; // Pointer to versionstring static const char g_Version[] = { SQLINST_VERSION }; struct ParstArgsData_Struct { // Name of the Arg char ArgName[SQLINST_MAX_BUFFER]; // If Arg known than the id, or -1 if unknown. char ArgID; // Arg values unsigned char ArgValueCount; // Number char ArgValue[SQLINST_MAX_ARG_VALUE][SQLINST_MAX_BUFFER]; }; // What have the (Un)Installer todo? struct RunningOptionData_Struct { // What have I todo? (SQLINST_ACTION_*) unsigned char DoFollow; // Which Drivers? (SQLINST_DRIVER_*) unsigned char FollowDriver; // Install follow dll (Used when: FollowDriver & SQLINST_DRIVER_DLL) char DirectDll[SQLINST_MAX_BUFFER]; // Shut up... BOOL Quiet; }; // Parse the Arg, return number when some found unsigned char ParseArg(int argc, char* argv[], struct ParstArgsData_Struct *pDestArg, unsigned char MaxDestArg ); // Install or Uninstall (return 0 for success) int RunUnInstaller( const struct RunningOptionData_Struct *pRunData ); // Seperate Arg and values from type "-d=sql2,sql2u", return starting point from values char *SeperateArgAndValue( char *pArgName ); // Give back the Arg ID (SQLINST_ARGID_*) char GetArgID( const char *pArgName ); // Save valuelist in struct void SaveValues( struct ParstArgsData_Struct *pDestArg, const char *pValues ); // Put Messsage to user void MessageToUser( const char *pMessage ); // Remove path void MakeTempFile( char *pDestBuffer, int MaxDestBuffer, const char *pSourceBuffer ); // Error Message Buffer #define SQLINST_MAX_ERROR_BUFFER 4096 char g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER]; BOOL g_ShowErrorInWindowsMessageBoxes = FALSE; int main(int argc, char* argv[]) { struct ParstArgsData_Struct Arguments[SQLINST_MAX_ARGS]; // Parst Argument data unsigned char ArgCount; // Number of Arguments unsigned char Count, Driver, Value; // Counter struct RunningOptionData_Struct RunData; // Run Program BOOL Found; // Found Value (or not) // Check if any arguments need to be checked ArgCount = ParseArg(argc, argv, Arguments, SQLINST_MAX_ARGS); if ( ArgCount ) { // Init RunData memset( &RunData, 0, sizeof(struct RunningOptionData_Struct) ); RunData.DoFollow = SQLINST_ACTION_NOT_KNOWN; // Check all Args for ( Count = 0; Count < ArgCount; Count++ ) { // Procced ArgID switch ( Arguments[Count].ArgID ) { default: case SQLINST_ARGID_UNKNOWN: _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Unknown argument: %s\n", Arguments[Count].ArgName ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; break; case SQLINST_ARGID_HELP: // Set print help RunData.DoFollow = SQLINST_ACTION_PRINT_HELP; // Break: for ( Count = 0; Count < ArgCount; Count++ ) Count = ArgCount; break; case SQLINST_ARGID_VERSION: // Print Version _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "SQLiteODBCInstaller %s\n", g_Version ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Return OK return 0; break; case SQLINST_ARGID_INSTALL: // Check if RunData.DoFollow already set if ( RunData.DoFollow ) { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Please use only -i OR -u one time and alone!\n" ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; } // if ( InstallOption ) // Set InstallOption to "INSTALL" RunData.DoFollow = SQLINST_ACTION_INSTALL; break; case SQLINST_ARGID_UNINSTALL: // Check if RunData.DoFollow already set if ( RunData.DoFollow ) { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Please use only -i OR -u one time and alone!\n" ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; } // if ( InstallOption ) // Set InstallOption to "UNINSTALL" RunData.DoFollow = SQLINST_ACTION_UNINSTALL; break; case SQLINST_ARGID_ALL: // (Un)Install all Drivers for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) { // If not special entry if ( strlen(g_SQLiteDriverData[Driver].pDLLName) ) { RunData.FollowDriver |= g_SQLiteDriverData[Driver].ArgFlag; } } // for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) break; case SQLINST_ARGID_DRIVER: // Any Driver give? if ( 0 == Arguments[Count].ArgValueCount ) { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Argument: \"%s\" need options! Use -h for help!\n", Arguments[Count].ArgName ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; } // if ( 0 == Arguments[Count].ArgValueCount ) // Check if given driver in Database for ( Value = 0; Value < Arguments[Count].ArgValueCount; Value++ ) { // Driver not found in Database Found = FALSE; for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) { // Ignore special entry. if ( !strlen(g_SQLiteDriverData[Driver].pDLLName) ) { continue; } // If Identical set Flag if ( 0 == strcmp( g_SQLiteDriverData[Driver].pArgOptionName, Arguments[Count].ArgValue[Value]) ) { RunData.FollowDriver |= g_SQLiteDriverData[Driver].ArgFlag; Found = TRUE; // Break: for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) break; } // if ( NULL == strcmp( g_SQLiteDriverData[Driver].pArgOptionName, Arguments[Count].ArgValue[Value]) ) } // for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) // Return with error if unknown drivername given if ( !Found ) { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Argument: %s unknown drivername: %s! Use -h for help!\n", Arguments[Count].ArgName, Arguments[Count].ArgValue[Value] ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; } // if ( !Found ) } // for ( Value = 0; Value < Arguments[Count].ArgValueCount; Value++ ) break; case SQLINST_ARGID_DLL: // Need one given DLL if ( 1 == Arguments[Count].ArgValueCount ) { // Copy DLL to run struct RunData.FollowDriver |= SQLINST_DRIVER_DLL; strncpy( RunData.DirectDll, Arguments[Count].ArgValue[0], SQLINST_MAX_BUFFER ); RunData.DirectDll[SQLINST_MAX_BUFFER-1] = 0; } else { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Argument: %s need dllname! Use -h for help!\n", Arguments[Count].ArgName ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); } break; case SQLINST_ARGID_QUIET: RunData.Quiet = TRUE; break; case SQLINST_ARGID_SHOW_MSG_BOX: g_ShowErrorInWindowsMessageBoxes = TRUE; break; } // switch ( Arguments[Count].ArgID ) } // for ( Count = 0; Count < ArgCount; Count++ ) // Check if any driver given, if not use all (Make argument "-a" default!) if ( !RunData.FollowDriver ) { // Install all Drivers for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) { // If not special entry if ( strlen(g_SQLiteDriverData[Driver].pDLLName) ) { RunData.FollowDriver |= g_SQLiteDriverData[Driver].ArgFlag; } } // for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) } // if ( !RunData.FollowDriver ) switch ( RunData.DoFollow ) { case SQLINST_ACTION_NOT_KNOWN: // No Argument for Install or Uninstall given _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Please give install(-i) or uninstall option(-u)!\n" ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; break; case SQLINST_ACTION_INSTALL: // Install driver case SQLINST_ACTION_UNINSTALL: // Uninstall driver // Ok now (un)install return RunUnInstaller( &RunData ); break; default: case SQLINST_ACTION_PRINT_HELP: // Print Help // Do nothing break; } } // if ( ArgCount ) // Print help printf( "SQLiteODBCInstaller [-i or -u] [-a, -d=driverlist or -l=fullpath\\dllname]\n" ); printf( "Version: %s\n", g_Version ); printf( "\n"); // Print all Options for ( Count = 0; Count < SQLINST_ARGID_COUNT; Count++ ) { // Print comment printf( "%s\n", g_ArgData[Count].pArgComment ); // If ArgID driver print availble driver if ( SQLINST_ARGID_DRIVER == g_ArgData[Count].ArgID ) { // Print all known driver printf( " {" ); for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) { // Ignore special entry. if ( !strlen(g_SQLiteDriverData[Driver].pDLLName) ) { continue; } // Seperator ";" if needed if ( Driver ) { printf( "; "); } // Data printf( "%s=%s", g_SQLiteDriverData[Driver].pArgOptionName, g_SQLiteDriverData[Driver].pDriverName ); } // for ( Count = 0; Count < SQLINST_DRIVER_COUNT; Count++ ) printf( "}\n" ); } } // for ( Count = 0; Count < SQLINST_ARGID_COUNT; Count++ ) // Print some examples printf( "\n"); printf( "Example 1: Install all driver\n"); printf( "SQLiteODBCInstaller -i -a\n"); printf( "\n"); printf( "Example 2: Uninstall all driver\n"); printf( "SQLiteODBCInstaller -u -a\n"); printf( "\n"); printf( "Example 3: Install only SQLite2 and SQLite2 UTF8 driver\n"); printf( "SQLiteODBCInstaller -i -d=sql2,sql2u\n"); printf( "\n"); printf( "Example 4: Install dll directly\n"); printf( "SQLiteODBCInstaller -i -l=\"c:\\download\\sqlite3odbc.dll\"\n"); printf( "\n"); return 0; } // Parse the Arg, return TRUE when some found unsigned char ParseArg(int argc, char* argv[], struct ParstArgsData_Struct *pDestArg, unsigned char MaxDestArg ) { unsigned char ArgCount; // Counters int DestArg; // Count of parst arguments char *pValues; // Pointer to values // No args parst yet DestArg = -1; // Check all arguments but not me self (ArgCount=0) for ( ArgCount = 1; ArgCount < argc; ArgCount++ ) { // Need "-" or more windows like "/" at start of argument if ( '-' == argv[ArgCount][0] || '/' == argv[ArgCount][0] ) { // Stop at max arguments if ( DestArg+1 > MaxDestArg ) { return DestArg; } // Use Next argument DestArg++; // Init memset( &pDestArg[DestArg], 0, sizeof( struct ParstArgsData_Struct) ); // Copy Argument strncpy( pDestArg[DestArg].ArgName, &argv[ArgCount][1], SQLINST_MAX_BUFFER ); pDestArg[DestArg].ArgName[SQLINST_MAX_BUFFER-1] = 0; // If from type "-d=sql2,sql2u" break after space or "=" pValues = SeperateArgAndValue( pDestArg[DestArg].ArgName ); // Find ArgID pDestArg[DestArg].ArgID = GetArgID( pDestArg[DestArg].ArgName ); // Save values if needed if ( pValues ) { // Save valuelist in struct SaveValues( &pDestArg[DestArg], pValues ); } } // if ( argv[ArgCount][0] = '-' || argv[ArgCount][0] = '/' ) else { // No argument so it should be an value // if -d from type "-d = sql2,sql2u" ignore "=" if ( '=' == argv[ArgCount][0] ) { continue; } // if ( '=' == argv[ArgCount][0] ) // Save valuelist in struct if ( -1 < DestArg ) { SaveValues( &pDestArg[DestArg], argv[ArgCount] ); } } // if ( argv[ArgCount][0] = '-' || argv[ArgCount][0] = '/' ) } // for ( ArgCount = 0; ArgCount < argc; ArgCount++ ) // Be sure to give only unsigned value back (DestArg starts with -1) DestArg++; return DestArg; } // Give back the Arg ID (SQLINST_ARGID_*) char GetArgID( const char *pArgName ) { unsigned char IdCount; // Counter // Get ArgID for ( IdCount = 0; IdCount < SQLINST_ARGID_COUNT; IdCount++ ) { // Check if arg found in database if ( 0 == strcmp(g_ArgData[IdCount].pArgName, pArgName) ) { // Save ID return g_ArgData[IdCount].ArgID; } // if ( NULL == strcmp( g_ArgData[IdCount].pArgName, &argv[ArgCount][1] ) } // for ( IdCount = 0; IdCount < SQLINST_ARGID_COUNT; IdCount++ ) // Nothing found... return SQLINST_ARGID_UNKNOWN; } // Seperate Arg and values from type "-d=sql2,sql2u", return starting point from values char *SeperateArgAndValue( char *pArgName ) { unsigned int StringPos; BOOL CheckValaue; // Parse String StringPos = 0; // First pos in string CheckValaue = FALSE; // Arg not ended while ( pArgName[StringPos] ) { // Check some end chars switch ( pArgName[StringPos] ) { case '\t': case '=': // Arg-Type? if ( !CheckValaue ) { // Arg ends pArgName[StringPos] = 0; CheckValaue = TRUE; } // if ( !CheckValaue ) break; default: // Value starts if ( CheckValaue ) { return &pArgName[StringPos]; } break; } StringPos++; } // while ( pArgName[StringPos] ) // No value found return NULL; } // Save valuelist in struct void SaveValues( struct ParstArgsData_Struct *pDestArg, const char *pValues ) { unsigned int ValueLength; // Length of string unsigned int StringPos; // Position in string BOOL BreakMe; // Break while const char *pValueStart; unsigned char Quote; // Parse from start StringPos = 0; // do not write above dest buffer stop when string ends while ( (pDestArg->ArgValueCount < SQLINST_MAX_ARG_VALUE) && pValues[StringPos] ) { // no value startet ValueLength = 0; BreakMe = FALSE; pValueStart = &pValues[StringPos]; Quote = 0; // Parse string while ( pValues[StringPos] && !BreakMe ) { // If some End chars switch ( pValues[StringPos] ) { case ' ': case '\n': case ',': if ( !Quote ) { BreakMe = TRUE; } break; case '"': if ( Quote ) { BreakMe = TRUE; } else { Quote = 1; } break; default: ValueLength++; break; } // switch ( pValues[StringPos] ) StringPos++; } // while ( pValues[StringPos] ) // When somethings to save if ( ValueLength ) { if ( ValueLength > SQLINST_MAX_BUFFER ) { ValueLength = SQLINST_MAX_BUFFER; } // Copy value strncpy( pDestArg->ArgValue[pDestArg->ArgValueCount], pValueStart, ValueLength ); // Saved... pDestArg->ArgValueCount++; } // if ( ValueLength ) } // while ( pDestArg->ArgValueCount < SQLINST_MAX_ARG_VALUE ) } // Install or Uninstall int RunUnInstaller( const struct RunningOptionData_Struct *pRunData ) { unsigned int Driver; // Counter char SystemPath[1024]; // System path (C:\Windows\System32) char WorkPath[1024]; // My own path char TempPath[1024]; // Temp path for working char TempFile[1024]; // TempFile char SourceFile[2048]; // SourceFile char DestFile[2048]; // DestFile HMODULE hDll; // DLL-Handle InstallFunc Install; // DLL-Function UnInstallFunc UnInstall; // DLL-Function // Get needed Pathes: // Systempath GetSystemDirectory( SystemPath, 1024 ); SystemPath[1024-1] = 0; // Workpath _getcwd( WorkPath, 1024 ); WorkPath[1024-1] = 0; // Temppath GetTempPath( 1024, TempPath ); TempPath[1024-1] = 0; // Install uninstall all drivers for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) { // (Un)Install follow driver if ( !(pRunData->FollowDriver & g_SQLiteDriverData[Driver].ArgFlag) ) { // No... continue; } // if ( (pRunData->FollowDriver & g_SQLiteDriverData[Driver].ArgFlag) ) // What have I todo? switch ( pRunData->DoFollow ) { case SQLINST_ACTION_INSTALL: if ( g_SQLiteDriverData[Driver].ArgFlag == SQLINST_DRIVER_DLL ) { _snprintf( SourceFile, 2048, "%s", pRunData->DirectDll ); SourceFile[2048-1] = 0; } else { _snprintf( SourceFile, 2048, "%s\\%s", WorkPath, g_SQLiteDriverData[Driver].pDLLName ); SourceFile[2048-1] = 0; } // Try to load the DLL hDll = LoadLibrary( SourceFile ); if ( !hDll ) { _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Could not open DLL: %s\n", SourceFile ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); continue; } // if ( !hDll ) // Get Address from the Install Function; Install = (InstallFunc)GetProcAddress(hDll, "install"); if ( !Install ) { FreeLibrary(hDll); _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Dll not provid install function: %s\n", SourceFile ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); continue; } // Use the install function... if ( pRunData->Quiet ) { Install( NULL, NULL, "quiet", 0 ); } else { Install( NULL, NULL, "", 0 ); } // Cleaning... FreeLibrary(hDll); break; case SQLINST_ACTION_UNINSTALL: if ( g_SQLiteDriverData[Driver].ArgFlag == SQLINST_DRIVER_DLL ) { MakeTempFile( TempFile, 1024, pRunData->DirectDll ); _snprintf( SourceFile, 2048, "%s", pRunData->DirectDll ); _snprintf( DestFile, 2048, "%s\\%s", TempPath, TempFile ); } else { _snprintf( SourceFile, 2048, "%s\\%s", SystemPath, g_SQLiteDriverData[Driver].pDLLName ); _snprintf( DestFile, 2048, "%s\\%s", TempPath, g_SQLiteDriverData[Driver].pDLLName ); } SourceFile[2048-1] = 0; DestFile[2048-1] = 0; // Delete maybe old file before copy DeleteFile( DestFile ); if ( !CopyFile( SourceFile, DestFile, FALSE ) ) { // Could not copy File _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Error: Could not copy %s to temppath!\n", SourceFile ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); continue; } // Try to load the DLL hDll = LoadLibrary( DestFile ); if ( !hDll ) { // Use the SourceFile path (user should know what source dll is incompatibel) _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Could not open DLL: %s\n", SourceFile ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); continue; } // if ( !hDll ) // Get Address from the Install Function; UnInstall = (InstallFunc)GetProcAddress(hDll, "uninstall"); if ( !UnInstall ) { FreeLibrary(hDll); // Use the SourceFile path (user should know what source dll is incompatibel) _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Dll not provid install function: %s\n", SourceFile ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); continue; } // Use the uninstall function... if ( pRunData->Quiet ) { UnInstall( NULL, NULL, "quiet", 0 ); } else { UnInstall( NULL, NULL, "", 0 ); } // Cleaning... FreeLibrary(hDll); DeleteFile( DestFile ); break; default: _snprintf( g_ErrorMessage, SQLINST_MAX_ERROR_BUFFER, "Internel error: %s: Can not run: %d\n", "RunUnInstaller", pRunData->DoFollow ); g_ErrorMessage[SQLINST_MAX_ERROR_BUFFER-1] = 0; MessageToUser( g_ErrorMessage ); // Break with error return -1; break; } // switch ( pRunData->DoFollow ) } // for ( Driver = 0; Driver < SQLINST_DRIVER_COUNT; Driver++ ) // return with all ok return 0; } // Put Messsage to user void MessageToUser( const char *pMessage ) { if ( g_ShowErrorInWindowsMessageBoxes ) { MessageBox( NULL, pMessage, "Message", MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND ); } else { printf ( "%s", pMessage ); } // if ( g_ShowErrorInWindowsMessageBoxes ) } // Remove path void MakeTempFile( char *pDestBuffer, int MaxDestBuffer, const char *pSourceBuffer ) { int StartPosition; // Position in String // in case of doubt return nothing pDestBuffer[0] = 0; // Start with last char StartPosition = (int)strlen(pSourceBuffer); if ( !StartPosition ) { return; } StartPosition--; // 0-Index // Find filename beginning: while ( StartPosition >= 0 ) { if ( '\\' == pSourceBuffer[StartPosition] || '/' == pSourceBuffer[StartPosition] || ':' == pSourceBuffer[StartPosition] ) { // Found break; } StartPosition--; } // while ( SrcPosition >= 0 ) // if -1 or skip "\" or "/" or ":" StartPosition++; // Copy Filename (Or nothing: "C:\path\") strncpy( pDestBuffer, &pSourceBuffer[StartPosition], MaxDestBuffer ); // return in evry situation a string pDestBuffer[MaxDestBuffer-1] = 0; } ./sqliteodbc-0.992/blobtoxy.c0100644000076400001440000014277212074001562014550 0ustar chwusers/** * @file blobtoxy.c * SQLite extension module for read-only BLOB to X/Y mapping * using SQLite 3.3.x virtual table API plus some useful * scalar and aggregate functions. * * $Id: blobtoxy.c,v 1.22 2013/01/11 12:19:55 chw Exp chw $ * * Copyright (c) 2007-2013 Christian Werner * * See the file "license.terms" for information on usage * and redistribution of this file and for a * DISCLAIMER OF ALL WARRANTIES. * * Usage: * * Master (non-virtual) table: * * CREATE TABLE t( * key INTEGER PRIMARY KEY, * data BLOB, * scale DOUBLE, * offset DOUBLE, * foo TEXT, * bar TEXT * ); * * BLOB to X/Y mapping: * * CREATE VIRTUAL TABLE t1 * USING blobtoxy (t, key, data, short_le, x_scale, x_offset, * y_scale, y_offset, "foo, bar"); *
CREATE VIRTUAL TABLE t2 * USING blobtoxy (t, key, data, uchar, null, null, null, null, 'bar'); *
CREATE VIRTUAL TABLE t3 * USING blobtoxy (t, key, data, int_be, 10.0, null, 10.0, null, "foo"); *
CREATE VIRTUAL TABLE t4 * USING blobtoxy (t, key, data, float, null, -10, null, 10); * * Arguments to "blobtoxy" module: * * 0. master table name (required).
* 1. key column in master table (required).
* 2. blob column in master table (required).
* 3. type code (optional), defaults to "char".
* 4. X scale column in master table (optional), * may be specified as integer or float constant, too, * to explicitely omit scale, use an empty string ('') * or null.
* 5. X offset column in master table (optional), * may be specified as integer or float constant, too, * to explicitely omit offset, use an empty string ('') * or null.
* 6. Y scale column in master table (optional), see point 4.
* 7. Y offset column in master table (optional), see point 5.
* 8. other columns of the master table to appear in the * result set (optional), must be specified as a * single or double quoted string with comma * separated column names as a sequence of named * columns as it would be written in a SELECT * statement.
* 9. X start index (optional), specified as integer * in type specific blob units, zero based.
* 10. X length (optional), specified as integer, * number of blob units (= number of rows).
* * Supported data types: * * "char" -> BLOB is a signed char array
* "uchar" -> BLOB is an unsigned char array
* "short_le" -> BLOB is a short array little endian
* "short_be" -> BLOB is a short array big endian
* "ushort_le" -> BLOB is an unsigned short array little endian
* "ushort_be" -> BLOB is an unsigned short array big endian
* "int_le" -> BLOB is a int array little endian
* "int_be" -> BLOB is a int array big endian
* "uint_le" -> BLOB is an unsigned int array little endian
* "uint_be" -> BLOB is an unsigned int array big endian
* "bigint_le" -> BLOB is an large integer array little endian
* "bigint_be" -> BLOB is an large integer array big endian
* "float" -> BLOB is a float array
* "double" -> BLOB is a double array
* * Columns of "blobtoxy" mapped virtual table: * * "key" Key column for JOINing with master table
* "x" index within BLOB.
* This value is optionally translated by * the "x_scale" and "x_offset" columns * i.e. x' = x * x_scale + x_offset, yielding * a floating point result.
* "y" BLOB's value at "x"-unscaled-index
* This value is optionally translated by * the "y_scale" and "y_offset" columns * i.e. y' = y * y_scale + y_offset, yielding * a floating point result.
* ... Other columns, see above
* * If the "key" field of the master table is an integer data * type, it is used as the ROWID of the mapped virtual table. * Otherwise the ROWID is a 0-based counter of the output rows. * * * Exported SQLite functions (svg|tk)_path[_from_blob], blt_vec_(x|y) * * Scalar context: * * svg_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset)
* tk_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset)
* blt_vec_(x|y)(data, type, x_scale, x_offset, y_scale, y_offset)
* tk3d_path_from_blob(data, type, x_scale, x_offset, y_scale, y_offset, * z_value, z_scale, z_offset)
* * Like BLOB to X/Y mapping but produces SVG or Tk Canvas * path/polyline as a string, e.g. * * SVG: "M 1 1 L 2 2 L 3 7 L 4 1
* Tk Canvas: "1 1 2 2 3 7 4 1"
* BLT Vector X: "1 2 3 4"
* BLT Vector Y: "1 2 7 1"
* Tk 3D Canvas: "1 1 0 2 2 0 3 7 0 4 1 0"
* * Arguments: * * 0. blob data (required); this parameter is always * interpreted as blob. It must contain at least * two elements, otherwise the function's result * is NULL to indicate that nothing need be drawn
* 1. type code (optional), defaults to "char"
* 2. X scale (optional), see above
* 3. X offset (optional), see above
* 4. Y scale (optional), see above
* 5. Y offset (optional), see above
* 6. Z value (optional)
* 8. Z scale (optional)
* 9. Z offset (optional)
* * Aggregate context: * * svg_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset)
* tk_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset)
* blt_vec(data, scale, offset)
* tk3d_path(xdata, ydata, x_scale, x_offset, y_scale, y_offset, * zdata, z_scale, z_offset)
* * Same behaviour except that xdata/ydata/data/zdata are interpreted * directly as numeric values. * * * Exported SQLite function subblob * * subblob(data, start, length, size, skip) * * Works somewhat like substr, e.g. * * select quote(subblob(X'0A0B0C0D0E0F0001',2,2,1,3))
* -> X'0B0F' * * Arguments: * * 0. blob data (required); this parameter is always * interpreted as blob.
* 1. start offset (required) in bytes as in substr * function (1-based, negative offsets count from end)
* 2. length (required) in bytes to be copied
* 3. size (optional) of items in bytes to be copied * in combination with skip argument
* 4. skip (optional) in bytes after one item of * size argument has been copied
* * * Exported SQLite function rownumber * * rownumber(any) * * Returns the row number counting from 0 in simple * selects. An arbitrary dummy but constant argument * must be provided to this function in order to satisfy * some needs of the SQLite3 C API, e.g. * * rownumber(0), rownumber('foo') right
* rownumber(column_name) wrong, will yield always 0
* */ #ifdef STANDALONE #include #else #include static SQLITE_EXTENSION_INIT1 #endif #include #include #include #include #ifdef _WIN32 #define strcasecmp _stricmp #define strncasecmp _strnicmp #define vsnprintf _vsnprintf #endif #define TYPE_CODE(num, type) (((num) << 8) | (sizeof (type))) #define TYPE_SIZE(code) ((code) & 0xFF) #define TYPE_CHAR TYPE_CODE( 0, char) #define TYPE_UCHAR TYPE_CODE( 1, char) #define TYPE_SHORT_LE TYPE_CODE( 2, short) #define TYPE_USHORT_LE TYPE_CODE( 3, short) #define TYPE_SHORT_BE TYPE_CODE( 4, short) #define TYPE_USHORT_BE TYPE_CODE( 5, short) #define TYPE_INT_LE TYPE_CODE( 6, int) #define TYPE_UINT_LE TYPE_CODE( 7, int) #define TYPE_INT_BE TYPE_CODE( 8, int) #define TYPE_UINT_BE TYPE_CODE( 9, int) #define TYPE_BIGINT_LE TYPE_CODE(10, sqlite_int64) #define TYPE_BIGINT_BE TYPE_CODE(11, sqlite_int64) #define TYPE_FLOAT TYPE_CODE(12, float) #define TYPE_DOUBLE TYPE_CODE(13, double) /** * @typedef b2xy_table * @struct b2xy_table * Structure to describe a virtual table. */ typedef struct b2xy_table { sqlite3_vtab base; /**< SQLite's base virtual table struct */ sqlite3 *db; /**< Open database */ char *master_table; /**< Table where to fetch BLOB from */ char *fq_master_table; /**< Fully qualified master_table */ char *key_column; /**< Name of key column */ char *blob_column; /**< Name of BLOB column */ char *x_scale_column; /**< Name of column giving X scale or NULL */ char *x_offset_column; /**< Name of column giving X offset or NULL */ char *y_scale_column; /**< Name of column giving Y scale or NULL */ char *y_offset_column; /**< Name of column giving Y offset or NULL */ char *other_columns; /**< Other columns or empty string */ int type; /**< Data type of BLOB */ int do_x_sl; /**< If true, apply X start/length */ int x_start, x_length; /**< X start/length */ int argc; /**< Number args from b2xy_create() call */ char **argv; /**< Argument vector from b2xy_create() call */ } b2xy_table; /** * @typedef b2xy_cursor * @struct b2xy_cursor * Structure to describe a cursor in the virtual table. */ typedef struct b2xy_cursor { sqlite3_vtab_cursor base; /**< SQLite's base cursor struct */ b2xy_table *table; /**< Link to table struct */ sqlite3_stmt *select; /**< Prepared SELECT statement or NULL */ sqlite3_value *key; /**< Value of current key */ int fix_cols; /**< Fixed number of columns of result set */ int num_cols; /**< Total number of columns of result set */ char *val; /**< Value of current BLOB */ int val_len; /**< Length of current BLOB */ int x_scale_col; /**< Column number of X scale or 0 */ int x_offset_col; /**< Column number of X offset or 0 */ double x_scale, x_offset; /**< Current X scale and offset */ int y_scale_col; /**< Column number of Y scale or 0 */ int y_offset_col; /**< Column number of Y offset or 0 */ double y_scale, y_offset; /**< Current X scale and offset */ int do_x_scale; /**< If true, use X scale and offset */ int do_y_scale; /**< If true, use Y scale and offset */ int do_x_sl; /**< If true, apply X start/length */ int x_start, x_length; /**< X start/length */ int type; /**< Data type of BLOB */ int index; /**< Current index in BLOB */ int rowid_from_key; /**< When true, ROWID used from key column */ sqlite_int64 rowid; /**< Current ROWID */ } b2xy_cursor; /** * Map type string to type code. * @param str type string, e.g. "char" * @result type code, e.g. TYPE_CHAR */ static int string_to_type(const char *str) { if (strcasecmp(str, "char") == 0) { return TYPE_CHAR; } if (strcasecmp(str, "uchar") == 0) { return TYPE_UCHAR; } if (strcasecmp(str, "short_le") == 0) { return TYPE_SHORT_LE; } if (strcasecmp(str, "ushort_le") == 0) { return TYPE_USHORT_LE; } if (strcasecmp(str, "short_be") == 0) { return TYPE_SHORT_BE; } if (strcasecmp(str, "ushort_be") == 0) { return TYPE_USHORT_BE; } if (strcasecmp(str, "int_le") == 0) { return TYPE_INT_LE; } if (strcasecmp(str, "uint_le") == 0) { return TYPE_UINT_LE; } if (strcasecmp(str, "int_be") == 0) { return TYPE_INT_BE; } if (strcasecmp(str, "uint_be") == 0) { return TYPE_UINT_BE; } if (strcasecmp(str, "bigint_le") == 0) { return TYPE_BIGINT_LE; } if (strcasecmp(str, "bigint_be") == 0) { return TYPE_BIGINT_BE; } if (strcasecmp(str, "float") == 0) { return TYPE_FLOAT; } if (strcasecmp(str, "double") == 0) { return TYPE_DOUBLE; } return 0; } /** * Destroy virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int b2xy_destroy(sqlite3_vtab *vtab) { b2xy_table *bt = (b2xy_table *) vtab; sqlite3_free(bt); return SQLITE_OK; } /** * Create virtual table * @param db SQLite database pointer * @param userdata user specific pointer (unused) * @param argc argument count * @param argv argument vector * @param vtabret pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code * * Argument vector contains: * * argv[0] - module name
* argv[1] - database name
* argv[2] - table name (virtual table)
* argv[3] - master table name (required)
* argv[4] - key column (required)
* argv[5] - blob column (required)
* argv[6] - type code (optional)
* argv[7] - X scale column (optional)
* argv[8] - X offset column (optional)
* argv[9] - Y scale column (optional)
* argv[10] - Y offset column (optional)
* argv[11] - other columns (optional)
* argv[12] - X start (optional)
* argv[13] - X length (optional)
*/ static int b2xy_create(sqlite3 *db, void *userdata, int argc, const char * const *argv, sqlite3_vtab **vtabret, char **errp) { int rc = SQLITE_NOMEM; b2xy_table *bt; int i, size, type = TYPE_CHAR; int x_start = -1, x_length = 0; if (argc < 6) { *errp = sqlite3_mprintf("need at least 3 arguments"); return SQLITE_ERROR; } if (argc > 6) { type = string_to_type(argv[6]); if (!type) { *errp = sqlite3_mprintf("unsupported type %Q", argv[6]); return SQLITE_ERROR; } } if (argc > 11) { if ((argv[11][0] != '"') && (argv[11][0] != '\'')) { *errp = sqlite3_mprintf("other columns must be quoted"); return SQLITE_ERROR; } } if (argc > 12) { char *endp = 0; x_start = strtol(argv[12], &endp, 10); if ((endp == argv[12]) || (endp && (endp[0] != '\0'))) { *errp = sqlite3_mprintf("X start index must be integer"); return SQLITE_ERROR; } if (x_start < 0) { *errp = sqlite3_mprintf("X start index must be >= 0"); return SQLITE_ERROR; } } if (argc > 13) { char *endp = 0; x_length = strtol(argv[13], &endp, 10); if ((endp == argv[13]) || (endp && (endp[0] != '\0'))) { *errp = sqlite3_mprintf("X length must be integer"); return SQLITE_ERROR; } if (x_length <= 0) { *errp = sqlite3_mprintf("X length must be > 0"); return SQLITE_ERROR; } } size = sizeof (char *) * argc; for (i = 0; i < argc; i++) { size += argv[i] ? (strlen(argv[i]) + 1) : 0; } /* additional space for '"' + argv[1] '"."' + argv[3] + '"' */ size += argv[1] ? (strlen(argv[1]) + 3) : 3; size += argv[3] ? (strlen(argv[3]) + 3) : 0; bt = sqlite3_malloc(sizeof (b2xy_table) + size); if (bt) { char *p, *key_type = 0, *x_type, *y_type, *other_types = 0; memset(bt, 0, sizeof (b2xy_table) + size); bt->db = db; bt->type = type; bt->x_start = x_start; bt->x_length = x_length; bt->do_x_sl = (x_start >= 0) || (x_length > 0); if (bt->x_start < 0) { bt->x_start = 0; } bt->argc = argc; bt->argv = (char **) (bt + 1); p = (char *) (bt->argv + argc); for (i = 0; i < argc; i++) { if (argv[i]) { bt->argv[i] = p; strcpy(p, argv[i]); p += strlen(p) + 1; } } bt->master_table = bt->argv[3]; bt->fq_master_table = p; p[0] = '\0'; if (bt->argv[1]) { strcat(p, "\""); strcat(p, bt->argv[1]); strcat(p, "\"."); } if (bt->argv[3]) { strcat(p, "\""); strcat(p, bt->argv[3]); strcat(p, "\""); } bt->key_column = bt->argv[4]; bt->blob_column = bt->argv[5]; if ((bt->argc > 7) && bt->argv[7][0]) { bt->x_scale_column = bt->argv[7]; if (strcasecmp(bt->x_scale_column, "null") == 0) { bt->x_scale_column = 0; } } if ((bt->argc > 8) && bt->argv[8][0]) { bt->x_offset_column = bt->argv[8]; if (strcasecmp(bt->x_offset_column, "null") == 0) { bt->x_offset_column = 0; } } if ((bt->argc > 9) && bt->argv[9][0]) { bt->y_scale_column = bt->argv[9]; if (strcasecmp(bt->y_scale_column, "null") == 0) { bt->y_scale_column = 0; } } if ((bt->argc > 10) && bt->argv[10][0]) { bt->y_offset_column = bt->argv[10]; if (strcasecmp(bt->y_offset_column, "null") == 0) { bt->y_offset_column = 0; } } if (bt->argc > 11) { p = bt->argv[11]; p[0] = ','; bt->other_columns = p; p += strlen(p) - 1; if ((*p == '"') || (*p == '\'')) { *p = '\0'; } } else { bt->other_columns = ""; } /* find out types of key and x/y columns */ if (bt->x_scale_column || bt->x_offset_column || (bt->type == TYPE_FLOAT) || (bt->type == TYPE_DOUBLE)) { x_type = " DOUBLE"; } else { x_type = " INTEGER"; } if (bt->y_scale_column || bt->y_offset_column || (bt->type == TYPE_FLOAT) || (bt->type == TYPE_DOUBLE)) { y_type = " DOUBLE"; } else { y_type = " INTEGER"; } p = sqlite3_mprintf("PRAGMA %Q.table_info(%Q)", bt->argv[1] ? bt->argv[1] : "MAIN", bt->master_table); if (p) { int nrows = 0, ncols = 0; char **rows = 0; rc = sqlite3_get_table(db, p, &rows, &nrows, &ncols, 0); sqlite3_free(p); if (rc == SQLITE_OK) { for (i = 1; (ncols >= 3) && (i <= nrows); i++) { p = rows[i * ncols + 1]; if (p && (strcasecmp(bt->key_column, p) == 0)) { key_type = sqlite3_mprintf(" %s", rows[i * ncols + 2]); break; } } } if (rows) { sqlite3_free_table(rows); } } /* find out types of other columns */ p = 0; if (bt->other_columns[0]) { p = sqlite3_mprintf("SELECT %s FROM %s WHERE 0", bt->other_columns + 1, bt->fq_master_table); } if (p) { sqlite3_stmt *stmt = 0; #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 rc = sqlite3_prepare_v2(db, p, -1, &stmt, 0); #else rc = sqlite3_prepare(db, p, -1, &stmt, 0); #endif sqlite3_free(p); if ((rc == SQLITE_OK) && stmt) { sqlite3_step(stmt); for (i = 0; i < sqlite3_column_count(stmt); i++) { p = sqlite3_mprintf("%s%s\"%s\" %s", other_types ? other_types : "", other_types ? "," : "", sqlite3_column_name(stmt, i), sqlite3_column_decltype(stmt, i)); sqlite3_free(other_types); other_types = 0; if (p) { other_types = p; } else { break; } } sqlite3_finalize(stmt); if (other_types) { p = sqlite3_mprintf(",%s", other_types); sqlite3_free(other_types); other_types = p; } } } p = sqlite3_mprintf("CREATE TABLE \"%s\"(key%s CONSTRAINT fk " "REFERENCES \"%s\"(\"%s\"),x%s,y%s%s)", argv[2], key_type ? key_type : "", bt->master_table, bt->key_column, x_type, y_type, other_types ? other_types : bt->other_columns); if (key_type) { sqlite3_free(key_type); } if (other_types) { sqlite3_free(other_types); } if (p) { rc = sqlite3_declare_vtab(db, p); sqlite3_free(p); } if (rc != SQLITE_OK) { b2xy_destroy((sqlite3_vtab *) bt); bt = 0; } } *vtabret = (sqlite3_vtab *) bt; return rc; } /** * Open virtual table and return cursor. * @param vtab virtual table pointer * @param curret pointer receiving cursor pointer * @result SQLite error code */ static int b2xy_open(sqlite3_vtab *vtab, sqlite3_vtab_cursor **curret) { int rc = SQLITE_NOMEM; b2xy_table *bt = (b2xy_table *) vtab; b2xy_cursor *bc; bc = sqlite3_malloc(sizeof (b2xy_cursor)); if (bc) { memset(bc, 0, sizeof(b2xy_cursor)); bc->table = bt; bc->type = bt->type; bc->do_x_sl = bt->do_x_sl; bc->x_start = bt->x_start; bc->x_length = bt->x_length; *curret = (sqlite3_vtab_cursor *) bc; rc = SQLITE_OK; } return rc; } /** * Close virtual table cursor. * @param cur cursor pointer * @result SQLite error code */ static int b2xy_close(sqlite3_vtab_cursor *cur) { b2xy_cursor *bc = (b2xy_cursor *) cur; sqlite3_finalize(bc->select); sqlite3_free(bc); return SQLITE_OK; } /** * Return column data of virtual table. * @param cur virtual table cursor * @param ctx SQLite function context * @param i column index * @result SQLite error code */ static int b2xy_column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i) { b2xy_cursor *bc = (b2xy_cursor *) cur; char *p; double v; switch (i) { case 0: sqlite3_result_value(ctx, bc->key); break; case 1: if (bc->do_x_scale) { v = bc->index * bc->x_scale + bc->x_offset; sqlite3_result_double(ctx, v); } else { sqlite3_result_int(ctx, bc->index); } break; case 2: if (!bc->val || ((bc->index + 1) * TYPE_SIZE(bc->type) > bc->val_len)) { goto put_null; } p = bc->val + bc->index * TYPE_SIZE(bc->type); switch (bc->type) { case TYPE_CHAR: if (bc->do_y_scale) { v = p[0]; goto scale_it; } sqlite3_result_int(ctx, p[0]); break; case TYPE_UCHAR: if (bc->do_y_scale) { v = p[0] & 0xFF; goto scale_it; } sqlite3_result_int(ctx, p[0] & 0xFF); break; case TYPE_SHORT_LE: if (bc->do_y_scale) { v = (p[0] & 0xFF) | (p[1] << 8); goto scale_it; } sqlite3_result_int(ctx, (p[0] & 0xFF) | (p[1] << 8)); break; case TYPE_USHORT_LE: if (bc->do_y_scale) { v = (p[0] & 0xFF) | ((p[1] & 0xFF) << 8); goto scale_it; } sqlite3_result_int(ctx, (p[0] & 0xFF) | ((p[1] & 0xFF) << 8)); break; case TYPE_SHORT_BE: if (bc->do_y_scale) { v = (p[1] & 0xFF) | (p[0] << 8); goto scale_it; } sqlite3_result_int(ctx, (p[1] & 0xFF) | (p[0] << 8)); break; case TYPE_USHORT_BE: if (bc->do_y_scale) { v = (p[1] & 0xFF) | ((p[0] & 0xFF) << 8); goto scale_it; } sqlite3_result_int(ctx, (p[1] & 0xFF) | ((p[0] & 0xFF) << 8)); break; case TYPE_INT_LE: if (bc->do_y_scale) { v = (p[0] & 0xFF) | ((p[1] & 0xFF) << 8) | ((p[2] & 0xFF) << 16) | (p[3] << 24); goto scale_it; } sqlite3_result_int64(ctx, (p[0] & 0xFF) | ((p[1] & 0xFF) << 8) | ((p[2] & 0xFF) << 16) | (p[3] << 24)); break; case TYPE_UINT_LE: if (bc->do_y_scale) { v = (p[0] & 0xFF) | ((p[1] & 0xFF) << 8) | ((p[2] & 0xFF) << 16) | ((p[3] & 0xFF) << 24); goto scale_it; } sqlite3_result_int64(ctx, (p[0] & 0xFF) | ((p[1] & 0xFF) << 8) | ((p[2] & 0xFF) << 16) | ((p[3] & 0xFF) << 24)); break; case TYPE_INT_BE: if (bc->do_y_scale) { v = (p[3] & 0xFF) | ((p[2] & 0xFF) << 8) | ((p[1] & 0xFF) << 16) | (p[0] << 24); goto scale_it; } sqlite3_result_int64(ctx, (p[3] & 0xFF) | ((p[2] & 0xFF) << 8) | ((p[1] & 0xFF) << 16) | (p[0] << 24)); break; case TYPE_UINT_BE: if (bc->do_y_scale) { v = (p[3] & 0xFF) | ((p[2] & 0xFF) << 8) | ((p[1] & 0xFF) << 16) | ((p[0] & 0xFF) << 24); goto scale_it; } sqlite3_result_int64(ctx, (p[3] & 0xFF) | ((p[2] & 0xFF) << 8) | ((p[1] & 0xFF) << 16) | ((p[0] & 0xFF) << 24)); break; case TYPE_BIGINT_LE: if (bc->do_y_scale) { v = (p[0] & 0xFFLL) | ((p[1] & 0xFFLL) << 8) | ((p[2] & 0xFFLL) << 16) | ((p[3] & 0xFFLL) << 24) | ((p[4] & 0xFFLL) << 32) | ((p[5] & 0xFFLL) << 40) | ((p[6] & 0xFFLL) << 48) | ((p[6] & 0xFFLL) << 56); goto scale_it; } sqlite3_result_int64(ctx, (p[0] & 0xFFLL) | ((p[1] & 0xFFLL) << 8) | ((p[2] & 0xFFLL) << 16) | ((p[3] & 0xFFLL) << 24) | ((p[4] & 0xFFLL) << 32) | ((p[5] & 0xFFLL) << 40) | ((p[6] & 0xFFLL) << 48) | ((p[7] & 0xFFLL) << 56)); break; case TYPE_BIGINT_BE: if (bc->do_y_scale) { v = (p[7] & 0xFFLL) | ((p[6] & 0xFFLL) << 8) | ((p[5] & 0xFFLL) << 16) | ((p[4] & 0xFFLL) << 24) | ((p[3] & 0xFFLL) << 32) | ((p[2] & 0xFFLL) << 40) | ((p[1] & 0xFFLL) << 48) | ((p[0] & 0xFFLL) << 56); goto scale_it; } sqlite3_result_int64(ctx, (p[7] & 0xFFLL) | ((p[6] & 0xFFLL) << 8) | ((p[5] & 0xFFLL) << 16) | ((p[4] & 0xFFLL) << 24) | ((p[3] & 0xFFLL) << 32) | ((p[2] & 0xFFLL) << 40) | ((p[1] & 0xFFLL) << 48) | ((p[0] & 0xFFLL) << 56)); break; case TYPE_FLOAT: v = ((float *) p)[0]; goto scale_it; case TYPE_DOUBLE: v = ((double *) p)[0]; if (bc->do_y_scale) { scale_it: v = v * bc->y_scale + bc->y_offset; } sqlite3_result_double(ctx, v); break; default: put_null: sqlite3_result_null(ctx); break; } break; default: i += bc->fix_cols - 3; if ((i < 0) || (i >= bc->num_cols)) { sqlite3_result_null(ctx); } else { sqlite3_result_value(ctx, sqlite3_column_value(bc->select, i)); } break; } return SQLITE_OK; } /** * Return current rowid of virtual table cursor * @param cur virtual table cursor * @param rowidp value buffer to receive current rowid * @result SQLite error code */ static int b2xy_rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *rowidp) { b2xy_cursor *bc = (b2xy_cursor *) cur; *rowidp = bc->rowid; return SQLITE_OK; } /** * Return end of table state of virtual table cursor * @param cur virtual table cursor * @result true/false */ static int b2xy_eof(sqlite3_vtab_cursor *cur) { b2xy_cursor *bc = (b2xy_cursor *) cur; return bc->select ? 0 : 1; } /** * Retrieve next row from virtual table cursor * @param cur virtual table cursor * @result SQLite error code */ static int b2xy_next(sqlite3_vtab_cursor *cur) { b2xy_cursor *bc = (b2xy_cursor *) cur; b2xy_table *bt = bc->table; int rc, dofetch = 0; if (!bc->select) { return SQLITE_OK; } if (bc->val) { bc->index += 1; } if (!bc->val) { dofetch = 1; } else if (bc->do_x_sl && bc->x_length) { if (bc->index >= bc->x_start + bc->x_length) { dofetch = 1; } } else if ((bc->index + 1) * TYPE_SIZE(bc->type) > bc->val_len) { dofetch = 1; } if (dofetch) { refetch: rc = sqlite3_step(bc->select); if (rc == SQLITE_SCHEMA) { rc = sqlite3_step(bc->select); } if (rc != SQLITE_ROW) { sqlite3_finalize(bc->select); bc->select = 0; return SQLITE_OK; } bc->rowid_from_key = 0; bc->index = bc->x_start; bc->val = (char *) sqlite3_column_blob(bc->select, 1); bc->val_len = sqlite3_column_bytes(bc->select, 1); if (!bc->val) { if (bc->do_x_sl && bc->x_length) { bc->val = (char *) sqlite3_column_text(bc->select, 1); if (!bc->val) { goto refetch; } } else { goto refetch; } } if (!(bc->do_x_sl && bc->x_length) && (((bc->index + 1) * TYPE_SIZE(bc->type) > bc->val_len))) { goto refetch; } bc->key = sqlite3_column_value(bc->select, 0); if (sqlite3_column_type(bc->select, 0) == SQLITE_INTEGER) { bc->rowid_from_key = 1; bc->rowid = sqlite3_column_int64(bc->select, 0); } bc->do_x_scale = 0; bc->x_scale = 1.0; bc->x_offset = 0.0; if (bt->x_scale_column) { bc->x_scale = sqlite3_column_double(bc->select, bc->x_scale_col); bc->do_x_scale++; } if (bt->x_offset_column) { bc->x_offset = sqlite3_column_double(bc->select, bc->x_offset_col); bc->do_x_scale++; } bc->do_y_scale = 0; bc->y_scale = 1.0; bc->y_offset = 0.0; if (bt->y_scale_column) { bc->y_scale = sqlite3_column_double(bc->select, bc->y_scale_col); bc->do_y_scale++; } if (bt->y_offset_column) { bc->y_offset = sqlite3_column_double(bc->select, bc->y_offset_col); bc->do_y_scale++; } } if (!bc->rowid_from_key) { bc->rowid++; } return SQLITE_OK; } /** * Filter function for virtual table. * @param cur virtual table cursor * @param idxNum used for expression (<, =, >, etc.) * @param idxStr optional order by clause * @param argc number arguments (0 or 1) * @param argv argument (nothing or RHS of filter expression) * @result SQLite error code */ static int b2xy_filter(sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) { b2xy_cursor *bc = (b2xy_cursor *) cur; b2xy_table *bt = bc->table; char *query, *tmp, *op = 0; int rc; bc->rowid_from_key = 0; bc->rowid = 0; if (bc->select) { sqlite3_finalize(bc->select); bc->select = 0; } bc->fix_cols = 2; query = sqlite3_mprintf("select \"%s\",\"%s\"", bt->key_column, bt->blob_column); if (!query) { return SQLITE_NOMEM; } if (bt->x_scale_column) { tmp = sqlite3_mprintf("%s,\"%s\"", query, bt->x_scale_column); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; bc->x_scale_col = bc->fix_cols; bc->fix_cols++; } if (bt->x_offset_column) { tmp = sqlite3_mprintf("%s,\"%s\"", query, bt->x_offset_column); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; bc->x_offset_col = bc->fix_cols; bc->fix_cols++; } if (bt->y_scale_column) { tmp = sqlite3_mprintf("%s,\"%s\"", query, bt->y_scale_column); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; bc->y_scale_col = bc->fix_cols; bc->fix_cols++; } if (bt->y_offset_column) { tmp = sqlite3_mprintf("%s,\"%s\"", query, bt->y_offset_column); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; bc->y_offset_col = bc->fix_cols; bc->fix_cols++; } tmp = sqlite3_mprintf("%s%s from %s", query, bt->other_columns, bt->fq_master_table); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; if (idxNum && (argc > 0)) { switch (idxNum) { case SQLITE_INDEX_CONSTRAINT_EQ: op = "="; break; case SQLITE_INDEX_CONSTRAINT_GT: op = ">"; break; case SQLITE_INDEX_CONSTRAINT_LE: op = "<="; break; case SQLITE_INDEX_CONSTRAINT_LT: op = "<"; break; case SQLITE_INDEX_CONSTRAINT_GE: op = ">="; break; case SQLITE_INDEX_CONSTRAINT_MATCH: op = "like"; break; } if (op) { tmp = sqlite3_mprintf("%s where \"%s\" %s ?", query, bt->key_column, op); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; } } if (idxStr) { tmp = sqlite3_mprintf("%s %s", query, idxStr); sqlite3_free(query); if (!tmp) { return SQLITE_NOMEM; } query = tmp; } bc->num_cols = bc->fix_cols; #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 rc = sqlite3_prepare_v2(bt->db, query, -1, &bc->select, 0); #else rc = sqlite3_prepare(bt->db, query, -1, &bc->select, 0); if (rc == SQLITE_SCHEMA) { rc = sqlite3_prepare(bt->db, query, -1, &bc->select, 0); } #endif sqlite3_free(query); if (rc == SQLITE_OK) { bc->num_cols = sqlite3_column_count(bc->select); if (op) { sqlite3_bind_value(bc->select, 1, argv[0]); } } return (rc == SQLITE_OK) ? b2xy_next(cur) : rc; } /** * Determines information for filter function * according to constraints. * @param tab virtual table * @param info index/constraint iinformation * @result SQLite error code */ static int b2xy_bestindex(sqlite3_vtab *tab, sqlite3_index_info *info) { b2xy_table *bt = (b2xy_table *) tab; int i, key_order = 0, consumed = 0; /* preset to not using index */ info->idxNum = 0; /* * Only when the key column of the master table * (0th column in virtual table) is used in a * constraint, a WHERE condition in the xFilter * function can be coded. This is indicated by * setting "idxNum" to the "op" value of that * constraint. */ for (i = 0; i < info->nConstraint; ++i) { if (info->aConstraint[i].usable) { if ((info->aConstraint[i].iColumn == 0) && (info->aConstraint[i].op != 0)) { info->idxNum = info->aConstraint[i].op; info->aConstraintUsage[i].argvIndex = 1; info->aConstraintUsage[i].omit = 1; info->estimatedCost = 1.0; break; } } } /* * ORDER BY can be optimized, when our X column * is not present or to be sorted ascending. * Additionally when the key column is to be sorted * an ORDER BY is sent to the xFilter function. */ for (i = 0; i < info->nOrderBy; i++) { if (info->aOrderBy[i].iColumn == 0) { key_order = info->aOrderBy[i].desc ? -1 : 1; consumed++; } else if ((info->aOrderBy[i].iColumn == 1) && !info->aOrderBy[i].desc) { consumed++; } } if (consumed) { /* check for other ORDER BY columns */ for (i = 0; i < info->nOrderBy; i++) { if ((info->aOrderBy[i].iColumn == 1) && info->aOrderBy[i].desc) { consumed = 0; } else if (info->aOrderBy[i].iColumn > 1) { consumed = 0; } } } if (consumed && key_order) { info->idxStr = sqlite3_mprintf("ORDER BY \"%s\" %s", bt->key_column, (key_order < 0) ? "DESC" : "ASC"); info->needToFreeIdxStr = 1; } info->orderByConsumed = consumed; return SQLITE_OK; } #if (SQLITE_VERSION_NUMBER > 3004000) /** * Rename virtual table. * @param newname new name for table * @result SQLite error code */ static int b2xy_rename(sqlite3_vtab *tab, const char *newname) { return SQLITE_OK; } #endif static const sqlite3_module b2xy_module = { 1, /* iVersion */ b2xy_create, /* xCreate */ b2xy_create, /* xConnect */ b2xy_bestindex, /* xBestIndex */ b2xy_destroy, /* xDisconnect */ b2xy_destroy, /* xDestroy */ b2xy_open, /* xOpen */ b2xy_close, /* xClose */ b2xy_filter, /* xFilter */ b2xy_next, /* xNext */ b2xy_eof, /* xEof */ b2xy_column, /* xColumn */ b2xy_rowid, /* xRowid */ 0, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ 0, /* xFindFunction */ #if (SQLITE_VERSION_NUMBER > 3004000) b2xy_rename, /* xRename */ #endif }; /** * @typedef strbuf * @struct strbuf * Internal dynamic string buffer. */ typedef struct { int max; /**< maximum capacity */ int idx; /**< current index */ char *str; /**< string buffer */ } strbuf; /** * Initialize dynamic string buffer with capacity 1024. * @param sb pointer to string buffer * @result SQLite error code */ static int init_strbuf(strbuf *sb) { int n = 1024; if ((sb->max <= 0) || !sb->str) { sb->str = sqlite3_malloc(n); if (!sb->str) { return SQLITE_NOMEM; } sb->max = n; } sb->idx = 0; return SQLITE_OK; } /** * Expand or initialize dynamic string buffer. * @param sb pointer to string buffer * @result SQLite error code */ static int expand_strbuf(strbuf *sb) { int n; char *str; if ((sb->max <= 0) || !sb->str) { return init_strbuf(sb); } n = sb->max * 2; str = sqlite3_realloc(sb->str, n); if (!str) { return SQLITE_NOMEM; } sb->max = n; sb->str = str; return SQLITE_OK; } /** * Free resources of dynamic string buffer. * @param sb pointer to string buffer */ static void drop_strbuf(strbuf *sb) { if (sb->str) { sqlite3_free(sb->str); sb->str = 0; } sb->max = 0; } /** * Format printf-like into dynamic string buffer. * @param sb pointer to string buffer * @param fmt printf-like format string * @result SQLite error code */ static int print_strbuf(strbuf *sb, const char *fmt, ...) { int i, n, rc; va_list ap; va_start(ap, fmt); for (i = 0; i < 2; i++) { if (sb->max - (sb->idx + 1) < 256) { rc = expand_strbuf(sb); if (rc != SQLITE_OK) { return rc; } } rc = SQLITE_NOMEM; n = vsnprintf(sb->str + sb->idx, sb->max - sb->idx, fmt, ap); if ((n >= 0) && ((sb->idx + n) < (sb->max - 1))) { sb->idx += n; rc = SQLITE_OK; break; } } va_end(ap); return rc; } #define PATH_MODE_TK ((void *) 0) #define PATH_MODE_SVG ((void *) 1) #define PATH_MODE_BLT_X ((void *) 2) #define PATH_MODE_BLT_Y ((void *) 3) #define PATH_MODE_BLT ((void *) 4) #define PATH_MODE_TK3D ((void *) 5) /** * Make path/polyline from blob. * @param ctx SQLite function context * @param nargs number arguments * @param args arguments * * Arguments: * * args[0] - blob data (required)
* args[1] - type (optional, default "char")
* args[2] - X scale (optional)
* args[3] - X offset (optional)
* args[4] - Y scale (optional)
* args[5] - Y offset (optional)
* args[6] - Z value (optional)
* args[7] - Z scale (optional)
* args[8] - Z offset (optional)
*/ static void common_path_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { void *mode = sqlite3_user_data(ctx); char *data; int i, linebreak, size, type = TYPE_CHAR; int do_x_scale = 0, do_y_scale = 0, do_z_scale = 0; double x_scale, x_offset, y_scale, y_offset, z0, z_scale, z_offset; strbuf sb; if (nargs < 1) { sqlite3_result_error(ctx, "need at least 1 argument", -1); return; } if (nargs > 1) { type = string_to_type((const char *) sqlite3_value_text(args[1])); if (!type) { sqlite3_result_error(ctx, "bad type name", -1); return; } } data = (char *) sqlite3_value_blob(args[0]); size = sqlite3_value_bytes(args[0]) / TYPE_SIZE(type); if (!data || ((mode != PATH_MODE_BLT_X) && (mode != PATH_MODE_BLT_Y) && (size < 2)) || (size < 1)) { goto nullorempty; } x_scale = 1; x_offset = 0; if (nargs > 2) { x_scale = sqlite3_value_double(args[2]); do_x_scale++; } if (nargs > 3) { x_offset = sqlite3_value_double(args[3]); do_x_scale++; } y_scale = 1; y_offset = 0; if (nargs > 4) { y_scale = sqlite3_value_double(args[4]); do_y_scale++; } if (nargs > 5) { y_offset = sqlite3_value_double(args[5]); do_y_scale++; } z0 = 0; z_scale = 1; z_offset = 0; if ((mode == PATH_MODE_TK3D) && (nargs > 6)) { z0 = sqlite3_value_double(args[6]); } if ((mode == PATH_MODE_TK3D) && (nargs > 7)) { z_scale = sqlite3_value_double(args[7]); do_z_scale++; } if ((mode == PATH_MODE_TK3D) && (nargs > 8)) { z_offset = sqlite3_value_double(args[8]); do_z_scale++; } memset(&sb, 0, sizeof (sb)); if (init_strbuf(&sb) != SQLITE_OK) { goto nullorempty; } linebreak = 100; for (i = 0; i < size; i++, data += TYPE_SIZE(type)) { double x, y = 0, z = z0; char *fmt; if (do_z_scale) { z = z0 * z_scale + z_offset; } if (do_x_scale) { x = i * x_scale + x_offset; } else { x = i; } switch (type) { case TYPE_CHAR: y = data[0]; break; case TYPE_UCHAR: y = data[0] & 0xFF; break; case TYPE_SHORT_LE: y = (data[0] & 0xFF) | (data[1] << 8); break; case TYPE_USHORT_LE: y = (data[0] & 0xFF) | ((data[1] & 0xFF) << 8); break; case TYPE_SHORT_BE: y = (data[1] & 0xFF) | (data[0] << 8); break; case TYPE_USHORT_BE: y = (data[1] & 0xFF) | ((data[0] & 0xFF) << 8); break; case TYPE_INT_LE: y = (data[0] & 0xFF) | ((data[1] & 0xFF) << 8) | ((data[2] & 0xFF) << 16) | (data[3] << 24); break; case TYPE_UINT_LE: y = (data[0] & 0xFF) | ((data[1] & 0xFF) << 8) | ((data[2] & 0xFF) << 16) | ((data[3] & 0xFF) << 24); break; case TYPE_INT_BE: y = (data[3] & 0xFF) | ((data[2] & 0xFF) << 8) | ((data[1] & 0xFF) << 16) | (data[0] << 24); break; case TYPE_UINT_BE: y = (data[3] & 0xFF) | ((data[2] & 0xFF) << 8) | ((data[1] & 0xFF) << 16) | ((data[0] & 0xFF) << 24); break; case TYPE_FLOAT: y = ((float *) data)[0]; break; case TYPE_DOUBLE: y = ((double *) data)[0]; break; } if (do_y_scale) { y = y * y_scale + y_offset; } if ((mode == PATH_MODE_BLT_X) || (mode == PATH_MODE_BLT_Y)) { double v = (mode == PATH_MODE_BLT_X) ? x : y; if (print_strbuf(&sb, (i == 0) ? "%g" : " %g", v) != SQLITE_OK) { drop_strbuf(&sb); break; } continue; } if ((mode == PATH_MODE_SVG) && (i == 0)) { fmt = "M %g %g"; } else if ((mode == PATH_MODE_SVG) && (i == 1)) { fmt = " L %g %g"; } else if ((mode == PATH_MODE_SVG) && (sb.idx >= linebreak)) { fmt = "\nL %g %g"; linebreak = sb.idx + 100; } else if (i == 0) { fmt = (mode == PATH_MODE_TK3D) ? "%g %g %g" : "%g %g"; } else { fmt = (mode == PATH_MODE_TK3D) ? " %g %g %g" : " %g %g"; } if (print_strbuf(&sb, fmt, x, y, z) != SQLITE_OK) { drop_strbuf(&sb); break; } } if (sb.str) { sqlite3_result_text(ctx, sb.str, sb.idx, sqlite3_free); sb.str = 0; return; } nullorempty: if ((mode == PATH_MODE_BLT_X) || (mode == PATH_MODE_BLT_Y)) { sqlite3_result_text(ctx, "", 0, SQLITE_STATIC); } else { sqlite3_result_null(ctx); } } /** * @typedef path_aggctx * @struct path_aggctx * Internal aggregate context for path/polyline function. */ typedef struct { int init; /**< init flag, true when initialized */ int count; /**< counts formatted elements */ int linebreak; /**< when to add newline to output */ void *mode; /**< mode, see PATH_* defines */ strbuf sb; /**< string buffer for result */ } path_aggctx; /** * Path/polyline step callback for "tk_path", "svg_path", and * "tk3d_path" aggregate functions. * @param ctx SQLite function context * @param nargs number arguments * @param args arguments * * Arguments: * * args[0] - X value (required)
* args[1] - Y value (required)
* args[2] - X scale (optional)
* args[3] - X offset (optional)
* args[4] - Y scale (optional)
* args[5] - Y offset (optional)
* args[6] - Z value (optional)
* args[7] - Z scale (optional)
* args[8] - Z offset (optional)
*/ static void common_path_step(sqlite3_context *ctx, int nargs, sqlite3_value **args) { path_aggctx *pag; int type; char *fmt; double x, y, z = 0; double x_scale, y_scale, x_offset, y_offset, z_scale, z_offset; if (nargs < 2) { return; } pag = sqlite3_aggregate_context(ctx, sizeof (*pag)); if (!pag->init) { if (init_strbuf(&pag->sb) != SQLITE_OK) { return; } pag->linebreak = 100; pag->count = 0; pag->mode = sqlite3_user_data(ctx); pag->init = 1; } type = sqlite3_value_type(args[0]); if ((type != SQLITE_INTEGER) && (type != SQLITE_FLOAT)) { return; } type = sqlite3_value_type(args[1]); if ((type != SQLITE_INTEGER) && (type != SQLITE_FLOAT)) { return; } x = sqlite3_value_double(args[0]); y = sqlite3_value_double(args[1]); x_scale = 1; x_offset = 0; if (nargs > 2) { type = sqlite3_value_type(args[2]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { x_scale = sqlite3_value_double(args[2]); } } if (nargs > 3) { type = sqlite3_value_type(args[3]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { x_offset = sqlite3_value_double(args[3]); } } y_scale = 1; y_offset = 0; if (nargs > 4) { type = sqlite3_value_type(args[4]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { y_scale = sqlite3_value_double(args[4]); } } if (nargs > 5) { type = sqlite3_value_type(args[5]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { y_offset = sqlite3_value_double(args[5]); } } z_scale = 1; z_offset = 0; if ((pag->mode == PATH_MODE_TK3D) && (nargs > 6)) { z = sqlite3_value_double(args[6]); if (nargs > 7) { type = sqlite3_value_type(args[7]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { z_scale = sqlite3_value_double(args[7]); } } if (nargs > 8) { type = sqlite3_value_type(args[8]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { z_offset = sqlite3_value_double(args[8]); } } z = z * z_scale + z_offset; } x = x * x_scale + x_offset; y = y * y_scale + y_offset; if ((pag->mode == PATH_MODE_SVG) && (pag->count == 0)) { fmt = "M %g %g"; } else if ((pag->mode == PATH_MODE_SVG) && (pag->count == 1)) { fmt = " L %g %g"; } else if ((pag->mode == PATH_MODE_SVG) && (pag->sb.idx >= pag->linebreak)) { fmt = "\nL %g %g"; pag->linebreak = pag->sb.idx + 100; } else if (pag->count == 0) { fmt = (pag->mode == PATH_MODE_TK3D) ? "%g %g %g" : "%g %g"; } else { fmt = (pag->mode == PATH_MODE_TK3D) ? " %g %g %g" : " %g %g"; } if (print_strbuf(&pag->sb, fmt, x, y, z) != SQLITE_OK) { drop_strbuf(&pag->sb); pag->init = 0; } else { pag->count++; } } /** * Path/polyline finalizer. * @param ctx SQLite function context */ static void common_path_finalize(sqlite3_context *ctx) { path_aggctx *pag = sqlite3_aggregate_context(ctx, sizeof (*pag)); if (pag->init) { if ((pag->count > 1) || (pag->mode == PATH_MODE_BLT)) { sqlite3_result_text(ctx, pag->sb.str, pag->sb.idx, sqlite3_free); pag->sb.str = 0; pag->init = 0; return; } drop_strbuf(&pag->sb); } if (pag->mode == PATH_MODE_BLT) { sqlite3_result_text(ctx, "", 0, SQLITE_STATIC); } else { sqlite3_result_null(ctx); } } /** * Path/polyline step callback for "blt_vec" aggregate functions. * @param ctx SQLite function context * @param nargs number arguments * @param args arguments * * Arguments: * * args[0] - value (required)
* args[1] - scale (optional)
* args[2] - offset (optional)
*/ static void blt_vec_step(sqlite3_context *ctx, int nargs, sqlite3_value **args) { path_aggctx *pag; int type; double v, scale, offset; if (nargs < 1) { return; } pag = sqlite3_aggregate_context(ctx, sizeof (*pag)); if (!pag->init) { if (init_strbuf(&pag->sb) != SQLITE_OK) { return; } pag->count = 0; pag->mode = PATH_MODE_BLT; pag->init = 1; } type = sqlite3_value_type(args[0]); if ((type != SQLITE_INTEGER) && (type != SQLITE_FLOAT)) { return; } v = sqlite3_value_double(args[0]); scale = 1; offset = 0; if (nargs > 1) { type = sqlite3_value_type(args[1]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { scale = sqlite3_value_double(args[2]); } } if (nargs > 2) { type = sqlite3_value_type(args[2]); if ((type == SQLITE_INTEGER) || (type == SQLITE_FLOAT)) { offset = sqlite3_value_double(args[3]); } } v = v * scale + offset; if (print_strbuf(&pag->sb, (pag->count == 0) ? "%g" : " %g", v) != SQLITE_OK) { drop_strbuf(&pag->sb); pag->init = 0; } else { pag->count++; } } /** * "subblob" function similar to "substr". * @param ctx SQLite function context * @param nargs number arguments * @param args arguments */ static void subblob_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { int insize, outsize, start, itemsize = 1, itemskip = 0; int i, k, n; char *indata, *outdata; if (nargs < 3) { sqlite3_result_error(ctx, "need at least 1 argument", -1); return; } indata = (char *) sqlite3_value_blob(args[0]); insize = sqlite3_value_bytes(args[0]); if (!indata || (insize <= 0)) { isnull: sqlite3_result_null(ctx); return; } start = sqlite3_value_int(args[1]); if (start < 0) { start = insize - start; if (start < 0) { start = 0; } } else if (start > 0) { start--; } if (start >= insize) { goto isnull; } outsize = sqlite3_value_int(args[2]); if (outsize > insize - start) { outsize = insize - start; } if (outsize <= 0) { goto isnull; } if (nargs > 3) { itemsize = sqlite3_value_int(args[3]); if ((itemsize <= 0) || (itemsize > outsize)) { goto isnull; } } if (nargs > 4) { itemskip = sqlite3_value_int(args[4]); if (itemskip < 0) { goto isnull; } } outdata = sqlite3_malloc(outsize); if (!outdata) { sqlite3_result_error(ctx, "out of memory", -1); return; } for (i = n = 0; i < outsize; i++) { for (k = 0; k < itemsize; k++) { outdata[i + k] = indata[start]; n++; start++; if (start >= insize) { break; } } start += itemskip; if (start >= insize) { break; } } if (n > 0) { sqlite3_result_blob(ctx, outdata, n, sqlite3_free); return; } sqlite3_result_null(ctx); sqlite3_free(outdata); } /** * @typedef rownumber_ctx * @struct rownumber_ctx * SQLite context structure for "rownumber" function. */ typedef struct { sqlite3_context *ctx; /**< SQLite context */ sqlite3_value *value; /**< SQLite value for this context */ sqlite_int64 count; /**< Counter giving row number */ } rownumber_ctx; /** * "rownumber" function. * @param ctx SQLite function context * @param nargs number arguments * @param args arguments */ static void rownumber_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { rownumber_ctx *rn = sqlite3_get_auxdata(ctx, 0); if (!rn || (rn->ctx != ctx) || (rn->value != args[0])) { rn = sqlite3_malloc(sizeof (*rn)); if (rn) { rn->ctx = ctx; rn->value = args[0]; rn->count = 0; } sqlite3_set_auxdata(ctx, 0, rn, sqlite3_free); } else { rn->count++; } sqlite3_result_int64(ctx, rn ? rn->count : 0); } /** * Module initializer creating SQLite functions and * modules. * @param db SQLite database pointer * @result SQLite error code */ #ifndef STANDALONE static #endif int b2xy_init(sqlite3 *db) { sqlite3_create_function(db, "subblob", -1, SQLITE_ANY, (void *) 0, subblob_func, 0, 0); sqlite3_create_function(db, "tk_path_from_blob", -1, SQLITE_UTF8, PATH_MODE_TK, common_path_func, 0, 0); sqlite3_create_function(db, "svg_path_from_blob", -1, SQLITE_UTF8, PATH_MODE_SVG, common_path_func, 0, 0); sqlite3_create_function(db, "blt_vec_x", -1, SQLITE_UTF8, PATH_MODE_BLT_X, common_path_func, 0, 0); sqlite3_create_function(db, "blt_vec_y", -1, SQLITE_UTF8, PATH_MODE_BLT_Y, common_path_func, 0, 0); sqlite3_create_function(db, "tk3d_path_from_blob", -1, SQLITE_UTF8, PATH_MODE_TK3D, common_path_func, 0, 0); sqlite3_create_function(db, "tk_path", -1, SQLITE_ANY, PATH_MODE_TK, 0, common_path_step, common_path_finalize); sqlite3_create_function(db, "svg_path", -1, SQLITE_ANY, PATH_MODE_SVG, 0, common_path_step, common_path_finalize); sqlite3_create_function(db, "blt_vec", -1, SQLITE_ANY, PATH_MODE_BLT, 0, blt_vec_step, common_path_finalize); sqlite3_create_function(db, "tk3d_path", -1, SQLITE_ANY, PATH_MODE_TK3D, 0, common_path_step, common_path_finalize); sqlite3_create_function(db, "rownumber", 1, SQLITE_ANY, 0, rownumber_func, 0, 0); return sqlite3_create_module(db, "blobtoxy", &b2xy_module, 0); } #ifndef STANDALONE /** * Initializer for SQLite extension load mechanism. * @param db SQLite database pointer * @param errmsg pointer receiving error message * @param api SQLite API routines * @result SQLite error code */ int sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { SQLITE_EXTENSION_INIT2(api); return b2xy_init(db); } #endif ./sqliteodbc-0.992/blobtoxy.rc0100644000076400001440000000243312074001042014710 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 Extension BLOB to X/Y\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "BLOBTOXY\0" VALUE "LegalCopyright", "Copyright İ 2007-2013 \0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3_MOD_BLOBTOXY.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/impexp.c0100644000076400001440000016300312102415777014207 0ustar chwusers/** * @file impexp.c * SQLite extension module for importing/exporting * database information from/to SQL source text and * export to CSV text. * * 2007 January 27 * * The author disclaims copyright to this source code. In place of * a legal notice, here is a blessing: * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. * ******************************************************************** * *
 * Usage:
 *
 *  SQLite function:
 *       SELECT import_sql(filename);
 *
 *  C function:
 *       int impexp_import_sql(sqlite3 *db,
 *                             char *filename);
 *
 *       Reads SQL commands from filename and executes them
 *       against the current database. Returns the number
 *       of changes to the current database.
 *
 *
 *  SQLite function:
 *       SELECT export_sql(filename, [mode, tablename, ...]);
 *
 *  C function:
 *       int impexp_export_sql(sqlite3 *db, char *filename, int mode, ...);
 *
 *       Writes SQL to filename similar to SQLite's shell
 *       ".dump" meta command. Mode selects the output format:
 *       Mode 0 (default): dump schema and data using the
 *       optional table names following the mode argument.
 *       Mode 1: dump data only using the optional table
 *       names following the mode argument.
 *       Mode 2: dump schema and data using the optional
 *       table names following the mode argument; each
 *       table name is followed by a WHERE clause, i.e.
 *       "mode, table1, where1, table2, where2, ..."
 *       Mode 3: dump data only, same rules as in mode 2.
 *       Returns approximate number of lines written or
 *       -1 when an error occurred.
 *
 *       Bit 1 of mode:      when 1 dump data only
 *       Bits 8..9 of mode:  blob quoting mode
 *           0   default
 *         256   ORACLE
 *         512   SQL Server
 *         768   MySQL
 *
 *
 *  SQLite function:
 *       SELECT export_csv(filename, hdr, prefix1, tablename1, schema1, ...]);
 *
 *  C function:
 *       int impexp_export_csv(sqlite3 *db, char *filename, int hdr, ...);
 *                             [char *prefix1, char *tablename1,
 *                             char *schema1, ...]
 *
 *       Writes entire tables as CSV to provided filename. A header
 *       row is written when the hdr parameter is true. The
 *       rows are optionally introduced with a column made up of
 *       the prefix (non-empty string) for the respective table.
 *       If "schema" is NULL, "sqlite_master" is used, otherwise
 *       specify e.g. "sqlite_temp_master" for temporary tables or 
 *       "att.sqlite_master" for the attached database "att".
 *
 *          CREATE TABLE A(a,b);
 *          INSERT INTO A VALUES(1,2);
 *          INSERT INTO A VALUES(3,'foo');
 *          CREATE TABLE B(c);
 *          INSERT INTO B VALUES('hello');
 *          SELECT export_csv('out.csv', 0, 'aa', 'A', NULL, 'bb', 'B', NULL);
 *          -- CSV output
 *          "aa",1,2
 *          "aa",3,"foo"
 *          "bb","hello"
 *          SELECT export_csv('out.csv', 1, 'aa', 'A', NULL, 'bb', 'B', NULL);
 *          -- CSV output
 *          "aa","a","b"
 *          "aa",1,2
 *          "aa",3,"foo"
 *          "bb","c"
 *          "bb","hello"
 *
 *
 *  SQLite function:
 *       SELECT export_xml(filename, appendflag, indent,
 *                         [root, item, tablename, schema]+);
 *
 *  C function:
 *       int impexp_export_xml(sqlite3 *db, char *filename,
 *                             int append, int indent, char *root,
 *                             char *item, char *tablename, char *schema);
 *
 *       Writes a table as simple XML to provided filename. The
 *       rows are optionally enclosed with the "root" tag,
 *       the row data is enclosed in "item" tags. If "schema"
 *       is NULL, "sqlite_master" is used, otherwise specify
 *       e.g. "sqlite_temp_master" for temporary tables or 
 *       "att.sqlite_master" for the attached database "att".
 *          
 *          
 *           value
 *           ...
 *          
 *
 *       e.g.
 *
 *          CREATE TABLE A(a,b);
 *          INSERT INTO A VALUES(1,2.1);
 *          INSERT INTO A VALUES(3,'foo');
 *          INSERT INTO A VALUES('',NULL);
 *          INSERT INTO A VALUES(X'010203','');
 *          SELECT export_xml('out.xml', 0, 2, 'TBL_A', 'ROW', 'A');
 *          -- XML output
 *            
 *              
 *                <a TYPE="INTEGER">1</a>
 *                <b TYPE="REAL">2.1</b>
 *              
 *              
 *                <a TYPE="INTEGER">3</a>
 *                <b TYPE="TEXT">foo</b>
 *              
 *              
 *                <a TYPE="TEXT"></a>
 *                <b TYPE="NULL"></b>
 *              
 *              
 *                <a TYPE="BLOB">&x03;</a>
 *                <b TYPE="TEXT">&lt;blob&gt;</b>
 *              
 *            
 *
 *       Quoting of XML entities is performed only on the data,
 *       not on column names and root/item tags.
 *
 *
 *  SQLite function:
 *       SELECT export_json(filename, sql);
 *
 *  C function:
 *       int impexp_export_json(sqlite3 *db, char *sql,
 *                              impexp_putc pfunc, void *parg);
 *
 *       Executes arbitrary SQL statements and formats
 *       the result in JavaScript Object Notation (JSON).
 *       The layout of the result is:
 *
 *        object {results, sql}
 *         results[] object {columns, rows, changes, last_insert_rowid, error}
 *          columns[]
 *           object {name, decltype, type }     (sqlite3_column_*)
 *          rows[][]                            (sqlite3_column_*)
 *          changes                             (sqlite3_changes)
 *          last_insert_rowid                   (sqlite3_last_insert_rowid)
 *          error                               (sqlite3_errmsg)
 *         sql                                  (SQL text)
 *
 *       For each single SQL statement in "sql" an object in the
 *       "results" array is produced.
 *
 *       The function pointer for the output function to
 *       "impexp_export_json" has a signature compatible
 *       with fputc(3).
 *
 *
 * On Win32 the filename argument may be specified as NULL in order
 * to open a system file dialog for interactive filename selection.
 * 
*/ #ifdef STANDALONE #include #define sqlite3_api_routines void #else #include static SQLITE_EXTENSION_INIT1 #endif #include #include #include #include #ifdef _WIN32 #include #define strcasecmp _stricmp #define strncasecmp _strnicmp #else #include #endif #include "impexp.h" /** * @typedef struct json_pfs * @struct json_pfs * JSON output helper structure */ typedef struct { impexp_putc pfunc; /**< function like fputc() */ void *parg; /**< argument to function */ } json_pfs; static const char space_chars[] = " \f\n\r\t\v"; #define ISSPACE(c) ((c) && (strchr(space_chars, (c)) != 0)) /** * Read one line of input into dynamically allocated buffer * which the caller must free with sqlite3_free() * @param fin FILE pointer * @result dynamically allocated input line */ static char * one_input_line(FILE *fin) { char *line, *tmp; int nline; int n; int eol; nline = 256; line = sqlite3_malloc(nline); if (!line) { return 0; } n = 0; eol = 0; while (!eol) { if (n + 256 > nline) { nline = nline * 2 + 256; tmp = sqlite3_realloc(line, nline); if (!tmp) { sqlite3_free(line); return 0; } line = tmp; } if (!fgets(line + n, nline - n, fin)) { if (n == 0) { sqlite3_free(line); return 0; } line[n] = 0; eol = 1; break; } while (line[n]) { n++; } if ((n > 0) && (line[n-1] == '\n')) { n--; line[n] = 0; eol = 1; } } tmp = sqlite3_realloc(line, n + 1); if (!tmp) { sqlite3_free(line); } return tmp; } /** * Test if string ends with a semicolon * @param str string to be tested * @param n length of string * @result true or false */ static int ends_with_semicolon(const char *str, int n) { while ((n > 0) && ISSPACE(str[n - 1])) { n--; } return (n > 0) && (str[n - 1] == ';'); } /** * Test if string contains entirely whitespace or SQL comment * @param str string to be tested * @result true or false */ static int all_whitespace(const char *str) { for (; str[0]; str++) { if (ISSPACE(str[0])) { continue; } if ((str[0] == '/') && (str[1] == '*')) { str += 2; while (str[0] && ((str[0] != '*') || (str[1] != '/'))) { str++; } if (!str[0]) { return 0; } str++; continue; } if ((str[0] == '-') && (str[1] == '-')) { str += 2; while (str[0] && (str[0] != '\n')) { str++; } if (!str[0]) { return 1; } continue; } return 0; } return 1; } /** * Process contents of FILE pointer as SQL commands * @param db SQLite database to work on * @param fin input FILE pointer * @result number of errors */ static int process_input(sqlite3 *db, FILE *fin) { char *line = 0; char *sql = 0; int nsql = 0; int rc; int errors = 0; while (1) { line = one_input_line(fin); if (!line) { break; } if ((!sql || !sql[0]) && all_whitespace(line)) { continue; } if (!sql) { int i; for (i = 0; line[i] && ISSPACE(line[i]); i++) { /* empty loop body */ } if (line[i]) { nsql = strlen(line); sql = sqlite3_malloc(nsql + 1); if (!sql) { errors++; break; } strcpy(sql, line); } } else { int len = strlen(line); char *tmp; tmp = sqlite3_realloc(sql, nsql + len + 2); if (!tmp) { errors++; break; } sql = tmp; strcpy(sql + nsql, "\n"); nsql++; strcpy(sql + nsql, line); nsql += len; } sqlite3_free(line); line = 0; if (sql && ends_with_semicolon(sql, nsql) && sqlite3_complete(sql)) { rc = sqlite3_exec(db, sql, 0, 0, 0); if (rc != SQLITE_OK) { errors++; } sqlite3_free(sql); sql = 0; nsql = 0; } } if (sql) { sqlite3_free(sql); } if (line) { sqlite3_free(line); } return errors; } /** * SQLite function to quote SQLite value depending on optional quote mode * @param context SQLite function context * @param argc number of arguments * @param argv argument vector * * Layout of arguments: * * argv[0] - value to be quoted
* argv[1] - value of quote mode (optional)
*/ static void quote_func(sqlite3_context *context, int argc, sqlite3_value **argv) { int mode = 0; if (argc < 1) { return; } if (argc > 1) { mode = sqlite3_value_int(argv[1]); } switch (sqlite3_value_type(argv[0])) { case SQLITE_NULL: { sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC); break; } case SQLITE_INTEGER: case SQLITE_FLOAT: { sqlite3_result_value(context, argv[0]); break; } case SQLITE_BLOB: { char *text = 0; unsigned char *blob = (unsigned char *) sqlite3_value_blob(argv[0]); int nblob = sqlite3_value_bytes(argv[0]); if (2 * nblob + 4 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } text = (char *) sqlite3_malloc((2 * nblob) + 4); if (!text) { sqlite3_result_error(context, "out of memory", -1); } else { int i, k = 0; static const char xdigits[] = "0123456789ABCDEF"; if (mode == 1) { /* ORACLE enclosed in '' */ text[k++] = '\''; } else if (mode == 2) { /* SQL Server 0x prefix */ text[k++] = '0'; text[k++] = 'x'; } else if (mode == 3) { /* MySQL x'..' */ text[k++] = 'x'; text[k++] = '\''; } else { /* default */ text[k++] = 'X'; text[k++] = '\''; } for (i = 0; i < nblob; i++) { text[k++] = xdigits[(blob[i] >> 4 ) & 0x0F]; text[k++] = xdigits[blob[i] & 0x0F]; } if (mode == 1) { /* ORACLE enclosed in '' */ text[k++] = '\''; } else if (mode == 2) { /* SQL Server 0x prefix */ } else if (mode == 3) { /* MySQL x'..' */ text[k++] = '\''; } else { /* default */ text[k++] = '\''; } text[k] = '\0'; sqlite3_result_text(context, text, k, SQLITE_TRANSIENT); sqlite3_free(text); } break; } case SQLITE_TEXT: { int i, n; const unsigned char *arg = sqlite3_value_text(argv[0]); char *p; if (!arg) { return; } for (i = 0, n = 0; arg[i]; i++) { if (arg[i] == '\'') { n++; } } if (i + n + 3 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } p = sqlite3_malloc(i + n + 3); if (!p) { sqlite3_result_error(context, "out of memory", -1); return; } p[0] = '\''; for (i = 0, n = 1; arg[i]; i++) { p[n++] = arg[i]; if (arg[i] == '\'') { p[n++] = '\''; } } p[n++] = '\''; p[n] = 0; sqlite3_result_text(context, p, n, SQLITE_TRANSIENT); sqlite3_free(p); break; } } } /** * SQLite function to quote an SQLite value in CSV format * @param context SQLite function context * @param argc number of arguments * @param argv argument vector */ static void quote_csv_func(sqlite3_context *context, int argc, sqlite3_value **argv) { if (argc < 1) { return; } switch (sqlite3_value_type(argv[0])) { case SQLITE_NULL: { sqlite3_result_text(context, "", 0, SQLITE_STATIC); break; } case SQLITE_INTEGER: case SQLITE_FLOAT: { sqlite3_result_value(context, argv[0]); break; } case SQLITE_BLOB: { char *text = 0; unsigned char *blob = (unsigned char *) sqlite3_value_blob(argv[0]); int nblob = sqlite3_value_bytes(argv[0]); if (2 * nblob + 4 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } text = (char *) sqlite3_malloc((2 * nblob) + 4); if (!text) { sqlite3_result_error(context, "out of memory", -1); } else { int i, k = 0; static const char xdigits[] = "0123456789ABCDEF"; text[k++] = '"'; for (i = 0; i < nblob; i++) { text[k++] = xdigits[(blob[i] >> 4 ) & 0x0F]; text[k++] = xdigits[blob[i] & 0x0F]; } text[k++] = '"'; text[k] = '\0'; sqlite3_result_text(context, text, k, SQLITE_TRANSIENT); sqlite3_free(text); } break; } case SQLITE_TEXT: { int i, n; const unsigned char *arg = sqlite3_value_text(argv[0]); char *p; if (!arg) { return; } for (i = 0, n = 0; arg[i]; i++) { if (arg[i] == '"') { n++; } } if (i + n + 3 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } p = sqlite3_malloc(i + n + 3); if (!p) { sqlite3_result_error(context, "out of memory", -1); return; } p[0] = '"'; for (i = 0, n = 1; arg[i]; i++) { p[n++] = arg[i]; if (arg[i] == '"') { p[n++] = '"'; } } p[n++] = '"'; p[n] = 0; sqlite3_result_text(context, p, n, SQLITE_TRANSIENT); sqlite3_free(p); break; } } } /** * SQLite function to make XML indentation * @param context SQLite function context * @param argc number of arguments * @param argv argument vector */ static void indent_xml_func(sqlite3_context *context, int argc, sqlite3_value **argv) { static const char spaces[] = " "; int n = 0; if (argc > 0) { n = sqlite3_value_int(argv[0]); if (n > 32) { n = 32; } else if (n < 0) { n = 0; } } sqlite3_result_text(context, spaces, n, SQLITE_STATIC); } /** * SQLite function to quote a string for XML * @param context SQLite function context * @param argc number of arguments * @param argv argument vector */ static void quote_xml_func(sqlite3_context *context, int argc, sqlite3_value **argv) { static const char xdigits[] = "0123456789ABCDEF"; int type, addtype = 0; if (argc < 1) { return; } if (argc > 1) { addtype = sqlite3_value_int(argv[1]); } type = sqlite3_value_type(argv[0]); switch (type) { case SQLITE_NULL: { if (addtype > 0) { sqlite3_result_text(context, " TYPE=\"NULL\">", -1, SQLITE_STATIC); } else { sqlite3_result_text(context, "", 0, SQLITE_STATIC); } break; } case SQLITE_INTEGER: case SQLITE_FLOAT: { if (addtype > 0) { char *text = (char *) sqlite3_malloc(128); int k; if (!text) { sqlite3_result_error(context, "out of memory", -1); return; } strcpy(text, (type == SQLITE_FLOAT) ? " TYPE=\"REAL\">" : " TYPE=\"INTEGER\">"); k = strlen(text); strcpy(text + k, (char *) sqlite3_value_text(argv[0])); k = strlen(text); sqlite3_result_text(context, text, k, SQLITE_TRANSIENT); sqlite3_free(text); } else { sqlite3_result_value(context, argv[0]); } break; } case SQLITE_BLOB: { char *text = 0; unsigned char *blob = (unsigned char *) sqlite3_value_blob(argv[0]); int nblob = sqlite3_value_bytes(argv[0]); int i, k = 0; if (6 * nblob + 34 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } text = (char *) sqlite3_malloc((6 * nblob) + 34); if (!text) { sqlite3_result_error(context, "out of memory", -1); return; } if (addtype > 0) { strcpy(text, " TYPE=\"BLOB\">"); k = strlen(text); } for (i = 0; i < nblob; i++) { text[k++] = '&'; text[k++] = '#'; text[k++] = 'x'; text[k++] = xdigits[(blob[i] >> 4 ) & 0x0F]; text[k++] = xdigits[blob[i] & 0x0F]; text[k++] = ';'; } text[k] = '\0'; sqlite3_result_text(context, text, k, SQLITE_TRANSIENT); sqlite3_free(text); break; } case SQLITE_TEXT: { int i, n; const unsigned char *arg = sqlite3_value_text(argv[0]); char *p; if (!arg) { return; } for (i = 0, n = 0; arg[i]; i++) { if ((arg[i] == '"') || (arg[i] == '\'') || (arg[i] == '<') || (arg[i] == '>') || (arg[i] == '&') || (arg[i] < ' ')) { n += 5; } } if (i + n + 32 > 1000000000) { sqlite3_result_error(context, "value too large", -1); return; } p = sqlite3_malloc(i + n + 32); if (!p) { sqlite3_result_error(context, "out of memory", -1); return; } n = 0; if (addtype > 0) { strcpy(p, " TYPE=\"TEXT\">"); n = strlen(p); } for (i = 0; arg[i]; i++) { if (arg[i] == '"') { p[n++] = '&'; p[n++] = 'q'; p[n++] = 'u'; p[n++] = 'o'; p[n++] = 't'; p[n++] = ';'; } else if (arg[i] == '\'') { p[n++] = '&'; p[n++] = 'a'; p[n++] = 'p'; p[n++] = 'o'; p[n++] = 's'; p[n++] = ';'; } else if (arg[i] == '<') { p[n++] = '&'; p[n++] = 'l'; p[n++] = 't'; p[n++] = ';'; } else if (arg[i] == '>') { p[n++] = '&'; p[n++] = 'g'; p[n++] = 't'; p[n++] = ';'; } else if (arg[i] == '&') { p[n++] = '&'; p[n++] = 'a'; p[n++] = 'm'; p[n++] = 'p'; p[n++] = ';'; } else if (arg[i] < ' ') { p[n++] = '&'; p[n++] = '#'; p[n++] = 'x'; p[n++] = xdigits[(arg[i] >> 4 ) & 0x0F]; p[n++] = xdigits[arg[i] & 0x0F]; p[n++] = ';'; } else if (addtype < 0 && (arg[i] == ' ')) { p[n++] = '&'; p[n++] = '#'; p[n++] = 'x'; p[n++] = xdigits[(arg[i] >> 4 ) & 0x0F]; p[n++] = xdigits[arg[i] & 0x0F]; p[n++] = ';'; } else { p[n++] = arg[i]; } } p[n] = '\0'; sqlite3_result_text(context, p, n, SQLITE_TRANSIENT); sqlite3_free(p); break; } } } /** * SQLite function to read and process SQL commands from a file * @param ctx SQLite function context * @param nargs number of arguments * @param args argument vector */ static void import_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); int changes0 = sqlite3_changes(db); char *filename = 0; FILE *fin; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_PATHMUSTEXIST; if (GetOpenFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } fin = fopen(filename, "r"); if (!fin) { goto done; } process_input(db, fin); fclose(fin); done: sqlite3_result_int(ctx, sqlite3_changes(db) - changes0); } /* see doc in impexp.h */ int impexp_import_sql(sqlite3 *db, char *filename) { int changes0; FILE *fin; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (!db) { return 0; } changes0 = sqlite3_changes(db); #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_PATHMUSTEXIST; if (GetOpenFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } fin = fopen(filename, "r"); if (!fin) { goto done; } process_input(db, fin); fclose(fin); done: return sqlite3_changes(db) - changes0; } /** * @typedef DUMP_DATA * @struct DUMP_DATA * Structure for dump callback */ typedef struct { sqlite3 *db; /**< SQLite database pointer */ int with_schema; /**< if true, output schema */ int quote_mode; /**< mode for quoting data */ char *where; /**< optional where clause of dump */ int nlines; /**< counter for output lines */ int indent; /**< current indent level */ FILE *out; /**< output file pointer */ } DUMP_DATA; /** * Write indentation to dump * @param dd information structure for dump */ static void indent(DUMP_DATA *dd) { int i; for (i = 0; i < dd->indent; i++) { fputc(' ', dd->out); } } /** * Execute SQL to dump contents of one table * @param dd information structure for dump * @param errp pointer receiving error message * @param fmt if true, use sqlite3_*printf() on SQL * @param query SQL text to perform dump of table * @param ... optional arguments * @result SQLite error code */ static int table_dump(DUMP_DATA *dd, char **errp, int fmt, const char *query, ...) { sqlite3_stmt *select = 0; int rc; const char *rest, *q = query; va_list ap; if (errp && *errp) { sqlite3_free(*errp); *errp = 0; } if (fmt) { va_start(ap, query); q = sqlite3_vmprintf(query, ap); va_end(ap); if (!q) { return SQLITE_NOMEM; } } #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 rc = sqlite3_prepare_v2(dd->db, q, -1, &select, &rest); #else rc = sqlite3_prepare(dd->db, q, -1, &select, &rest); #endif if (fmt) { sqlite3_free((char *) q); } if ((rc != SQLITE_OK) || !select) { return rc; } rc = sqlite3_step(select); while (rc == SQLITE_ROW) { if (fputs((char *) sqlite3_column_text(select, 0), dd->out) > 0) { dd->nlines++; } if (dd->quote_mode >= 0) { fputc(';', dd->out); } if (dd->quote_mode == -1) { fputc('\r', dd->out); } if (dd->quote_mode >= -1) { fputc('\n', dd->out); } rc = sqlite3_step(select); } rc = sqlite3_finalize(select); if (rc != SQLITE_OK) { if (errp) { *errp = sqlite3_mprintf("%s", sqlite3_errmsg(dd->db)); } } return rc; } /** * Free dynamically allocated string buffer * @param in input string pointer */ static void append_free(char **in) { long *p = (long *) *in; if (p) { p -= 2; sqlite3_free(p); *in = 0; } } /** * Append a string to dynamically allocated string buffer * with optional quoting * @param in input string pointer * @param append string to append * @param quote quote character or NUL * @result new string to be free'd with append_free() */ static char * append(char **in, char const *append, char quote) { long *p = (long *) *in; long len, maxlen, actlen; int i; char *pp; int nappend = append ? strlen(append) : 0; if (p) { p -= 2; maxlen = p[0]; actlen = p[1]; } else { maxlen = actlen = 0; } len = nappend + actlen; if (quote) { len += 2; for (i = 0; i < nappend; i++) { if (append[i] == quote) { len++; } } } else if (!nappend) { return *in; } if (len >= maxlen - 1) { long *q; maxlen = (len + 0x03ff) & (~0x3ff); q = (long *) sqlite3_realloc(p, maxlen + 1 + 2 * sizeof (long)); if (!q) { return 0; } if (!p) { q[1] = 0; } p = q; p[0] = maxlen; *in = (char *) (p + 2); } pp = *in + actlen; if (quote) { *pp++ = quote; for (i = 0; i < nappend; i++) { *pp++ = append[i]; if (append[i] == quote) { *pp++ = quote; } } *pp++ = quote; *pp = '\0'; } else { if (nappend) { memcpy(pp, append, nappend); pp += nappend; *pp = '\0'; } } p[1] = pp - *in; return *in; } /** * Quote string for XML output during dump * @param dd information structure for dump * @param str string to be output */ static void quote_xml_str(DUMP_DATA *dd, char *str) { static const char xdigits[] = "0123456789ABCDEF"; int i; if (!str) { return; } for (i = 0; str[i]; i++) { if (str[i] == '"') { fputs(""", dd->out); } else if (str[i] == '\'') { fputs("'", dd->out); } else if (str[i] == '<') { fputs("<", dd->out); } else if (str[i] == '>') { fputs(">", dd->out); } else if (str[i] == '&') { fputs("&", dd->out); } else if ((unsigned char) str[i] <= ' ') { char buf[8]; buf[0] = '&'; buf[1] = '&'; buf[2] = '#'; buf[3] = 'x'; buf[4] = xdigits[(str[i] >> 4 ) & 0x0F]; buf[5] = xdigits[str[i] & 0x0F]; buf[6] = ';'; buf[7] = '\0'; fputs(buf, dd->out); } else { fputc(str[i], dd->out); } } } /** * Callback for sqlite3_exec() to dump one data row * @param udata information structure for dump * @param nargs number of columns * @param args column data * @param cols column labels * @result 0 to continue, 1 to abort */ static int dump_cb(void *udata, int nargs, char **args, char **cols) { int rc; const char *table, *type, *sql; DUMP_DATA *dd = (DUMP_DATA *) udata; if ((nargs != 3) || (args == NULL)) { return 1; } table = args[0]; type = args[1]; sql = args[2]; if (strcmp(table, "sqlite_sequence") == 0) { if (dd->with_schema) { if (fputs("DELETE FROM sqlite_sequence;\n", dd->out) >= 0) { dd->nlines++; } } } else if (strcmp(table, "sqlite_stat1") == 0) { if (dd->with_schema) { if (fputs("ANALYZE sqlite_master;\n", dd->out) >= 0) { dd->nlines++; } } } else if (strncmp(table, "sqlite_", 7) == 0) { return 0; } else if (strncmp(sql, "CREATE VIRTUAL TABLE", 20) == 0) { if (dd->with_schema) { sqlite3_stmt *stmt = 0; char *creat = 0, *table_info = 0; append(&table_info, "PRAGMA table_info(", 0); append(&table_info, table, '"'); append(&table_info, ")", 0); #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 rc = sqlite3_prepare_v2(dd->db, table_info, -1, &stmt, 0); #else rc = sqlite3_prepare(dd->db, table_info, -1, &stmt, 0); #endif append_free(&table_info); if ((rc != SQLITE_OK) || !stmt) { bailout0: if (stmt) { sqlite3_finalize(stmt); } append_free(&creat); return 1; } append(&creat, table, '"'); append(&creat, "(", 0); rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { const char *p; p = (const char *) sqlite3_column_text(stmt, 1); append(&creat, p, '"'); append(&creat, " ", 0); p = (const char *) sqlite3_column_text(stmt, 2); if (p && p[0]) { append(&creat, p, 0); } if (sqlite3_column_int(stmt, 5)) { append(&creat, " PRIMARY KEY", 0); } if (sqlite3_column_int(stmt, 3)) { append(&creat, " NOT NULL", 0); } p = (const char *) sqlite3_column_text(stmt, 4); if (p && p[0]) { append(&creat, " DEFAULT ", 0); append(&creat, p, 0); } rc = sqlite3_step(stmt); if (rc == SQLITE_ROW) { append(&creat, ",", 0); } } if (rc != SQLITE_DONE) { goto bailout0; } sqlite3_finalize(stmt); append(&creat, ")", 0); if (creat && fprintf(dd->out, "CREATE TABLE %s;\n", creat) > 0) { dd->nlines++; } append_free(&creat); } } else { if (dd->with_schema) { if (fprintf(dd->out, "%s;\n", sql) > 0) { dd->nlines++; } } } if ((strcmp(type, "table") == 0) || ((dd->quote_mode < 0) && (strcmp(type, "view") == 0))) { sqlite3_stmt *stmt = 0; char *select = 0, *hdr = 0, *table_info = 0; char buffer[256]; append(&table_info, "PRAGMA table_info(", 0); append(&table_info, table, '"'); append(&table_info, ")", 0); #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 rc = sqlite3_prepare_v2(dd->db, table_info, -1, &stmt, 0); #else rc = sqlite3_prepare(dd->db, table_info, -1, &stmt, 0); #endif append_free(&table_info); if ((rc != SQLITE_OK) || !stmt) { bailout1: if (stmt) { sqlite3_finalize(stmt); } append_free(&hdr); append_free(&select); return 1; } if (dd->quote_mode < -1) { if (dd->where) { append(&select, "SELECT ", 0); sprintf(buffer, "indent_xml(%d)", dd->indent); append(&select, buffer, 0); append(&select, " || '<' || quote_xml(", 0); append(&select, dd->where, '"'); append(&select, ",-1) || '>\n' || ", 0); } else { append(&select, "SELECT ", 0); } } else if (dd->quote_mode < 0) { if (dd->where) { append(&select, "SELECT quote_csv(", 0); append(&select, dd->where, '"'); append(&select, ") || ',' || ", 0); } else { append(&select, "SELECT ", 0); } if (dd->indent) { append(&hdr, select, 0); } } else { char *tmp = 0; if (dd->with_schema) { append(&select, "SELECT 'INSERT INTO ' || ", 0); } else { append(&select, "SELECT 'INSERT OR REPLACE INTO ' || ", 0); } append(&tmp, table, '"'); if (tmp) { append(&select, tmp, '\''); append_free(&tmp); } } if ((dd->quote_mode >= 0) && !dd->with_schema) { char *tmp = 0; append(&select, " || ' (' || ", 0); rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { const char *text = (const char *) sqlite3_column_text(stmt, 1); append(&tmp, text, '"'); if (tmp) { append(&select, tmp, '\''); append_free(&tmp); } rc = sqlite3_step(stmt); if (rc == SQLITE_ROW) { append(&select, " || ',' || ", 0); } } if (rc != SQLITE_DONE) { goto bailout1; } sqlite3_reset(stmt); append(&select, "|| ')'", 0); } if ((dd->quote_mode == -1) && dd->indent) { rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { const char *text = (const char *) sqlite3_column_text(stmt, 1); append(&hdr, "quote_csv(", 0); append(&hdr, text, '"'); rc = sqlite3_step(stmt); if (rc == SQLITE_ROW) { append(&hdr, ") || ',' || ", 0); } else { append(&hdr, ")", 0); } } if (rc != SQLITE_DONE) { goto bailout1; } sqlite3_reset(stmt); } if (dd->quote_mode >= 0) { append(&select, " || ' VALUES(' || ", 0); } rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { const char *text = (const char *) sqlite3_column_text(stmt, 1); const char *type = (const char *) sqlite3_column_text(stmt, 2); int tlen = strlen(type ? type : ""); if (dd->quote_mode < -1) { sprintf(buffer, "indent_xml(%d)", dd->indent + 1); append(&select, buffer, 0); append(&select, "|| '<' || quote_xml(", 0); append(&select, text, '\''); append(&select, ",-1) || quote_xml(", 0); append(&select, text, '"'); append(&select, ",1) || '\n'", 0); } else if (dd->quote_mode < 0) { /* leave out BLOB columns */ if (((tlen >= 4) && (strncasecmp(type, "BLOB", 4) == 0)) || ((tlen >= 6) && (strncasecmp(type, "BINARY", 6) == 0))) { rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { tlen = strlen(select); if (tlen > 10) { select[tlen - 10] = '\0'; } } continue; } append(&select, "quote_csv(", 0); append(&select, text, '"'); } else { append(&select, "quote_sql(", 0); append(&select, text, '"'); if (dd->quote_mode) { char mbuf[32]; sprintf(mbuf, ",%d", dd->quote_mode); append(&select, mbuf, 0); } } rc = sqlite3_step(stmt); if (rc == SQLITE_ROW) { if (dd->quote_mode >= -1) { append(&select, ") || ',' || ", 0); } else { append(&select, " || ", 0); } } else { if (dd->quote_mode >= -1) { append(&select, ") ", 0); } else { append(&select, " ", 0); } } } if (rc != SQLITE_DONE) { goto bailout1; } sqlite3_finalize(stmt); stmt = 0; if (dd->quote_mode >= 0) { append(&select, "|| ')' FROM ", 0); } else { if ((dd->quote_mode < -1) && dd->where) { sprintf(buffer, " || indent_xml(%d)", dd->indent); append(&select, buffer, 0); append(&select, " || 'where, '"'); append(&select, ",-1) || '>\n' FROM ", 0); } else { append(&select, "FROM ", 0); } } append(&select, table, '"'); if ((dd->quote_mode >= 0) && dd->where) { append(&select, " ", 0); append(&select, dd->where, 0); } if (hdr) { rc = table_dump(dd, 0, 0, hdr); append_free(&hdr); hdr = 0; } rc = table_dump(dd, 0, 0, select); if (rc == SQLITE_CORRUPT) { append(&select, " ORDER BY rowid DESC", 0); rc = table_dump(dd, 0, 0, select); } append_free(&select); } return 0; } /** * Execute SQL on sqlite_master table in order to dump data. * @param dd information structure for dump * @param errp pointer receiving error message * @param query SQL for sqlite3_*printf() * @param ... argument list * @result SQLite error code */ static int schema_dump(DUMP_DATA *dd, char **errp, const char *query, ...) { int rc; char *q; va_list ap; if (errp) { sqlite3_free(*errp); *errp = 0; } va_start(ap, query); q = sqlite3_vmprintf(query, ap); va_end(ap); if (!q) { return SQLITE_NOMEM; } rc = sqlite3_exec(dd->db, q, dump_cb, dd, errp); if (rc == SQLITE_CORRUPT) { char *tmp; tmp = sqlite3_mprintf("%s ORDER BY rowid DESC", q); sqlite3_free(q); if (!tmp) { return rc; } q = tmp; if (errp) { sqlite3_free(*errp); *errp = 0; } rc = sqlite3_exec(dd->db, q, dump_cb, dd, errp); } sqlite3_free(q); return rc; } /** * SQLite function for SQL output, see impexp_export_sql * @param ctx SQLite function context * @param nargs number of arguments * @param args argument vector */ static void export_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { DUMP_DATA dd0, *dd = &dd0; sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); int i, mode = 0; char *filename = 0; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif dd->db = db; dd->where = 0; dd->nlines = -1; dd->indent = 0; if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } dd->out = fopen(filename, "w"); if (!dd->out) { goto done; } if (nargs > 1) { mode = sqlite3_value_int(args[1]); } dd->with_schema = !(mode & 1); dd->quote_mode = (mode >> 8) & 3; dd->nlines = 0; if (fputs("BEGIN TRANSACTION;\n", dd->out) >= 0) { dd->nlines++; } if (nargs <= 2) { schema_dump(dd, 0, "SELECT name, type, sql FROM sqlite_master" " WHERE sql NOT NULL AND type = 'table'"); if (dd->with_schema) { table_dump(dd, 0, 0, "SELECT sql FROM sqlite_master WHERE" " sql NOT NULL AND type IN ('index','trigger','view')"); } } else { for (i = 2; i < nargs; i += (mode & 2) ? 2 : 1) { dd->where = 0; if ((mode & 2) && (i + 1 < nargs)) { dd->where = (char *) sqlite3_value_text(args[i + 1]); } schema_dump(dd, 0, "SELECT name, type, sql FROM sqlite_master" " WHERE tbl_name LIKE %Q AND type = 'table'" " AND sql NOT NULL", sqlite3_value_text(args[i])); if (dd->with_schema) { table_dump(dd, 0, 1, "SELECT sql FROM sqlite_master" " WHERE sql NOT NULL" " AND type IN ('index','trigger','view')" " AND tbl_name LIKE %Q", sqlite3_value_text(args[i])); } } } if (fputs("COMMIT;\n", dd->out) >= 0) { dd->nlines++; } fclose(dd->out); done: sqlite3_result_int(ctx, dd->nlines); } /** * SQLite function for CSV output, see impexp_export_csv * @param ctx SQLite function context * @param nargs number of arguments * @param args argument vector */ static void export_csv_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { DUMP_DATA dd0, *dd = &dd0; sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); int i; char *filename = 0; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif dd->db = db; dd->where = 0; dd->nlines = -1; dd->indent = 0; dd->with_schema = 0; dd->quote_mode = -1; if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } #ifdef _WIN32 dd->out = fopen(filename, "wb"); #else dd->out = fopen(filename, "w"); #endif if (!dd->out) { goto done; } dd->nlines = 0; if (nargs > 1) { if (sqlite3_value_type(args[1]) != SQLITE_NULL) { if (sqlite3_value_int(args[1])) { dd->indent = 1; } } } for (i = 2; i <= nargs - 3; i += 3) { char *schema = 0, *sql; dd->where = 0; if (sqlite3_value_type(args[i]) != SQLITE_NULL) { dd->where = (char *) sqlite3_value_text(args[i]); if (dd->where && !dd->where[0]) { dd->where = 0; } } if (sqlite3_value_type(args[i + 2]) != SQLITE_NULL) { schema = (char *) sqlite3_value_text(args[i + 2]); } if (!schema || (schema[0] == '\0')) { schema = "sqlite_master"; } sql = sqlite3_mprintf("SELECT name, type, sql FROM %s" " WHERE tbl_name LIKE %%Q AND " " (type = 'table' OR type = 'view')" " AND sql NOT NULL", schema); if (sql) { schema_dump(dd, 0, sql, sqlite3_value_text(args[i + 1])); sqlite3_free(sql); } } fclose(dd->out); done: sqlite3_result_int(ctx, dd->nlines); } /** * SQLite function for XML output, see impexp_export_xml * @param ctx SQLite function context * @param nargs number of arguments * @param args argument vector */ static void export_xml_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { DUMP_DATA dd0, *dd = &dd0; sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); int i; char *filename = 0; char *openmode = "w"; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif dd->db = db; dd->where = 0; dd->nlines = -1; dd->indent = 0; dd->with_schema = 0; dd->quote_mode = -2; if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } if (nargs > 1) { if (sqlite3_value_type(args[1]) != SQLITE_NULL) { if (sqlite3_value_int(args[1])) { openmode = "a"; } } } if (nargs > 2) { if (sqlite3_value_type(args[2]) != SQLITE_NULL) { dd->indent = sqlite3_value_int(args[2]); if (dd->indent < 0) { dd->indent = 0; } } } dd->out = fopen(filename, openmode); if (!dd->out) { goto done; } dd->nlines = 0; for (i = 3; i <= nargs - 4; i += 4) { char *root = 0, *schema = 0, *sql; if (sqlite3_value_type(args[i]) != SQLITE_NULL) { root = (char *) sqlite3_value_text(args[i]); if (root && !root[0]) { root = 0; } } dd->where = 0; if (sqlite3_value_type(args[i + 1]) != SQLITE_NULL) { dd->where = (char *) sqlite3_value_text(args[i + 1]); if (dd->where && !dd->where[0]) { dd->where = 0; } } if (root) { indent(dd); dd->indent++; fputs("<", dd->out); quote_xml_str(dd, root); fputs(">\n", dd->out); } if (sqlite3_value_type(args[i + 3]) != SQLITE_NULL) { schema = (char *) sqlite3_value_text(args[i + 3]); } if (!schema || (schema[0] == '\0')) { schema = "sqlite_master"; } sql = sqlite3_mprintf("SELECT name, type, sql FROM %s" " WHERE tbl_name LIKE %%Q AND" " (type = 'table' OR type = 'view')" " AND sql NOT NULL", schema); if (sql) { schema_dump(dd, 0, sql, sqlite3_value_text(args[i + 2])); sqlite3_free(sql); } if (root) { dd->indent--; indent(dd); fputs("out); quote_xml_str(dd, root); fputs(">\n", dd->out); } } fclose(dd->out); done: sqlite3_result_int(ctx, dd->nlines); } /* see doc in impexp.h */ int impexp_export_sql(sqlite3 *db, char *filename, int mode, ...) { DUMP_DATA dd0, *dd = &dd0; va_list ap; char *table; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (!db) { return 0; } dd->db = db; dd->where = 0; dd->nlines = -1; #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } dd->out = fopen(filename, "w"); if (!dd->out) { goto done; } dd->with_schema = !(mode & 1); dd->nlines = 0; if (fputs("BEGIN TRANSACTION;\n", dd->out) >= 0) { dd->nlines++; } va_start(ap, mode); table = va_arg(ap, char *); if (!table) { schema_dump(dd, 0, "SELECT name, type, sql FROM sqlite_master" " WHERE sql NOT NULL AND type = 'table'"); if (dd->with_schema) { table_dump(dd, 0, 0, "SELECT sql FROM sqlite_master WHERE" " sql NOT NULL AND type IN ('index','trigger','view')"); } } else { while (table) { dd->where = 0; if ((mode & 2)) { dd->where = va_arg(ap, char *); } schema_dump(dd, 0, "SELECT name, type, sql FROM sqlite_master" " WHERE tbl_name LIKE %Q AND type = 'table'" " AND sql NOT NULL", table); if (dd->with_schema) { table_dump(dd, 0, 1, "SELECT sql FROM sqlite_master" " WHERE sql NOT NULL" " AND type IN ('index','trigger','view')" " AND tbl_name LIKE %Q", table); } table = va_arg(ap, char *); } } va_end(ap); if (fputs("COMMIT;\n", dd->out) >= 0) { dd->nlines++; } fclose(dd->out); done: return dd->nlines; } /* see doc in impexp.h */ int impexp_export_csv(sqlite3 *db, char *filename, int hdr, ...) { DUMP_DATA dd0, *dd = &dd0; va_list ap; char *prefix, *table, *schema; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (!db) { return 0; } dd->db = db; dd->where = 0; dd->nlines = -1; dd->indent = 0; dd->with_schema = 0; dd->quote_mode = -1; dd->indent = hdr != 0; #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } #ifdef _WIN32 dd->out = fopen(filename, "wb"); #else if ((hdr < 0) && access(filename, W_OK) == 0) { dd->out = fopen(filename, "a"); dd->indent = 0; } else { dd->out = fopen(filename, "w"); } #endif if (!dd->out) { goto done; } dd->nlines = 0; va_start(ap, hdr); prefix = va_arg(ap, char *); table = va_arg(ap, char *); schema = va_arg(ap, char *); while (table != NULL) { char *sql; dd->where = (prefix && prefix[0]) ? prefix : 0; if (!schema || (schema[0] == '\0')) { schema = "sqlite_master"; } sql = sqlite3_mprintf("SELECT name, type, sql FROM %s" " WHERE tbl_name LIKE %%Q AND" " (type = 'table' OR type = 'view')" " AND sql NOT NULL", schema); if (sql) { schema_dump(dd, 0, sql, table); sqlite3_free(sql); } prefix = va_arg(ap, char *); table = va_arg(ap, char *); schema = va_arg(ap, char *); } va_end(ap); fclose(dd->out); done: return dd->nlines; } /* see doc in impexp.h */ int impexp_export_xml(sqlite3 *db, char *filename, int append, int indnt, char *root, char *item, char *tablename, char *schema) { DUMP_DATA dd0, *dd = &dd0; char *sql; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (!db) { return 0; } dd->db = db; dd->where = item; dd->nlines = -1; dd->indent = (indnt > 0) ? indnt : 0; dd->with_schema = 0; dd->quote_mode = -2; #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } dd->out = fopen(filename, append ? "a" : "w"); if (!dd->out) { goto done; } dd->nlines = 0; if (root) { indent(dd); dd->indent++; fputs("<", dd->out); quote_xml_str(dd, root); fputs(">\n", dd->out); } if (!schema || (schema[0] == '\0')) { schema = "sqlite_master"; } sql = sqlite3_mprintf("SELECT name, type, sql FROM %s" " WHERE tbl_name LIKE %%Q AND" " (type = 'table' OR type = 'view')" " AND sql NOT NULL", schema); if (sql) { schema_dump(dd, 0, sql, tablename); sqlite3_free(sql); } if (root) { dd->indent--; indent(dd); fputs("out); quote_xml_str(dd, root); fputs(">\n", dd->out); } fclose(dd->out); done: return dd->nlines; } /** * Write string using JSON output function * @param string string to be written * @param pfs JSON output function */ static void json_pstr(const char *string, json_pfs *pfs) { while (*string) { pfs->pfunc(*string, pfs->parg); string++; } } /** * Quote and write string using JSON output function * @param string string to be written * @param pfs JSON output function */ static void json_pstrq(const char *string, json_pfs *pfs) { impexp_putc pfunc = pfs->pfunc; void *parg = pfs->parg; char buf[64]; if (!string) { json_pstr("null", pfs); return; } pfunc('"', parg); while (*string) { switch (*string) { case '"': case '\\': pfunc('\\', parg); pfunc(*string, parg); break; case '\b': pfunc('\\', parg); pfunc('b', parg); break; case '\f': pfunc('\\', parg); pfunc('f', parg); break; case '\n': pfunc('\\', parg); pfunc('n', parg); break; case '\r': pfunc('\\', parg); pfunc('r', parg); break; case '\t': pfunc('\\', parg); pfunc('t', parg); break; default: if (((*string < ' ') && (*string > 0)) || (*string == 0x7f)) { sprintf(buf, "\\u%04x", *string); json_pstr(buf, pfs); } else if (*string < 0) { unsigned char c = string[0]; unsigned long uc = 0; if (c < 0xc0) { uc = c; } else if (c < 0xe0) { if ((string[1] & 0xc0) == 0x80) { uc = ((c & 0x1f) << 6) | (string[1] & 0x3f); ++string; } else { uc = c; } } else if (c < 0xf0) { if (((string[1] & 0xc0) == 0x80) && ((string[2] & 0xc0) == 0x80)) { uc = ((c & 0x0f) << 12) | ((string[1] & 0x3f) << 6) | (string[2] & 0x3f); string += 2; } else { uc = c; } } else if (c < 0xf8) { if (((string[1] & 0xc0) == 0x80) && ((string[2] & 0xc0) == 0x80) && ((string[3] & 0xc0) == 0x80)) { uc = ((c & 0x03) << 18) | ((string[1] & 0x3f) << 12) | ((string[2] & 0x3f) << 6) | (string[4] & 0x3f); string += 3; } else { uc = c; } } else if (c < 0xfc) { if (((string[1] & 0xc0) == 0x80) && ((string[2] & 0xc0) == 0x80) && ((string[3] & 0xc0) == 0x80) && ((string[4] & 0xc0) == 0x80)) { uc = ((c & 0x01) << 24) | ((string[1] & 0x3f) << 18) | ((string[2] & 0x3f) << 12) | ((string[4] & 0x3f) << 6) | (string[5] & 0x3f); string += 4; } else { uc = c; } } else { /* ignore */ ++string; } if (uc < 0x10000) { sprintf(buf, "\\u%04lx", uc); } else if (uc < 0x100000) { uc -= 0x10000; sprintf(buf, "\\u%04lx", 0xd800 | ((uc >> 10) & 0x3ff)); json_pstr(buf, pfs); sprintf(buf, "\\u%04lx", 0xdc00 | (uc & 0x3ff)); } else { strcpy(buf, "\\ufffd"); } json_pstr(buf, pfs); } else { pfunc(*string, parg); } break; } ++string; } pfunc('"', parg); } /** * Conditionally quote and write string using JSON output function * @param string string to be written * @param pfs JSON output function */ static void json_pstrc(const char *string, json_pfs *pfs) { if (*string && strchr(".0123456789-+", *string)) { json_pstr(string, pfs); } else { json_pstrq(string, pfs); } } /** * Write a blob as base64 string using JSON output function * @param blk pointer to blob * @param len length of blob * @param pfs JSON output function */ static void json_pb64(const unsigned char *blk, int len, json_pfs *pfs) { impexp_putc pfunc = pfs->pfunc; void *parg = pfs->parg; int i, reg[5]; char buf[16]; static const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; if (!blk) { json_pstr("null", pfs); return; } buf[4] = '\0'; pfunc('"', parg); for (i = 0; i < len; i += 3) { reg[1] = reg[2] = reg[3] = reg[4] = 0; reg[0] = blk[i]; if (i + 1 < len) { reg[1] = blk[i + 1]; reg[3] = 1; } if (i + 2 < len) { reg[2] = blk[i + 2]; reg[4] = 1; } buf[0] = b64[reg[0] >> 2]; buf[1] = b64[((reg[0] << 4) & 0x30) | (reg[1] >> 4)]; if (reg[3]) { buf[2] = b64[((reg[1] << 2) & 0x3c) | (reg[2] >> 6)]; } else { buf[2] = '='; } if (reg[4]) { buf[3] = b64[reg[2] & 0x3f]; } else { buf[3] = '='; } json_pstr(buf, pfs); } pfunc('"', parg); } /** * Execute SQL and write output as JSON * @param db SQLite database pointer * @param sql SQL text * @param pfunc JSON output function * @param parg argument for output function * @result SQLite error code */ static int json_output(sqlite3 *db, char *sql, impexp_putc pfunc, void *parg) { json_pfs pfs0, *pfs = &pfs0; const char *tail = sql; int i, nresults = 0, result = SQLITE_ERROR; pfs->pfunc = pfunc; pfs->parg = parg; json_pstr("{\"sql\":", pfs); json_pstrq(sql, pfs); json_pstr(",\"results\":[", pfs); do { sqlite3_stmt *stmt; int firstrow = 1, nrows = 0; char buf[256]; ++nresults; json_pstr((nresults == 1) ? "{" : ",{", pfs); result = sqlite3_prepare(db, tail, -1, &stmt, &tail); if (result != SQLITE_OK) { doerr: if (nrows == 0) { json_pstr("\"columns\":null,\"rows\":null,\"changes\":0," "\"last_insert_rowid\":null,", pfs); } json_pstr("\"error:\"", pfs); json_pstrq(sqlite3_errmsg(db), pfs); pfunc('}', parg); break; } result = sqlite3_step(stmt); while ((result == SQLITE_ROW) || (result == SQLITE_DONE)) { if (firstrow) { for (i = 0; i < sqlite3_column_count(stmt); i++) { char *type; json_pstr((i == 0) ? "\"columns\":[" : ",", pfs); json_pstr("{\"name\":", pfs); json_pstrq(sqlite3_column_name(stmt, i), pfs); json_pstr(",\"decltype\":", pfs); json_pstrq(sqlite3_column_decltype(stmt, i), pfs); json_pstr(",\"type\":", pfs); switch (sqlite3_column_type(stmt, i)) { case SQLITE_INTEGER: type = "integer"; break; case SQLITE_FLOAT: type = "float"; break; case SQLITE_BLOB: type = "blob"; break; case SQLITE_TEXT: type = "text"; break; case SQLITE_NULL: type = "null"; break; default: type = "unknown"; break; } json_pstrq(type, pfs); pfunc('}', parg); } if (i) { pfunc(']', parg); } firstrow = 0; } if (result == SQLITE_DONE) { break; } ++nrows; json_pstr((nrows == 1) ? ",\"rows\":[" : ",", pfs); for (i = 0; i < sqlite3_column_count(stmt); i++) { pfunc((i == 0) ? '[' : ',', parg); switch (sqlite3_column_type(stmt, i)) { case SQLITE_INTEGER: json_pstr((char *) sqlite3_column_text(stmt, i), pfs); break; case SQLITE_FLOAT: json_pstrc((char *) sqlite3_column_text(stmt, i), pfs); break; case SQLITE_BLOB: json_pb64((unsigned char *) sqlite3_column_blob(stmt, i), sqlite3_column_bytes(stmt, i), pfs); break; case SQLITE_TEXT: json_pstrq((char *) sqlite3_column_text(stmt, i), pfs); break; case SQLITE_NULL: default: json_pstr("null", pfs); break; } } json_pstr((i == 0) ? "null]" : "]", pfs); result = sqlite3_step(stmt); } if (nrows > 0) { pfunc(']', parg); } result = sqlite3_finalize(stmt); if (result != SQLITE_OK) { if (nrows > 0) { sprintf(buf, #ifdef _WIN32 ",\"changes\":%d,\"last_insert_rowid\":%I64d", #else ",\"changes\":%d,\"last_insert_rowid\":%lld", #endif sqlite3_changes(db), sqlite3_last_insert_rowid(db)); json_pstr(buf, pfs); } goto doerr; } if (nrows == 0) { json_pstr("\"columns\":null,\"rows\":null", pfs); } sprintf(buf, #ifdef _WIN32 ",\"changes\":%d,\"last_insert_rowid\":%I64d", #else ",\"changes\":%d,\"last_insert_rowid\":%lld", #endif sqlite3_changes(db), sqlite3_last_insert_rowid(db)); json_pstr(buf, pfs); json_pstr(",\"error\":null}", pfs); } while (tail && *tail); json_pstr("]}", pfs); return result; } /** * SQLite function for JSON output, see impexp_export_json * @param ctx SQLite function context * @param nargs number of arguments * @param args argument vector */ static void export_json_func(sqlite3_context *ctx, int nargs, sqlite3_value **args) { sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); int result = -1; char *filename = 0; char *sql = 0; FILE *out = 0; #ifdef _WIN32 char fnbuf[MAX_PATH]; #endif if (nargs > 0) { if (sqlite3_value_type(args[0]) != SQLITE_NULL) { filename = (char *) sqlite3_value_text(args[0]); } } #ifdef _WIN32 if (!filename) { OPENFILENAME ofn; memset(&ofn, 0, sizeof (ofn)); memset(fnbuf, 0, sizeof (fnbuf)); ofn.lStructSize = sizeof (ofn); ofn.lpstrFile = fnbuf; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if (GetSaveFileName(&ofn)) { filename = fnbuf; } } #endif if (!filename) { goto done; } out = fopen(filename, "w"); if (!out) { goto done; } if (nargs > 1) { sql = (char *) sqlite3_value_text(args[1]); } if (sql) { result = json_output(db, sql, (impexp_putc) fputc, out); } fclose(out); done: sqlite3_result_int(ctx, result); } /* see doc in impexp.h */ int impexp_export_json(sqlite3 *db, char *sql, impexp_putc pfunc, void *parg) { return json_output(db, sql, pfunc, parg); } /** * Initializer for SQLite extension load mechanism. * @param db SQLite database pointer * @param errmsg pointer receiving error message * @param api SQLite API routines * @result SQLite error code */ #ifdef STANDALONE static int #else int #endif sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { int rc, i; static const struct { const char *name; void (*func)(sqlite3_context *, int, sqlite3_value **); int nargs; int textrep; } ftab[] = { { "quote_sql", quote_func, -1, SQLITE_UTF8 }, { "import_sql", import_func, -1, SQLITE_UTF8 }, { "export_sql", export_func, -1, SQLITE_UTF8 }, { "quote_csv", quote_csv_func, -1, SQLITE_UTF8 }, { "export_csv", export_csv_func, -1, SQLITE_UTF8 }, { "indent_xml", indent_xml_func, 1, SQLITE_UTF8 }, { "quote_xml", quote_xml_func, -1, SQLITE_UTF8 }, { "export_xml", export_xml_func, -1, SQLITE_UTF8 }, { "export_json", export_json_func, -1, SQLITE_UTF8 } }; #ifndef STANDALONE if (api != NULL) { SQLITE_EXTENSION_INIT2(api); } #endif for (i = 0; i < sizeof (ftab) / sizeof (ftab[0]); i++) { rc = sqlite3_create_function(db, ftab[i].name, ftab[i].nargs, ftab[i].textrep, db, ftab[i].func, 0, 0); if (rc != SQLITE_OK) { for (--i; i >= 0; --i) { sqlite3_create_function(db, ftab[i].name, ftab[i].nargs, ftab[i].textrep, 0, 0, 0, 0); } break; } } return rc; } /* see doc in impexp.h */ int impexp_init(sqlite3 *db) { return sqlite3_extension_init(db, NULL, NULL); } ./sqliteodbc-0.992/impexp.h0100644000076400001440000001565512005452413014213 0ustar chwusers#ifndef _IMPEXP_H #define _IMPEXP_H /** * @file impexp.h * SQLite extension module for importing/exporting * database information from/to SQL source text and * export to CSV text. * * 2007 January 27 * * The author disclaims copyright to this source code. In place of * a legal notice, here is a blessing: * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. * ******************************************************************** */ /** * Reads SQL commands from filename and executes them * against the current database. Returns the number * of changes to the current database. * @param db SQLite database pointer * @param filename name of input file * @result number of changes to database */ int impexp_import_sql(sqlite3 *db, char *filename); /** * Writes SQL to filename similar to SQLite's shell * ".dump" meta command. Mode selects the output format. * @param db SQLite database pointer * @param filename name of output file * @param mode selects output format * @param ... optional table names or tuples of table name, * and where-clause depending on mode parameter * @result approximate number of lines written or * -1 when an error occurred * * Mode 0 (default): dump schema and data using the * optional table names following the mode argument.
* Mode 1: dump data only using the optional table * names following the mode argument.
* Mode 2: dump schema and data using the optional * table names following the mode argument; each * table name is followed by a WHERE clause, i.e. * "mode, table1, where1, table2, where2, ..."
* Mode 3: dump data only, same rules as in mode 2.
* * Other flags in mode: * *
 *       Bit 1 of mode:      when 1 dump data only
 *       Bits 8..9 of mode:  blob quoting mode
 *
 *           0   default
 *         256   ORACLE
 *         512   SQL Server
 *         768   MySQL
 * 
*/ int impexp_export_sql(sqlite3 *db, char *filename, int mode, ...); /** * Writes entire tables as CSV to provided filename. A header * row is written when the hdr parameter is true. The * rows are optionally introduced with a column made up of * the prefix (non-empty string) for the respective table. * If "schema" is NULL, "sqlite_master" is used, otherwise * specify e.g. "sqlite_temp_master" for temporary tables or * "att.sqlite_master" for the attached database "att". * @param db SQLite database pointer * @param filename name of output file * @param hdr write header lines when true * @param ... tuples of prefix, table name, schema name * @result number of output lines * * Example: * *
 *   CREATE TABLE A(a,b);
 *   INSERT INTO A VALUES(1,2);
 *   INSERT INTO A VALUES(3,'foo')
 *   CREATE TABLE B(c);
 *   INSERT INTO B VALUES('hello');
 *   SELECT export_csv('out.csv', 0, 'aa', 'A', NULL, 'bb', 'B', NULL);
 *   -- CSV output
 *   "aa",1,2
 *   "aa",3,"foo"
 *   "bb","hello"
 *   SELECT export_csv('out.csv', 1, 'aa', 'A', NULL, 'bb', 'B', NULL);
 *   -- CSV output
 *   "aa","a","b"
 *   "aa",1,2
 *   "aa",3,"foo"
 *   "bb","c"
 *   "bb","hello"
 * 
*/ int impexp_export_csv(sqlite3 *db, char *filename, int hdr, ...); /** * Writes a table as simple XML to provided filename. The * rows are optionally enclosed with the "root" tag, * the row data is enclosed in "item" tags. If "schema" * is NULL, "sqlite_master" is used, otherwise specify * e.g. "sqlite_temp_master" for temporary tables or * "att.sqlite_master" for the attached database "att". * @param db SQLite database pointer * @param filename name of output file * @param append if true, append to existing output file * @param indent number of blanks to indent output * @param root optional tag use to enclose table output * @param item tag to use per row * @param tablename table to be output * @param schema optional schema or NULL * @result number of output lines * * Layout of an output row: *
 *  
 *   value
 *   ...
 *  
 * 
* * Example: *
 *  CREATE TABLE A(a,b);
 *  INSERT INTO A VALUES(1,2.1);
 *  INSERT INTO A VALUES(3,'foo');
 *  INSERT INTO A VALUES('',NULL);
 *  INSERT INTO A VALUES(X'010203','');
 *  SELECT export_xml('out.xml', 0, 2, 'TBL_A', 'ROW', 'A');
 *  -- XML output
 *    
 *       
 *          <a TYPE="INTEGER">1</a>
 *          <b TYPE="REAL">2.1</b>
 *       
 *       
 *          <a TYPE="INTEGER">3</a>
 *          <b TYPE="TEXT">foo</b>
 *       
 *       
 *          <a TYPE="TEXT"></a>
 *          <b TYPE="NULL"></b>
 *       
 *       
 *          <a TYPE="BLOB">&x03;</a>
 *          <b TYPE="TEXT">&lt;blob&gt;</b>
 *       
 *     
 * 
* * Quoting of XML entities is performed only on the data, * not on column names and root/item tags. */ int impexp_export_xml(sqlite3 *db, char *filename, int append, int indent, char *root, char *item, char *tablename, char *schema); /** * @typedef impexp_putc * The function pointer for the output function to * "impexp_export_json" has a signature compatible * with fputc(3). */ typedef void (*impexp_putc)(int c, void *arg); /** * Executes arbitrary SQL statements and formats * the result in JavaScript Object Notation (JSON). * @param db SQLite database pointer * @param sql SQL to be executed * @param pfunc pointer to output function * @param parg argument for output function * @result SQLite error code * * The layout of the result output is: * *
 *  object {results, sql}
 *    results[] object {columns, rows, changes, last_insert_rowid, error}
 *      columns[]
 *        object {name, decltype, type }    (sqlite3_column_*)
 *      rows[][]                            (sqlite3_column_*)
 *      changes                             (sqlite3_changes)
 *      last_insert_rowid                   (sqlite3_last_insert_rowid)
 *      error                               (sqlite3_errmsg)
 *    sql                                   (SQL text)
 * 
* * For each single SQL statement in "sql" an object in the * "results" array is produced. */ int impexp_export_json(sqlite3 *db, char *sql, impexp_putc pfunc, void *parg); /** * Registers the SQLite functions * @param db SQLite database pointer * @result SQLite error code * * Registered functions: * *
 *  import_sql(filename)
 *  export_sql(filename, [mode, tablename, ...])
 *  export_csv(filename, hdr, prefix1, tablename1, schema1, ...)
 *  export_xml(filename, appendflg, indent, [root, item, tablename, schema]+)
 *  export_json(filename, sql)
 * 
* * On Win32 the filename argument may be specified as NULL in * order to open a system file dialog for interactive filename * selection. */ int impexp_init(sqlite3 *db); #endif ./sqliteodbc-0.992/impexp.rc0100644000076400001440000000240211535635235014366 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 Extension SQL Import/Export\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "IMPEXP\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3_MOD_IMPEXP.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/csvtable.c0100644000076400001440000010150012052701777014504 0ustar chwusers/** * @file csvtable.c * SQLite extension module for mapping a CSV file as * a read-only SQLite virtual table plus extension * function to import a CSV file as a real table. * * 2012 July 27 * * The author disclaims copyright to this source code. In place of * a legal notice, here is a blessing: * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. * ******************************************************************** */ #ifdef STANDALONE #include #else #include static SQLITE_EXTENSION_INIT1 #endif #include #include #include #include #ifdef _WIN32 #include #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif /** * @typedef csv_file * @struct csv_file * Structure to implement CSV file handle. */ typedef struct csv_file { FILE *f; /**< CSV file */ char *sep; /**< column separator characters */ char *quot; /**< text quoting characters */ int isdos; /**< true, when DOS format detected */ int maxl; /**< max. capacity of line buffer */ char *line; /**< line buffer */ long pos0; /**< file position for rewind */ int maxc; /**< max. capacity of column buffer */ int ncols; /**< number of columns */ char **cols; /**< column buffer */ } csv_file; /** * @typedef csv_guess_fmt * @struct csv_guess_fmt * Info to guess CSV layout. */ typedef struct csv_guess_fmt { int nlines; int hist[256]; } csv_guess_fmt; /** * @typedef csv_vtab * @struct csv_vtab * Structure to describe a CSV virtual table. */ typedef struct csv_vtab { sqlite3_vtab vtab; /**< SQLite virtual table */ csv_file *csv; /**< CSV file handle */ int convert; /**< convert flags */ char coltypes[1]; /**< column types */ } csv_vtab; /** * @typedef csv_cursor * @struct csv_cursor * Structure to describe CSV virtual table cursor. */ typedef struct { sqlite3_vtab_cursor cursor; /**< SQLite virtual table cursor */ long pos; /**< CSV file position */ } csv_cursor; /** * Free dynamically allocated string buffer * @param in input string pointer */ static void append_free(char **in) { long *p = (long *) *in; if (p) { p -= 2; sqlite3_free(p); *in = 0; } } /** * Append a string to dynamically allocated string buffer * with optional quoting * @param in input string pointer * @param append string to append * @param quote quote character or NUL * @result new string to be free'd with append_free() */ static char * append(char **in, char const *append, char quote) { long *p = (long *) *in; long len, maxlen, actlen; int i; char *pp; int nappend = append ? strlen(append) : 0; if (p) { p -= 2; maxlen = p[0]; actlen = p[1]; } else { maxlen = actlen = 0; } len = nappend + actlen; if (quote) { len += 2; for (i = 0; i < nappend; i++) { if (append[i] == quote) { len++; } } } else if (!nappend) { return *in; } if (len >= maxlen - 1) { long *q; maxlen = (len + 0x03ff) & (~0x3ff); q = (long *) sqlite3_realloc(p, maxlen + 1 + 2 * sizeof (long)); if (!q) { return 0; } if (!p) { q[1] = 0; } p = q; p[0] = maxlen; *in = (char *) (p + 2); } pp = *in + actlen; if (quote) { *pp++ = quote; for (i = 0; i < nappend; i++) { *pp++ = append[i]; if (append[i] == quote) { *pp++ = quote; } } *pp++ = quote; *pp = '\0'; } else { if (nappend) { memcpy(pp, append, nappend); pp += nappend; *pp = '\0'; } } p[1] = pp - *in; return *in; } /** * Strip off quotes given string. * @param in string to be processed * @result new string to be free'd with sqlite3_free() */ static char * unquote(char const *in) { char c, *ret; int i; ret = sqlite3_malloc(strlen(in) + 1); if (ret) { c = in[0]; if ((c == '"') || (c == '\'')) { i = strlen(in + 1); if ((i > 0) && (in[i] == c)) { strcpy(ret, in + 1); ret[i - 1] = '\0'; return ret; } } strcpy(ret, in); } return ret; } /** * Map string to SQLite data type. * @param type string to be mapped * @result SQLITE_TEXT et.al. */ static int maptype(char const *type) { int typelen = type ? strlen(type) : 0; if ((typelen >= 3) && (strncasecmp(type, "integer", 7) == 0)) { return SQLITE_INTEGER; } if ((typelen >= 6) && (strncasecmp(type, "double", 6) == 0)) { return SQLITE_FLOAT; } if ((typelen >= 5) && (strncasecmp(type, "float", 5) == 0)) { return SQLITE_FLOAT; } if ((typelen >= 4) && (strncasecmp(type, "real", 4) == 0)) { return SQLITE_FLOAT; } return SQLITE_TEXT; } /** * Convert and collapse white space in column names to underscore * @param names string vector of column names * @param ncols number of columns */ static void conv_names(char **names, int ncols) { int i; char *p, *q; static const char ws[] = "\n\t\r\b\v "; if (!names || ncols <= 0) { return; } for (i = 0; i < ncols; i++) { p = names[i]; while (*p) { if (strchr(ws, *p)) { *p++ = '_'; q = p; while (*q && strchr(ws, *q)) { ++q; } if (*q && q > p) { strcpy(p, q); } continue; } ++p; } } } /** * Make result data or parameter binding accoring to type * @param ctx SQLite function context or NULL * @param stmt SQLite statement or NULL * @param idx parameter number, 1-based * @param data string data * @param len string length * @param type SQLite type */ static void result_or_bind(sqlite3_context *ctx, sqlite3_stmt *stmt, int idx, char *data, int len, int type) { char *endp; if (!data) { if (ctx) { sqlite3_result_null(ctx); } else { sqlite3_bind_null(stmt, idx); } return; } if (type == SQLITE_INTEGER) { sqlite_int64 val; #if defined(_WIN32) || defined(_WIN64) char endc; if (sscanf(data, "%I64d%c", &val, &endc) == 1) { if (ctx) { sqlite3_result_int64(ctx, val); } else { sqlite3_bind_int64(stmt, idx, val); } return; } #else endp = 0; #ifdef __osf__ val = strtol(data, &endp, 0); #else val = strtoll(data, &endp, 0); #endif if (endp && (endp != data) && !*endp) { if (ctx) { sqlite3_result_int64(ctx, val); } else { sqlite3_bind_int64(stmt, idx, val); } return; } #endif } else if (type == SQLITE_FLOAT) { double val; endp = 0; val = strtod(data, &endp); if (endp && (endp != data) && !*endp) { if (ctx) { sqlite3_result_double(ctx, val); } else { sqlite3_bind_double(stmt, idx, val); } return; } } if (ctx) { sqlite3_result_text(ctx, data, len, SQLITE_TRANSIENT); } else { sqlite3_bind_text(stmt, idx, data, len, SQLITE_TRANSIENT); } } /** * Process one column of the current row * @param ctx SQLite function context or NULL * @param stmt SQLite statement or NULL * @param idx parameter index, 1-based * @param data string data * @param type SQLite type * @param conv conversion flags */ static int process_col(sqlite3_context *ctx, sqlite3_stmt *stmt, int idx, char *data, int type, int conv) { char c, *p; const char flchars[] = "Ee+-.,0123456789"; if (!data) { goto putdata; } /* * Floating point number test, * converts single comma to dot. */ c = data[0]; if ((c != '\0') && strchr(flchars + 2, c)) { p = data + 1; while (*p && strchr(flchars, *p)) { ++p; } if (*p == '\0') { char *first = 0; int n = 0; p = data; while (p) { p = strchr(p, ','); if (!p) { break; } if (++n == 1) { first = p; } ++p; } if (first) { *first = '.'; goto putdata; } } } if (conv) { char *utf = sqlite3_malloc(strlen(data) * 2 + 2); if (utf) { p = utf; while ((c = *data) != '\0') { if (((conv & 10) == 10) && (c == '\\')) { if (data[1] == 'q') { *p++ = '\''; data += 2; continue; } } if ((conv & 2) && (c == '\\')) { char c2 = data[1]; switch (c2) { case '\0': goto convdone; case 'n': *p = '\n'; break; case 't': *p = '\t'; break; case 'r': *p = '\r'; break; case 'f': *p = '\f'; break; case 'v': *p = '\v'; break; case 'b': *p = '\b'; break; case 'a': *p = '\a'; break; case '?': *p = '\?'; break; case '\'': *p = '\''; break; case '"': *p = '\"'; break; case '\\': *p = '\\'; break; default: *p++ = c; *p = c2; break; } p++; data += 2; continue; } if ((conv & 1) && (c & 0x80)) { *p++ = 0xc0 | ((c >> 6) & 0x1f); *p++ = 0x80 | (c & 0x3f); } else { *p++ = c; } data++; } convdone: *p = '\0'; result_or_bind(ctx, stmt, idx, utf, p - utf, type); sqlite3_free(utf); return SQLITE_OK; } else { if (ctx) { sqlite3_result_error(ctx, "out of memory", -1); } return SQLITE_NOMEM; } } putdata: result_or_bind(ctx, stmt, idx, data, -1, type); return SQLITE_OK; } /** * Open CSV file for reading and return handle to it. * @param filename name of CSV file * @param sep column separator characters or NULL * @param quot string quote characters or NULL * @result CSV file handle */ static csv_file * csv_open(const char *filename, const char *sep, const char *quot) { FILE *f; csv_file *csv; #ifdef _WIN32 f = fopen(filename, "rb"); #else f = fopen(filename, "r"); #endif if (!f) { return 0; } csv = sqlite3_malloc(sizeof (csv_file)); if (!csv) { error0: fclose(f); return 0; } csv->f = f; if (sep && sep[0]) { csv->sep = sqlite3_malloc(strlen(sep) + 1); if (!csv->sep) { error1: sqlite3_free(csv); goto error0; } strcpy(csv->sep, sep); } else { csv->sep = 0; } if (quot && quot[0]) { csv->quot = sqlite3_malloc(strlen(quot) + 1); if (!csv->quot) { if (csv->sep) { sqlite3_free(csv->sep); } goto error1; } strcpy(csv->quot, quot); } else { csv->quot = 0; } csv->isdos = 0; csv->maxl = 0; csv->line = 0; csv->pos0 = 0; csv->maxc = 0; csv->ncols = 0; csv->cols = 0; return csv; } /** * Close CSV file handle. * @param csv CSV file handle */ static void csv_close(csv_file *csv) { if (csv) { if (csv->sep) { sqlite3_free(csv->sep); } if (csv->quot) { sqlite3_free(csv->quot); } if (csv->line) { sqlite3_free(csv->line); } if (csv->cols) { sqlite3_free(csv->cols); } if (csv->f) { fclose(csv->f); } sqlite3_free(csv); } } /** * Test EOF on CSV file handle. * @param csv CSV file handle * @result true when file position is at EOF */ static int csv_eof(csv_file *csv) { if (csv && csv->f) { return feof(csv->f); } return 1; } /** * Position CSV file handle. * @param csv CSV file handle * @param pos position to seek * @result 0 on success, EOF on error */ static long csv_seek(csv_file *csv, long pos) { if (csv && csv->f) { return fseek(csv->f, pos, SEEK_SET); } return EOF; } /** * Rewind CSV file handle. * @param csv CSV file handle */ static void csv_rewind(csv_file *csv) { if (csv && csv->f) { csv_seek(csv, csv->pos0); } } /** * Return current position of CSV file handle. * @param csv CSV file handle * @result current file position */ static long csv_tell(csv_file *csv) { if (csv && csv->f) { return ftell(csv->f); } return EOF; } /** * Read and process one line of CSV file handle. * @param csv CSV file handle * @param guess NULL or buffer for guessing file format * @result number of columns on success, EOF on error */ static int csv_getline(csv_file *csv, csv_guess_fmt *guess) { int i, index = 0, inq = 0, c, col; char *p, *sep; if (!csv || !csv->f) { return EOF; } while (1) { c = fgetc(csv->f); if (c == EOF) { if (index > 0) { break; } return EOF; } if (c == '\0') { continue; } if (c == '\r') { int c2 = fgetc(csv->f); c = '\n'; if (c2 == '\n') { csv->isdos = 1; } else if (c2 != EOF) { ungetc(c2, csv->f); } } /* check for DOS EOF (Ctrl-Z) */ if (csv->isdos && (c == '\032')) { int c2 = fgetc(csv->f); if (c2 == EOF) { if (index > 0) { break; } return EOF; } ungetc(c2, csv->f); } if (index >= csv->maxl - 1) { int n = csv->maxl * 2; char *line; if (n <= 0) { n = 4096; } line = sqlite3_malloc(n); if (!line) { return EOF; } if (csv->line) { memcpy(line, csv->line, index); sqlite3_free(csv->line); } csv->maxl = n; csv->line = line; } csv->line[index++] = c; if (csv->quot && (p = strchr(csv->quot, c))) { if (inq) { if (*p == inq) { inq = 0; } } else { inq = *p; } } if (!inq && (c == '\n')) { break; } } if (guess) { for (i = 0; i < index; i++) { guess->hist[csv->line[i] & 0xFF] += 1; } guess->nlines += 1; csv->ncols = 0; return 0; } for (i = index - 1; i >= 0; i--) { if (csv->line[i] != '\n') { break; } } index = i + 1; csv->line[index] = '\0'; i = inq = col = 0; sep = csv->sep ? csv->sep : ";"; if (!csv->cols) { int n = 128; csv->cols = sqlite3_malloc(sizeof (char *) * n); if (!csv->cols) { return EOF; } csv->maxc = n; } csv->cols[col++] = csv->line; while (i < index) { if (csv->quot && (p = strchr(csv->quot, csv->line[i]))) { if (inq) { if (*p == inq) { inq = 0; } } else { inq = *p; } } if (!inq && (p = strchr(sep, csv->line[i]))) { p = csv->line + i; *p = '\0'; if (col >= csv->maxc) { int n = csv->maxc * 2; char **cols; cols = sqlite3_realloc(csv->cols, sizeof (char *) * n); if (!cols) { return EOF; } csv->cols = cols; csv->maxc = n; } csv->cols[col++] = p + 1; } ++i; } csv->ncols = col; /* strip off quotes */ if (csv->quot) { for (i = 0; i < col; i++) { if (*csv->cols[i]) { p = strchr(csv->quot, *csv->cols[i]); if (p) { char *src, *dst; c = *p; csv->cols[i] += 1; sep = csv->cols[i] + strlen(csv->cols[i]) - 1; if ((sep >= csv->cols[i]) && (*sep == c)) { *sep = '\0'; } /* collapse quote escape sequences */ src = csv->cols[i]; dst = 0; while (*src) { if ((*src == c) && (src[1] == c)) { if (!dst) { dst = src; } src++; while (*src) { *dst++ = *src++; if (*src == c) { --src; break; } } } ++src; } if (dst) { *dst++ = '\0'; } } } } } return col; } /** * Return number of columns of current row in CSV file. * @param csv CSV file handle * @result number of columns of current row */ static int csv_ncols(csv_file *csv) { if (csv && csv->cols) { return csv->ncols; } return 0; } /** * Return nth column of current row in CSV file. * @param csv CSV file handle * @param n column number * @result string pointer or NULL */ static char * csv_coldata(csv_file *csv, int n) { if (csv && csv->cols && (n >= 0) && (n < csv->ncols)) { return csv->cols[n]; } return 0; } /** * Guess CSV layout of CSV file handle. * @param csv CSV file handle * @result 0 on succes, EOF on error */ static int csv_guess(csv_file *csv) { csv_guess_fmt guess; int i, n; char *p, sep[32], quot[4]; const struct { int c; int min; } sep_test[] = { { ',', 2 }, { ';', 2 }, { '\t', 2 }, { ' ', 4 }, { '|', 2 } }; if (!csv) { return EOF; } memset(&guess, 0, sizeof (guess)); csv->pos0 = 0; csv_rewind(csv); for (i = n = 0; i < 10; i++) { n = csv_getline(csv, &guess); if (n == EOF) { break; } } csv_rewind(csv); if (n && !i) { return EOF; } p = quot; n = '"'; if (guess.hist[n] > 1) { *p++ = n; } n = '\''; if (guess.hist[n] > 1) { *p++ = n; } *p = '\0'; p = sep; for (i = 0; i < sizeof (sep_test) / sizeof (sep_test[0]); i++) { if (guess.hist[sep_test[i].c] > sep_test[i].min * guess.nlines) { *p++ = sep_test[i].c; } } *p = '\0'; if (quot[0]) { p = sqlite3_malloc(strlen(quot) + 1); if (p) { strcpy(p, quot); if (csv->quot) { sqlite3_free(csv->quot); } csv->quot = p; } else { return EOF; } } if (sep[0]) { p = sqlite3_malloc(strlen(sep) + 1); if (p) { strcpy(p, sep); if (csv->sep) { sqlite3_free(csv->sep); } csv->sep = p; } else { return EOF; } } return 0; } /** * Connect to virtual table * @param db SQLite database pointer * @param aux user specific pointer (unused) * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code * * Argument vector contains: * * argv[0] - module name
* argv[1] - database name
* argv[2] - table name (virtual table)
* argv[3] - filename (required)
* argv[4] - number, when non-zero use first line as column names, * when negative use given type names (optional)
* argv[5] - number, when non-zero, translate data (optional, see below)
* argv[6] - column separator characters (optional)
* argv[7] - string quoting characters (optional)
* argv[8] - column/type name for first column (optional)
* ..
* argv[X] - column/type name for last column (optional)

* * Translation flags: * * 1 - convert ISO-8859-1 to UTF-8
* 2 - perform backslash substitution
* 4 - convert and collapse white-space in column names to underscore
* 10 - convert \q to single quote, in addition to backslash substitution
*/ static int csv_vtab_connect(sqlite3* db, void *aux, int argc, const char * const *argv, sqlite3_vtab **vtabp, char **errp) { csv_file *csv; int rc = SQLITE_ERROR, i, ncnames, row1; char **cnames, *schema = 0, **nargv; csv_vtab *vtab; if (argc < 4) { *errp = sqlite3_mprintf("input file name missing"); return SQLITE_ERROR; } nargv = sqlite3_malloc(sizeof (char *) * argc); memset(nargv, 0, sizeof (char *) * argc); for (i = 3; i < argc; i++) { nargv[i] = unquote(argv[i]); } csv = csv_open(nargv[3], (argc > 6) ? nargv[6] : 0, (argc > 7) ? nargv[7] : 0); if (!csv) { *errp = sqlite3_mprintf("unable to open input file"); cleanup: append_free(&schema); for (i = 3; i < argc; i++) { if (nargv[i]) { sqlite3_free(nargv[i]); } } return rc; } if (!csv->sep && !csv->quot) { csv_guess(csv); } csv->pos0 = 0; row1 = 0; if (argc > 4) { row1 = strtol(nargv[4], 0, 10); } if (row1) { /* use column names from 1st row */ csv_getline(csv, 0); if (csv->ncols < 1) { csv_close(csv); *errp = sqlite3_mprintf("unable to get column names"); goto cleanup; } csv->pos0 = csv_tell(csv); csv_rewind(csv); ncnames = csv_ncols(csv); cnames = csv->cols; } else if (argc > 8) { ncnames = argc - 8; cnames = (char **) nargv + 8; } else { /* use number of columns from 1st row */ csv_getline(csv, 0); if (csv->ncols < 1) { csv_close(csv); *errp = sqlite3_mprintf("unable to get column names"); goto cleanup; } csv_rewind(csv); ncnames = csv_ncols(csv); cnames = 0; } vtab = sqlite3_malloc(sizeof(csv_vtab) + ncnames); if (!vtab) { csv_close(csv); *errp = sqlite3_mprintf("out of memory"); goto cleanup; } memset(vtab, 0, sizeof (*vtab)); vtab->convert = 0; if (argc > 5) { vtab->convert = strtol(nargv[5], 0, 10); if (row1 && (vtab->convert & 4)) { conv_names(cnames, ncnames); } } vtab->csv = csv; append(&schema, "CREATE TABLE x(", 0); for (i = 0; i < ncnames; i++) { vtab->coltypes[i] = SQLITE_TEXT; if (!cnames || !cnames[i]) { char colname[64]; sprintf(colname, "column_%d", i + 1); append(&schema, colname, '"'); } else if (row1 > 0) { append(&schema, cnames[i], '"'); } else if (row1 < 0) { append(&schema, cnames[i], '"'); if (i + 8 < argc) { char *type = nargv[i + 8]; append(&schema, " ", 0); append(&schema, type, 0); vtab->coltypes[i] = maptype(type); } } else { char *type = cnames[i]; append(&schema, cnames[i], 0); while (*type && !strchr(" \t", *type)) { type++; } while (*type && strchr(" \t", *type)) { type++; } vtab->coltypes[i] = maptype(type); } if (i < ncnames - 1) { append(&schema, ",", 0); } } append(&schema, ")", 0); rc = sqlite3_declare_vtab(db, schema); if (rc != SQLITE_OK) { csv_close(csv); sqlite3_free(vtab); *errp = sqlite3_mprintf("table definition failed, error %d, " "schema '%s'", rc, schema); goto cleanup; } *vtabp = &vtab->vtab; *errp = 0; goto cleanup; } /** * Create virtual table * @param db SQLite database pointer * @param aux user specific pointer (unused) * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code */ static int csv_vtab_create(sqlite3* db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) { return csv_vtab_connect(db, aux, argc, argv, vtabp, errp); } /** * Disconnect virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int csv_vtab_disconnect(sqlite3_vtab *vtab) { csv_vtab *tab = (csv_vtab *) vtab; csv_close(tab->csv); sqlite3_free(tab); return SQLITE_OK; } /** * Destroy virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int csv_vtab_destroy(sqlite3_vtab *vtab) { return csv_vtab_disconnect(vtab); } /** * Determines information for filter function according to constraints. * @param vtab virtual table * @param info index/constraint iinformation * @result SQLite error code */ static int csv_vtab_bestindex(sqlite3_vtab *vtab, sqlite3_index_info *info) { return SQLITE_OK; } /** * Open virtual table and return cursor. * @param vtab virtual table pointer * @param cursorp pointer receiving cursor pointer * @result SQLite error code */ static int csv_vtab_open(sqlite3_vtab *vtab, sqlite3_vtab_cursor **cursorp) { csv_cursor *cur = sqlite3_malloc(sizeof(*cur)); csv_vtab *tab = (csv_vtab *) vtab; if (!cur) { return SQLITE_ERROR; } cur->cursor.pVtab = vtab; csv_rewind(tab->csv); cur->pos = csv_tell(tab->csv); *cursorp = &cur->cursor; return SQLITE_OK; } /** * Close virtual table cursor. * @param cursor cursor pointer * @result SQLite error code */ static int csv_vtab_close(sqlite3_vtab_cursor *cursor) { sqlite3_free(cursor); return SQLITE_OK; } /** * Retrieve next row from virtual table cursor * @param cursor virtual table cursor * @result SQLite error code */ static int csv_vtab_next(sqlite3_vtab_cursor *cursor) { csv_cursor *cur = (csv_cursor *) cursor; csv_vtab *tab = (csv_vtab *) cur->cursor.pVtab; cur->pos = csv_tell(tab->csv); csv_getline(tab->csv, 0); return SQLITE_OK; } /** * Filter function for virtual table. * @param cursor virtual table cursor * @param idxNum unused (always 0) * @param idxStr unused * @param argc number arguments (unused, 0) * @param argv argument (nothing) * @result SQLite error code */ static int csv_vtab_filter(sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) { csv_cursor *cur = (csv_cursor *) cursor; csv_vtab *tab = (csv_vtab *) cur->cursor.pVtab; csv_rewind(tab->csv); return csv_vtab_next(cursor); } /** * Return end of table state of virtual table cursor * @param cursor virtual table cursor * @result true/false */ static int csv_vtab_eof(sqlite3_vtab_cursor *cursor) { csv_cursor *cur = (csv_cursor *) cursor; csv_vtab *tab = (csv_vtab *) cur->cursor.pVtab; return csv_eof(tab->csv); } /** * Return column data of virtual table. * @param cursor virtual table cursor * @param ctx SQLite function context * @param n column index * @result SQLite error code */ static int csv_vtab_column(sqlite3_vtab_cursor *cursor, sqlite3_context *ctx, int n) { csv_cursor *cur = (csv_cursor *) cursor; csv_vtab *tab = (csv_vtab *) cur->cursor.pVtab; char *data = csv_coldata(tab->csv, n); return process_col(ctx, 0, 0, data, tab->coltypes[n], tab->convert); } /** * Return current rowid of virtual table cursor * @param cursor virtual table cursor * @param rowidp value buffer to receive current rowid * @result SQLite error code */ static int csv_vtab_rowid(sqlite3_vtab_cursor *cursor, sqlite_int64 *rowidp) { csv_cursor *cur = (csv_cursor *) cursor; *rowidp = cur->pos; return SQLITE_OK; } #if (SQLITE_VERSION_NUMBER > 3004000) /** * Rename virtual table. * @param newname new name for table * @result SQLite error code */ static int csv_vtab_rename(sqlite3_vtab *vtab, const char *newname) { return SQLITE_OK; } #endif /** * SQLite module descriptor. */ static const sqlite3_module csv_vtab_mod = { 1, /* iVersion */ csv_vtab_create, /* xCreate */ csv_vtab_connect, /* xConnect */ csv_vtab_bestindex, /* xBestIndex */ csv_vtab_disconnect, /* xDisconnect */ csv_vtab_destroy, /* xDestroy */ csv_vtab_open, /* xOpen */ csv_vtab_close, /* xClose */ csv_vtab_filter, /* xFilter */ csv_vtab_next, /* xNext */ csv_vtab_eof, /* xEof */ csv_vtab_column, /* xColumn */ csv_vtab_rowid, /* xRowid */ 0, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ 0, /* xFindFunction */ #if (SQLITE_VERSION_NUMBER > 3004000) csv_vtab_rename, /* xRename */ #endif }; /** * Import CSV file as table into database * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector * * Argument vector contains: * * argv[0] - name of table to create (required)
* argv[1] - filename (required)
* argv[2] - number, when non-zero use first line as column names, * when negative use given type names (optional)
* argv[3] - number, when non-zero, translate data (optional, see below)
* argv[4] - column separator characters (optional)
* argv[5] - string quoting characters (optional)
* argv[6] - column/type name for first column (optional)
* ..
* argv[X] - column/type name for last column (optional)

* * Translation flags: * * 1 - convert ISO-8859-1 to UTF-8
* 2 - perform backslash substitution
* 4 - convert and collapse white-space in column names to underscore
* 10 - convert \q to single quote, in addition to backslash substitution
*/ static void csv_import_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { csv_file *csv; int rc, i, ncnames, row1, convert = 0, useargs = 0; char *tname, *fname, *sql = 0, **cnames, *coltypes = 0; sqlite3 *db = (sqlite3 *) sqlite3_user_data(ctx); sqlite3_stmt *stmt = 0; if (argc < 2) { sqlite3_result_error(ctx, "need at least 2 arguments", -1); return; } tname = (char *) sqlite3_value_text(argv[0]); if (!tname) { sqlite3_result_error(ctx, "table name is NULL", -1); return; } fname = (char *) sqlite3_value_text(argv[1]); if (!fname) { sqlite3_result_error(ctx, "file name is NULL", -1); return; } csv = csv_open(fname, (argc > 4) ? (char *) sqlite3_value_text(argv[4]) : 0, (argc > 5) ? (char *) sqlite3_value_text(argv[5]) : 0); if (!csv) { sqlite3_result_error(ctx, "unable to open input file", -1); cleanup: if (stmt) { sqlite3_finalize(stmt); } append_free(&sql); if (coltypes) { sqlite3_free(coltypes); } if (csv) { csv_close(csv); } return; } if (!csv->sep && !csv->quot) { csv_guess(csv); } csv->pos0 = 0; row1 = 0; if (argc > 2) { row1 = sqlite3_value_int(argv[2]); } if (row1) { /* use column names from 1st row */ csv_getline(csv, 0); if (csv->ncols < 1) { sqlite3_result_error(ctx, "unable to get column names", -1); goto cleanup; } csv->pos0 = csv_tell(csv); csv_rewind(csv); ncnames = csv_ncols(csv); cnames = csv->cols; } else if (argc > 6) { ncnames = argc - 6; cnames = 0; useargs = 1; } else { /* use number of columns from 1st row */ csv_getline(csv, 0); if (csv->ncols < 1) { sqlite3_result_error(ctx, "unable to get column names", -1); goto cleanup; } csv_rewind(csv); ncnames = csv_ncols(csv); cnames = 0; } convert = 0; if (argc > 3) { convert = sqlite3_value_int(argv[3]); if (row1 && (convert & 4)) { conv_names(cnames, ncnames); } } /* test if table exists */ append(&sql, "PRAGMA table_info(", 0); append(&sql, tname, '"'); append(&sql, ")", 0); if (!sql) { oom: sqlite3_result_error(ctx, "out of memory", -1); goto cleanup; } rc = sqlite3_prepare_v2(db, sql, -1, &stmt, 0); append_free(&sql); if (rc != SQLITE_OK) { prepfail: sqlite3_result_error(ctx, "prepare failed", -1); goto cleanup; } /* find number of colums */ i = 0; rc = sqlite3_step(stmt); while (rc == SQLITE_ROW) { i++; rc = sqlite3_step(stmt); } if (rc != SQLITE_DONE) { selfail: sqlite3_result_error(ctx, "select failed", -1); goto cleanup; } if (i > 0) { /* get column types */ sqlite3_reset(stmt); ncnames = i; coltypes = sqlite3_malloc(ncnames); if (!coltypes) { goto oom; } rc = sqlite3_step(stmt); i = 0; while (rc == SQLITE_ROW) { coltypes[i++] = maptype((char *) sqlite3_column_text(stmt, 2)); rc = sqlite3_step(stmt); } if (rc != SQLITE_DONE) { goto selfail; } } else { /* create new table */ sqlite3_finalize(stmt); stmt = 0; coltypes = sqlite3_malloc(ncnames); if (!coltypes) { goto oom; } append(&sql, "CREATE TABLE ", 0); append(&sql, tname, '"'); append(&sql, "(", 0); for (i = 0; i < ncnames; i++) { char colname[64]; coltypes[i] = SQLITE_TEXT; if (useargs) { char *type = (char *) sqlite3_value_text(argv[i + 6]); if (!type) { goto defcol; } append(&sql, type, 0); while (*type && !strchr(" \t", *type)) { type++; } while (*type && strchr(" \t", *type)) { type++; } coltypes[i] = maptype(type); } else if (!cnames || !cnames[i]) { defcol: sprintf(colname, "column_%d", i + 1); append(&sql, colname, '"'); } else if (row1 > 0) { append(&sql, cnames[i], '"'); } else if (row1 < 0) { append(&sql, cnames[i], '"'); if (i + 6 < argc) { char *type = (char *) sqlite3_value_text(argv[i + 6]); if (type) { append(&sql, " ", 0); append(&sql, type, 0); coltypes[i] = maptype(type); } } } if (i < ncnames - 1) { append(&sql, ",", 0); } } append(&sql, ")", 0); rc = sqlite3_prepare_v2(db, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { goto prepfail; } rc = sqlite3_step(stmt); if ((rc != SQLITE_DONE) && (rc != SQLITE_OK)) { sqlite3_result_error(ctx, "create table failed", -1); goto cleanup; } append_free(&sql); } sqlite3_finalize(stmt); stmt = 0; /* make INSERT statement */ append(&sql, "INSERT INTO ", 0); append(&sql, tname, '"'); append(&sql, " VALUES(", 0); for (i = 0; i < ncnames; i++) { append(&sql, (i < ncnames - 1) ? "?," : "?)", 0); } rc = sqlite3_prepare_v2(db, sql, -1, &stmt, 0); if (rc != SQLITE_OK) { goto prepfail; } append_free(&sql); /* import the CSV file */ row1 = 0; while (csv_getline(csv, 0) != EOF) { for (i = 0; i < ncnames; i++) { char *data = csv_coldata(csv, i); rc = process_col(0, stmt, i + 1, data, coltypes[i], convert); if (rc != SQLITE_OK) { goto inserr; } } rc = sqlite3_step(stmt); if ((rc != SQLITE_DONE) && (rc != SQLITE_OK)) { if ((rc != SQLITE_MISMATCH) && (rc != SQLITE_CONSTRAINT)) { inserr: sqlite3_result_error(ctx, "insert failed", -1); goto cleanup; } } else { row1++; } sqlite3_reset(stmt); } sqlite3_result_int(ctx, row1); goto cleanup; } /** * Module initializer creating SQLite functions and modules * @param db database pointer * @result SQLite error code */ #ifndef STANDALONE static #endif int csv_vtab_init(sqlite3 *db) { sqlite3_create_function(db, "import_csv", -1, SQLITE_UTF8, (void *) db, csv_import_func, 0, 0); return sqlite3_create_module(db, "csvtable", &csv_vtab_mod, 0); } #ifndef STANDALONE /** * Initializer for SQLite extension load mechanism. * @param db SQLite database pointer * @param errmsg pointer receiving error message * @param api SQLite API routines * @result SQLite error code */ int sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { SQLITE_EXTENSION_INIT2(api); return csv_vtab_init(db); } #endif ./sqliteodbc-0.992/csvtable.rc0100644000076400001440000000240212004734526014662 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 Extension SQL CSV Table\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "CSVTABLE\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3_MOD_CSVTABLE.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/zipfile.c0100644000076400001440000014700212125014070014332 0ustar chwusers/** * @file zipfile.c * SQLite extension module for mapping a ZIP file as a read-only * SQLite virtual table plus some supporting SQLite functions. * * 2012 September 12 * * The author disclaims copyright to this source code. * In place of a legal notice, here is a blessing: * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. * ******************************************************************** */ #ifdef linux #define _GNU_SOURCE #endif #ifdef STANDALONE #include #else #include static SQLITE_EXTENSION_INIT1 #endif #if defined(_WIN32) || defined(_WIN64) #include #else #include #include #include #include #endif #include #include #include #include #include #define ZIP_SIG_LEN 4 #define ZIP_LOCAL_HEADER_SIG 0x04034b50 #define ZIP_LOCAL_HEADER_FLAGS 6 #define ZIP_LOCAL_HEADER_LEN 30 #define ZIP_LOCAL_EXTRA_OFFS 28 #define ZIP_CENTRAL_HEADER_SIG 0x02014b50 #define ZIP_CENTRAL_HEADER_FLAGS 8 #define ZIP_CENTRAL_HEADER_LEN 46 #define ZIP_CENTRAL_COMPMETH_OFFS 10 #define ZIP_CENTRAL_MTIME_OFFS 12 #define ZIP_CENTRAL_MDATE_OFFS 14 #define ZIP_CENTRAL_CRC32_OFFS 16 #define ZIP_CENTRAL_COMPLEN_OFFS 20 #define ZIP_CENTRAL_UNCOMPLEN_OFFS 24 #define ZIP_CENTRAL_PATHLEN_OFFS 28 #define ZIP_CENTRAL_EXTRALEN_OFFS 30 #define ZIP_CENTRAL_COMMENTLEN_OFFS 32 #define ZIP_CENTRAL_LOCALHDR_OFFS 42 #define ZIP_CENTRAL_END_SIG 0x06054b50 #define ZIP_CENTRAL_END_LEN 22 #define ZIP_CENTRAL_ENTS_OFFS 8 #define ZIP_CENTRAL_DIRSTART_OFFS 16 #define ZIP_COMPMETH_STORED 0 #define ZIP_COMPMETH_DEFLATED 8 #define zip_read_int(p) \ ((p)[0] | ((p)[1] << 8) | ((p)[2] << 16) | ((p)[3] << 24)) #define zip_read_short(p) \ ((p)[0] | ((p)[1] << 8)) /** * @typedef zip_file * @struct zip_file * Structure to implement ZIP file handle. */ typedef struct zip_file { off_t length; /**< length of ZIP file */ unsigned char *data; /**< mmap()'ed ZIP file */ #if defined(_WIN32) || defined(_WIN64) HANDLE h; /**< Windows file handle */ HANDLE mh; /**< Windows file mapping */ #endif int nentries; /**< Number of directory entries */ unsigned char *entries[1]; /**< Pointer to first entry */ } zip_file; /** * @typedef zip_vtab * @struct zip_vtab * Structure to describe a ZIP virtual table. */ typedef struct zip_vtab { sqlite3_vtab vtab; /**< SQLite virtual table */ sqlite3 *db; /**< Open database */ zip_file *zip; /**< ZIP file handle */ int sorted; /**< 1 = sorted by path, -1 = sorting, 0 = unsorted */ char tblname[1]; /**< Name, format "database"."table" */ } zip_vtab; /** * @typedef zip_cursor * @struct zip_cursor * Structure to describe ZIP virtual table cursor. */ typedef struct { sqlite3_vtab_cursor cursor; /**< SQLite virtual table cursor */ int pos; /**< ZIP file position */ int nmatches; /**< For filter EQ */ int *matches; /**< For filter EQ */ } zip_cursor; #ifdef SQLITE_OPEN_URI /** * @typedef mem_blk * @struct mem_blk * Structure to describe in-core SQLite database read from BLOB. */ typedef struct mem_blk { #define MEM_MAGIC "MVFS" char magic[4]; /**< magic number */ int opened; /**< open counter */ #if defined(_WIN32) || defined(_WIN64) HANDLE mh; /**< handle for memory mapping */ #else long psize; /**< page size */ #ifdef linux sqlite3_mutex *mutex; /**< mutex to protect mapping */ int lcnt; /**< lock counter */ #endif #endif unsigned long size; /**< size of memory mapped area */ unsigned long length; /**< real length of data area */ unsigned char *data; /**< data area */ } mem_blk; /** * @typedef mem_file * @struct mem_file * SQLite3 file structure enhanced by mem_blk. */ typedef struct mem_file { sqlite3_file base; /**< sqlite3_file base structure */ #ifdef linux int lock; /**< lock state */ #endif mem_blk *mb; /**< pointer to memory block */ } mem_file; /* * Private VFS name */ static char mem_vfs_name[64]; #endif /* SQLITE_OPEN_URI */ /** * Memory map ZIP file for reading and return handle to it. * @param filename name of ZIP file * @result ZIP file handle */ static zip_file * zip_open(const char *filename) { #if defined(_WIN32) || defined(_WIN64) HANDLE h, mh = INVALID_HANDLE_VALUE; DWORD n, length; unsigned char *data = 0; #else int fd; off_t length; unsigned char *data = MAP_FAILED; #endif int nentries, i; zip_file *zip = 0; unsigned char *p, *q, magic[ZIP_SIG_LEN]; if (!filename) { return 0; } #if defined(_WIN32) || defined(_WIN64) h = CreateFile(filename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); if (h == INVALID_HANDLE_VALUE) { goto error; } if (!ReadFile(h, magic, sizeof (magic), &n, 0) || (n != sizeof (magic))) { goto error; } if (zip_read_int(magic) != ZIP_LOCAL_HEADER_SIG) { goto error; } length = GetFileSize(h, 0); if ((length == INVALID_FILE_SIZE) || (length < ZIP_CENTRAL_END_LEN)) { goto error; } mh = CreateFileMapping(h, 0, PAGE_READONLY, 0, length, 0); if (mh == INVALID_HANDLE_VALUE) { goto error; } data = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, length); if (!data) { goto error; } #else fd = open(filename, O_RDONLY); if (fd < 0) { goto error; } if (read(fd, magic, ZIP_SIG_LEN) != ZIP_SIG_LEN) { goto error; } if (zip_read_int(magic) != ZIP_LOCAL_HEADER_SIG) { goto error; } length = lseek(fd, 0, SEEK_END); if ((length == -1) || (length < ZIP_CENTRAL_END_LEN)) { goto error; } data = (unsigned char *) mmap(0, length, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0); if (data == MAP_FAILED) { goto error; } close(fd); fd = -1; #endif p = data + length - ZIP_CENTRAL_END_LEN; while (p >= data) { if (*p == (ZIP_CENTRAL_END_SIG & 0xFF)) { if (zip_read_int(p) == ZIP_CENTRAL_END_SIG) { break; } p -= ZIP_SIG_LEN; } else { --p; } } if (p < data) { goto error; } nentries = zip_read_short(p + ZIP_CENTRAL_ENTS_OFFS); if (nentries == 0) { goto error; } p = data + zip_read_int(p + ZIP_CENTRAL_DIRSTART_OFFS); q = p; for (i = 0; i < nentries; i++) { int pathlen, comlen, extra; if ((q + ZIP_CENTRAL_HEADER_LEN) > (data + length)) { goto error; } if (zip_read_int(q) != ZIP_CENTRAL_HEADER_SIG) { goto error; } pathlen = zip_read_short(q + ZIP_CENTRAL_PATHLEN_OFFS); comlen = zip_read_short(q + ZIP_CENTRAL_COMMENTLEN_OFFS); extra = zip_read_short(q + ZIP_CENTRAL_EXTRALEN_OFFS); q += pathlen + comlen + extra + ZIP_CENTRAL_HEADER_LEN; } zip = sqlite3_malloc(sizeof (zip_file) + nentries * sizeof (unsigned char *)); if (!zip) { goto error; } #if defined(_WIN32) || defined(_WIN64) zip->h = zip->mh = INVALID_HANDLE_VALUE; #endif zip->length = length; zip->data = data; zip->nentries = nentries; q = p; for (i = 0; i < nentries; i++) { int pathlen, comlen, extra; if ((q + ZIP_CENTRAL_HEADER_LEN) > (data + length)) { goto error; } if (zip_read_int(q) != ZIP_CENTRAL_HEADER_SIG) { goto error; } zip->entries[i] = q; pathlen = zip_read_short(q + ZIP_CENTRAL_PATHLEN_OFFS); comlen = zip_read_short(q + ZIP_CENTRAL_COMMENTLEN_OFFS); extra = zip_read_short(q + ZIP_CENTRAL_EXTRALEN_OFFS); q += pathlen + comlen + extra + ZIP_CENTRAL_HEADER_LEN; } zip->entries[i] = 0; #if defined(_WIN32) || defined(_WIN64) zip->h = h; zip->mh = mh; #endif return zip; error: if (zip) { sqlite3_free(zip); } #if defined(_WIN32) || defined(_WIN64) if (data) { UnmapViewOfFile(data); } if (mh != INVALID_HANDLE_VALUE) { CloseHandle(mh); } if (h != INVALID_HANDLE_VALUE) { CloseHandle(h); } #else if (data != MAP_FAILED) { munmap(data, length); } if (fd >= 0) { close(fd); } #endif return 0; } /** * Close ZIP file handle. * @param zip ZIP file handle */ static void zip_close(zip_file *zip) { if (zip) { #if defined(_WIN32) || defined(_WIN64) if (zip->data) { UnmapViewOfFile(zip->data); } if (zip->mh != INVALID_HANDLE_VALUE) { CloseHandle(zip->mh); } if (zip->h != INVALID_HANDLE_VALUE) { CloseHandle(zip->h); } #else if (zip->data) { munmap(zip->data, zip->length); } #endif zip->length = 0; zip->data = 0; zip->nentries = 0; sqlite3_free(zip); } } /** * Strip off quotes given string. * @param in string to be processed * @result new string to be free'd with sqlite3_free() */ static char * unquote(char const *in) { char c, *ret; int i; ret = sqlite3_malloc(strlen(in) + 1); if (ret) { c = in[0]; if ((c == '"') || (c == '\'')) { i = strlen(in + 1); if ((i > 0) && (in[i] == c)) { strcpy(ret, in + 1); ret[i - 1] = '\0'; return ret; } } strcpy(ret, in); } return ret; } /** * Connect to virtual table * @param db SQLite database pointer * @param aux user specific pointer (unused) * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code * * Argument vector contains: * * argv[0] - module name
* argv[1] - database name
* argv[2] - table name (virtual table)
* argv[3] - filename of ZIP file
*/ static int zip_vtab_connect(sqlite3* db, void *aux, int argc, const char * const *argv, sqlite3_vtab **vtabp, char **errp) { zip_file *zip = 0; int rc = SQLITE_ERROR; char *filename; zip_vtab *vtab; if (argc < 4) { *errp = sqlite3_mprintf("input file name missing"); return SQLITE_ERROR; } filename = unquote(argv[3]); if (filename) { zip = zip_open(filename); sqlite3_free(filename); } if (!zip) { *errp = sqlite3_mprintf("unable to open input file"); return rc; } vtab = sqlite3_malloc(sizeof(zip_vtab) + 6 + strlen(argv[1]) + strlen(argv[2])); if (!vtab) { zip_close(zip); *errp = sqlite3_mprintf("out of memory"); return rc; } memset(vtab, 0, sizeof (*vtab)); strcpy(vtab->tblname, "\""); strcat(vtab->tblname, argv[1]); strcat(vtab->tblname, "\".\""); strcat(vtab->tblname, argv[2]); strcat(vtab->tblname, "\""); vtab->db = db; vtab->zip = zip; rc = sqlite3_declare_vtab(db, "CREATE TABLE x(path, comp, mtime, " "crc32, length, data, clength, cdata)"); if (rc != SQLITE_OK) { zip_close(zip); sqlite3_free(vtab); *errp = sqlite3_mprintf("table definition failed (error %d)", rc); return rc; } *vtabp = &vtab->vtab; *errp = 0; return SQLITE_OK; } /** * Create virtual table * @param db SQLite database pointer * @param aux user specific pointer (unused) * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code */ static int zip_vtab_create(sqlite3* db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) { return zip_vtab_connect(db, aux, argc, argv, vtabp, errp); } /** * Disconnect virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int zip_vtab_disconnect(sqlite3_vtab *vtab) { zip_vtab *tab = (zip_vtab *) vtab; zip_close(tab->zip); sqlite3_free(tab); return SQLITE_OK; } /** * Destroy virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int zip_vtab_destroy(sqlite3_vtab *vtab) { return zip_vtab_disconnect(vtab); } /** * Determines information for filter function according to constraints. * @param vtab virtual table * @param info index/constraint information * @result SQLite error code */ static int zip_vtab_bestindex(sqlite3_vtab *vtab, sqlite3_index_info *info) { zip_vtab *tab = (zip_vtab *) vtab; int i; info->idxNum = 0; if (tab->sorted == 0) { char *sql = 0; unsigned char **entries = 0; sqlite3_stmt *stmt = 0; int rc, count, i; size_t tmp; /* perform sorting on 0th column (path, string) */ tab->sorted = -1; entries = sqlite3_malloc(tab->zip->nentries * sizeof (entries)); sql = sqlite3_mprintf("SELECT rowid FROM %s ORDER BY path", tab->tblname); if (sql && entries) { rc = sqlite3_prepare_v2(tab->db, sql, -1, &stmt, 0); if ((rc == SQLITE_OK) && stmt) { count = 0; while (1) { rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { break; } tmp = sqlite3_column_int(stmt, 0); entries[count++] = (unsigned char *) tmp; } if ((rc == SQLITE_DONE) && (count == tab->zip->nentries)) { for (i = 0; i < count; i++) { tmp = (size_t) entries[i]; tmp = (size_t) tab->zip->entries[tmp]; entries[i] = (unsigned char *) tmp; } memcpy(tab->zip->entries, entries, i * sizeof (entries)); tab->sorted = 1; } } } if (stmt) { sqlite3_finalize(stmt); } if (sql) { sqlite3_free(sql); } if (entries) { sqlite3_free(entries); } } /* no optimization while table is being sorted or is unsorted */ if (tab->sorted != 1) { return SQLITE_OK; } /* support EQ or simple MATCH constraint on 0th column (path) */ for (i = 0; i < info->nConstraint; i++) { if (info->aConstraint[i].usable && (info->aConstraint[i].iColumn == 0)) { if (info->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ) { info->idxNum = 1; info->aConstraintUsage[i].argvIndex = 1; info->aConstraintUsage[i].omit = 1; info->estimatedCost = 1.0; break; } else if (info->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_MATCH) { info->idxNum = 2; info->aConstraintUsage[i].argvIndex = 1; info->aConstraintUsage[i].omit = 1; info->estimatedCost = 2.0; break; } } } /* ORDER BY is ascending on 0th column (path) when table is sorted */ if (info->nOrderBy > 0) { if ((info->aOrderBy[0].iColumn == 0) && !info->aOrderBy[0].desc) { info->orderByConsumed = 1; } } return SQLITE_OK; } /** * Open virtual table and return cursor. * @param vtab virtual table pointer * @param cursorp pointer receiving cursor pointer * @result SQLite error code */ static int zip_vtab_open(sqlite3_vtab *vtab, sqlite3_vtab_cursor **cursorp) { zip_cursor *cur = sqlite3_malloc(sizeof(*cur)); if (!cur) { return SQLITE_ERROR; } cur->cursor.pVtab = vtab; cur->pos = -1; cur->nmatches = 0; cur->matches = 0; *cursorp = &cur->cursor; return SQLITE_OK; } /** * Close virtual table cursor. * @param cursor cursor pointer * @result SQLite error code */ static int zip_vtab_close(sqlite3_vtab_cursor *cursor) { zip_cursor *cur = (zip_cursor *) cursor; if (cur->matches) { sqlite3_free(cur->matches); } sqlite3_free(cur); return SQLITE_OK; } /** * Retrieve next row from virtual table cursor * @param cursor virtual table cursor * @result SQLite error code */ static int zip_vtab_next(sqlite3_vtab_cursor *cursor) { zip_cursor *cur = (zip_cursor *) cursor; if (cur->nmatches >= 0) { cur->pos++; } return SQLITE_OK; } /** * Filter function for virtual table. * @param cursor virtual table cursor * @param idxNum used for expression (1 -> EQ, 2 -> MATCH, 0 else) * @param idxStr nod used * @param argc number arguments (1 -> EQ/MATCH, 0 else) * @param argv argument (nothing or RHS of filter expression) * @result SQLite error code */ static int zip_vtab_filter(sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) { zip_cursor *cur = (zip_cursor *) cursor; zip_vtab *tab = (zip_vtab *) cur->cursor.pVtab; if (cur->matches) { sqlite3_free(cur->matches); cur->matches = 0; } cur->nmatches = 0; /* if EQ or MATCH constraint is active, add match array to cursor */ if (idxNum && (argc > 0)) { int i, k, d, found, leneq, len; unsigned char *eq; eq = (unsigned char *) sqlite3_value_text(argv[0]); if (!eq) { cur->nmatches = -1; goto done; } if (idxNum > 1) { unsigned char *p = (unsigned char *) strrchr((char *) eq, '*'); if (!p || (p[1] != '\0')) { return SQLITE_ERROR; } leneq = p - eq; } else { leneq = sqlite3_value_bytes(argv[0]); if (leneq == 0) { cur->nmatches = -1; goto done; } } cur->matches = sqlite3_malloc(tab->zip->nentries * sizeof (int)); if (!cur->matches) { return SQLITE_NOMEM; } memset(cur->matches, 0, tab->zip->nentries * sizeof (int)); for (k = found = 0; k < tab->zip->nentries; k++) { len = zip_read_short(tab->zip->entries[k] + ZIP_CENTRAL_PATHLEN_OFFS); if (idxNum > 1) { if (len < leneq) { continue; } } else if (len != leneq) { if (found) { break; } continue; } d = memcmp(tab->zip->entries[k] + ZIP_CENTRAL_HEADER_LEN, eq, leneq); if (d == 0) { found++; cur->matches[k] = 1; } else if (d > 0) { break; } } for (i = k = 0; i < tab->zip->nentries; i++) { if (cur->matches[i]) { cur->matches[k++] = i; } } cur->nmatches = k; } done: cur->pos = -1; return zip_vtab_next(cursor); } /** * Return end of table state of virtual table cursor * @param cursor virtual table cursor * @result true/false */ static int zip_vtab_eof(sqlite3_vtab_cursor *cursor) { zip_cursor *cur = (zip_cursor *) cursor; zip_vtab *tab = (zip_vtab *) cur->cursor.pVtab; if (cur->nmatches < 0) { return 1; } if (cur->nmatches) { return cur->pos >= cur->nmatches; } return cur->pos >= tab->zip->nentries; } /** * Return column data of virtual table. * @param cursor virtual table cursor * @param ctx SQLite function context * @param n column index * @result SQLite error code */ static int zip_vtab_column(sqlite3_vtab_cursor *cursor, sqlite3_context *ctx, int n) { zip_cursor *cur = (zip_cursor *) cursor; zip_vtab *tab = (zip_vtab *) cur->cursor.pVtab; unsigned char *data = 0; unsigned char *dest = 0; int length; if (cur->nmatches) { int pos; if ((cur->pos < 0) || (cur->pos >= cur->nmatches)) { sqlite3_result_error(ctx, "out of bounds", -1); return SQLITE_ERROR; } pos = cur->matches[cur->pos]; data = tab->zip->entries[pos]; } else { if ((cur->pos < 0) || (cur->pos >= tab->zip->nentries)) { sqlite3_result_error(ctx, "out of bounds", -1); return SQLITE_ERROR; } data = tab->zip->entries[cur->pos]; } switch (n) { case 0: /* "path": pathname */ length = zip_read_short(data + ZIP_CENTRAL_PATHLEN_OFFS); data += ZIP_CENTRAL_HEADER_LEN; sqlite3_result_text(ctx, (char *) data, length, SQLITE_TRANSIENT); return SQLITE_OK; case 1: /* "comp": compression method */ length = zip_read_short(data + ZIP_CENTRAL_COMPMETH_OFFS); sqlite3_result_int(ctx, length); return SQLITE_OK; case 2: /* "mtime": modification time/date */ { int time = zip_read_short(data + ZIP_CENTRAL_MTIME_OFFS); int date = zip_read_short(data + ZIP_CENTRAL_MDATE_OFFS); char mtbuf[64]; sprintf(mtbuf, "%04d-%02d-%02d %02d:%02d:%02d", (date >> 9) + 1980, (date >> 5) & 0xf, date & 0x1f, time >> 11, (time >> 5) & 0x3f, (time & 0x1f) << 1); sqlite3_result_text(ctx, mtbuf, -1, SQLITE_TRANSIENT); return SQLITE_OK; } case 3: /* "crc32": CRC32 of uncompress data */ length = zip_read_int(data + ZIP_CENTRAL_CRC32_OFFS); sqlite3_result_int(ctx, length); return SQLITE_OK; case 4: /* "length": uncompress length of data */ length = zip_read_int(data + ZIP_CENTRAL_UNCOMPLEN_OFFS); sqlite3_result_int(ctx, length); return SQLITE_OK; case 5: /* "data": uncompressed data */ { int clength, offs, extra, pathlen, cmeth; offs = zip_read_int(data + ZIP_CENTRAL_LOCALHDR_OFFS); if ((offs + ZIP_LOCAL_HEADER_LEN) > tab->zip->length) { goto donull; } extra = zip_read_short(tab->zip->data + offs + ZIP_LOCAL_EXTRA_OFFS); pathlen = zip_read_short(data + ZIP_CENTRAL_PATHLEN_OFFS); length = zip_read_int(data + ZIP_CENTRAL_UNCOMPLEN_OFFS); clength = zip_read_int(data + ZIP_CENTRAL_COMPLEN_OFFS); cmeth = zip_read_short(data + ZIP_CENTRAL_COMPMETH_OFFS); offs += ZIP_LOCAL_HEADER_LEN + pathlen + extra; if ((offs + clength) > tab->zip->length) { goto donull; } data = tab->zip->data + offs; if (cmeth == ZIP_COMPMETH_STORED) { sqlite3_result_blob(ctx, data, clength, SQLITE_TRANSIENT); return SQLITE_OK; } else if (cmeth == ZIP_COMPMETH_DEFLATED) { z_stream stream; int err; stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.next_in = data; stream.avail_in = clength; stream.next_out = dest = sqlite3_malloc(length); stream.avail_out = length; stream.opaque = 0; if (!dest) { goto donull; } if (inflateInit2(&stream, -15) != Z_OK) { goto donull; } err = inflate(&stream, Z_SYNC_FLUSH); inflateEnd(&stream); if ((err == Z_STREAM_END) || ((err == Z_OK) && (stream.avail_in == 0))) { sqlite3_result_blob(ctx, dest, length, sqlite3_free); return SQLITE_OK; } } donull: if (dest) { sqlite3_free(dest); } sqlite3_result_null(ctx); return SQLITE_OK; } case 6: /* "clength": compressed length */ length = zip_read_int(data + ZIP_CENTRAL_COMPLEN_OFFS); sqlite3_result_int(ctx, length); return SQLITE_OK; case 7: /* "cdata": raw data */ { int clength, offs, extra, pathlen; offs = zip_read_int(data + ZIP_CENTRAL_LOCALHDR_OFFS); if ((offs + ZIP_LOCAL_HEADER_LEN) > tab->zip->length) { goto donull; } extra = zip_read_short(tab->zip->data + offs + ZIP_LOCAL_EXTRA_OFFS); pathlen = zip_read_short(data + ZIP_CENTRAL_PATHLEN_OFFS); length = zip_read_int(data + ZIP_CENTRAL_UNCOMPLEN_OFFS); clength = zip_read_int(data + ZIP_CENTRAL_COMPLEN_OFFS); offs += ZIP_LOCAL_HEADER_LEN + pathlen + extra; if ((offs + clength) > tab->zip->length) { goto donull; } data = tab->zip->data + offs; sqlite3_result_blob(ctx, data, clength, SQLITE_TRANSIENT); return SQLITE_OK; } } sqlite3_result_error(ctx, "invalid column number", -1); return SQLITE_ERROR; } /** * Return current rowid of virtual table cursor * @param cursor virtual table cursor * @param rowidp value buffer to receive current rowid * @result SQLite error code */ static int zip_vtab_rowid(sqlite3_vtab_cursor *cursor, sqlite_int64 *rowidp) { zip_cursor *cur = (zip_cursor *) cursor; if (cur->nmatches < 0) { *rowidp = -1; } else if ((cur->pos >= 0) && (cur->nmatches > 0)) { *rowidp = cur->matches[cur->pos]; } else { *rowidp = cur->pos; } return SQLITE_OK; } /** * Internal MATCH function for virtual table. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void zip_vtab_matchfunc(sqlite3_context *ctx, int argc, sqlite3_value **argv) { int ret = 0; if (argc == 2) { unsigned char *q = (unsigned char *) sqlite3_value_text(argv[0]); unsigned char *p = (unsigned char *) sqlite3_value_text(argv[1]); if (p && q) { unsigned char *eq = (unsigned char *) strrchr((char *) q, '*'); int lenq, lenp; if (eq && (eq[1] == '\0')) { lenq = eq - q; if (lenq) { lenp = strlen((char *) p); if ((lenp >= lenq) && !memcmp(p, q, lenq)) { ret = 1; } } } } } sqlite3_result_int(ctx, ret); } /** * Find overloaded function on virtual table. * @param vtab virtual table * @param narg number arguments * @param name function name * @param pfunc pointer to function (value return) * @param parg pointer to function's argument (value return) * @result 0 or 1 */ static int zip_vtab_findfunc(sqlite3_vtab *vtab, int narg, const char *name, void (**pfunc)(sqlite3_context *, int, sqlite3_value **), void **parg) { if ((narg == 2) && !strcmp(name, "match")) { *pfunc = zip_vtab_matchfunc; *parg = 0; return 1; } return 0; } #if (SQLITE_VERSION_NUMBER > 3004000) /** * Rename virtual table. * @param newname new name for table * @result SQLite error code */ static int zip_vtab_rename(sqlite3_vtab *vtab, const char *newname) { return SQLITE_OK; } #endif /** * SQLite module descriptor. */ static const sqlite3_module zip_vtab_mod = { 1, /* iVersion */ zip_vtab_create, /* xCreate */ zip_vtab_connect, /* xConnect */ zip_vtab_bestindex, /* xBestIndex */ zip_vtab_disconnect, /* xDisconnect */ zip_vtab_destroy, /* xDestroy */ zip_vtab_open, /* xOpen */ zip_vtab_close, /* xClose */ zip_vtab_filter, /* xFilter */ zip_vtab_next, /* xNext */ zip_vtab_eof, /* xEof */ zip_vtab_column, /* xColumn */ zip_vtab_rowid, /* xRowid */ 0, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ zip_vtab_findfunc, /* xFindFunction */ #if (SQLITE_VERSION_NUMBER > 3004000) zip_vtab_rename, /* xRename */ #endif }; /** * Compute CRC32 given blob * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void zip_crc32_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { int crc, length; unsigned char *data; if (argc != 1) { sqlite3_result_error(ctx, "need one argument", -1); } data = (unsigned char *) sqlite3_value_blob(argv[0]); length = sqlite3_value_bytes(argv[0]); crc = crc32(0, 0, 0); if (data && (length > 0)) { crc = crc32(crc, data, length); } sqlite3_result_int(ctx, crc); } /** * Inflate data given blob * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void zip_inflate_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { int err, length, dlength, avail; unsigned char *data, *dest, *newdest; z_stream stream; if (argc != 1) { sqlite3_result_error(ctx, "need one argument", -1); return; } data = (unsigned char *) sqlite3_value_blob(argv[0]); length = sqlite3_value_bytes(argv[0]); stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.next_in = data; stream.avail_in = length; avail = length; stream.next_out = dest = sqlite3_malloc(avail); stream.avail_out = avail; stream.opaque = 0; if (!dest) { goto oom; } if (inflateInit2(&stream, -15) != Z_OK) { goto nomem; } dlength = 0; while (1) { err = inflate(&stream, Z_SYNC_FLUSH); if ((err == Z_STREAM_END) || ((err == Z_OK) && (stream.avail_in == 0))) { dlength += length - stream.avail_out; newdest = sqlite3_realloc(dest, dlength); inflateEnd(&stream); if (!newdest) { nomem: if (dest) { sqlite3_free(dest); } oom: sqlite3_result_error_nomem(ctx); return; } sqlite3_result_blob(ctx, newdest, dlength, sqlite3_free); return; } if ((err == Z_BUF_ERROR) || (err == Z_OK)) { newdest = sqlite3_realloc(dest, avail + length); dlength += length - stream.avail_out; if (!newdest) { inflateEnd(&stream); goto nomem; } avail += length; stream.next_out = newdest + (stream.next_out - dest); dest = newdest; stream.avail_out += length; } else { inflateEnd(&stream); sqlite3_free(dest); sqlite3_result_error(ctx, "inflate error", -1); return; } } } /** * Deflate data given blob and optional compression level * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void zip_deflate_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { int err, level = 9; unsigned long avail, length; unsigned char *data, *dest = 0; z_stream stream; if ((argc < 1) || (argc > 2)) { sqlite3_result_error(ctx, "need one or two arguments", -1); return; } if (argc > 1) { level = sqlite3_value_int(argv[1]); } data = (unsigned char *) sqlite3_value_blob(argv[0]); length = sqlite3_value_bytes(argv[0]); stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.next_in = data; stream.avail_in = length; stream.next_out = 0; stream.avail_out = 0; stream.opaque = 0; if (deflateInit2(&stream, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) { goto deflerr; } avail = deflateBound(&stream, length); if (avail == 0) { sqlite3_result_null(ctx); return; } stream.next_out = dest = sqlite3_malloc(avail); stream.avail_out = avail; if (!dest) { sqlite3_result_error_nomem(ctx); return; } err = deflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { deflateEnd(&stream); deflerr: if (dest) { sqlite3_free(dest); } sqlite3_result_error(ctx, "deflate error", -1); return; } length = stream.total_out; err = deflateEnd(&stream); if (err != Z_OK) { goto deflerr; } sqlite3_result_blob(ctx, dest, length, sqlite3_free); } /** * Compress data given blob and optional compression level * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void zip_compress_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { int err, level = 9; unsigned long length, dlength; unsigned char *data, *dest; if ((argc < 1) || (argc > 2)) { sqlite3_result_error(ctx, "need one or two arguments", -1); return; } if (argc > 1) { level = sqlite3_value_int(argv[1]); } data = (unsigned char *) sqlite3_value_blob(argv[0]); length = sqlite3_value_bytes(argv[0]); dlength = compressBound(length); dest = sqlite3_malloc(dlength); if (!dest) { sqlite3_result_error_nomem(ctx); return; } err = compress2(dest, &dlength, data, length, level); if (err == Z_OK) { sqlite3_result_blob(ctx, dest, dlength, sqlite3_free); return; } if (err == Z_MEM_ERROR) { sqlite3_result_error(ctx, "memory error", -1); } else if (err == Z_BUF_ERROR) { sqlite3_result_error(ctx, "buffer error", -1); } else { sqlite3_result_error(ctx, "compress error", -1); } sqlite3_free(dest); } #ifdef SQLITE_OPEN_URI /** * Create mem_blk from given data buffer and length. * @param data data buffer * @param length length of buffer * @result pointer to mem_blk or NULL */ static mem_blk * mem_createmb(const unsigned char *data, unsigned long length) { mem_blk *mb; #if defined(_WIN32) || defined(_WIN64) HANDLE mh; #else long psize; #endif unsigned long size; #if defined(_WIN32) || defined(_WIN64) size = sizeof (mem_blk) + length; mh = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, 0); if (mh == INVALID_HANDLE_VALUE) { return 0; } mb = (mem_blk *) MapViewOfFile(mh, FILE_MAP_ALL_ACCESS, 0, 0, length); if (!mb) { return 0; } #else psize = sysconf(_SC_PAGESIZE); #ifdef linux mb = (mem_blk *) sqlite3_malloc(sizeof (mem_blk)); if (!mb) { return 0; } size = length + 1; mb->data = (unsigned char *) mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (mb->data == MAP_FAILED) { sqlite3_free(mb); return 0; } #else size = sizeof (mem_blk) + psize + length + 1; mb = (mem_blk *) mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (mb == MAP_FAILED) { return 0; } #endif #endif if (mb) { memcpy(mb->magic, MEM_MAGIC, 4); mb->opened = 1; mb->size = size; mb->length = length; #if defined(_WIN32) || defined(_WIN64) mb->mh = mh; mb->data = (unsigned char *) (mb + 1); memcpy(mb->data, data, length); #else mb->psize = psize; #ifdef linux mb->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); sqlite3_mutex_enter(mb->mutex); mb->lcnt = 0; memcpy(mb->data, data, length); #else if (psize >= sizeof (mem_blk)) { mb->data = (unsigned char *) mb + psize; memcpy(mb->data, data, length); #ifndef linux mprotect(mb->data, length, PROT_READ); #endif } else { mb->data = (unsigned char *) (mb + 1); memcpy(mb->data, data, length); } #endif #endif } return mb; } /** * Destroy given mem_blk. * @param mb mem_blk pointer */ static void mem_destroymb(mem_blk *mb) { #if defined(_WIN32) || defined(_WIN64) HANDLE mh; #endif if (mb) { memset(mb->magic, 0, 4); #if defined(_WIN32) || defined(_WIN64) mh = mb->mh; UnmapViewOfFile(mb); CloseHandle(mh); #else #ifdef linux munmap(mb->data, mb->size); sqlite3_mutex_leave(mb->mutex); sqlite3_mutex_free(mb->mutex); sqlite3_free(mb); #else munmap(mb, mb->size); #endif #endif } } /** * Close mem_file and release associated mem_blk if open count drops to zero. * @param file SQLite3 file pointer * @result SQLite error code */ static int mem_close(sqlite3_file *file) { mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; if (mb) { #ifdef linux sqlite3_mutex_enter(mb->mutex); if (mf->lock > 0) { mb->lcnt = 0; } #endif mb->opened--; if (mb->opened <= 0) { mem_destroymb(mb); } #ifdef linux else { sqlite3_mutex_leave(mb->mutex); } #endif mf->mb = 0; } return SQLITE_OK; } /** * Read data from mem_file. * @param file SQLite3 file pointer * @param buf where to read data to * @param len length to be read * @param offs file offset * @result SQLite error code */ static int mem_read(sqlite3_file *file, void *buf, int len, sqlite_int64 offs) { mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; int rc = SQLITE_IOERR_READ; #ifdef linux if (mb) { sqlite3_mutex_enter(mb->mutex); } #endif if (mb && (offs <= mb->length)) { rc = SQLITE_OK; if (offs + len > mb->length) { rc = SQLITE_IOERR_SHORT_READ; len = mb->length - offs; } memcpy(buf, mb->data + offs, len); } #ifdef linux if (mb) { sqlite3_mutex_leave(mb->mutex); } #endif return rc; } /** * Truncate mem_file. * @param file SQLite3 file pointer * @param offs file size * @result SQLite error code */ static int #ifdef linux mem_truncate_unlocked(sqlite3_file *file, sqlite_int64 offs) #else mem_truncate(sqlite3_file *file, sqlite_int64 offs) #endif { #ifdef linux mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; unsigned char *p; long psize = mb->psize; unsigned long length = offs; unsigned long size; size = length + 1; if ((psize > 0) && (size / psize == mb->size / psize)) { p = mb->data; } else { p = mremap(mb->data, mb->size, size, MREMAP_MAYMOVE); } if (p == MAP_FAILED) { return SQLITE_IOERR_TRUNCATE; } mb->size = size; mb->length = length; mb->data = p; return SQLITE_OK; #else return SQLITE_IOERR_TRUNCATE; #endif } #ifdef linux static int mem_truncate(sqlite3_file *file, sqlite_int64 offs) { mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; int rc = SQLITE_IOERR_TRUNCATE; if (mb) { sqlite3_mutex_enter(mb->mutex); rc = mem_truncate_unlocked(file, offs); sqlite3_mutex_leave(mb->mutex); } return rc; } #endif /** * Write data to mem_file. * @param file SQLite3 file pointer * @param buf what to write * @param len length to be written * @param offs file offset * @result SQLite error code */ static int mem_write(sqlite3_file *file, const void *buf, int len, sqlite_int64 offs) { #ifdef linux mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; sqlite3_mutex_enter(mb->mutex); if (offs + len > mb->length) { if (mem_truncate_unlocked(file, offs + len) != SQLITE_OK) { sqlite3_mutex_leave(mb->mutex); return SQLITE_IOERR_WRITE; } } memcpy(mb->data + offs, buf, len); sqlite3_mutex_leave(mb->mutex); return SQLITE_OK; #else return SQLITE_IOERR_WRITE; #endif } /** * Sync mem_file. * @param file SQLite3 file pointer * @param flags sync flags * @result SQLite error code */ static int mem_sync(sqlite3_file *file, int flags) { #ifdef linux return SQLITE_OK; #else return SQLITE_IOERR_FSYNC; #endif } /** * Report file size of mem_file. * @param file SQLite3 file pointer * @param size value return * @result SQLite error code */ static int mem_filesize(sqlite3_file *file, sqlite_int64 *size) { mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; if (mb) { #ifdef linux sqlite3_mutex_enter(mb->mutex); #endif *size = mb->length; #ifdef linux sqlite3_mutex_leave(mb->mutex); #endif return SQLITE_OK; } return SQLITE_IOERR_FSTAT; } /** * Lock mem_file. * @param file SQLite3 file pointer * @param lck new lock status * @result SQLite error code, always SQLITE_OK */ static int mem_lock(sqlite3_file *file, int lck) { #ifdef linux mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; int rc = SQLITE_IOERR_LOCK; if (mb) { sqlite3_mutex_enter(mb->mutex); if (lck > 0) { rc = SQLITE_BUSY; if ((mf->lock == 0) && (mb->lcnt == 0)) { mb->lcnt = 1; mf->lock = lck; rc = SQLITE_OK; } else if ((mf->lock > 0) && (mb->lcnt == 1)) { mf->lock = lck; rc = SQLITE_OK; } } sqlite3_mutex_leave(mb->mutex); } return rc; #else return SQLITE_OK; #endif } /** * Unlock mem_file. * @param file SQLite3 file pointer * @param lck new lock status * @result SQLite error code, always SQLITE_OK */ static int mem_unlock(sqlite3_file *file, int lck) { #ifdef linux mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; int rc = SQLITE_IOERR_UNLOCK; if (mb) { sqlite3_mutex_enter(mb->mutex); if (mf->lock == lck) { rc = SQLITE_OK; } else if (lck == 0) { if (mf->lock) { mb->lcnt = 0; mf->lock = 0; } rc = SQLITE_OK; } else if ((lck < mf->lock) && (mb->lcnt != 0)) { mf->lock = lck; rc = SQLITE_OK; } sqlite3_mutex_leave(mb->mutex); } return rc; #else return SQLITE_OK; #endif } /** * Check lock state of mem_file. * @param file SQLite3 file pointer * @param out current lock status * @result SQLite error code, always SQLITE_OK */ static int mem_checkreservedlock(sqlite3_file *file, int *out) { #ifdef linux mem_file *mf = (mem_file *) file; mem_blk *mb = mf->mb; int rc = SQLITE_IOERR_CHECKRESERVEDLOCK; if (mb) { sqlite3_mutex_enter(mb->mutex); *out = mf->lock >= 2; sqlite3_mutex_leave(mb->mutex); rc = SQLITE_OK; } else { *out = 0; } return rc; #else *out = 0; return SQLITE_OK; #endif } /** * File control operation on mem_file. * @param file SQLite3 file pointer * @param op operation code * @param arg argument for operation * @result SQLite error code, always SQLITE_OK */ static int mem_filecontrol(sqlite3_file *file, int op, void *arg) { #ifdef SQLITE_FCNTL_PRAGMA if (op == SQLITE_FCNTL_PRAGMA) { return SQLITE_NOTFOUND; } #endif return SQLITE_OK; } /** * Report sector size of mem_file. * @param file SQLite3 file pointer * @result always 4096 */ static int mem_sectorsize(sqlite3_file *file) { return 4096; } /** * Device characteristics of mem_file. * @param file SQLite3 file pointer * @result always 0 */ static int mem_devicecharacteristics(sqlite3_file *file) { return 0; } /** * I/O method structure of mem_file. */ static sqlite3_io_methods mem_methods = { 1, /* iVersion */ mem_close, /* xClose */ mem_read, /* xRead */ mem_write, /* xWrite */ mem_truncate, /* xTruncate */ mem_sync, /* xSync */ mem_filesize, /* xFileSize */ mem_lock, /* xLock */ mem_unlock, /* xUnlock */ mem_checkreservedlock, /* xCheckReservedLock */ mem_filecontrol, /* xFileControl */ mem_sectorsize, /* xSectorSize */ mem_devicecharacteristics /* xDeviceCharacteristics */ }; /** * Open mem_file given file name in mem_vfs. * @param vfs SQLite VFS * @param name file name * @param file SQLite3 file pointer to be filled * @param flags open flags * @param outflags value return of open flags * @result SQLite error code */ static int mem_open(sqlite3_vfs *vfs, const char *name, sqlite3_file *file, int flags, int *outflags) { mem_file *mf = (mem_file *) file; mem_blk *mb = 0; #ifdef _WIN64 unsigned long long t = 0; #else unsigned long t = 0; #endif #if !defined(_WIN32) && !defined(_WIN64) mem_blk mb0; int pfd[2]; int n; #endif if (!name) { return SQLITE_IOERR; } if (flags & (SQLITE_OPEN_MAIN_JOURNAL | SQLITE_OPEN_WAL | #ifndef linux SQLITE_OPEN_READWRITE | #endif SQLITE_OPEN_CREATE)) { return SQLITE_CANTOPEN; } #ifdef _WIN64 sscanf(name + 1, "%I64x", &t); #else t = strtoul(name + 1, 0, 16); #endif mb = (mem_blk *) t; if (!mb) { return SQLITE_CANTOPEN; } #if !defined(_WIN32) && !defined(_WIN64) if (pipe(pfd) < 0) { return SQLITE_CANTOPEN; } n = (write(pfd[1], (char *) mb, sizeof (mem_blk)) < 0) ? errno : 0; if (n == EFAULT) { cantopen: close(pfd[0]); close(pfd[1]); return SQLITE_CANTOPEN; } n = read(pfd[0], (char *) &mb0, sizeof (mem_blk)); if (n != sizeof (mem_blk)) { goto cantopen; } if (memcmp(mb0.magic, MEM_MAGIC, 4) == 0) { #ifdef linux n = (write(pfd[1], (char *) mb0.data, 1) < 0) ? errno : 0; if (n == EFAULT) { goto cantopen; } #endif if (mb0.length > 0) { n = (write(pfd[1], (char *) mb0.data + mb0.length - 1, 1) < 0) ? errno : 0; if (n == EFAULT) { goto cantopen; } } close(pfd[0]); close(pfd[1]); #ifdef linux sqlite3_mutex_enter(mb->mutex); #endif mb->opened++; #ifdef linux sqlite3_mutex_leave(mb->mutex); #endif } else { goto cantopen; } #else if (memcmp(mb->magic, MEM_MAGIC, 4) == 0) { mb->opened++; } else { return SQLITE_CANTOPEN; } #endif memset(mf, 0, sizeof (mem_file)); mf->mb = mb; mf->base.pMethods = &mem_methods; if (outflags) { *outflags = flags; } return SQLITE_OK; } /** * Delete mem_vfs file given name. * @param vfs SQLite VFS * @param name file name * @param sync perform sync before deletion * @result SQLite error code, always SQLITE_IOERR_DELETE */ static int mem_delete(sqlite3_vfs *vfs, const char *name, int sync) { return SQLITE_IOERR_DELETE; } /** * Test mem_vfs file access given name and flags * @param vfs SQLite VFS * @param name file name * @param flags access to be tested * @param outflags value return of tested access modes * @result SQLite error code */ static int mem_access(sqlite3_vfs *vfs, const char *name, int flags, int *outflags) { char *endp = 0; unsigned long t; t = strtol(name + 1, &endp, 16); if ((t == 0) || #ifndef linux (flags == SQLITE_ACCESS_READWRITE) || #endif !endp || endp[0]) { *outflags = 0; } else { *outflags = 1; } return SQLITE_OK; } /** * Return full pathname on mem_vfs given name. * @param vfs SQLite VFS * @param name file name * @param len length of output buffer * @param out output buffer * @result SQLite error code, always SQLITE_OK */ static int mem_fullpathname(sqlite3_vfs *vfs, const char *name, int len, char *out) { sqlite3_snprintf(len, out, "%s", name); out[len - 1] = '\0'; return SQLITE_OK; } /** * Open shared library on mem_vfs given name. * @param vfs SQLite VFS * @param name file name * @result handle, always 0 */ static void * mem_dlopen(sqlite3_vfs *vfs, const char *name) { return 0; } /** * Report last error of shared library operation on mem_vfs. * @param vfs SQLite VFS * @param len length of output buffer * @param out output buffer */ static void mem_dlerror(sqlite3_vfs *vfs, int len, char *out) { sqlite3_snprintf(len, out, "Loadable extensions are not supported"); out[len - 1] = '\0'; } /** * Lookup symbol in shared library on mem_vfs given name. * @param vfs SQLite VFS * @param handle shared library handle * @param sym symbol name * @result symbol address, always 0 */ static void (*mem_dlsym(sqlite3_vfs *vfs, void *handle, const char *sym))(void) { return 0; } /** * Close shared library on mem_vfs given handle. * @param vfs SQLite VFS * @param handle shared library handle */ static void mem_dlclose(sqlite3_vfs *vfs, void *handle) { } /** * Return buffer filled with random bytes * @param vfs SQLite VFS * @param len length of output buffer * @param out output buffer * @result SQLite error code */ static int mem_randomness(sqlite3_vfs *vfs, int len, char *out) { sqlite3_vfs *ovfs = (sqlite3_vfs *) vfs->pAppData; return ovfs->xRandomness(ovfs, len, out); } /** * Sleep for given number of microseconds. * @param vfs SQLite VFS * @param micro microseconds to sleep * @result SQLite error code */ static int mem_sleep(sqlite3_vfs *vfs, int micro) { sqlite3_vfs *ovfs = (sqlite3_vfs *) vfs->pAppData; return ovfs->xSleep(ovfs, micro); } /** * Return current time. * @param vfs SQLite VFS * @param out output buffer * @result SQLite error code */ static int mem_currenttime(sqlite3_vfs *vfs, double *out) { sqlite3_vfs *ovfs = (sqlite3_vfs *) vfs->pAppData; return ovfs->xCurrentTime(ovfs, out); } /** * VFS structure of mem_vfs */ static sqlite3_vfs mem_vfs = { 1, /* iVersion */ sizeof (mem_file), /* szOsFile */ 256, /* mxPathname */ 0, /* pNext */ mem_vfs_name, /* zName */ 0, /* pAppData */ mem_open, /* xOpen */ mem_delete, /* xDelete */ mem_access, /* xAccess */ mem_fullpathname, /* xFullPathname */ mem_dlopen, /* xDlOpen */ mem_dlerror, /* xDlError */ mem_dlsym, /* xDlSym */ mem_dlclose, /* xDlClose */ mem_randomness, /* xDlError */ mem_sleep, /* xDlSym */ mem_currenttime /* xDlClose */ }; /** * Attach (read-only) embedded SQLite database given blob. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector * * Arguments: * * BLOB - the BLOB containing the embedded SQLite database
* dbname - the name of the attached database
* * Function result: * * NULL - attached r/o database
* URI string - attached database
* all else - error occurred
* * Example: * * CREATE VIRTUAL TABLE Z USING ZIPFILE('zipfile.zip');
* SELECT blob_attach(data, 'ZDB') FROM Z WHERE PATH = 'embedded.db';
* DROP VIRTUAL TABLE Z;
*/ static void blob_attach_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { unsigned long length; const unsigned char *data; mem_blk *mb = 0; char *sql = 0; int sqllen = 0; #ifdef linux int isrw = 0; #endif if (argc != 2) { sqlite3_result_error(ctx, "need two arguments", -1); return; } data = (const unsigned char *) sqlite3_value_blob(argv[0]); length = sqlite3_value_bytes(argv[0]); if (!data || !length) { sqlite3_result_error(ctx, "empty blob", -1); return; } mb = mem_createmb(data, length); if (!mb) { sqlite3_result_error(ctx, "cannot map blob", -1); return; } sql = sqlite3_mprintf("ATTACH " #ifdef _WIN64 "'file:/%llX" #else "'file:/%lX" #endif "?vfs=%s&" #ifdef linux "mode=rw&" #else "mode=ro&" #endif "cache=private' AS %Q", #ifdef _WIN64 (unsigned long long) mb, #else (unsigned long) mb, #endif mem_vfs_name, (char *) sqlite3_value_text(argv[1])); if (!sql) { sqlite3_result_error(ctx, "cannot map blob", -1); mem_destroymb(mb); return; } #ifdef linux sqlite3_mutex_leave(mb->mutex); #endif if (sqlite3_exec(sqlite3_context_db_handle(ctx), sql, 0, 0, 0) != SQLITE_OK) { sqlite3_free(sql); sqlite3_result_error(ctx, "cannot attach blob", -1); #ifdef linux sqlite3_mutex_enter(mb->mutex); #endif mem_destroymb(mb); return; } sqllen = strlen(sql); sqlite3_snprintf(sqllen, sql, "PRAGMA %Q.synchronous = OFF", (char *) sqlite3_value_text(argv[1])); sqlite3_exec(sqlite3_context_db_handle(ctx), sql, 0, 0, 0); #ifdef linux sqlite3_snprintf(sqllen, sql, "PRAGMA %Q.journal_mode = OFF", (char *) sqlite3_value_text(argv[1])); if (sqlite3_exec(sqlite3_context_db_handle(ctx), sql, 0, 0, 0) == SQLITE_OK) { isrw = 1; } #endif #ifdef linux sqlite3_mutex_enter(mb->mutex); #endif if (--mb->opened < 1) { sqlite3_snprintf(sqllen, sql, "DETACH %Q", (char *) sqlite3_value_text(argv[1])); sqlite3_exec(sqlite3_context_db_handle(ctx), sql, 0, 0, 0); sqlite3_free(sql); sqlite3_result_error(ctx, "cannot attach blob", -1); mem_destroymb(mb); return; } #ifdef linux sqlite3_mutex_leave(mb->mutex); if (isrw) { sqlite3_snprintf(sqllen, sql, "file:/%lX?vfs=%s&mode=rw&cache=private", (unsigned long) mb, mem_vfs_name); sqlite3_result_text(ctx, sql, -1, sqlite3_free); return; } #endif sqlite3_free(sql); sqlite3_result_null(ctx); } /** * Dump memory mapped (writable) database to blob. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector * * Arguments: * * ADDR - the memory mapped database
* * Function result: * * blob - success
* all else - error occurred
* */ static void blob_dump_func(sqlite3_context *ctx, int argc, sqlite3_value **argv) { char *uri, vfs[64]; #ifdef _WIN64 unsigned long long addr = 0; #else unsigned long addr = 0; #endif #ifdef linux int pfd[2], n; mem_blk *mb; #endif if (argc != 1) { sqlite3_result_error(ctx, "need one argument", -1); return; } uri = (char *) sqlite3_value_text(argv[0]); vfs[0] = '\0'; if (!uri || (sscanf(uri, #ifdef _WIN64 "file:/%I64X?vfs=%63[^&]", #else "file:/%lX?vfs=%63[^&]", #endif &addr, vfs) != 2)) { inval: sqlite3_result_error(ctx, "invalid object", -1); return; } vfs[63] = '\0'; if ((strcmp(mem_vfs_name, vfs) != 0) || (addr == 0)) { goto inval; } #ifdef linux if (pipe(pfd) < 0) { goto inval; } n = (write(pfd[1], (char *) addr, 1) < 0) ? errno : 0; close(pfd[0]); close(pfd[1]); if (n == EFAULT) { goto inval; } mb = (mem_blk *) addr; if (memcmp(mb->magic, MEM_MAGIC, 4) != 0) { goto inval; } sqlite3_mutex_enter(mb->mutex); sqlite3_result_blob(ctx, mb->data, mb->length, SQLITE_STATIC); sqlite3_mutex_leave(mb->mutex); #else sqlite3_result_error(ctx, "unsupported function", -1); #endif } #endif /* SQLITE_OPEN_URI */ /** * Module initializer creating SQLite module and functions. * @param db database pointer * @result SQLite error code */ #ifndef STANDALONE static #endif int zip_vtab_init(sqlite3 *db) { sqlite3_create_function(db, "crc32", 1, SQLITE_UTF8, (void *) db, zip_crc32_func, 0, 0); sqlite3_create_function(db, "inflate", 1, SQLITE_UTF8, (void *) db, zip_inflate_func, 0, 0); sqlite3_create_function(db, "deflate", 1, SQLITE_UTF8, (void *) db, zip_deflate_func, 0, 0); sqlite3_create_function(db, "uncompress", 1, SQLITE_UTF8, (void *) db, zip_inflate_func, 0, 0); sqlite3_create_function(db, "compress", -1, SQLITE_UTF8, (void *) db, zip_compress_func, 0, 0); #ifdef SQLITE_OPEN_URI if (!mem_vfs.pAppData) { sqlite3_vfs *parent = sqlite3_vfs_find(0); if (parent) { sqlite3_snprintf(sizeof (mem_vfs_name), mem_vfs_name, #ifdef _WIN64 "mem_vfs_%llX", (unsigned long long) &mem_vfs #else "mem_vfs_%lX", (unsigned long) &mem_vfs #endif ); if (sqlite3_vfs_register(&mem_vfs, 0) == SQLITE_OK) { mem_vfs.pAppData = (void *) parent; } } } if (mem_vfs.pAppData) { sqlite3_create_function(db, "blob_attach", 2, SQLITE_UTF8, (void *) db, blob_attach_func, 0, 0); sqlite3_create_function(db, "blob_dump", 1, SQLITE_UTF8, (void *) db, blob_dump_func, 0, 0); } #endif return sqlite3_create_module(db, "zipfile", &zip_vtab_mod, 0); } #ifndef STANDALONE /** * Initializer for SQLite extension load mechanism. * @param db SQLite database pointer * @param errmsg pointer receiving error message * @param api SQLite API routines * @result SQLite error code */ int sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { SQLITE_EXTENSION_INIT2(api); return zip_vtab_init(db); } #endif ./sqliteodbc-0.992/zipfile.rc0100644000076400001440000000237312025530110014512 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 Extension ZIP File\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "ZIPFILE\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3_MOD_ZIPFILE.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/xpath.c0100644000076400001440000011726412123247137014035 0ustar chwusers/** * @file xpath.c * SQLite extension module to select parts of XML documents * using libxml2 XPath and SQLite's virtual table mechanism. * * 2013 March 15 * * The author disclaims copyright to this source code. * In place of a legal notice, here is a blessing: * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. * ******************************************************************** */ #if defined(_WIN32) || defined(_WIN64) #include #endif #include #include #include #include #include #include #include #ifdef WITH_XSLT #include #include #include #endif #ifdef STANDALONE #include #else #include static SQLITE_EXTENSION_INIT1 #endif /** * @typedef XDOC * @struct XDOC * Structure to cache XML document. */ typedef struct XDOC { xmlDocPtr doc; /**< XML document. */ int refcnt; /**< Reference counter. */ } XDOC; /** * @typedef XMOD * @struct XMOD * Structure holding per module/database data. */ typedef struct XMOD { int refcnt; /**< Reference counter. */ sqlite3_mutex *mutex; /**< DOC table mutex. */ int sdoc; /**< Size of docs array. */ int ndoc; /**< Number of used entries in docs array. */ XDOC *docs; /**< Array of modules's DOCs. */ } XMOD; static int initialized = 0; static XMOD *xmod = 0; /** * @typedef XTAB * @struct XTAB * Structure to describe virtual table. */ typedef struct XTAB { sqlite3_vtab vtab; /**< SQLite virtual table. */ sqlite3 *db; /**< Open database. */ XMOD *xm; /**< Module data. */ struct XCSR *xc; /**< Current cursor. */ int sdoc; /**< Size of idocs array. */ int ndoc; /**< Number of used entries in idocs array. */ int *idocs; /**< Indexes in module-wide DOC table. */ } XTAB; /** * @typedef XEXP * @struct XEXP * Structure to describe XPath expression. */ typedef struct XEXP { struct XEXP *next; /**< Next item. */ struct XEXP *prev; /**< Previous item. */ xmlDocPtr doc; /**< Current XML document. */ xmlXPathContextPtr pctx; /**< Current XPath context. */ xmlXPathObjectPtr pobj; /**< Current XPath objects. */ xmlNodePtr parent; /**< Current parent node or NULL. */ int pos; /**< Position within XPath expr. */ int conv; /**< Conversion: string/boolean/number. */ char expr[1]; /**< XPath expression text. */ } XEXP; /** * @typedef XCSR * @struct XCSR * Structure to describe virtual table cursor. */ typedef struct XCSR { sqlite3_vtab_cursor cursor; /**< SQLite virtual table cursor */ int pos; /**< Current index. */ int nexpr; /**< Number of XPath expr. */ XEXP *first; /**< First XPath expr. */ XEXP *last; /**< Last XPath expr. */ } XCSR; /** * Connect to virtual table. * @param db SQLite database pointer * @param aux user specific pointer * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code * * Argument vector contains: * * argv[0] - module name
* argv[1] - database name
* argv[2] - table name (virtual table)
*/ static int xpath_connect(sqlite3* db, void *aux, int argc, const char * const *argv, sqlite3_vtab **vtabp, char **errp) { int rc = SQLITE_ERROR; XTAB *xt; xt = sqlite3_malloc(sizeof (XTAB)); if (!xt) { nomem: *errp = sqlite3_mprintf("out of memory"); return rc; } memset(xt, 0, sizeof (XTAB)); xt->db = db; xt->xm = (XMOD *) aux; xt->xc = 0; xt->sdoc = 128; xt->ndoc = 0; xt->idocs = sqlite3_malloc(xt->sdoc * sizeof (int)); if (!xt->idocs) { sqlite3_free(xt); goto nomem; } rc = sqlite3_declare_vtab(db, "CREATE TABLE x(" " DOCID INTEGER PRIMARY KEY," " XML HIDDEN BLOB," " PATH HIDDEN TEXT," " OPTIONS HIDDEN INTEGER," " ENCODING HIDDEN TEXT," " BASEURL HIDDEN TEXT," " XMLDUMP HIDDEN TEXT" ")"); if (rc != SQLITE_OK) { sqlite3_free(xt->idocs); sqlite3_free(xt); *errp = sqlite3_mprintf("table definition failed (error %d)", rc); return rc; } *vtabp = &xt->vtab; *errp = 0; return SQLITE_OK; } /** * Create virtual table. * @param db SQLite database pointer * @param aux user specific pointer * @param argc argument count * @param argv argument vector * @param vtabp pointer receiving virtual table pointer * @param errp pointer receiving error messag * @result SQLite error code */ static int xpath_create(sqlite3* db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) { return xpath_connect(db, aux, argc, argv, vtabp, errp); } /** * Disconnect virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int xpath_disconnect(sqlite3_vtab *vtab) { XTAB *xt = (XTAB *) vtab; XMOD *xm = xt->xm; int i, n; if (xm->mutex) { sqlite3_mutex_enter(xm->mutex); for (i = 0; xm->docs && (i < xt->ndoc); i++) { n = xt->idocs[i]; if ((n >= 0) && (n < xm->sdoc)) { xmlDocPtr doc = xm->docs[n].doc; if (doc) { xm->docs[n].refcnt -= 1; if (xm->docs[n].refcnt <= 0) { xm->docs[n].doc = 0; xm->docs[n].refcnt = 0; xm->ndoc--; xmlFreeDoc(doc); } } } } sqlite3_mutex_leave(xm->mutex); } sqlite3_free(xt->idocs); sqlite3_free(xt); return SQLITE_OK; } /** * Destroy virtual table. * @param vtab virtual table pointer * @result always SQLITE_OK */ static int xpath_destroy(sqlite3_vtab *vtab) { return xpath_disconnect(vtab); } /** * Determines information for filter function according to constraints. * @param vtab virtual table * @param info index/constraint information * @result SQLite error code */ static int xpath_bestindex(sqlite3_vtab *vtab, sqlite3_index_info *info) { return SQLITE_OK; } /** * Open virtual table and return cursor. * @param vtab virtual table pointer * @param cursorp pointer receiving cursor pointer * @result SQLite error code */ static int xpath_open(sqlite3_vtab *vtab, sqlite3_vtab_cursor **cursorp) { XCSR *xc = sqlite3_malloc(sizeof (XCSR)); if (!xc) { return SQLITE_ERROR; } xc->cursor.pVtab = vtab; xc->pos = -1; xc->nexpr = 0; xc->first = xc->last = 0; *cursorp = &xc->cursor; return SQLITE_OK; } /** * Close virtual table cursor. * @param cursor cursor pointer * @result SQLite error code */ static int xpath_close(sqlite3_vtab_cursor *cursor) { XCSR *xc = (XCSR *) cursor; XEXP *xp = xc->first, *next; XTAB *xt = (XTAB *) xc->cursor.pVtab; while (xp) { next = xp->next; if (xp->pobj) { xmlXPathFreeObject(xp->pobj); } if (xp->pctx) { xmlXPathFreeContext(xp->pctx); } sqlite3_free(xp); xp = next; } if (xt->xc == xc) { xt->xc = 0; } sqlite3_free(xc); return SQLITE_OK; } /** * Retrieve next row from virtual table cursor. * @param cursor virtual table cursor * @result SQLite error code */ static int xpath_next(sqlite3_vtab_cursor *cursor) { XCSR *xc = (XCSR *) cursor; XTAB *xt = (XTAB *) xc->cursor.pVtab; XEXP *xp; if (xc->pos < xt->ndoc) { int ninc = 0; if ((xc->pos >= 0) && xc->nexpr) { int newpos; xmlNodePtr node, parent = 0; xp = xc->first; while (xp) { if (xp->pobj) { if (xp == xc->first) { parent = xp->parent; } else if (parent != xp->parent) { break; } } xp = xp->next; } if (parent && !xp) { int pchg = 0; xp = xc->first; while (xp) { if (xp->pobj && (xp->pobj->type == XPATH_NODESET) && xp->pobj->nodesetval) { newpos = xp->pos + 1; if (newpos < xp->pobj->nodesetval->nodeNr) { node = xp->pobj->nodesetval->nodeTab[newpos]; if (node->parent != xp->parent) { pchg++; } } else { pchg++; } } xp = xp->next; } if ((pchg != 0) && (pchg != xc->nexpr)) { xp = xc->first; while (xp) { if (xp->pobj && (xp->pobj->type == XPATH_NODESET) && xp->pobj->nodesetval) { newpos = xp->pos + 1; if (newpos < xp->pobj->nodesetval->nodeNr) { node = xp->pobj->nodesetval->nodeTab[newpos]; if (node->parent == xp->parent) { xp->pos = newpos; ninc++; } } else { xp->pos = xp->pobj->nodesetval->nodeNr; ninc++; } } xp = xp->next; } } } if (!ninc) { xp = xc->first; while (xp) { if (xp->pobj && (xp->pobj->type == XPATH_NODESET) && xp->pobj->nodesetval) { newpos = xp->pos + 1; if (newpos < xp->pobj->nodesetval->nodeNr) { xp->pos = newpos; ninc++; } else { xp->pos = xp->pobj->nodesetval->nodeNr; } } xp = xp->next; } } } if (!ninc) { xc->pos++; xp = xc->first; while (xp) { xp->pos = -1; xp->parent = 0; xp = xp->next; } } } return SQLITE_OK; } /** * Filter function for virtual table. * @param cursor virtual table cursor * @param idxNum not used * @param idxStr nod used * @param argc number arguments (not used) * @param argv argument (nothing or RHS of filter expression, not used) * @result SQLite error code */ static int xpath_filter(sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) { XCSR *xc = (XCSR *) cursor; XTAB *xt = (XTAB *) xc->cursor.pVtab; xc->pos = -1; xt->xc = xc; return xpath_next(cursor); } /** * Return end of table state of virtual table cursor. * @param cursor virtual table cursor * @result true/false */ static int xpath_eof(sqlite3_vtab_cursor *cursor) { XCSR *xc = (XCSR *) cursor; XTAB *xt = (XTAB *) xc->cursor.pVtab; return xc->pos >= xt->ndoc; } /** * Return column data of virtual table. * @param cursor virtual table cursor * @param ctx SQLite function context * @param n column index * @result SQLite error code */ static int xpath_column(sqlite3_vtab_cursor *cursor, sqlite3_context *ctx, int n) { XCSR *xc = (XCSR *) cursor; XTAB *xt = (XTAB *) xc->cursor.pVtab; XMOD *xm = (XMOD *) xt->xm; if ((xc->pos < 0) || (xc->pos >= xt->ndoc)) { sqlite3_result_error(ctx, "column out of bounds", -1); return SQLITE_ERROR; } if (n == 0) { n = xt->idocs[xc->pos]; if (xm->docs[n].doc) { sqlite3_result_int(ctx, n + 1); return SQLITE_OK; } } else if (n == 6) { n = xt->idocs[xc->pos]; if (xm->docs[n].doc) { xmlChar *dump = 0; int dump_len = 0; xmlDocDumpFormatMemoryEnc(xm->docs[n].doc, &dump, &dump_len, "utf-8", 1); if (dump) { sqlite3_result_text(ctx, (char *) dump, dump_len, SQLITE_TRANSIENT); xmlFree(dump); return SQLITE_OK; } } } sqlite3_result_null(ctx); return SQLITE_OK; } /** * Return current rowid of virtual table cursor. * @param cursor virtual table cursor * @param rowidp value buffer to receive current rowid * @result SQLite error code */ static int xpath_rowid(sqlite3_vtab_cursor *cursor, sqlite3_int64 *rowidp) { XCSR *xc = (XCSR *) cursor; XTAB *xt = (XTAB *) xc->cursor.pVtab; XMOD *xm = (XMOD *) xt->xm; int n = xt->idocs[xc->pos]; if (xm->docs[n].doc) { *rowidp = (sqlite3_int64) (n + 1); return SQLITE_OK; } return SQLITE_ERROR; } /** * Insert/delete row into/from virtual table. * @param vtab virtual table pointer * @param argc number of arguments * @param argv argument vector * @param rowidp value buffer to receive rowid * @result SQLite error code * * Examples: * * CREATE VIRTUAL TABLE X USING xpath();
* INSERT INTO X(XML) VALUES('xml-string ...');
* INSERT INTO X(PATH,OPTIONS) VALUES(<url>,0);
* DELETE FROM X WHERE DOCID=<docid>;
* * Virtual table columns: * * DOCID - document identifier and ROWID
* XML - XML string
* PATH - pathname or URL
* OPTIONS - parser options, see libxml's XML_PARSE_* defines
* ENCODING - optional document encoding, default UTF-8
* BASEURL - optional base URL when XML string given
* XMLDUMP - output column, XML dump of document tree
* * All columns except DOCID are hidden. UPDATE on the virtual table * is not supported. Default parser options are XML_PARSE_NOERROR, * XML_PARSE_NOWARNING, and XML_PARSE_NONET. */ static int xpath_update(sqlite3_vtab *vtab, int argc, sqlite3_value **argv, sqlite3_int64 *rowidp) { int n = -1, rc = SQLITE_ERROR; XTAB *xt = (XTAB *) vtab; XMOD *xm = (XMOD *) xt->xm; xmlDocPtr doc = 0, docToFree = 0; if (argc == 1) { /* DELETE */ int i, k = -1; n = sqlite3_value_int(argv[0]); for (i = 0; i < xt->ndoc; i++) { if ((n - 1) == xt->idocs[i]) { k = xt->idocs[i]; memmove(xt->idocs + i, xt->idocs + i + 1, (xt->ndoc - (i + 1)) * sizeof (int)); xt->ndoc--; break; } } if ((k >= 0) && xm->mutex) { n = k; doc = xm->docs[n].doc; } rc = SQLITE_OK; } else if ((argc > 1) && (sqlite3_value_type(argv[0]) == SQLITE_NULL)) { /* INSERT */ int i, docid; int opts = (XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NONET); char *enc = 0; if (sqlite3_value_type(argv[1]) != SQLITE_NULL) { if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("ROWID must be NULL"); rc = SQLITE_CONSTRAINT; goto done; } if (sqlite3_value_type(argv[2]) != SQLITE_NULL) { docid = sqlite3_value_int(argv[2]); if ((sqlite3_value_type(argv[3]) != SQLITE_NULL) || (sqlite3_value_type(argv[4]) != SQLITE_NULL)) { if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("XML and PATH must be NULL"); rc = SQLITE_CONSTRAINT; goto done; } sqlite3_mutex_enter(xm->mutex); for (i = 0; xm->docs && (i < xt->ndoc); i++) { if ((docid - 1) == xt->idocs[i]) { sqlite3_mutex_leave(xm->mutex); if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("constraint violation"); rc = SQLITE_CONSTRAINT; goto done; } } if ((docid > 0) && (docid <= xm->sdoc)) { doc = xm->docs[docid - 1].doc; if (doc) { xm->docs[docid - 1].refcnt++; } } sqlite3_mutex_leave(xm->mutex); if (!doc) { if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("invalid DOCID"); goto done; } goto havedoc; } if (((sqlite3_value_type(argv[3]) == SQLITE_NULL) && (sqlite3_value_type(argv[4]) == SQLITE_NULL)) || ((sqlite3_value_type(argv[3]) != SQLITE_NULL) && (sqlite3_value_type(argv[4]) != SQLITE_NULL))) { if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("specify one of XML or PATH"); rc = SQLITE_CONSTRAINT; goto done; } if (sqlite3_value_type(argv[5]) != SQLITE_NULL) { opts = sqlite3_value_int(argv[5]); } if (sqlite3_value_type(argv[6]) != SQLITE_NULL) { enc = (char *) sqlite3_value_text(argv[6]); } if (sqlite3_value_type(argv[4]) != SQLITE_NULL) { doc = xmlReadFile((char *) sqlite3_value_text(argv[4]), enc, opts); } else { char *url = 0; if (sqlite3_value_type(argv[7]) != SQLITE_NULL) { url = (char *) sqlite3_value_text(argv[7]); } doc = xmlReadMemory(sqlite3_value_blob(argv[3]), sqlite3_value_bytes(argv[3]), url ? url : "", enc, opts); } if (!doc) { if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("read error"); goto done; } docToFree = doc; havedoc: if (xt->ndoc >= xt->sdoc) { int *idocs = sqlite3_realloc(xt->idocs, xt->sdoc + 128 * sizeof (int)); if (!idocs) { goto nomem; } xt->idocs = idocs; xt->sdoc += 128; } if (!xm->mutex) { goto nomem; } sqlite3_mutex_enter(xm->mutex); if (xm->ndoc >= xt->sdoc) { XDOC *docs = sqlite3_realloc(xm->docs, xt->sdoc + 128 * sizeof (XDOC)); if (!docs) { sqlite3_mutex_leave(xm->mutex); goto nomem; } xm->docs = docs; docs += xt->sdoc; memset(docs, 0, 128 * sizeof (XDOC)); xt->sdoc += 128; } for (i = 0; i < xm->sdoc; i++) { if (!xm->docs[i].doc) { xm->docs[i].doc = doc; xm->docs[i].refcnt = 1; xm->ndoc++; xt->idocs[xt->ndoc++] = i; *rowidp = (sqlite3_int64) (i + 1); doc = docToFree = 0; rc = SQLITE_OK; break; } } } else { /* UPDATE */ if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("UPDATE not supported"); } done: if (docToFree) { xmlFreeDoc(docToFree); } else if (doc && (n >= 0)) { sqlite3_mutex_enter(xm->mutex); xm->docs[n].refcnt -= 1; if (xm->docs[n].refcnt <= 0) { xm->docs[n].doc = 0; xm->docs[n].refcnt = 0; xm->ndoc--; xmlFreeDoc(doc); } sqlite3_mutex_leave(xm->mutex); } return rc; nomem: if (vtab->zErrMsg) { sqlite3_free(vtab->zErrMsg); } vtab->zErrMsg = sqlite3_mprintf("out of memory"); rc = SQLITE_NOMEM; goto done; } /** * Common XPath select function for virtual table. * @param ctx SQLite function context * @param conv conversion (0=string, 1=boolean, 2=number) * @param argc number of arguments * @param argv argument vector * * Examples: * * CREATE VIRTUAL TABLE X USING xpath();
* INSERT INTO X(XML) VALUES('xml-string ...');
* SELECT xpath_string(docid, '//book/title') FROM X;
* SELECT xpath_number(docid, '//book/price') FROM X;
* * The RHS of the xpath_* functions should be a constant string. */ static void xpath_vfunc_common(sqlite3_context *ctx, int conv, int argc, sqlite3_value **argv) { XTAB *xt = (XTAB *) sqlite3_user_data(ctx); XMOD *xm = xt->xm; XCSR *xc = xt->xc; XEXP *xp; xmlXPathContextPtr pctx = 0; xmlXPathObjectPtr pobj = 0; int n; char *p; if ((argc < 2) || !sqlite3_value_text(argv[1])) { sqlite3_result_error(ctx, "wrong arguments", -1); goto done; } if (!xc) { sqlite3_result_error(ctx, "not in virtual table context", -1); goto done; } if ((xc->pos < 0) || (xc->pos >= xt->ndoc)) { sqlite3_result_error(ctx, "cursor out of bounds", -1); goto done; } n = xt->idocs[xc->pos]; if (!xm->docs[n].doc) { sqlite3_result_error(ctx, "no docid", -1); goto done; } p = (char *) sqlite3_value_text(argv[1]); if (!p || !p[0]) { sqlite3_result_error(ctx, "no or empty XPath expression", -1); goto done; } xp = xc->first; while (xp) { if (!strcmp(p, xp->expr)) { break; } xp = xp->next; } if (!xp) { xp = sqlite3_malloc(sizeof (XEXP) + strlen(p)); if (!xp) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } xp->next = xp->prev = 0; strcpy(xp->expr, p); pctx = xmlXPathNewContext(xm->docs[n].doc); if (!pctx) { sqlite3_free(xp); sqlite3_result_error(ctx, "out of memory", -1); goto done; } pobj = xmlXPathEvalExpression((xmlChar *) xp->expr, pctx); if (!pobj) { sqlite3_free(xp); sqlite3_result_error(ctx, "bad XPath expression", -1); goto done; } xp->doc = xm->docs[n].doc; xp->pctx = pctx; xp->pobj = pobj; xp->parent = 0; xp->pos = -1; xp->conv = conv; pctx = 0; pobj = 0; xc->nexpr++; if (xc->first) { xc->last->next = xp; xp->prev = xc->last; xc->last = xp; } else { xc->first = xc->last = xp; } } else if (xm->docs[n].doc != xp->doc) { if (xp->pobj) { xmlXPathFreeObject(xp->pobj); xp->pobj = 0; } if (xp->pctx) { xmlXPathFreeContext(xp->pctx); xp->pctx = 0; } xp->doc = xm->docs[n].doc; xp->parent = 0; xp->pos = -1; if (xp->doc) { pctx = xmlXPathNewContext(xm->docs[n].doc); if (!pctx) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } pobj = xmlXPathEvalExpression((xmlChar *) xp->expr, pctx); if (!pobj) { sqlite3_result_error(ctx, "bad XPath expression", -1); goto done; } xp->pctx = pctx; xp->pobj = pobj; pctx = 0; pobj = 0; } } if (xp->pos < 0) { xp->pos = 0; } if (!xp->pobj) { xp->parent = 0; sqlite3_result_null(ctx); goto done; } if ((xp->pobj->type == XPATH_NODESET) && xp->pobj->nodesetval) { if ((xp->pos < 0) || (xp->pos >= xp->pobj->nodesetval->nodeNr)) { xp->parent = 0; sqlite3_result_null(ctx); } else { xmlNodePtr node = xp->pobj->nodesetval->nodeTab[xp->pos]; xmlBufferPtr buf = 0; xp->parent = node->parent; if (node) { switch (xp->conv) { case 1: p = (char *) xmlXPathCastNodeToString(node); n = xmlXPathCastStringToBoolean((xmlChar *) p); sqlite3_result_int(ctx, n); if (p) { xmlFree(p); } break; case 2: sqlite3_result_double(ctx, xmlXPathCastNodeToNumber(node)); break; case 3: buf = xmlBufferCreate(); if (!buf) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } xmlNodeDump(buf, xp->doc, node, 0, 0); sqlite3_result_text(ctx, (char *) xmlBufferContent(buf), xmlBufferLength(buf), SQLITE_TRANSIENT); xmlBufferFree(buf); break; default: p = (char *) xmlXPathCastNodeToString(node); sqlite3_result_text(ctx, p, -1, SQLITE_TRANSIENT); if (p) { xmlFree(p); } break; } } else { sqlite3_result_null(ctx); } } } else { xp->parent = 0; switch (xp->conv) { case 1: sqlite3_result_int(ctx, xmlXPathCastToBoolean(xp->pobj)); break; case 2: sqlite3_result_double(ctx, xmlXPathCastToNumber(xp->pobj)); break; default: p = (char *) xmlXPathCastToString(xp->pobj); sqlite3_result_text(ctx, p, -1, SQLITE_TRANSIENT); if (p) { xmlFree(p); } break; } } done: if (pobj) { xmlXPathFreeObject(pobj); } if (pctx) { xmlXPathFreeContext(pctx); } } /** * XPath select function returning string value from virtual table. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_vfunc_string(sqlite3_context *ctx, int argc, sqlite3_value **argv) { return xpath_vfunc_common(ctx, 0, argc, argv); } /** * XPath select function returning boolean value from virtual table. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_vfunc_boolean(sqlite3_context *ctx, int argc, sqlite3_value **argv) { return xpath_vfunc_common(ctx, 1, argc, argv); } /** * XPath select function returning number from virtual table. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_vfunc_number(sqlite3_context *ctx, int argc, sqlite3_value **argv) { return xpath_vfunc_common(ctx, 2, argc, argv); } /** * XPath select function returning XML from virtual table. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_vfunc_xml(sqlite3_context *ctx, int argc, sqlite3_value **argv) { return xpath_vfunc_common(ctx, 3, argc, argv); } /** * Find overloaded function on virtual table. * @param vtab virtual table * @param nargs number arguments * @param name function name * @param pfunc pointer to function (value return) * @param parg pointer to function's argument (value return) * @result 0 or 1 */ static int xpath_findfunc(sqlite3_vtab *vtab, int nargs, const char *name, void (**pfunc)(sqlite3_context *, int, sqlite3_value **), void **parg) { if (nargs != 2) { return 0; } if (!strcmp(name, "xpath_string")) { *pfunc = xpath_vfunc_string; *parg = vtab; return 1; } if (!strcmp(name, "xpath_boolean")) { *pfunc = xpath_vfunc_boolean; *parg = vtab; return 1; } if (!strcmp(name, "xpath_number")) { *pfunc = xpath_vfunc_number; *parg = vtab; return 1; } if (!strcmp(name, "xpath_xml")) { *pfunc = xpath_vfunc_xml; *parg = vtab; return 1; } return 0; } #if (SQLITE_VERSION_NUMBER > 3004000) /** * Rename virtual table. * @param newname new name for table * @result SQLite error code */ static int xpath_rename(sqlite3_vtab *vtab, const char *newname) { return SQLITE_OK; } #endif /** * SQLite module descriptor. */ static sqlite3_module xpath_mod = { 1, /* iVersion */ xpath_create, /* xCreate */ xpath_connect, /* xConnect */ xpath_bestindex, /* xBestIndex */ xpath_disconnect, /* xDisconnect */ xpath_destroy, /* xDestroy */ xpath_open, /* xOpen */ xpath_close, /* xClose */ xpath_filter, /* xFilter */ xpath_next, /* xNext */ xpath_eof, /* xEof */ xpath_column, /* xColumn */ xpath_rowid, /* xRowid */ xpath_update, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ xpath_findfunc, /* xFindFunction */ #if (SQLITE_VERSION_NUMBER > 3004000) xpath_rename, /* xRename */ #endif }; /** * Common XPath select function. * @param ctx SQLite function context * @param conv conversion (0=string, 1=boolean, 2=number) * @param argc number of arguments * @param argv argument vector * * Examples: * * SELECT xpath_string(<docid>, '//book/title');
* SELECT xpath_number(<xml-string>, '//book/price', * <options;>, <encoding>, * <base-url>);
* * The <docid> argument is the DOCID value of a row * in a virtual table. Otherwise a string containing an * XML document is expected. The optional arguments are
* <options> - parser options, see libxml's XML_PARSE_* defines
* <encoding> - encoding of the XML document
* <base-url> - base URL of the XML document
*/ static void xpath_func_common(sqlite3_context *ctx, int conv, int argc, sqlite3_value **argv) { xmlDocPtr doc = 0, docToFree = 0; xmlXPathContextPtr pctx = 0; xmlXPathObjectPtr pobj = 0; XMOD *xm = (XMOD *) sqlite3_user_data(ctx); int index = 0; char *p; if (argc < 2) { sqlite3_result_null(ctx); goto done; } if (sqlite3_value_type(argv[0]) == SQLITE_INTEGER) { index = sqlite3_value_int(argv[0]); if (!xm->mutex) { sqlite3_result_error(ctx, "init error", -1); goto done; } sqlite3_mutex_enter(xm->mutex); if ((index <= 0) || (index > xm->sdoc) || !xm->docs[index - 1].doc) { sqlite3_mutex_leave(xm->mutex); sqlite3_result_error(ctx, "invalid DOCID", -1); goto done; } doc = xm->docs[index - 1].doc; xm->docs[index - 1].refcnt += 1; sqlite3_mutex_leave(xm->mutex); } else { int opts = (XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NONET); char *enc = 0, *url = 0; p = (char *) sqlite3_value_blob(argv[0]); if (!p) { sqlite3_result_null(ctx); return; } if ((argc > 2) && (sqlite3_value_type(argv[2]) != SQLITE_NULL)) { opts = sqlite3_value_int(argv[2]); } if ((argc > 3) && (sqlite3_value_type(argv[3]) != SQLITE_NULL)) { enc = (char *) sqlite3_value_text(argv[3]); } if ((argc > 4) && (sqlite3_value_type(argv[4]) != SQLITE_NULL)) { url = (char *) sqlite3_value_text(argv[4]); } doc = xmlReadMemory(p, sqlite3_value_bytes(argv[0]), url ? url : "", enc, opts); docToFree = doc; if (!doc) { sqlite3_result_error(ctx, "read error", -1); goto done; } } p = (char *) sqlite3_value_text(argv[1]); if (!p) { sqlite3_result_null(ctx); goto done; } pctx = xmlXPathNewContext(doc); if (!pctx) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } pobj = xmlXPathEvalExpression((xmlChar *) p, pctx); if (!pobj) { sqlite3_result_error(ctx, "bad XPath expression", -1); goto done; } switch (conv) { case 1: sqlite3_result_int(ctx, xmlXPathCastToBoolean(pobj)); break; case 2: sqlite3_result_double(ctx, xmlXPathCastToNumber(pobj)); break; case 3: if ((pobj->type == XPATH_NODESET) && pobj->nodesetval && (pobj->nodesetval->nodeNr)) { xmlNodePtr node = pobj->nodesetval->nodeTab[0]; xmlBufferPtr buf = 0; buf = xmlBufferCreate(); if (!buf) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } xmlNodeDump(buf, doc, node, 0, 0); sqlite3_result_text(ctx, (char *) xmlBufferContent(buf), xmlBufferLength(buf), SQLITE_TRANSIENT); xmlBufferFree(buf); } else { sqlite3_result_null(ctx); } break; default: p = (char *) xmlXPathCastToString(pobj); sqlite3_result_text(ctx, p, -1, SQLITE_TRANSIENT); if (p) { xmlFree(p); } break; } done: if (pobj) { xmlXPathFreeObject(pobj); } if (pctx) { xmlXPathFreeContext(pctx); } if (docToFree) { xmlFreeDoc(docToFree); } else if (doc) { if (xm->mutex) { sqlite3_mutex_enter(xm->mutex); if (xm->docs && index) { xm->docs[index - 1].refcnt -= 1; if (xm->docs[index - 1].refcnt <= 0) { docToFree = doc; xm->docs[index - 1].refcnt = 0; xm->docs[index - 1].doc = 0; } } sqlite3_mutex_leave(xm->mutex); if (docToFree) { xmlFreeDoc(docToFree); } } } } /** * XPath select function returning string value. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_func_string(sqlite3_context *ctx, int argc, sqlite3_value **argv) { xpath_func_common(ctx, 0, argc, argv); } /** * XPath select function returning boolean value. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_func_boolean(sqlite3_context *ctx, int argc, sqlite3_value **argv) { xpath_func_common(ctx, 1, argc, argv); } /** * XPath select function returning number. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_func_number(sqlite3_context *ctx, int argc, sqlite3_value **argv) { xpath_func_common(ctx, 2, argc, argv); } /** * XPath select function returning XML. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector */ static void xpath_func_xml(sqlite3_context *ctx, int argc, sqlite3_value **argv) { xpath_func_common(ctx, 3, argc, argv); } /** * Function to dump XML document. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector * * Examples: * * SELECT xml_dump(<docid>, <encoding> <fmt>)
* * The <docid> argument is the DOCID value of a row * in a virtual table. The <encoding> argument is * the optional encoding (default UTF-8). The <fmt> * argument is the optional formatting flag for the * xmlDocDumpFormatMemoryEnc() libxml2 function. */ static void xpath_func_dump(sqlite3_context *ctx, int argc, sqlite3_value **argv) { XMOD *xm = (XMOD *) sqlite3_user_data(ctx); int index = 0, dump_len = 0, fmt = 1; xmlChar *dump = 0; char *enc = "utf-8"; if (argc < 1) { sqlite3_result_null(ctx); return; } index = sqlite3_value_int(argv[0]); if (argc > 1) { enc = (char *) sqlite3_value_text(argv[1]); if (!enc) { enc = "utf-8"; } } if (argc > 2) { fmt = sqlite3_value_int(argv[2]); } if (!xm->mutex) { sqlite3_result_error(ctx, "init error", -1); return; } sqlite3_mutex_enter(xm->mutex); if ((index <= 0) || (index > xm->sdoc) || !xm->docs[index - 1].doc) { sqlite3_mutex_leave(xm->mutex); sqlite3_result_error(ctx, "invalid DOCID", -1); return; } xmlDocDumpFormatMemoryEnc(xm->docs[index - 1].doc, &dump, &dump_len, enc, fmt); if (dump) { sqlite3_result_text(ctx, (char *) dump, dump_len, SQLITE_TRANSIENT); xmlFree(dump); } sqlite3_mutex_leave(xm->mutex); } #ifdef WITH_XSLT /** * Function to transform XML document using XSLT stylesheet. * @param ctx SQLite function context * @param argc number of arguments * @param argv argument vector * * Examples: * * SELECT xslt_transform(<docid>, <stylesheet>, ...)
* SELECT xslt_transform(<xml-string>, <stylesheet>, * <options;>, <encoding>, * <base-url>, ...);
* * The <docid> argument is the DOCID value of a row * in a virtual table. <stylesheet> is the stylesheet * to apply on that document. When the transformation succeeded, * the transformed document replaces the original document.
* In the second form an XML string is transformed with the * same parameters as in the xpath_string() SQLite function.
* The ellipsis optional arguments are the string parameters for * the XSLT transformation. */ static void xpath_func_transform(sqlite3_context *ctx, int argc, sqlite3_value **argv) { xmlDocPtr doc = 0, docToFree = 0, res = 0; xsltStylesheetPtr cur = 0; XMOD *xm = (XMOD *) sqlite3_user_data(ctx); int index = 0, nparams = 0, param0, i; char *p; const char **params = 0; if (argc < 2) { sqlite3_result_null(ctx); goto done; } if (sqlite3_value_type(argv[0]) == SQLITE_INTEGER) { index = sqlite3_value_int(argv[0]); if (!xm->mutex) { sqlite3_result_error(ctx, "init error", -1); goto done; } sqlite3_mutex_enter(xm->mutex); if ((index <= 0) || (index > xm->sdoc) || !xm->docs[index - 1].doc) { sqlite3_mutex_leave(xm->mutex); sqlite3_result_error(ctx, "invalid DOCID", -1); goto done; } doc = xm->docs[index - 1].doc; xm->docs[index - 1].refcnt += 1; sqlite3_mutex_leave(xm->mutex); param0 = 2; nparams = argc - 2; } else { int opts = (XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NONET); char *enc = 0, *url = 0; p = (char *) sqlite3_value_blob(argv[0]); if (!p) { sqlite3_result_null(ctx); return; } if ((argc > 2) && (sqlite3_value_type(argv[2]) != SQLITE_NULL)) { opts = sqlite3_value_int(argv[2]); } if ((argc > 3) && (sqlite3_value_type(argv[3]) != SQLITE_NULL)) { enc = (char *) sqlite3_value_text(argv[3]); } if ((argc > 4) && (sqlite3_value_type(argv[4]) != SQLITE_NULL)) { url = (char *) sqlite3_value_text(argv[4]); } doc = xmlReadMemory(p, sqlite3_value_bytes(argv[0]), url ? url : "", enc, opts); docToFree = doc; if (!doc) { sqlite3_result_error(ctx, "read error", -1); goto done; } param0 = 5; nparams = argc - 5; } p = (char *) sqlite3_value_text(argv[1]); if (!p) { sqlite3_result_null(ctx); goto done; } cur = xsltParseStylesheetFile((xmlChar *) p); if (!cur) { sqlite3_result_error(ctx, "read error on stylesheet", -1); goto done; } if (nparams <= 0) { nparams = 1; } else { nparams++; } params = sqlite3_malloc(nparams * sizeof (char *)); if (!params) { sqlite3_result_error(ctx, "out of memory", -1); goto done; } for (i = 0; i < (argc - param0); i++) { params[i] = (const char *) sqlite3_value_text(argv[i + param0]); if (!params[i]) { params[i] = ""; } } params[i] = 0; res = xsltApplyStylesheet(cur, doc, params); if (!res) { sqlite3_result_error(ctx, "transformation failed", -1); goto done; } if (docToFree) { xmlChar *str = 0; xmlFreeDoc(docToFree); docToFree = res; i = 0; xsltSaveResultToString(&str, &i, res, cur); if (str) { sqlite3_result_text(ctx, (char *) str, i, SQLITE_TRANSIENT); xmlFree(str); } else { sqlite3_result_null(ctx); } } done: if (params) { sqlite3_free(params); } if (cur) { xsltFreeStylesheet(cur); } if (docToFree) { xmlFreeDoc(docToFree); } else if (doc) { if (xm->mutex) { sqlite3_mutex_enter(xm->mutex); if (xm->docs && index) { docToFree = doc; xm->docs[index - 1].doc = 0; xmlFreeDoc(docToFree); docToFree = 0; xm->docs[index - 1].refcnt -= 1; xm->docs[index - 1].doc = res; if (xm->docs[index - 1].refcnt <= 0) { docToFree = res; xm->docs[index - 1].refcnt = 0; xm->docs[index - 1].doc = 0; } } sqlite3_mutex_leave(xm->mutex); if (docToFree) { xmlFreeDoc(docToFree); } } } } #endif /** * Module finalizer. * @param aux pointer to module data * @result SQLite error code */ static void xpath_fini(void *aux) { XMOD *xm = (XMOD *) aux; XDOC *docs; int i, n, cleanup = 0; sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); if (!mutex) { return; } sqlite3_mutex_enter(mutex); if (initialized) { xm->refcnt--; if (xm->refcnt <= 0) { xmod = 0; initialized = 0; cleanup = 1; } } else { cleanup = 1; } sqlite3_mutex_leave(mutex); if (cleanup) { sqlite3_mutex_enter(xm->mutex); mutex = xm->mutex; xm->mutex = 0; docs = xm->docs; n = xm->ndoc; xm->docs = 0; xm->sdoc = xm->ndoc = 0; sqlite3_mutex_leave(mutex); sqlite3_mutex_free(mutex); for (i = 0; i < n; i++) { if (docs->refcnt <= 0) { xmlFreeDoc(docs->doc); docs->doc = 0; } } sqlite3_free(docs); sqlite3_free(xm); } } /** * Module initializer creating SQLite module and functions. * @param db database pointer * @result SQLite error code */ #ifndef STANDALONE static #endif int xpath_init(sqlite3 *db) { XMOD *xm; int rc; sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); if (!mutex) { return SQLITE_NOMEM; } sqlite3_mutex_enter(mutex); if (!initialized) { xm = sqlite3_malloc(sizeof (XMOD)); if (!xm) { sqlite3_mutex_leave(mutex); return SQLITE_NOMEM; } xm->refcnt = 1; xm->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); if (!xm->mutex) { sqlite3_mutex_leave(mutex); sqlite3_free(xm); return SQLITE_NOMEM; } xm->sdoc = 128; xm->ndoc = 0; xm->docs = sqlite3_malloc(xm->sdoc * sizeof (XDOC)); if (!xm->docs) { sqlite3_mutex_leave(mutex); sqlite3_mutex_free(xm->mutex); sqlite3_free(xm); return SQLITE_NOMEM; } memset(xm->docs, 0, xm->sdoc * sizeof (XDOC)); xmod = xm; initialized = 1; } else { xm = xmod; xm->refcnt++; } sqlite3_mutex_leave(mutex); sqlite3_create_function(db, "xpath_string", -1, SQLITE_UTF8, (void *) xm, xpath_func_string, 0, 0); sqlite3_create_function(db, "xpath_boolean", -1, SQLITE_UTF8, (void *) xm, xpath_func_boolean, 0, 0); sqlite3_create_function(db, "xpath_number", -1, SQLITE_UTF8, (void *) xm, xpath_func_number, 0, 0); sqlite3_create_function(db, "xpath_xml", -1, SQLITE_UTF8, (void *) xm, xpath_func_xml, 0, 0); sqlite3_create_function(db, "xml_dump", -1, SQLITE_UTF8, (void *) xm, xpath_func_dump, 0, 0); #ifdef WITH_XSLT sqlite3_create_function(db, "xslt_transform", -1, SQLITE_UTF8, (void *) xm, xpath_func_transform, 0, 0); #endif rc = sqlite3_create_module_v2(db, "xpath", &xpath_mod, (void *) xm, xpath_fini); if (rc != SQLITE_OK) { sqlite3_create_function(db, "xpath_string", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); sqlite3_create_function(db, "xpath_boolean", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); sqlite3_create_function(db, "xpath_number", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); sqlite3_create_function(db, "xpath_xml", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); sqlite3_create_function(db, "xml_dump", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); #ifdef WITH_XSLT sqlite3_create_function(db, "xslt_transform", -1, SQLITE_UTF8, (void *) xm, 0, 0, 0); #endif xpath_fini(xm); } return rc; } #ifndef STANDALONE /** * Initializer for SQLite extension load mechanism. * @param db SQLite database pointer * @param errmsg pointer receiving error message * @param api SQLite API routines * @result SQLite error code */ int sqlite3_extension_init(sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) { SQLITE_EXTENSION_INIT2(api); return xpath_init(db); } #endif ./sqliteodbc-0.992/xpath.rc0100644000076400001440000000236412121314657014211 0ustar chwusers#include #include #include "resource3.h" #include "sqlite3.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_C,0,0 PRODUCTVERSION VERSION_C,0,0 FILEFLAGSMASK (3) FILEFLAGS (0) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE (0) BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "Christian Werner Software & Consulting\0" VALUE "FileDescription", "SQLite3 Extension XPath\0" VALUE "FileVersion", VERSION "\0" VALUE "InternalName", "XPATH\0" VALUE "LegalCopyright", "Public Domain\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "SQLITE3_MOD_XPATH.DLL\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "ODBC Driver for SQLite3 " SQLITE_VERSION "\0" VALUE "ProductVersion", VERSION "\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END ///////////////////////////////////////////////////////////////////////////// // // Icon // ico1 ICON "sqliteodbc.ico" ./sqliteodbc-0.992/sqlite+tcc.c0100644000076400001440000002311711573621241014750 0ustar chwusers/* ** 2006 August 22 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Experimental combination of SQLite 3.3.x and TinyCC 0.9.25 ** using the new SQLite loadable extension mechanism. ** ** This module creates an SQLite scalar function 'tcc_compile' ** which takes one argument which is a string made up of ** C source code to be on-the-fly compiled using TinyCC. ** The SQLite API is visible during compilation when ** 'sqlite3.h' is included. ** ** select tcc_compile(c_string, opt, ...) ** ** c_string string containing C code ** opt ... zero or more compile options as strings ** -Lpath add library path ** -lfile add library ** -Ipath add include path ** -ipath add system include path ** everything else starting with '-' is ignored ** everything else is taken as C source file to be ** compiled ** ** WARNING: TinyCC's libtcc.a must be created with necessary ** compiler switches to be linked into a shared object. This ** usually means that "-fPIC" must be added to compiler flags ** in TinyCC's Makefile for the targets libtcc.o/libtcc.a. */ #ifdef _WIN32 #include #endif #include #include "libtcc.h" #include "sqlite3ext.h" #define APIOFF(n) ((int) ((char *) &((sqlite3_api_routines *) 0)->n)) #define SYM(n) { "sqlite3_"#n, APIOFF(n) } #define SYM2(n, n2) { "sqlite3_"#n, APIOFF(n2) } #define SYM_END { 0, 0 } static struct { const char *name; /* TCC name for tcc_add_symbol() */ int offs; /* Offset into struct sqlite3_api_routines */ } symtab[] = { SYM(aggregate_context), SYM(aggregate_count), SYM(bind_blob), SYM(bind_double), SYM(bind_int), SYM(bind_int64), SYM(bind_null), SYM(bind_parameter_count), SYM(bind_parameter_index), SYM(bind_parameter_name), SYM(bind_text), SYM(bind_text16), SYM(bind_value), SYM(busy_handler), SYM(busy_timeout), SYM(changes), SYM(close), SYM(collation_needed), SYM(collation_needed16), SYM(column_blob), SYM(column_bytes), SYM(column_bytes16), SYM(column_count), SYM(column_database_name), SYM(column_database_name16), SYM(column_decltype), SYM(column_decltype16), SYM(column_double), SYM(column_int), SYM(column_int64), SYM(column_name), SYM(column_name16), SYM(column_origin_name), SYM(column_origin_name16), SYM(column_table_name), SYM(column_table_name16), SYM(column_text), SYM(column_text16), SYM(column_type), SYM(column_value), SYM(commit_hook), SYM(complete), SYM(complete16), SYM(create_collation), SYM(create_collation16), SYM(create_function), SYM(create_function16), SYM(create_module), SYM(data_count), SYM(db_handle), SYM(declare_vtab), SYM(enable_shared_cache), SYM(errcode), SYM(errmsg), SYM(errmsg16), SYM(exec), #if 0 SYM(expired), #endif SYM(finalize), SYM(free), SYM(free_table), SYM(get_autocommit), SYM(get_auxdata), SYM(get_table), #if 0 SYM(global_recover), #endif SYM2(interrupt, interruptx), SYM(last_insert_rowid), SYM(libversion), SYM(libversion_number), SYM(malloc), SYM(mprintf), SYM(open), SYM(open16), SYM(prepare), SYM(prepare16), SYM(profile), SYM(progress_handler), SYM(realloc), SYM(reset), SYM(result_blob), SYM(result_double), SYM(result_error), SYM(result_error16), SYM(result_int), SYM(result_int64), SYM(result_null), SYM(result_text), SYM(result_text16), SYM(result_text16be), SYM(result_text16le), SYM(result_value), SYM(rollback_hook), SYM(set_authorizer), SYM(set_auxdata), SYM(snprintf), SYM(step), SYM(table_column_metadata), SYM(thread_cleanup), SYM(total_changes), SYM(trace), #if 0 SYM(transfer_bindings), #endif SYM(update_hook), SYM(user_data), SYM(value_blob), SYM(value_bytes), SYM(value_bytes16), SYM(value_double), SYM(value_int), SYM(value_int64), SYM(value_numeric_type), SYM(value_text), SYM(value_text16), SYM(value_text16be), SYM(value_text16le), SYM(value_type), SYM(vmprintf), #if defined(HAVE_SQLITE3OVERLOADFUNCTION) && HAVE_SQLITE3OVERLOADFUNCTION SYM(overload_function), #endif #if defined(HAVE_SQLITE3PREPAREV2) && HAVE_SQLITE3PREPAREV2 SYM(prepare_v2), SYM(prepare16_v2), #endif #if defined(HAVE_SQLITE3CLEARBINDINGS) && HAVE_SQLITE3CLEARBINDINGS SYM(clear_bindings), #endif #if defined(HAVE_SQLITE3CREATEMODULEV2) && HAVE_SQLITE3CREATEMODULEV2 SYM(create_module_v2) #endif #if defined(HAVE_SQLITE3VFS) && HAVE_SQLITE3VFS SYM(bind_zeroblob), SYM(blob_bytes), SYM(blob_close), SYM(blob_open), SYM(blob_read), SYM(blob_write), SYM(create_collation_v2), SYM(memory_highwater), SYM(memory_used), SYM(mutex_alloc), SYM(mutex_enter), SYM(mutex_free), SYM(mutex_leave), SYM(mutex_enter), SYM(mutex_try), SYM(open_v2), SYM(release_memory), SYM(result_error_nomem), SYM(result_error_toobig), SYM(sleep), SYM(soft_heap_limit), SYM(vfs_find), SYM(vfs_register), SYM(vfs_unregister), SYM(file_control), SYM2(threadsafe, xthreadsafe), SYM(result_zeroblob), SYM(result_error_code), SYM(test_control), SYM(randomness), SYM(context_db_handle), SYM(extended_result_codes), SYM(limit), SYM(next_stmt), SYM(sql), SYM(status), SYM(backup_finish), SYM(backup_init), SYM(backup_pagecount), SYM(backup_remaining), SYM(backup_step), SYM(compileoption_get), SYM(compileoption_used), SYM(create_function_v2), SYM(db_config), SYM(db_mutes), SYM(db_status), SYM(extended_errcode), SYM(long), SYM(soft_heap_limit64), SYM(sourceid), SYM(stmt_status), SYM(strnicmp), SYM(unlock_notify), SYM(wal_autocheckpoint), SYM(wal_checkpoint), SYM(wal_hook), #endif SYM_END }; #ifdef _WIN32 /* TCC is not thread safe, provide a guard */ static CRITICAL_SECTION tcc_mutex; static HANDLE tcc_hinst; #endif /* Module pointer to SQLite3 API function vector. */ static SQLITE_EXTENSION_INIT1 static void tcc_compile( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ TCCState *t; int i; unsigned long val; void (*xInit)(void *); void *code; sqlite3 *db = sqlite3_user_data(ctx); if( argc<1 ){ sqlite3_result_error(ctx, "need at least one argument", -1); return; } #ifdef _WIN32 EnterCriticalSection(&tcc_mutex); #endif t = tcc_new(); if( !t ){ sqlite3_result_error(ctx, "no compile context", -1); #ifdef _WIN32 LeaveCriticalSection(&tcc_mutex); #endif return; } #ifdef _WIN32 tcc_set_lib_path_mod(t, tcc_hinst); #endif tcc_set_output_type(t, TCC_OUTPUT_MEMORY); for( i=1; ireg2 = asm_parse_reg(); } - skip(','); - op->shift = get_reg_shift(s1); + if (tok == ',') { + next(); + op->shift = get_reg_shift(s1); + } } skip(')'); } @@ -410,14 +421,15 @@ static void asm_opcode(TCCState *s1, int opcode) { const ASMInstr *pa; - int i, modrm_index, reg, v, op1, is_short_jmp; + int i, modrm_index, reg, v, op1, is_short_jmp, has_seg_prefix; int nb_ops, s, ss; - Operand ops[MAX_OPERANDS], *pop; + Operand ops[MAX_OPERANDS], *pop, seg_prefix; int op_type[3]; /* decoded op type */ /* get operands */ pop = ops; nb_ops = 0; + has_seg_prefix = 0; for(;;) { if (tok == ';' || tok == TOK_LINEFEED) break; @@ -425,6 +437,18 @@ error("incorrect number of operands"); } parse_operand(s1, pop); + if (tok == ':') { + if (pop->type != OP_SEG || has_seg_prefix) { + error("incorrect prefix"); + } + seg_prefix = *pop; + has_seg_prefix = 1; + next(); + parse_operand(s1, pop); + if (!(pop->type & OP_EA)) { + error("segment prefix must be followed by memory reference"); + } + } pop++; nb_ops++; if (tok != ',') @@ -538,6 +562,8 @@ /* now generates the operation */ if (pa->instr_type & OPC_FWAIT) g(0x9b); + if (has_seg_prefix) + g(segment_prefixes[seg_prefix.reg]); v = pa->opcode; if (v == 0x69 || v == 0x69) { diff -Nur tcc-0.9.23.orig/i386-gen.c tcc-0.9.23/i386-gen.c --- tcc-0.9.23.orig/i386-gen.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/i386-gen.c 2007-01-27 18:24:55.000000000 +0100 @@ -321,6 +321,7 @@ } static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX }; +static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX }; /* Generate function call. The function address is pushed first, then all the parameters in call order. This functions pops all the @@ -381,13 +382,21 @@ func_sym = vtop->type.ref; func_call = func_sym->r; /* fast call case */ - if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) { + if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) || + func_call == FUNC_FASTCALLW) { int fastcall_nb_regs; - fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1; + uint8_t *fastcall_regs_ptr; + if (func_call == FUNC_FASTCALLW) { + fastcall_regs_ptr = fastcallw_regs; + fastcall_nb_regs = 2; + } else { + fastcall_regs_ptr = fastcall_regs; + fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1; + } for(i = 0;i < fastcall_nb_regs; i++) { if (args_size <= 0) break; - o(0x58 + fastcall_regs[i]); /* pop r */ + o(0x58 + fastcall_regs_ptr[i]); /* pop r */ /* XXX: incorrect for struct/floats */ args_size -= 4; } @@ -409,6 +418,7 @@ { int addr, align, size, func_call, fastcall_nb_regs; int param_index, param_addr; + uint8_t *fastcall_regs_ptr; Sym *sym; CType *type; @@ -418,8 +428,13 @@ loc = 0; if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) { fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1; + fastcall_regs_ptr = fastcall_regs; + } else if (func_call == FUNC_FASTCALLW) { + fastcall_nb_regs = 2; + fastcall_regs_ptr = fastcallw_regs; } else { fastcall_nb_regs = 0; + fastcall_regs_ptr = NULL; } param_index = 0; @@ -449,7 +464,7 @@ /* save FASTCALL register */ loc -= 4; o(0x89); /* movl */ - gen_modrm(fastcall_regs[param_index], VT_LOCAL, NULL, loc); + gen_modrm(fastcall_regs_ptr[param_index], VT_LOCAL, NULL, loc); param_addr = loc; } else { param_addr = addr; @@ -585,7 +600,8 @@ gsym(vtop->c.i); } } else { - if (is_float(vtop->type.t)) { + if (is_float(vtop->type.t) || + (vtop->type.t & VT_BTYPE) == VT_LLONG) { vpushi(0); gen_op(TOK_NE); } diff -Nur tcc-0.9.23.orig/libtcc.h tcc-0.9.23/libtcc.h --- tcc-0.9.23.orig/libtcc.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/libtcc.h 2007-01-27 18:25:07.000000000 +0100 @@ -12,6 +12,11 @@ /* create a new TCC compilation context */ TCCState *tcc_new(void); +#ifdef _WIN32 +/* when libtcc linked to DLL, use this from DllMain() */ +void tcc_set_lib_path(void *module_handle); +#endif + /* free a TCC compilation context */ void tcc_delete(TCCState *s); @@ -60,6 +65,7 @@ #define TCC_OUTPUT_EXE 1 /* executable file */ #define TCC_OUTPUT_DLL 2 /* dynamic library */ #define TCC_OUTPUT_OBJ 3 /* object file */ +#define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */ int tcc_set_output_type(TCCState *s, int output_type); #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */ diff -Nur tcc-0.9.23.orig/Makefile tcc-0.9.23/Makefile --- tcc-0.9.23.orig/Makefile 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/Makefile 2007-01-27 18:23:59.000000000 +0100 @@ -3,7 +3,7 @@ # include config.mak -CFLAGS=-O2 -g -Wall +CFLAGS+=-g -Wall ifndef CONFIG_WIN32 LIBS=-ldl BCHECK_O=bcheck.o @@ -171,7 +171,7 @@ ifdef CONFIG_WIN32 # for windows, we must use TCC because we generate ELF objects LIBTCC1_OBJS=$(addprefix win32/lib/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o) libtcc1.o -LIBTCC1_CC=./tcc.exe -Bwin32 +LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE -DWIN32 else LIBTCC1_OBJS=libtcc1.o LIBTCC1_CC=$(CC) @@ -192,28 +192,28 @@ install: tcc_install libinstall tcc_install: $(PROGS) tcc.1 libtcc1.a $(BCHECK_O) tcc-doc.html tcc.1 - mkdir -p "$(bindir)" - $(INSTALL) -s -m755 $(PROGS) "$(bindir)" + mkdir -p "$(DESTDIR)$(bindir)" + $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)$(bindir)" ifndef CONFIG_WIN32 - mkdir -p "$(mandir)/man1" - $(INSTALL) tcc.1 "$(mandir)/man1" + mkdir -p "$(DESTDIR)$(mandir)/man1" + $(INSTALL) tcc.1 "$(DESTDIR)$(mandir)/man1" endif - mkdir -p "$(tccdir)" - mkdir -p "$(tccdir)/include" + mkdir -p "$(DESTDIR)$(tccdir)" + mkdir -p "$(DESTDIR)$(tccdir)/include" ifdef CONFIG_WIN32 - mkdir -p "$(tccdir)/lib" - $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib" - cp -r win32/include/. "$(tccdir)/include" - cp -r win32/examples/. "$(tccdir)/examples" + mkdir -p "$(DESTDIR)$(tccdir)/lib" + $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(DESTDIR)$(tccdir)/lib" + cp -r win32/include/. "$(DESTDIR)$(tccdir)/include" + cp -r win32/examples/. "$(DESTDIR)$(tccdir)/examples" else - $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(tccdir)" + $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(DESTDIR)$(tccdir)" $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ - tcclib.h "$(tccdir)/include" + tcclib.h "$(DESTDIR)$(tccdir)/include" endif - mkdir -p "$(docdir)" - $(INSTALL) -m644 tcc-doc.html "$(docdir)" + mkdir -p "$(DESTDIR)$(docdir)" + $(INSTALL) -m644 tcc-doc.html "$(DESTDIR)$(docdir)" ifdef CONFIG_WIN32 - $(INSTALL) -m644 win32/readme.txt "$(docdir)" + $(INSTALL) -m644 win32/readme.txt "$(DESTDIR)$(docdir)" endif clean: @@ -231,13 +231,13 @@ # libtcc generation and example libinstall: libtcc.a - mkdir -p "$(libdir)" - $(INSTALL) -m644 libtcc.a "$(libdir)" - mkdir -p "$(includedir)" - $(INSTALL) -m644 libtcc.h "$(includedir)" + mkdir -p "$(DESTDIR)$(libdir)" + $(INSTALL) -m644 libtcc.a "$(DESTDIR)$(libdir)" + mkdir -p "$(DESTDIR)$(includedir)" + $(INSTALL) -m644 libtcc.h "$(DESTDIR)$(includedir)" libtcc.o: tcc.c i386-gen.c Makefile - $(CC) $(CFLAGS) -DLIBTCC -c -o $@ $< + $(CC) $(CFLAGS) -DLIBTCC -DTCC_TARGET_PE -c -o $@ $< libtcc.a: libtcc.o $(AR) rcs $@ $^ diff -Nur tcc-0.9.23.orig/mingw-cross-build.sh tcc-0.9.23/mingw-cross-build.sh --- tcc-0.9.23.orig/mingw-cross-build.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.23/mingw-cross-build.sh 2007-01-27 18:45:27.000000000 +0100 @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Build script for cross compiling TCC for Win32 +# for integration into SQLite ODBC driver. +# Tested on Fedora Core 3 and 5. +# +# Cross toolchain and NSIS for Linux/i386 can be fetched from +# http://www.ch-werner.de/xtools/cross-mingw32-3.1-3.i386.rpm +# http://www.ch-werner.de/xtools/nsis-2.11-1.i386.rpm + +set -e + +rm -rf ../TCC +sh cross-configure.sh --prefix=/TCC --enable-mingw32 +sh cross-make.sh clean all +sh cross-make.sh DESTDIR=.. install +sh cross-make.sh distclean diff -Nur tcc-0.9.23.orig/stdarg.h tcc-0.9.23/stdarg.h --- tcc-0.9.23.orig/stdarg.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/stdarg.h 2007-01-27 18:25:17.000000000 +0100 @@ -6,6 +6,7 @@ /* only correct for i386 */ #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) #define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) +#define va_copy(dest, src) (dest) = (src) #define va_end(ap) /* fix a buggy dependency on GCC in libio.h */ diff -Nur tcc-0.9.23.orig/tccasm.c tcc-0.9.23/tccasm.c --- tcc-0.9.23.orig/tccasm.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tccasm.c 2007-01-27 18:26:24.000000000 +0100 @@ -916,21 +916,23 @@ nb_outputs = nb_operands; if (tok == ':') { next(); - /* input args */ - parse_asm_operands(operands, &nb_operands, 0); - if (tok == ':') { - /* clobber list */ - /* XXX: handle registers */ - next(); - for(;;) { - if (tok != TOK_STR) - expect("string constant"); - asm_clobber(clobber_regs, tokc.cstr->data); + if (tok != ')') { + /* input args */ + parse_asm_operands(operands, &nb_operands, 0); + if (tok == ':') { + /* clobber list */ + /* XXX: handle registers */ next(); - if (tok == ',') { + for(;;) { + if (tok != TOK_STR) + expect("string constant"); + asm_clobber(clobber_regs, tokc.cstr->data); next(); - } else { - break; + if (tok == ',') { + next(); + } else { + break; + } } } } diff -Nur tcc-0.9.23.orig/tcc.c tcc-0.9.23/tcc.c --- tcc-0.9.23.orig/tcc.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tcc.c 2007-01-28 22:28:55.000000000 +0100 @@ -44,10 +44,15 @@ #ifndef WIN32 #include #include +#include #endif #endif /* !CONFIG_TCCBOOT */ +#ifndef PAGESIZE +#define PAGESIZE 4096 +#endif + #include "elf.h" #include "stab.h" @@ -131,9 +136,15 @@ char str[1]; } TokenSym; +#ifdef TCC_TARGET_PE +typedef unsigned short nwchar_t; +#else +typedef int nwchar_t; +#endif + typedef struct CString { int size; /* size in bytes */ - void *data; /* either 'char *' or 'int *' */ + void *data; /* either 'char *' or 'nwchar_t *' */ int size_allocated; void *data_allocated; /* if non NULL, data has been malloced */ } CString; @@ -199,7 +210,7 @@ int sh_entsize; /* elf entry size */ unsigned long sh_size; /* section size (only used during output) */ unsigned long sh_addr; /* address at which the section is relocated */ - unsigned long sh_offset; /* address at which the section is relocated */ + unsigned long sh_offset; /* file offset */ int nb_hashed_syms; /* used to resize the hash table */ struct Section *link; /* link to another section */ struct Section *reloc; /* corresponding section for relocation, if any */ @@ -237,6 +248,7 @@ #define FUNC_FASTCALL1 2 /* first param in %eax */ #define FUNC_FASTCALL2 3 /* first parameters in %eax, %edx */ #define FUNC_FASTCALL3 4 /* first parameter in %eax, %edx, %ecx */ +#define FUNC_FASTCALLW 5 /* first parameter in %ecx, %edx */ /* field 'Sym.t' for macros */ #define MACRO_OBJ 0 /* object like macro */ @@ -491,6 +503,9 @@ /* pack stack */ int pack_stack[PACK_STACK_SIZE]; int *pack_stack_ptr; + + /* output file for preprocessing */ + FILE *outfile; }; /* The current value can be: */ @@ -704,11 +719,24 @@ #define TOK_UIDENT TOK_DEFINE #ifdef WIN32 + +#define PAGE_NOACCESS 0x0001 +#define PAGE_READONLY 0x0002 +#define PAGE_READWRITE 0x0004 +#define PAGE_WRITECOPY 0x0008 +#define PAGE_EXECUTE 0x0010 +#define PAGE_EXECUTE_READ 0x0020 +#define PAGE_EXECUTE_READWRITE 0x0040 +#define PAGE_EXECUTE_WRITECOPY 0x0080 +#define PAGE_GUARD 0x0100 +#define PAGE_NOCACHE 0x0200 + int __stdcall GetModuleFileNameA(void *, char *, int); void *__stdcall GetProcAddress(void *, const char *); void *__stdcall GetModuleHandleA(const char *); void *__stdcall LoadLibraryA(const char *); int __stdcall FreeConsole(void); +int __stdcall VirtualProtect(void *, int, int, int *); #define snprintf _snprintf #define vsnprintf _vsnprintf @@ -785,7 +813,9 @@ static int lvalue_type(int t); static int parse_btype(CType *type, AttributeDef *ad); static void type_decl(CType *type, AttributeDef *ad, int *v, int td); +static int compare_types(CType *type1, CType *type2, int unqualified); static int is_compatible_types(CType *type1, CType *type2); +static int is_compatible_parameter_types(CType *type1, CType *type2); int ieee_finite(double d); void error(const char *fmt, ...); @@ -826,6 +856,7 @@ #define AFF_PRINT_ERROR 0x0001 /* print error if file not found */ #define AFF_REFERENCED_DLL 0x0002 /* load a referenced dll from another dll */ +#define AFF_PREPROCESS 0x0004 /* preprocess file */ static int tcc_add_file_internal(TCCState *s, const char *filename, int flags); /* tcccoff.c */ @@ -833,7 +864,7 @@ /* tccpe.c */ void *resolve_sym(TCCState *s1, const char *sym, int type); -int pe_load_def_file(struct TCCState *s1, FILE *fp); +int pe_load_def_file(struct TCCState *s1, FILE *fp, int output_type); void pe_setup_paths(struct TCCState *s1, int *p_output_type, const char **p_outfile, char *first_file); unsigned long pe_add_runtime(struct TCCState *s1); int tcc_output_pe(struct TCCState *s1, const char *filename); @@ -1556,10 +1587,10 @@ static void cstr_wccat(CString *cstr, int ch) { int size; - size = cstr->size + sizeof(int); + size = cstr->size + sizeof(nwchar_t); if (size > cstr->size_allocated) cstr_realloc(cstr, size); - *(int *)(((unsigned char *)cstr->data) + size - sizeof(int)) = ch; + *(nwchar_t *)(((unsigned char *)cstr->data) + size - sizeof(nwchar_t)) = ch; cstr->size = size; } @@ -1649,9 +1680,9 @@ for(i=0;idata)[i]); } else { - len = (cstr->size / sizeof(int)) - 1; + len = (cstr->size / sizeof(nwchar_t)) - 1; for(i=0;idata)[i]); + add_char(&cstr_buf, ((nwchar_t *)cstr->data)[i]); } cstr_ccat(&cstr_buf, '\"'); cstr_ccat(&cstr_buf, '\0'); @@ -1662,6 +1693,8 @@ case TOK_GT: v = '>'; goto addv; + case TOK_DOTS: + return strcpy(p, "..."); case TOK_A_SHL: return strcpy(p, "<<="); case TOK_A_SAR: @@ -1820,6 +1853,7 @@ { int fd; BufferedFile *bf; + int i, len; fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) @@ -1834,6 +1868,10 @@ bf->buf_end = bf->buffer; bf->buffer[0] = CH_EOB; /* put eob symbol */ pstrcpy(bf->filename, sizeof(bf->filename), filename); + len = strlen(bf->filename); + for (i = 0; i < len; i++) + if (bf->filename[i] == '\\') + bf->filename[i] = '/'; bf->line_num = 1; bf->ifndef_macro = 0; bf->ifdef_stack_ptr = s1->ifdef_stack_ptr; @@ -3724,7 +3762,7 @@ if (!is_long) char_size = 1; else - char_size = sizeof(int); + char_size = sizeof(nwchar_t); if (tokcstr.size <= char_size) error("empty character constant"); if (tokcstr.size > 2 * char_size) @@ -3733,7 +3771,7 @@ tokc.i = *(int8_t *)tokcstr.data; tok = TOK_CCHAR; } else { - tokc.i = *(int *)tokcstr.data; + tokc.i = *(nwchar_t *)tokcstr.data; tok = TOK_LCHAR; } } else { @@ -4216,7 +4254,10 @@ /* if number, then create a number token */ /* NOTE: no need to allocate because tok_str_add2() does it */ - tokc.cstr = &cstr; + cstr_reset(&tokcstr); + tokcstr = cstr; + cstr_new(&cstr); + tokc.cstr = &tokcstr; } else { /* if identifier, we must do a test to validate we have a correct identifier */ @@ -4586,7 +4627,7 @@ #ifdef TCC_TARGET_I386 /* x86 specific: need to pop fp register ST0 if saved */ if (r == TREG_ST0) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(0) */ } #endif /* special long long case */ @@ -5010,7 +5051,7 @@ #ifdef TCC_TARGET_I386 /* for x86, we need to pop the FP stack */ if (v == TREG_ST0 && !nocode_wanted) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(0) */ } else #endif if (v == VT_JMP || v == VT_JMPI) { @@ -5735,6 +5776,10 @@ bits = 32 - bits; vpushi(bits); gen_op(TOK_SHL); + /* result must be signed or the SAR is converted to an SHL + This was not the case when "t" was a signed short + and the last value on the stack was an unsigned int */ + vtop->type.t &= ~VT_UNSIGNED; vpushi(bits); gen_op(TOK_SAR); } @@ -5822,6 +5867,7 @@ /* we handle char/short/etc... with generic code */ if (dbt != (VT_INT | VT_UNSIGNED) && dbt != (VT_LLONG | VT_UNSIGNED) && + dbt != VT_BOOL && dbt != VT_LLONG) dbt = VT_INT; if (c) { @@ -5837,6 +5883,10 @@ case VT_LDOUBLE: vtop->c.ui = (unsigned int)vtop->c.d; break; } break; + case VT_BOOL: + vpushi(0); + gen_op(TOK_NE); + break; default: /* int case */ switch(sbt) { @@ -5980,7 +6030,7 @@ while (s1 != NULL) { if (s2 == NULL) return 0; - if (!is_compatible_types(&s1->type, &s2->type)) + if (!is_compatible_parameter_types(&s1->type, &s2->type)) return 0; s1 = s1->next; s2 = s2->next; @@ -5990,17 +6040,22 @@ return 1; } -/* return true if type1 and type2 are exactly the same (including - qualifiers). +/* return true if type1 and type2 are the same. If unqualified is + true, qualifiers on the types are ignored. - enums are not checked as gcc __builtin_types_compatible_p () */ -static int is_compatible_types(CType *type1, CType *type2) +static int compare_types(CType *type1, CType *type2, int unqualified) { int bt1, t1, t2; t1 = type1->t & VT_TYPE; t2 = type2->t & VT_TYPE; + if (unqualified) { + /* strip qualifiers before comparing */ + t1 &= ~(VT_CONSTANT | VT_VOLATILE); + t2 &= ~(VT_CONSTANT | VT_VOLATILE); + } /* XXX: bitfields ? */ if (t1 != t2) return 0; @@ -6019,6 +6074,21 @@ } } +/* return true if type1 and type2 are exactly the same (including + qualifiers). +*/ +static int is_compatible_types(CType *type1, CType *type2) +{ + return compare_types(type1,type2,0); +} + +/* return true if type1 and type2 are the same (ignoring qualifiers). +*/ +static int is_compatible_parameter_types(CType *type1, CType *type2) +{ + return compare_types(type1,type2,1); +} + /* print a type. If 'varstr' is not NULL, then the variable is also printed in the type */ /* XXX: union */ @@ -6411,6 +6481,11 @@ ad->func_call = FUNC_FASTCALL1 + n - 1; skip(')'); break; + case TOK_FASTCALL1: + case TOK_FASTCALL2: + case TOK_FASTCALL3: + ad->func_call = FUNC_FASTCALLW; + break; #endif case TOK_DLLEXPORT: ad->dllexport = 1; @@ -6442,7 +6517,7 @@ { int a, v, size, align, maxalign, c, offset; int bit_size, bit_pos, bsize, bt, lbit_pos; - Sym *s, *ss, **ps; + Sym *s, *ss, *ass, **ps; AttributeDef ad; CType type1, btype; @@ -6513,7 +6588,9 @@ v = 0; type1 = btype; if (tok != ':') { - type_decl(&type1, &ad, &v, TYPE_DIRECT); + type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT); + if (v == 0 && (type1.t & VT_BTYPE) != VT_STRUCT) + expect("identifier"); if ((type1.t & VT_BTYPE) == VT_FUNC || (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE))) error("invalid type for '%s'", @@ -6576,7 +6653,7 @@ } else { bit_pos = 0; } - if (v) { + if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) { /* add new memory data only if starting bit field */ if (lbit_pos == 0) { @@ -6602,6 +6679,15 @@ } printf("\n"); #endif + } + if (v == 0 && (type1.t & VT_BTYPE) == VT_STRUCT) { + ass = type1.ref; + while ((ass = ass->next) != NULL) { + ss = sym_push(ass->v, &ass->type, 0, offset + ass->c); + *ps = ss; + ps = &ss->next; + } + } else if (v) { ss = sym_push(v | SYM_FIELD, &type1, 0, offset); *ps = ss; ps = &ss->next; @@ -6772,6 +6858,7 @@ t |= (s->type.t & ~VT_TYPEDEF); type->ref = s->type.ref; next(); + typespec_found = 1; break; } type_found = 1; @@ -6819,35 +6906,39 @@ l = 0; first = NULL; plast = &first; - while (tok != ')') { - /* read param name and compute offset */ - if (l != FUNC_OLD) { - if (!parse_btype(&pt, &ad1)) { - if (l) { - error("invalid type"); - } else { - l = FUNC_OLD; - goto old_proto; + if (tok != ')') { + for(;;) { + /* read param name and compute offset */ + if (l != FUNC_OLD) { + if (!parse_btype(&pt, &ad1)) { + if (l) { + error("invalid type"); + } else { + l = FUNC_OLD; + goto old_proto; + } } + l = FUNC_NEW; + if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')') + break; + type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); + if ((pt.t & VT_BTYPE) == VT_VOID) + error("parameter declared as void"); + } else { + old_proto: + n = tok; + if (n < TOK_UIDENT) + expect("identifier"); + pt.t = VT_INT; + next(); } - l = FUNC_NEW; - if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')') + convert_parameter_type(&pt); + s = sym_push(n | SYM_FIELD, &pt, 0, 0); + *plast = s; + plast = &s->next; + if (tok == ')') break; - type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); - if ((pt.t & VT_BTYPE) == VT_VOID) - error("parameter declared as void"); - } else { - old_proto: - n = tok; - pt.t = VT_INT; - next(); - } - convert_parameter_type(&pt); - s = sym_push(n | SYM_FIELD, &pt, 0, 0); - *plast = s; - plast = &s->next; - if (tok == ',') { - next(); + skip(','); if (l == FUNC_NEW && tok == TOK_DOTS) { l = FUNC_ELLIPSIS; next(); @@ -7129,7 +7220,11 @@ } break; case TOK_LSTR: +#ifdef TCC_TARGET_PE + t = VT_SHORT | VT_UNSIGNED; +#else t = VT_INT; +#endif goto str_init; case TOK_STR: /* string parsing */ @@ -7726,6 +7821,9 @@ } else if (bt1 == VT_PTR || bt2 == VT_PTR) { /* XXX: test pointer compatibility */ type = type1; + } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) { + /* XXX: test function pointer compatibility */ + type = type1; } else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) { /* XXX: test structure compatibility */ type = type1; @@ -8403,6 +8501,9 @@ no_oblock = 1; if ((first && tok != TOK_LSTR && tok != TOK_STR) || tok == '{') { + if (tok != '{') + error("character array initializer must be a literal," + " optionally enclosed in braces"); skip('{'); no_oblock = 0; } @@ -8410,7 +8511,11 @@ /* only parse strings here if correct type (otherwise: handle them as ((w)char *) expressions */ if ((tok == TOK_LSTR && +#ifdef TCC_TARGET_PE + (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)) || +#else (t1->t & VT_BTYPE) == VT_INT) || +#endif (tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) { while (tok == TOK_STR || tok == TOK_LSTR) { @@ -8422,7 +8527,7 @@ if (tok == TOK_STR) cstr_len = cstr->size; else - cstr_len = cstr->size / sizeof(int); + cstr_len = cstr->size / sizeof(nwchar_t); cstr_len--; nb = cstr_len; if (n >= 0 && nb > (n - array_length)) @@ -8440,7 +8545,7 @@ if (tok == TOK_STR) ch = ((unsigned char *)cstr->data)[i]; else - ch = ((int *)cstr->data)[i]; + ch = ((nwchar_t *)cstr->data)[i]; init_putv(t1, sec, c + (array_length + i) * size1, ch, EXPR_VAL); } @@ -8986,7 +9091,7 @@ #if 0 { char buf[500]; - type_to_str(buf, sizeof(buf), t, get_tok_str(v, NULL)); + type_to_str(buf, sizeof(buf), &type, get_tok_str(v, NULL)); printf("type = '%s'\n", buf); } #endif @@ -9001,7 +9106,7 @@ if (tok == '{') { if (l == VT_LOCAL) error("cannot use local functions"); - if (!(type.t & VT_FUNC)) + if ((type.t & VT_BTYPE) != VT_FUNC) expect("function definition"); /* reject abstract declarators in function definition */ @@ -9233,6 +9338,47 @@ return s1->nb_errors != 0 ? -1 : 0; } +/* Preprocess the current file */ +/* XXX: add line and file infos, add options to preserve spaces */ +static int tcc_preprocess(TCCState *s1) +{ + Sym *define_start; + int last_is_space; + + preprocess_init(s1); + + define_start = define_stack; + + ch = file->buf_ptr[0]; + tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; + parse_flags = PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_PREPROCESS | + PARSE_FLAG_LINEFEED; + last_is_space = 1; + next(); + for(;;) { + if (tok == TOK_EOF) + break; + if (!last_is_space) { + fputc(' ', s1->outfile); + } + fputs(get_tok_str(tok, &tokc), s1->outfile); + if (tok == TOK_LINEFEED) { + last_is_space = 1; + /* XXX: suppress that hack */ + parse_flags &= ~PARSE_FLAG_LINEFEED; + next(); + parse_flags |= PARSE_FLAG_LINEFEED; + } else { + last_is_space = 0; + next(); + } + } + + free_defines(define_start); + + return 0; +} + #ifdef LIBTCC int tcc_compile_string(TCCState *s, const char *str) { @@ -9615,6 +9761,30 @@ if (s->reloc) relocate_section(s1, s); } + + /* mark executable sections as executable in memory */ + for(i = 1; i < s1->nb_sections; i++) { + s = s1->sections[i]; + if ((s->sh_flags & (SHF_ALLOC | SHF_EXECINSTR)) == + (SHF_ALLOC | SHF_EXECINSTR)) { +#ifdef WIN32 + { + int old_protect; + VirtualProtect(s->data, s->data_offset, + PAGE_EXECUTE_READWRITE, &old_protect); + } +#else + { + unsigned long start, end; + start = (unsigned long)(s->data) & ~(PAGESIZE - 1); + end = (unsigned long)(s->data + s->data_offset); + end = (end + PAGESIZE - 1) & ~(PAGESIZE - 1); + mprotect((void *)start, end - start, + PROT_READ | PROT_WRITE | PROT_EXEC); + } +#endif + } + } return 0; } @@ -9728,7 +9898,14 @@ /* tiny C & gcc defines */ tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned int"); tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int"); +#ifdef TCC_TARGET_PE + tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short"); +#ifdef WIN32 + tcc_define_symbol(s, "_WIN32", NULL); +#endif +#else tcc_define_symbol(s, "__WCHAR_TYPE__", "int"); +#endif /* default library paths */ #ifdef TCC_TARGET_PE @@ -9870,7 +10047,9 @@ goto fail1; } - if (!ext || !strcmp(ext, "c")) { + if (flags & AFF_PREPROCESS) { + ret = tcc_preprocess(s1); + } else if (!ext || !strcmp(ext, "c")) { /* C file assumed */ ret = tcc_compile(s1); } else @@ -9885,7 +10064,7 @@ #endif #ifdef TCC_TARGET_PE if (!strcmp(ext, "def")) { - ret = pe_load_def_file(s1, fdopen(file->fd, "rb")); + ret = pe_load_def_file(s1, fdopen(file->fd, "rb"), s1->output_type); } else #endif { @@ -10157,8 +10336,6 @@ flag_name, value); } -#if !defined(LIBTCC) - /* extract the basename of a file */ static const char *tcc_basename(const char *name) { @@ -10175,6 +10352,26 @@ return p; } +#ifdef WIN32 +void tcc_set_lib_path(void *module_handle) +{ + static char path[1024]; + char *p, *d; + + path[0] = '\0'; + GetModuleFileNameA(module_handle, path, sizeof path); + p = d = strlwr(path); + while (*d) { + if (*d == '\\') *d = '/', p = d; + ++d; + } + *p = '\0'; + if (path[0]) tcc_lib_path = path; +} +#endif + +#if !defined(LIBTCC) + static int64_t getclock_us(void) { #ifdef WIN32 @@ -10190,7 +10387,7 @@ void help(void) { - printf("tcc version " TCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2005 Fabrice Bellard\n" + printf("tcc version " TCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n" "usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n" " [-Wwarn] [-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-static]\n" " [infile1 infile2...] [-run infile args...]\n" @@ -10206,6 +10403,7 @@ " -Wwarning set or reset (with 'no-' prefix) 'warning' (see man page)\n" " -w disable all warnings\n" "Preprocessor options:\n" + " -E preprocess only\n" " -Idir add include path 'dir'\n" " -Dsym[=val] define 'sym' with value 'val'\n" " -Usym undefine 'sym'\n" @@ -10264,6 +10462,7 @@ TCC_OPTION_v, TCC_OPTION_w, TCC_OPTION_pipe, + TCC_OPTION_E, }; static const TCCOption tcc_options[] = { @@ -10299,6 +10498,7 @@ { "v", TCC_OPTION_v, 0 }, { "w", TCC_OPTION_w, 0 }, { "pipe", TCC_OPTION_pipe, 0}, + { "E", TCC_OPTION_E, 0}, { NULL }, }; @@ -10527,6 +10727,9 @@ } } break; + case TCC_OPTION_E: + output_type = TCC_OUTPUT_PREPROCESS; + break; default: if (s->warn_unsupported) { unsupported_option: @@ -10550,22 +10753,8 @@ #ifdef WIN32 /* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */ - { - static char path[1024]; - char *p, *d; - - GetModuleFileNameA(NULL, path, sizeof path); - p = d = strlwr(path); - while (*d) - { - if (*d == '\\') *d = '/', p = d; - ++d; - } - *p = '\0'; - tcc_lib_path = path; - } + tcc_set_lib_path(NULL); #endif - s = tcc_new(); output_type = TCC_OUTPUT_EXE; outfile = NULL; @@ -10600,7 +10789,16 @@ error("cannot specify libraries with -c"); } - if (output_type != TCC_OUTPUT_MEMORY) { + + if (output_type == TCC_OUTPUT_PREPROCESS) { + if (!outfile) { + s->outfile = stdout; + } else { + s->outfile = fopen(outfile, "wb"); + if (!s->outfile) + error("could not open '%s", outfile); + } + } else if (output_type != TCC_OUTPUT_MEMORY) { if (!outfile) { /* compute default outfile name */ pstrcpy(objfilename, sizeof(objfilename) - 1, @@ -10635,13 +10833,18 @@ const char *filename; filename = files[i]; - if (filename[0] == '-') { - if (tcc_add_library(s, filename + 2) < 0) - error("cannot find %s", filename); - } else { - if (tcc_add_file(s, filename) < 0) { - ret = 1; - goto the_end; + if (output_type == TCC_OUTPUT_PREPROCESS) { + tcc_add_file_internal(s, filename, + AFF_PRINT_ERROR | AFF_PREPROCESS); + } else { + if (filename[0] == '-') { + if (tcc_add_library(s, filename + 2) < 0) + error("cannot find %s", filename); + } else { + if (tcc_add_file(s, filename) < 0) { + ret = 1; + goto the_end; + } } } } @@ -10662,7 +10865,11 @@ total_bytes / total_time / 1000000.0); } - if (s->output_type == TCC_OUTPUT_MEMORY) { + if (s->output_type == TCC_OUTPUT_PREPROCESS) { + if (outfile) + fclose(s->outfile); + ret = 0; + } else if (s->output_type == TCC_OUTPUT_MEMORY) { ret = tcc_run(s, argc - optind, argv + optind); } else #ifdef TCC_TARGET_PE diff -Nur tcc-0.9.23.orig/tccelf.c tcc-0.9.23/tccelf.c --- tcc-0.9.23.orig/tccelf.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tccelf.c 2007-01-27 18:26:13.000000000 +0100 @@ -2095,7 +2095,7 @@ { Elf32_Ehdr ehdr; Elf32_Shdr *shdr, *sh, *sh1; - int i, nb_syms, nb_dts, sym_bind, ret; + int i, j, nb_syms, nb_dts, sym_bind, ret; Elf32_Sym *sym, *dynsym; Elf32_Dyn *dt, *dynamic; unsigned char *dynstr; @@ -2184,8 +2184,8 @@ switch(dt->d_tag) { case DT_NEEDED: name = dynstr + dt->d_un.d_val; - for(i = 0; i < s1->nb_loaded_dlls; i++) { - dllref = s1->loaded_dlls[i]; + for(j = 0; j < s1->nb_loaded_dlls; j++) { + dllref = s1->loaded_dlls[j]; if (!strcmp(name, dllref->name)) goto already_loaded; } @@ -2277,13 +2277,49 @@ return c; } +static int ld_add_file_list(TCCState *s1, int as_needed) +{ + char filename[1024]; + int t, ret; + + t = ld_next(s1, filename, sizeof(filename)); + if (t != '(') + expect("("); + t = ld_next(s1, filename, sizeof(filename)); + for(;;) { + if (t == LD_TOK_EOF) { + error_noabort("unexpected end of file"); + return -1; + } else if (t == ')') { + break; + } else if (t != LD_TOK_NAME) { + error_noabort("filename expected"); + return -1; + } + if (!strcmp(filename, "AS_NEEDED")) { + ret = ld_add_file_list(s1, 1); + if (ret) + return ret; + } else { + /* TODO: Implement AS_NEEDED support. Ignore it for now */ + if (!as_needed) + tcc_add_file(s1, filename); + } + t = ld_next(s1, filename, sizeof(filename)); + if (t == ',') { + t = ld_next(s1, filename, sizeof(filename)); + } + } + return 0; +} + /* interpret a subset of GNU ldscripts to handle the dummy libc.so files */ static int tcc_load_ldscript(TCCState *s1) { char cmd[64]; char filename[1024]; - int t; + int t, ret; ch = file->buf_ptr[0]; ch = handle_eob(); @@ -2295,26 +2331,9 @@ return -1; if (!strcmp(cmd, "INPUT") || !strcmp(cmd, "GROUP")) { - t = ld_next(s1, cmd, sizeof(cmd)); - if (t != '(') - expect("("); - t = ld_next(s1, filename, sizeof(filename)); - for(;;) { - if (t == LD_TOK_EOF) { - error_noabort("unexpected end of file"); - return -1; - } else if (t == ')') { - break; - } else if (t != LD_TOK_NAME) { - error_noabort("filename expected"); - return -1; - } - tcc_add_file(s1, filename); - t = ld_next(s1, filename, sizeof(filename)); - if (t == ',') { - t = ld_next(s1, filename, sizeof(filename)); - } - } + ret = ld_add_file_list(s1, 0); + if (ret) + return ret; } else if (!strcmp(cmd, "OUTPUT_FORMAT") || !strcmp(cmd, "TARGET")) { /* ignore some commands */ diff -Nur tcc-0.9.23.orig/tccpe.c tcc-0.9.23/tccpe.c --- tcc-0.9.23.orig/tccpe.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tccpe.c 2007-01-27 18:25:59.000000000 +0100 @@ -1077,11 +1077,11 @@ } /* ------------------------------------------------------------- */ -int pe_load_def_file(TCCState * s1, FILE * fp) +int pe_load_def_file(TCCState * s1, FILE * fp, int output_type) { DLLReference *dllref; int f = 0, sym_index; - char *p, line[120], dllname[40]; + char *p, *q, line[120], dllname[40]; while (fgets(line, sizeof line, fp)) { p = strchr(line, 0); while (p > line && p[-1] <= ' ') @@ -1110,8 +1110,12 @@ case 2: dllref = - tcc_malloc(sizeof(DLLReference) + strlen(dllname)); - strcpy(dllref->name, dllname); + tcc_malloc(sizeof(DLLReference) + strlen(dllname) + 4); + dllref->name[0] = '\0'; + if (output_type != TCC_OUTPUT_MEMORY) + if (0 == strncmp(dllname, "lib", 3)) + strcpy(dllref->name, "lib"); + strcat(dllref->name, dllname); dllref->level = 0; dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref); @@ -1120,6 +1124,10 @@ default: /* tccpe needs to know from what dll it should import the sym */ + q = p; + while (*q && *q > ' ' && *q != '@') + ++q; + *q = 0; sym_index = add_elf_sym(s1->dynsymtab_section, 0, 0, ELF32_ST_INFO(STB_GLOBAL, STT_FUNC), diff -Nur tcc-0.9.23.orig/tcctest.c tcc-0.9.23/tcctest.c --- tcc-0.9.23.orig/tcctest.c 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tcctest.c 2007-01-27 18:25:48.000000000 +0100 @@ -441,14 +441,21 @@ typedef int *my_ptr; +typedef int mytype1; +typedef int mytype2; + void typedef_test() { my_ptr a; + mytype1 mytype2; int b; + a = &b; *a = 1234; printf("typedef:\n"); printf("a=%d\n", *a); + mytype2 = 2; + printf("mytype2=%d\n", mytype2); } void forward_test() @@ -1066,6 +1073,8 @@ int a; char c; char tab[10]; + unsigned b,d; + short s; printf("cast_test:\n"); a = 0xfffff; @@ -1088,7 +1097,15 @@ printf("%d\n", a); printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c)); - + + /* test cast from unsigned to signed short to int */ + b = 0xf000; + d = (short)b; + printf("((unsigned)(short)0x%08x) = 0x%08x\n", b, d); + b = 0xf0f0; + d = (char)b; + printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d); + /* test implicit int casting for array accesses */ c = 0; tab[1] = 2; @@ -1803,14 +1820,14 @@ goto l1; l2: a = 1 + ({ - __label__ l1, l2, l3; - goto l4; - l5: - printf("aa1\n"); + __label__ l1, l2, l3, l4; goto l1; + l4: + printf("aa1\n"); + goto l3; l2: printf("aa3\n"); - goto l3; + goto l4; l1: printf("aa2\n"); goto l2; @@ -1819,12 +1836,12 @@ }); printf("a=%d\n", a); return; - l1: + l4: printf("bb1\n"); goto l2; - l4: + l1: printf("bb2\n"); - goto l5; + goto l4; } /* inline assembler test */ diff -Nur tcc-0.9.23.orig/tcctok.h tcc-0.9.23/tcctok.h --- tcc-0.9.23.orig/tcctok.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/tcctok.h 2007-01-27 18:25:29.000000000 +0100 @@ -101,6 +101,9 @@ DEF(TOK_STDCALL1, "stdcall") DEF(TOK_STDCALL2, "__stdcall") DEF(TOK_STDCALL3, "__stdcall__") + DEF(TOK_FASTCALL1, "fastcall") + DEF(TOK_FASTCALL2, "__fastcall") + DEF(TOK_FASTCALL3, "__fastcall__") DEF(TOK_DLLEXPORT, "dllexport") DEF(TOK_NORETURN1, "noreturn") DEF(TOK_NORETURN2, "__noreturn__") diff -Nur tcc-0.9.23.orig/win32/include/winapi/basetsd.h tcc-0.9.23/win32/include/winapi/basetsd.h --- tcc-0.9.23.orig/win32/include/winapi/basetsd.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/win32/include/winapi/basetsd.h 2007-01-27 18:29:00.000000000 +0100 @@ -4,7 +4,7 @@ #pragma GCC system_header #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #ifndef __int64 #define __int64 long long #endif diff -Nur tcc-0.9.23.orig/win32/include/winapi/basetyps.h tcc-0.9.23/win32/include/winapi/basetyps.h --- tcc-0.9.23.orig/win32/include/winapi/basetyps.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/win32/include/winapi/basetyps.h 2007-01-27 18:29:08.000000000 +0100 @@ -124,7 +124,7 @@ #ifndef GUID_SECTION #define GUID_SECTION ".text" #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define GUID_SECT __attribute__ ((section (GUID_SECTION))) #else #define GUID_SECT diff -Nur tcc-0.9.23.orig/win32/include/winapi/wincon.h tcc-0.9.23/win32/include/winapi/wincon.h --- tcc-0.9.23.orig/win32/include/winapi/wincon.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/win32/include/winapi/wincon.h 2007-01-27 18:29:15.000000000 +0100 @@ -92,7 +92,7 @@ } uChar; DWORD dwControlKeyState; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) /* gcc's alignment is not what win32 expects */ PACKED #endif diff -Nur tcc-0.9.23.orig/win32/include/winapi/windef.h tcc-0.9.23/win32/include/winapi/windef.h --- tcc-0.9.23.orig/win32/include/winapi/windef.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/win32/include/winapi/windef.h 2007-01-27 18:29:33.000000000 +0100 @@ -49,7 +49,7 @@ #define OPTIONAL #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define PACKED __attribute__((packed)) #ifndef _stdcall #define _stdcall __attribute__((stdcall)) @@ -92,7 +92,7 @@ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_EXPORT __declspec(dllexport) -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define DECLSPEC_NORETURN __declspec(noreturn) #define DECLARE_STDCALL_P( type ) __stdcall type #elif defined(__WATCOMC__) diff -Nur tcc-0.9.23.orig/win32/include/winapi/winnt.h tcc-0.9.23/win32/include/winapi/winnt.h --- tcc-0.9.23.orig/win32/include/winapi/winnt.h 2005-06-18 00:09:15.000000000 +0200 +++ tcc-0.9.23/win32/include/winapi/winnt.h 2007-01-27 18:29:43.000000000 +0100 @@ -118,7 +118,7 @@ typedef DWORD LCID; typedef PDWORD PLCID; typedef WORD LANGID; -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define _HAVE_INT64 #define _INTEGRAL_MAX_BITS 64 #undef __int64 @@ -2612,7 +2612,7 @@ typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX; #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__TINYC__) PVOID GetCurrentFiber(void); PVOID GetFiberData(void); ./sqliteodbc-0.992/tcc-0.9.24.patch0100644000076400001440000035172511054174262015071 0ustar chwusersdiff -Nur tcc-0.9.24.orig/configure tcc-0.9.24/configure --- tcc-0.9.24.orig/configure 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/configure 2008-08-24 07:30:07.000000000 +0200 @@ -120,7 +120,7 @@ ;; --enable-gprof) gprof="yes" ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" + --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32msvc-" ;; --enable-cross) build_cross="yes" ;; diff -Nur tcc-0.9.24.orig/cross-configure.sh tcc-0.9.24/cross-configure.sh --- tcc-0.9.24.orig/cross-configure.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/cross-configure.sh 2008-08-24 07:30:07.000000000 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh + +CONFIG_SHELL=/bin/sh +export CONFIG_SHELL +PREFIX=/opt/mingw +TARGET=i386-mingw32msvc +PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" +export PATH +cache=cross-config.cache +sh configure --cache-file="$cache" \ + --target=$TARGET --host=$TARGET --build=i386-linux \ + "$@" +status=$? +rm -f "$cache" +exit $status diff -Nur tcc-0.9.24.orig/cross-make.sh tcc-0.9.24/cross-make.sh --- tcc-0.9.24.orig/cross-make.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/cross-make.sh 2008-08-24 07:30:07.000000000 +0200 @@ -0,0 +1,7 @@ +#!/bin/sh + +PREFIX=/opt/mingw +TARGET=i386-mingw32msvc +PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" +export PATH +exec make "$@" diff -Nur tcc-0.9.24.orig/libtcc.h tcc-0.9.24/libtcc.h --- tcc-0.9.24.orig/libtcc.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/libtcc.h 2008-08-24 07:30:07.000000000 +0200 @@ -12,6 +12,11 @@ /* create a new TCC compilation context */ TCCState *tcc_new(void); +#ifdef _WIN32 +/* when libtcc linked to DLL, use this from DllMain() */ +void tcc_set_lib_path(void *module_handle); +#endif + /* free a TCC compilation context */ void tcc_delete(TCCState *s); diff -Nur tcc-0.9.24.orig/Makefile tcc-0.9.24/Makefile --- tcc-0.9.24.orig/Makefile 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/Makefile 2008-08-24 07:30:07.000000000 +0200 @@ -179,7 +179,7 @@ ifdef CONFIG_WIN32 # for windows, we must use TCC because we generate ELF objects LIBTCC1_OBJS=$(addprefix win32/lib/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o) libtcc1.o -LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE +LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE -DWIN32 else LIBTCC1_OBJS=libtcc1.o LIBTCC1_CC=$(CC) @@ -203,28 +203,28 @@ install: tcc_install libinstall tcc_install: $(PROGS) tcc.1 libtcc1.a $(BCHECK_O) tcc-doc.html - mkdir -p "$(bindir)" - $(INSTALL) -s -m755 $(PROGS) "$(bindir)" + mkdir -p "$(DESTDIR)$(bindir)" + $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)$(bindir)" ifndef CONFIG_WIN32 - mkdir -p "$(mandir)/man1" - $(INSTALL) tcc.1 "$(mandir)/man1" + mkdir -p "$(DESTDIR)$(mandir)/man1" + $(INSTALL) tcc.1 "$(DESTDIR)$(mandir)/man1" endif - mkdir -p "$(tccdir)" - mkdir -p "$(tccdir)/include" + mkdir -p "$(DESTDIR)$(tccdir)" + mkdir -p "$(DESTDIR)$(tccdir)/include" ifdef CONFIG_WIN32 - mkdir -p "$(tccdir)/lib" - $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib" - cp -r win32/include/. "$(tccdir)/include" - cp -r win32/examples/. "$(tccdir)/examples" + mkdir -p "$(DESTDIR)$(tccdir)/lib" + $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(DESTDIR)$(tccdir)/lib" + cp -r win32/include/. "$(DESTDIR)$(tccdir)/include" + cp -r win32/examples/. "$(DESTDIR)$(tccdir)/examples" else - $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(tccdir)" + $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(DESTDIR)$(tccdir)" $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ - tcclib.h "$(tccdir)/include" + tcclib.h "$(DESTDIR)$(tccdir)/include" endif - mkdir -p "$(docdir)" - $(INSTALL) -m644 tcc-doc.html "$(docdir)" + mkdir -p "$(DESTDIR)$(docdir)" + $(INSTALL) -m644 tcc-doc.html "$(DESTDIR)$(docdir)" ifdef CONFIG_WIN32 - $(INSTALL) -m644 win32/readme.txt "$(docdir)" + $(INSTALL) -m644 win32/readme.txt "$(DESTDIR)$(docdir)" endif clean: @@ -242,10 +242,10 @@ # libtcc generation and example libinstall: libtcc.a - mkdir -p "$(libdir)" - $(INSTALL) -m644 libtcc.a "$(libdir)" - mkdir -p "$(includedir)" - $(INSTALL) -m644 libtcc.h "$(includedir)" + mkdir -p "$(DESTDIR)$(libdir)" + $(INSTALL) -m644 libtcc.a "$(DESTDIR)$(libdir)" + mkdir -p "$(DESTDIR)$(includedir)" + $(INSTALL) -m644 libtcc.h "$(DESTDIR)$(includedir)" libtcc.o: tcc.c i386-gen.c Makefile ifdef CONFIG_WIN32 diff -Nur tcc-0.9.24.orig/mingw-cross-build.sh tcc-0.9.24/mingw-cross-build.sh --- tcc-0.9.24.orig/mingw-cross-build.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/mingw-cross-build.sh 2008-08-24 07:30:07.000000000 +0200 @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Build script for cross compiling TCC for Win32 +# for integration into SQLite ODBC driver. +# Tested on Fedora Core 3 and 5. +# +# Cross toolchain and NSIS for Linux/i386 can be fetched from +# http://www.ch-werner.de/xtools/cross-mingw32-3.1-4.i386.rpm +# http://www.ch-werner.de/xtools/nsis-2.11-1.i386.rpm + +set -e + +rm -rf ../TCC +sh cross-configure.sh --prefix=/TCC --enable-mingw32 +sh cross-make.sh clean all +sh cross-make.sh DESTDIR=.. install +sh cross-make.sh distclean diff -Nur tcc-0.9.24.orig/tcc.c tcc-0.9.24/tcc.c --- tcc-0.9.24.orig/tcc.c 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/tcc.c 2008-08-24 07:30:07.000000000 +0200 @@ -1098,6 +1098,18 @@ *p = 0; return strdup(path); } + +void tcc_set_lib_path(void *module_handle) +{ + static char path[1024]; + char *p; + + path[0] = '\0'; + GetModuleFileNameA(module_handle, path, sizeof path); + p = tcc_basename(normalize_slashes(strlwr(path))); + if (p) *p = 0; + tcc_lib_path = path; +} #endif void set_pages_executable(void *ptr, unsigned long length) @@ -4757,7 +4769,7 @@ #ifdef TCC_TARGET_I386 /* x86 specific: need to pop fp register ST0 if saved */ if (r == TREG_ST0) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(0) */ } #endif /* special long long case */ @@ -5196,7 +5208,7 @@ #ifdef TCC_TARGET_I386 /* for x86, we need to pop the FP stack */ if (v == TREG_ST0 && !nocode_wanted) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(0) */ } else #endif if (v == VT_JMP || v == VT_JMPI) { diff -Nur tcc-0.9.24.orig/win32/include/odbcinst.h tcc-0.9.24/win32/include/odbcinst.h --- tcc-0.9.24.orig/win32/include/odbcinst.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/odbcinst.h 2007-07-22 16:04:55.000000000 +0200 @@ -0,0 +1,148 @@ +#ifndef _ODBCINST_H +#define _ODBCINST_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif +#ifndef ODBCVER +#define ODBCVER 0x0351 +#endif +#define INSTAPI __stdcall +#define ODBC_ADD_DSN 1 +#define ODBC_CONFIG_DSN 2 +#define ODBC_REMOVE_DSN 3 +#if (ODBCVER >= 0x0250) +#define ODBC_ADD_SYS_DSN 4 +#define ODBC_CONFIG_SYS_DSN 5 +#define ODBC_REMOVE_SYS_DSN 6 +#define ODBC_INSTALL_INQUIRY 1 +#define ODBC_INSTALL_COMPLETE 2 +#define ODBC_INSTALL_DRIVER 1 +#define ODBC_REMOVE_DRIVER 2 +#define ODBC_CONFIG_DRIVER 3 +#define ODBC_CONFIG_DRIVER_MAX 100 +#endif /* (ODBCVER >= 0x0250) */ +#if (ODBCVER >= 0x0300) +#define ODBC_REMOVE_DEFAULT_DSN 7 +#define ODBC_BOTH_DSN 0 +#define ODBC_USER_DSN 1 +#define ODBC_SYSTEM_DSN 2 +#define ODBC_ERROR_GENERAL_ERR 1 +#define ODBC_ERROR_INVALID_BUFF_LEN 2 +#define ODBC_ERROR_INVALID_HWND 3 +#define ODBC_ERROR_INVALID_STR 4 +#define ODBC_ERROR_INVALID_REQUEST_TYPE 5 +#define ODBC_ERROR_COMPONENT_NOT_FOUND 6 +#define ODBC_ERROR_INVALID_NAME 7 +#define ODBC_ERROR_INVALID_KEYWORD_VALUE 8 +#define ODBC_ERROR_INVALID_DSN 9 +#define ODBC_ERROR_INVALID_INF 10 +#define ODBC_ERROR_REQUEST_FAILED 11 +#define ODBC_ERROR_INVALID_PATH 12 +#define ODBC_ERROR_LOAD_LIB_FAILED 13 +#define ODBC_ERROR_INVALID_PARAM_SEQUENCE 14 +#define ODBC_ERROR_INVALID_LOG_FILE 15 +#define ODBC_ERROR_USER_CANCELED 16 +#define ODBC_ERROR_USAGE_UPDATE_FAILED 17 +#define ODBC_ERROR_CREATE_DSN_FAILED 18 +#define ODBC_ERROR_WRITING_SYSINFO_FAILED 19 +#define ODBC_ERROR_REMOVE_DSN_FAILED 20 +#define ODBC_ERROR_OUT_OF_MEM 21 +#define ODBC_ERROR_OUTPUT_STRING_TRUNCATED 22 +#endif /* ODBCVER >= 0x0300 */ + +#ifndef RC_INVOKED +BOOL INSTAPI ConfigDSN(HWND,WORD,LPCSTR,LPCSTR); +BOOL INSTAPI ConfigDSNW(HWND,WORD,LPCWSTR,LPCWSTR); +BOOL INSTAPI ConfigTranslator(HWND,DWORD*); +BOOL INSTAPI SQLConfigDataSource(HWND,WORD,LPCSTR,LPCSTR); +BOOL INSTAPI SQLConfigDataSourceW(HWND,WORD,LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLCreateDataSource(HWND,LPCSTR); +BOOL INSTAPI SQLCreateDataSourceW(HWND,LPCWSTR); +BOOL INSTAPI SQLGetAvailableDrivers(LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLGetAvailableDriversW(LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLGetInstalledDrivers(LPSTR,WORD,WORD*); +BOOL INSTAPI SQLGetInstalledDriversW(LPWSTR,WORD,WORD*); +int INSTAPI SQLGetPrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,int,LPCSTR); +int INSTAPI SQLGetPrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int,LPCWSTR); +BOOL INSTAPI SQLGetTranslator(HWND,LPSTR,WORD,WORD*,LPSTR,WORD,WORD*,DWORD*); +BOOL INSTAPI SQLGetTranslatorW(HWND,LPWSTR,WORD,WORD*,LPWSTR,WORD,WORD*,DWORD*); +BOOL INSTAPI SQLInstallDriver(LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverManager(LPSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverManagerW(LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallODBC(HWND,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLInstallODBCW(HWND,LPCWSTR,LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLManageDataSources(HWND); +BOOL INSTAPI SQLRemoveDefaultDataSource(void); +BOOL INSTAPI SQLRemoveDSNFromIni(LPCSTR); +BOOL INSTAPI SQLRemoveDSNFromIniW(LPCWSTR); +BOOL INSTAPI SQLValidDSN(LPCSTR); +BOOL INSTAPI SQLValidDSNW(LPCWSTR); +BOOL INSTAPI SQLWriteDSNToIni(LPCSTR,LPCSTR); +BOOL INSTAPI SQLWriteDSNToIniW(LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLWritePrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLWritePrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR); +#if(ODBCVER >= 0x0250) +BOOL INSTAPI ConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI ConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallTranslator(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallTranslatorW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLRemoveDriver(LPCSTR,BOOL,LPDWORD); +BOOL INSTAPI SQLRemoveDriverManager(LPDWORD); +BOOL INSTAPI SQLRemoveDriverW(LPCWSTR,BOOL,LPDWORD); +BOOL INSTAPI SQLRemoveTranslator(LPCSTR,LPDWORD); +BOOL INSTAPI SQLRemoveTranslatorW(LPCWSTR,LPDWORD); +#endif /* ODBCVER >= 0x0250 */ +#if (ODBCVER >= 0x0300) +BOOL INSTAPI SQLGetConfigMode(UWORD*); +BOOL INSTAPI SQLInstallDriverEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallDriverExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +SQLRETURN INSTAPI SQLInstallerError(WORD,DWORD*,LPSTR,WORD,WORD*); +SQLRETURN INSTAPI SQLInstallerErrorW(WORD,DWORD*,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallTranslatorEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallTranslatorExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +SQLRETURN INSTAPI SQLPostInstallerError(DWORD,LPCSTR); +SQLRETURN INSTAPI SQLPostInstallerErrorW(DWORD,LPCWSTR); +BOOL INSTAPI SQLReadFileDSN(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLReadFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLSetConfigMode(UWORD); +BOOL INSTAPI SQLWriteFileDSN(LPCSTR,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLWriteFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR); +#endif /* ODBCVER >= 0x0300 */ + +#if defined (UNICODE) && !defined (SQL_NOUNICODEMAP) +#define SQLConfigDataSource SQLConfigDataSourceW +#define SQLConfigDriver SQLConfigDriverW +#define SQLCreateDataSource SQLCreateDataSourceW +#define SQLGetAvailableDrivers SQLGetAvailableDriversW +#define SQLGetInstalledDrivers SQLGetInstalledDriversW +#define SQLGetPrivateProfileString SQLGetPrivateProfileStringW +#define SQLGetTranslator SQLGetTranslatorW +#define SQLInstallDriver SQLInstallDriverW +#define SQLInstallDriverEx SQLInstallDriverExW +#define SQLInstallDriverManager SQLInstallDriverManagerW +#define SQLInstallerError SQLInstallerErrorW +#define SQLInstallODBC SQLInstallODBCW +#define SQLInstallTranslator SQLInstallTranslatorW +#define SQLInstallTranslatorEx SQLInstallTranslatorExW +#define SQLPostInstallerError SQLPostInstallerErrorW +#define SQLReadFileDSN SQLReadFileDSNW +#define SQLRemoveDriver SQLRemoveDriverW +#define SQLRemoveDSNFromIni SQLRemoveDSNFromIniW +#define SQLRemoveTranslator SQLRemoveTranslatorW +#define SQLValidDSN SQLValidDSNW +#define SQLWriteDSNToIni SQLWriteDSNToIniW +#define SQLWriteFileDSN SQLWriteFileDSNW +#define SQLWritePrivateProfileString SQLWritePrivateProfileStringW +#endif /* UNICODE && !SQL_NOUNICODEMAP */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif /* _ODBCINST_H */ diff -Nur tcc-0.9.24.orig/win32/include/sqlext.h tcc-0.9.24/win32/include/sqlext.h --- tcc-0.9.24.orig/win32/include/sqlext.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/sqlext.h 2007-07-22 16:04:55.000000000 +0200 @@ -0,0 +1,1218 @@ +#ifndef _SQLEXT_H +#define _SQLEXT_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#include +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_SPEC_MAJOR 3 +#define SQL_SPEC_MINOR 51 +#define SQL_SPEC_STRING "03.51" +#define SQL_ACCESS_MODE 101 +#define SQL_ACTIVE_CONNECTIONS 0 +#define SQL_ACTIVE_STATEMENTS 1 +#define SQL_ADD 4 +#define SQL_ALL_EXCEPT_LIKE 2 +#define SQL_API_ALL_FUNCTIONS 0 +#define SQL_API_LOADBYORDINAL 199 +#define SQL_API_SQLBINDPARAMETER 72 +#define SQL_API_SQLBROWSECONNECT 55 +#define SQL_API_SQLCOLATTRIBUTES 6 +#define SQL_API_SQLCOLUMNPRIVILEGES 56 +#define SQL_API_SQLDESCRIBEPARAM 58 +#define SQL_API_SQLDRIVERCONNECT 41 +#define SQL_API_SQLDRIVERS 71 +#define SQL_API_SQLEXTENDEDFETCH 59 +#define SQL_API_SQLFOREIGNKEYS 60 +#define SQL_API_SQLMORERESULTS 61 +#define SQL_API_SQLNATIVESQL 62 +#define SQL_API_SQLNUMPARAMS 63 +#define SQL_API_SQLPARAMOPTIONS 64 +#define SQL_API_SQLPRIMARYKEYS 65 +#define SQL_API_SQLPROCEDURECOLUMNS 66 +#define SQL_API_SQLPROCEDURES 67 +#define SQL_API_SQLSETPOS 68 +#define SQL_API_SQLSETSCROLLOPTIONS 69 +#define SQL_API_SQLTABLEPRIVILEGES 70 +#define SQL_ASYNC_ENABLE 4 +#define SQL_ASYNC_ENABLE_DEFAULT SQL_ASYNC_ENABLE_OFF +#define SQL_ASYNC_ENABLE_OFF 0UL +#define SQL_ASYNC_ENABLE_ON 1UL +#define SQL_ATTR_CONNECTION_DEAD 1209 +#define SQL_ATTR_READONLY 0 +#define SQL_ATTR_READWRITE_UNKNOWN 2 +#define SQL_ATTR_WRITE 1 +#define SQL_AUTOCOMMIT 102 +#define SQL_AUTOCOMMIT_DEFAULT SQL_AUTOCOMMIT_ON +#define SQL_AUTOCOMMIT_OFF 0UL +#define SQL_AUTOCOMMIT_ON 1UL +#define SQL_BEST_ROWID 1 +#define SQL_BIGINT (-5) +#define SQL_BINARY (-2) +#define SQL_BIND_BY_COLUMN 0UL +#define SQL_BIND_TYPE 5 +#define SQL_BIND_TYPE_DEFAULT SQL_BIND_BY_COLUMN +#define SQL_BIT (-7) +#define SQL_BOOKMARK_PERSISTENCE 82 +#define SQL_BP_CLOSE 1 +#define SQL_BP_DELETE 2 +#define SQL_BP_DROP 4 +#define SQL_BP_OTHER_HSTMT 32 +#define SQL_BP_SCROLL 64 +#define SQL_BP_TRANSACTION 8 +#define SQL_BP_UPDATE 16 +#define SQL_C_BINARY SQL_BINARY +#define SQL_C_BIT SQL_BIT +#define SQL_C_BOOKMARK SQL_C_ULONG +#define SQL_C_CHAR SQL_CHAR +#define SQL_C_DATE SQL_DATE +#define SQL_C_DEFAULT 99 +#define SQL_C_DOUBLE SQL_DOUBLE +#define SQL_C_FLOAT SQL_REAL +#define SQL_C_LONG SQL_INTEGER +#define SQL_C_SHORT SQL_SMALLINT +#define SQL_C_SLONG (SQL_C_LONG+SQL_SIGNED_OFFSET) +#define SQL_C_SSHORT (SQL_C_SHORT+SQL_SIGNED_OFFSET) +#define SQL_C_STINYINT (SQL_TINYINT+SQL_SIGNED_OFFSET) +#define SQL_C_TIME SQL_TIME +#define SQL_C_TIMESTAMP SQL_TIMESTAMP +#define SQL_C_TINYINT SQL_TINYINT +#define SQL_C_ULONG (SQL_C_LONG+SQL_UNSIGNED_OFFSET) +#define SQL_C_USHORT (SQL_C_SHORT+SQL_UNSIGNED_OFFSET) +#define SQL_C_UTINYINT (SQL_TINYINT+SQL_UNSIGNED_OFFSET) +#define SQL_CASCADE 0 +#define SQL_CB_NON_NULL 1 +#define SQL_CB_NULL 0 +#define SQL_CC_CLOSE SQL_CB_CLOSE /* deprecated */ +#define SQL_CC_DELETE SQL_CB_DELETE /* deprecated */ +#define SQL_CC_PRESERVE SQL_CB_PRESERVE /* deprecated */ +#define SQL_CD_FALSE 0L +#define SQL_CD_TRUE 1L +#define SQL_CN_ANY 2 +#define SQL_CN_DIFFERENT 1 +#define SQL_CN_NONE 0 +#define SQL_COLATT_OPT_MAX SQL_COLUMN_LABEL +#define SQL_COLATT_OPT_MIN SQL_COLUMN_COUNT +#define SQL_COLUMN_ALIAS 87 +#define SQL_COLUMN_AUTO_INCREMENT 11 +#define SQL_COLUMN_CASE_SENSITIVE 12 +#define SQL_COLUMN_COUNT 0 +#define SQL_COLUMN_DISPLAY_SIZE 6 +#define SQL_COLUMN_LABEL 18 +#define SQL_COLUMN_LENGTH 3 +#define SQL_COLUMN_MONEY 9 +#define SQL_COLUMN_NAME 1 +#define SQL_COLUMN_NULLABLE 7 +#define SQL_COLUMN_OWNER_NAME 16 +#define SQL_COLUMN_PRECISION 4 +#define SQL_COLUMN_QUALIFIER_NAME 17 +#define SQL_COLUMN_SCALE 5 +#define SQL_COLUMN_SEARCHABLE 13 +#define SQL_COLUMN_TABLE_NAME 15 +#define SQL_COLUMN_TYPE 2 +#define SQL_COLUMN_TYPE_NAME 14 +#define SQL_COLUMN_UNSIGNED 8 +#define SQL_COLUMN_UPDATABLE 10 +#define SQL_CONCAT_NULL_BEHAVIOR 22 +#define SQL_CONCUR_DEFAULT SQL_CONCUR_READ_ONLY +#define SQL_CONCUR_LOCK 2 +#define SQL_CONCUR_READ_ONLY 1 +#define SQL_CONCUR_ROWVER 3 +#define SQL_CONCUR_TIMESTAMP SQL_CONCUR_ROWVER /* deprecated */ +#define SQL_CONCUR_VALUES 4 +#define SQL_CONCURRENCY 7 +#define SQL_CONVERT_BIGINT 53 +#define SQL_CONVERT_BINARY 54 +#define SQL_CONVERT_BIT 55 +#define SQL_CONVERT_CHAR 56 +#define SQL_CONVERT_DATE 57 +#define SQL_CONVERT_DECIMAL 58 +#define SQL_CONVERT_DOUBLE 59 +#define SQL_CONVERT_FLOAT 60 +#define SQL_CONVERT_FUNCTIONS 48 +#define SQL_CONVERT_INTEGER 61 +#define SQL_CONVERT_LONGVARBINARY 71 +#define SQL_CONVERT_LONGVARCHAR 62 +#define SQL_CONVERT_NUMERIC 63 +#define SQL_CONVERT_REAL 64 +#define SQL_CONVERT_SMALLINT 65 +#define SQL_CONVERT_TIME 66 +#define SQL_CONVERT_TIMESTAMP 67 +#define SQL_CONVERT_TINYINT 68 +#define SQL_CONVERT_VARBINARY 69 +#define SQL_CONVERT_VARCHAR 70 +#define SQL_CORRELATION_NAME 74 +#define SQL_CR_CLOSE SQL_CB_CLOSE /* deprecated */ +#define SQL_CR_DELETE SQL_CB_DELETE /* deprecated */ +#define SQL_CR_PRESERVE SQL_CB_PRESERVE /* deprecated */ +#define SQL_CUR_DEFAULT SQL_CUR_USE_DRIVER +#define SQL_CUR_USE_DRIVER 2UL +#define SQL_CUR_USE_IF_NEEDED 0UL +#define SQL_CUR_USE_ODBC 1UL +#define SQL_CURRENT_QUALIFIER 109 +#define SQL_CURSOR_DYNAMIC 2UL +#define SQL_CURSOR_FORWARD_ONLY 0UL +#define SQL_CURSOR_KEYSET_DRIVEN 1UL +#define SQL_CURSOR_ROLLBACK_BEHAVIOR 24 +#define SQL_CURSOR_STATIC 3UL +#define SQL_CURSOR_TYPE 6 +#define SQL_CURSOR_TYPE_DEFAULT SQL_CURSOR_FORWARD_ONLY +#define SQL_CV_CASCADED 0x00000004L +#define SQL_CV_CHECK_OPTION 0x00000002L +#define SQL_CV_CREATE_VIEW 0x00000001L +#define SQL_CV_LOCAL 0x00000008L +#define SQL_CVT_BIGINT 0x00004000L +#define SQL_CVT_BINARY 0x00000400L +#define SQL_CVT_BIT 0x00001000L +#define SQL_CVT_CHAR 0x00000001L +#define SQL_CVT_DATE 0x00008000L +#define SQL_CVT_DECIMAL 0x00000004L +#define SQL_CVT_DOUBLE 0x00000080L +#define SQL_CVT_FLOAT 0x00000020L +#define SQL_CVT_INTEGER 0x00000008L +#define SQL_CVT_LONGVARBINARY 0x00040000L +#define SQL_CVT_LONGVARCHAR 0x00000200L +#define SQL_CVT_NUMERIC 0x00000002L +#define SQL_CVT_REAL 0x00000040L +#define SQL_CVT_SMALLINT 0x00000010L +#define SQL_CVT_TIME 0x00010000L +#define SQL_CVT_TIMESTAMP 0x00020000L +#define SQL_CVT_TINYINT 0x00002000L +#define SQL_CVT_VARBINARY 0x00000800L +#define SQL_CVT_VARCHAR 0x00000100L +#define SQL_DATABASE_NAME 16 /* deprecated */ +#define SQL_DATE 9 +#define SQL_DEFAULT_PARAM (-5) +#define SQL_DELETE 3 +#define SQL_DRIVER_COMPLETE 1 +#define SQL_DRIVER_COMPLETE_REQUIRED 3 +#define SQL_DRIVER_HDBC 3 +#define SQL_DRIVER_HENV 4 +#define SQL_DRIVER_HLIB 76 +#define SQL_DRIVER_HSTMT 5 +#define SQL_DRIVER_NAME 6 +#define SQL_DRIVER_NOPROMPT 0 +#define SQL_DRIVER_ODBC_VER 77 +#define SQL_DRIVER_PROMPT 2 +#define SQL_DRIVER_VER 7 +#define SQL_DTC_ENLIST_EXPENSIVE 1 +#define SQL_DTC_TRANSITION_COST 1750 +#define SQL_DTC_UNENLIST_EXPENSIVE 2 +#define SQL_ENSURE 1 +#define SQL_ENTIRE_ROWSET 0 +#define SQL_EXPRESSIONS_IN_ORDERBY 27 +#define SQL_FD_FETCH_BOOKMARK 128 +#define SQL_FD_FETCH_PREV SQL_FD_FETCH_PRIOR /* deprecated */ +#define SQL_FD_FETCH_RESUME 64 +#define SQL_FETCH_BOOKMARK 8 +#define SQL_FETCH_PREV SQL_FETCH_PRIOR /* deprecated */ +#define SQL_FETCH_RESUME 7 /* deprecated */ +#define SQL_FILE_CATALOG SQL_FILE_QUALIFIER +#define SQL_FILE_NOT_SUPPORTED 0x0000 +#define SQL_FILE_QUALIFIER 0x0002 +#define SQL_FILE_TABLE 0x0001 +#define SQL_FILE_USAGE 84 +#define SQL_FN_CVT_CONVERT 0x00000001L +#define SQL_FN_NUM_ABS 0x00000001L +#define SQL_FN_NUM_ACOS 0x00000002L +#define SQL_FN_NUM_ASIN 0x00000004L +#define SQL_FN_NUM_ATAN 0x00000008L +#define SQL_FN_NUM_ATAN2 0x00000010L +#define SQL_FN_NUM_CEILING 0x00000020L +#define SQL_FN_NUM_COS 0x00000040L +#define SQL_FN_NUM_COT 0x00000080L +#define SQL_FN_NUM_DEGREES 0x00040000L +#define SQL_FN_NUM_EXP 0x00000100L +#define SQL_FN_NUM_FLOOR 0x00000200L +#define SQL_FN_NUM_LOG 0x00000400L +#define SQL_FN_NUM_LOG10 0x00080000L +#define SQL_FN_NUM_MOD 0x00000800L +#define SQL_FN_NUM_PI 0x00010000L +#define SQL_FN_NUM_POWER 0x00100000L +#define SQL_FN_NUM_RADIANS 0x00200000L +#define SQL_FN_NUM_RAND 0x00020000L +#define SQL_FN_NUM_ROUND 0x00400000L +#define SQL_FN_NUM_SIGN 0x00001000L +#define SQL_FN_NUM_SIN 0x00002000L +#define SQL_FN_NUM_SQRT 0x00004000L +#define SQL_FN_NUM_TAN 0x00008000L +#define SQL_FN_NUM_TRUNCATE 0x00800000L +#define SQL_FN_STR_ASCII 0x00002000L +#define SQL_FN_STR_CHAR 0x00004000L +#define SQL_FN_STR_CONCAT 0x00000001L +#define SQL_FN_STR_DIFFERENCE 0x00008000L +#define SQL_FN_STR_INSERT 0x00000002L +#define SQL_FN_STR_LCASE 0x00000040L +#define SQL_FN_STR_LEFT 0x00000004L +#define SQL_FN_STR_LENGTH 0x00000010L +#define SQL_FN_STR_LOCATE 0x00000020L +#define SQL_FN_STR_LOCATE_2 0x00010000L +#define SQL_FN_STR_LTRIM 0x00000008L +#define SQL_FN_STR_REPEAT 0x00000080L +#define SQL_FN_STR_REPLACE 0x00000100L +#define SQL_FN_STR_RIGHT 0x00000200L +#define SQL_FN_STR_RTRIM 0x00000400L +#define SQL_FN_STR_SOUNDEX 0x00020000L +#define SQL_FN_STR_SPACE 0x00040000L +#define SQL_FN_STR_SUBSTRING 0x00000800L +#define SQL_FN_STR_UCASE 0x00001000L +#define SQL_FN_SYS_DBNAME 0x00000002L +#define SQL_FN_SYS_IFNULL 0x00000004L +#define SQL_FN_SYS_USERNAME 0x00000001L +#define SQL_FN_TD_CURDATE 0x00000002L +#define SQL_FN_TD_CURTIME 0x00000200L +#define SQL_FN_TD_DAYNAME 0x00008000L +#define SQL_FN_TD_DAYOFMONTH 0x00000004L +#define SQL_FN_TD_DAYOFWEEK 0x00000008L +#define SQL_FN_TD_DAYOFYEAR 0x00000010L +#define SQL_FN_TD_HOUR 0x00000400L +#define SQL_FN_TD_MINUTE 0x00000800L +#define SQL_FN_TD_MONTH 0x00000020L +#define SQL_FN_TD_MONTHNAME 0x00010000L +#define SQL_FN_TD_NOW 0x00000001L +#define SQL_FN_TD_QUARTER 0x00000040L +#define SQL_FN_TD_SECOND 0x00001000L +#define SQL_FN_TD_TIMESTAMPADD 0x00002000L +#define SQL_FN_TD_TIMESTAMPDIFF 0x00004000L +#define SQL_FN_TD_WEEK 0x00000080L +#define SQL_FN_TD_YEAR 0x00000100L +#define SQL_FN_TSI_DAY 0x00000010L +#define SQL_FN_TSI_FRAC_SECOND 0x00000001L +#define SQL_FN_TSI_HOUR 0x00000008L +#define SQL_FN_TSI_MINUTE 0x00000004L +#define SQL_FN_TSI_MONTH 0x00000040L +#define SQL_FN_TSI_QUARTER 0x00000080L +#define SQL_FN_TSI_SECOND 0x00000002L +#define SQL_FN_TSI_WEEK 0x00000020L +#define SQL_FN_TSI_YEAR 0x00000100L +#define SQL_GB_GROUP_BY_CONTAINS_SELECT 2 +#define SQL_GB_GROUP_BY_EQUALS_SELECT 1 +#define SQL_GB_NO_RELATION 3 +#define SQL_GB_NOT_SUPPORTED 0 +#define SQL_GD_BLOCK 4 +#define SQL_GD_BOUND 8 +#define SQL_GET_BOOKMARK 13 +#define SQL_GROUP_BY 88 +#define SQL_IGNORE (-6) +#define SQL_INFO_FIRST 0 +#define SQL_KEYSET_SIZE 8 +#define SQL_KEYSET_SIZE_DEFAULT 0UL +#define SQL_KEYWORDS 89 +#define SQL_LCK_EXCLUSIVE 2 +#define SQL_LCK_NO_CHANGE 1 +#define SQL_LCK_UNLOCK 4 +#define SQL_LEN_BINARY_ATTR(length) (-(length)+SQL_LEN_BINARY_ATTR_OFFSET) +#define SQL_LEN_BINARY_ATTR_OFFSET (-100) +#define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET) +#define SQL_LEN_DATA_AT_EXEC_OFFSET (-100) +#define SQL_LIKE_ESCAPE_CLAUSE 113 +#define SQL_LIKE_ONLY 1 +#define SQL_LOCK_EXCLUSIVE 1 +#define SQL_LOCK_NO_CHANGE 0 +#define SQL_LOCK_TYPES 78 +#define SQL_LOCK_UNLOCK 2 +#define SQL_LOGIN_TIMEOUT 103 +#define SQL_LOGIN_TIMEOUT_DEFAULT 15UL +#define SQL_LONGVARBINARY (-4) +#define SQL_LONGVARCHAR (-1) +#define SQL_MAX_BINARY_LITERAL_LEN 112 +#define SQL_MAX_CHAR_LITERAL_LEN 108 +#define SQL_MAX_DSN_LENGTH 32 +#define SQL_MAX_LENGTH 3 +#define SQL_MAX_LENGTH_DEFAULT 0UL +#define SQL_MAX_OPTION_STRING_LENGTH 256 +#define SQL_MAX_OWNER_NAME_LEN 32 +#define SQL_MAX_PROCEDURE_NAME_LEN 33 +#define SQL_MAX_QUALIFIER_NAME_LEN 34 +#define SQL_MAX_ROW_SIZE_INCLUDES_LONG 103 +#define SQL_MAX_ROWS 1 +#define SQL_MAX_ROWS_DEFAULT 0UL +#define SQL_MODE_DEFAULT SQL_MODE_READ_WRITE +#define SQL_MODE_READ_ONLY 1UL +#define SQL_MODE_READ_WRITE 0UL +#define SQL_MULT_RESULT_SETS 36 +#define SQL_MULTIPLE_ACTIVE_TXN 37 +#define SQL_NC_END 0x0004 +#define SQL_NC_START 0x0002 +#define SQL_NEED_LONG_DATA_LEN 111 +#define SQL_NNC_NON_NULL 0x0001 +#define SQL_NNC_NULL 0x0000 +#define SQL_NO_TOTAL (-4) +#define SQL_NON_NULLABLE_COLUMNS 75 +#define SQL_NOSCAN 2 +#define SQL_NOSCAN_DEFAULT SQL_NOSCAN_OFF +#define SQL_NOSCAN_OFF 0UL +#define SQL_NOSCAN_ON 1UL +#define SQL_NUMERIC_FUNCTIONS 49 +#define SQL_OAC_LEVEL1 0x0001 +#define SQL_OAC_LEVEL2 0x0002 +#define SQL_OAC_NONE 0x0000 +#define SQL_ODBC_API_CONFORMANCE 9 +#define SQL_ODBC_CURSORS 110 +#define SQL_ODBC_SAG_CLI_CONFORMANCE 12 +#define SQL_ODBC_SQL_CONFORMANCE 15 +#define SQL_ODBC_SQL_OPT_IEF 73 +#define SQL_ODBC_VER 10 +#define SQL_OPT_TRACE 104 +#define SQL_OPT_TRACE_DEFAULT SQL_OPT_TRACE_OFF +#define SQL_OPT_TRACE_FILE_DEFAULT "\\SQL.LOG" +#define SQL_OPT_TRACE_OFF 0UL +#define SQL_OPT_TRACE_ON 1UL +#define SQL_OPT_TRACEFILE 105 +#define SQL_OSC_CORE 1 +#define SQL_OSC_EXTENDED 2 +#define SQL_OSC_MINIMUM 0 +#define SQL_OSCC_COMPLIANT 1 +#define SQL_OSCC_NOT_COMPLIANT 0 +#define SQL_OU_DML_STATEMENTS 1 +#define SQL_OU_INDEX_DEFINITION 8 +#define SQL_OU_PRIVILEGE_DEFINITION 16 +#define SQL_OU_PROCEDURE_INVOCATION 2 +#define SQL_OU_TABLE_DEFINITION 4 +#define SQL_OUTER_JOINS 38 +#define SQL_OWNER_TERM 39 +#define SQL_OWNER_USAGE 91 +#define SQL_PACKET_SIZE 112 +#define SQL_PARAM_INPUT 1 +#define SQL_PARAM_INPUT_OUTPUT 2 +#define SQL_PARAM_OUTPUT 4 +#define SQL_PARAM_TYPE_DEFAULT SQL_PARAM_INPUT_OUTPUT +#define SQL_PARAM_TYPE_UNKNOWN 0 +#define SQL_PC_NOT_PSEUDO 1 +#define SQL_POS_ADD 16 +#define SQL_POS_DELETE 8 +#define SQL_POS_OPERATIONS 79 +#define SQL_POS_POSITION 1 +#define SQL_POS_REFRESH 2 +#define SQL_POS_UPDATE 4 +#define SQL_POSITION 0 +#define SQL_POSITIONED_STATEMENTS 80 +#define SQL_PRED_SEARCHABLE SQL_SEARCHABLE +#define SQL_PROCEDURE_TERM 40 +#define SQL_PROCEDURES 21 +#define SQL_PS_POSITIONED_DELETE 1 +#define SQL_PS_POSITIONED_UPDATE 2 +#define SQL_PS_SELECT_FOR_UPDATE 4 +#define SQL_PT_FUNCTION 2 +#define SQL_PT_PROCEDURE 1 +#define SQL_PT_UNKNOWN 0 +#define SQL_QL_END 0x0002 +#define SQL_QL_START 0x0001 +#define SQL_QU_DML_STATEMENTS 1 +#define SQL_QU_INDEX_DEFINITION 8 +#define SQL_QU_PRIVILEGE_DEFINITION 16 +#define SQL_QU_PROCEDURE_INVOCATION 2 +#define SQL_QU_TABLE_DEFINITION 4 +#define SQL_QUALIFIER_LOCATION 114 +#define SQL_QUALIFIER_NAME_SEPARATOR 41 +#define SQL_QUALIFIER_TERM 42 +#define SQL_QUALIFIER_USAGE 92 +#define SQL_QUERY_TIMEOUT 0 +#define SQL_QUERY_TIMEOUT_DEFAULT 0UL +#define SQL_QUICK 0 +#define SQL_QUIET_MODE 111 +#define SQL_QUOTED_IDENTIFIER_CASE 93 +#define SQL_RD_DEFAULT SQL_RD_ON +#define SQL_RD_OFF 0UL +#define SQL_RD_ON 1UL +#define SQL_REFRESH 1 +#define SQL_RESTRICT 1 +#define SQL_RESULT_COL 3 +#define SQL_RETRIEVE_DATA 11 +#define SQL_RETURN_VALUE 5 +#define SQL_ROW_ADDED 4 +#define SQL_ROW_DELETED 1 +#define SQL_ROW_ERROR 5 +#define SQL_ROW_NOROW 3 +#define SQL_ROW_NUMBER 14 +#define SQL_ROW_SUCCESS 0 +#define SQL_ROW_UPDATED 2 +#define SQL_ROW_UPDATES 11 +#define SQL_ROWSET_SIZE 9 +#define SQL_ROWSET_SIZE_DEFAULT 1UL +#define SQL_ROWVER 2 +#define SQL_SC_NON_UNIQUE 0UL +#define SQL_SC_TRY_UNIQUE 1UL +#define SQL_SC_UNIQUE 2UL +#define SQL_SCCO_OPT_TIMESTAMP SQL_SCCO_OPT_ROWVER /* deprecated */ +#define SQL_SCROLL_DYNAMIC (-2L) /* deprecated */ +#define SQL_SCROLL_FORWARD_ONLY 0L /* deprecated */ +#define SQL_SCROLL_KEYSET_DRIVEN (-1L) /* deprecated */ +#define SQL_SCROLL_OPTIONS 44 +#define SQL_SCROLL_STATIC (-3L) /* deprecated */ +#define SQL_SEARCHABLE 3 +#define SQL_SET_NULL 2 +#define SQL_SETPARAM_VALUE_MAX (-1L) +#define SQL_SETPOS_MAX_LOCK_VALUE SQL_LOCK_UNLOCK +#define SQL_SETPOS_MAX_OPTION_VALUE SQL_ADD +#define SQL_SIGNED_OFFSET (-20) +#define SQL_SIMULATE_CURSOR 10 +#define SQL_SO_DYNAMIC 4 +#define SQL_SO_FORWARD_ONLY 1 +#define SQL_SO_KEYSET_DRIVEN 2 +#define SQL_SO_MIXED 8 +#define SQL_SO_STATIC 16 +#define SQL_SQ_COMPARISON 1 +#define SQL_SQ_CORRELATED_SUBQUERIES 16 +#define SQL_SQ_EXISTS 2 +#define SQL_SQ_IN 4 +#define SQL_SQ_QUANTIFIED 8 +#define SQL_SQLSTATE_SIZE 5 +#define SQL_SS_ADDITIONS 1 +#define SQL_SS_DELETIONS 2 +#define SQL_SS_UPDATES 4 +#define SQL_STATIC_SENSITIVITY 83 +#define SQL_STRING_FUNCTIONS 50 +#define SQL_SUBQUERIES 95 +#define SQL_SYSTEM_FUNCTIONS 51 +#define SQL_TABLE_STAT 0 +#define SQL_TABLE_TERM 45 +#define SQL_TIME 10 +#define SQL_TIMEDATE_ADD_INTERVALS 109 +#define SQL_TIMEDATE_DIFF_INTERVALS 110 +#define SQL_TIMEDATE_FUNCTIONS 52 +#define SQL_TIMESTAMP 11 +#define SQL_TINYINT (-6) +#define SQL_TRANSLATE_DLL 106 +#define SQL_TRANSLATE_OPTION 107 +#define SQL_TXN_ISOLATION 108 +#define SQL_TXN_VERSIONING 16 +#define SQL_TYPE_NULL 0 +#define SQL_U_UNION 1 +#define SQL_U_UNION_ALL 2 +#define SQL_UB_DEFAULT SQL_UB_OFF +#define SQL_UB_OFF 0UL +#define SQL_UB_ON 01UL +#define SQL_UNION 96 +#define SQL_UNSEARCHABLE 0 +#define SQL_UNSIGNED_OFFSET (-22) +#define SQL_UPDATE 2 +#define SQL_USE_BOOKMARKS 12 +#define SQL_VARBINARY (-3) +#define SQL_POSITION_TO(s,r) SQLSetPos(s,r,SQL_POSITION,SQL_LOCK_NO_CHANGE) +#define SQL_LOCK_RECORD(s,r,l) SQLSetPos(s,r,SQL_POSITION,l) +#define SQL_REFRESH_RECORD(s,r,l) SQLSetPos(s,r,SQL_REFRESH,l) +#define SQL_UPDATE_RECORD(s,r) SQLSetPos(s,r,SQL_UPDATE,SQL_LOCK_NO_CHANGE) +#define SQL_DELETE_RECORD(s,r) SQLSetPos(s,r,SQL_DELETE,SQL_LOCK_NO_CHANGE) +#define SQL_ADD_RECORD(s,r) SQLSetPos(s,r,SQL_ADD,SQL_LOCK_NO_CHANGE) + +#if (ODBCVER < 0x0300) +#define SQL_CONNECT_OPT_DRVR_START 1000 +#define SQL_CONN_OPT_MAX SQL_PACKET_SIZE +#define SQL_CONN_OPT_MIN SQL_ACCESS_MODE +#define SQL_STMT_OPT_MAX SQL_ROW_NUMBER +#define SQL_STMT_OPT_MIN SQL_QUERY_TIMEOUT +#define SQL_TYPE_DRIVER_START SQL_INTERVAL_YEAR +#define SQL_TYPE_DRIVER_END SQL_UNICODE_LONGVARCHAR +#define SQL_TYPE_MIN SQL_BIT +#define SQL_TYPE_MAX SQL_VARCHAR +#endif + +#if (ODBCVER < 0x0300) +#define SQL_NO_DATA_FOUND 100 +#define SQL_INTERVAL_YEAR (-80) +#define SQL_INTERVAL_MONTH (-81) +#define SQL_INTERVAL_YEAR_TO_MONTH (-82) +#define SQL_INTERVAL_DAY (-83) +#define SQL_INTERVAL_HOUR (-84) +#define SQL_INTERVAL_MINUTE (-85) +#define SQL_INTERVAL_SECOND (-86) +#define SQL_INTERVAL_DAY_TO_HOUR (-87) +#define SQL_INTERVAL_DAY_TO_MINUTE (-88) +#define SQL_INTERVAL_DAY_TO_SECOND (-89) +#define SQL_INTERVAL_HOUR_TO_MINUTE (-90) +#define SQL_INTERVAL_HOUR_TO_SECOND (-91) +#define SQL_INTERVAL_MINUTE_TO_SECOND (-92) +#else +#define SQL_NO_DATA_FOUND SQL_NO_DATA +#define SQL_CODE_YEAR 1 +#define SQL_CODE_MONTH 2 +#define SQL_CODE_DAY 3 +#define SQL_CODE_HOUR 4 +#define SQL_CODE_MINUTE 5 +#define SQL_CODE_SECOND 6 +#define SQL_CODE_YEAR_TO_MONTH 7 +#define SQL_CODE_DAY_TO_HOUR 8 +#define SQL_CODE_DAY_TO_MINUTE 9 +#define SQL_CODE_DAY_TO_SECOND 10 +#define SQL_CODE_HOUR_TO_MINUTE 11 +#define SQL_CODE_HOUR_TO_SECOND 12 +#define SQL_CODE_MINUTE_TO_SECOND 13 +#define SQL_INTERVAL_YEAR (100 + SQL_CODE_YEAR) +#define SQL_INTERVAL_MONTH (100 + SQL_CODE_MONTH) +#define SQL_INTERVAL_DAY (100 + SQL_CODE_DAY) +#define SQL_INTERVAL_HOUR (100 + SQL_CODE_HOUR) +#define SQL_INTERVAL_MINUTE (100 + SQL_CODE_MINUTE) +#define SQL_INTERVAL_SECOND (100 + SQL_CODE_SECOND) +#define SQL_INTERVAL_YEAR_TO_MONTH (100 + SQL_CODE_YEAR_TO_MONTH) +#define SQL_INTERVAL_DAY_TO_HOUR (100 + SQL_CODE_DAY_TO_HOUR) +#define SQL_INTERVAL_DAY_TO_MINUTE (100 + SQL_CODE_DAY_TO_MINUTE) +#define SQL_INTERVAL_DAY_TO_SECOND (100 + SQL_CODE_DAY_TO_SECOND) +#define SQL_INTERVAL_HOUR_TO_MINUTE (100 + SQL_CODE_HOUR_TO_MINUTE) +#define SQL_INTERVAL_HOUR_TO_SECOND (100 + SQL_CODE_HOUR_TO_SECOND) +#define SQL_INTERVAL_MINUTE_TO_SECOND (100 + SQL_CODE_MINUTE_TO_SECOND) +#endif + +#if (ODBCVER <= 0x0300) +#define SQL_UNICODE (-95) +#define SQL_UNICODE_VARCHAR (-96) +#define SQL_UNICODE_LONGVARCHAR (-97) +#define SQL_UNICODE_CHAR SQL_UNICODE +#else +#define SQL_UNICODE SQL_WCHAR +#define SQL_UNICODE_VARCHAR SQL_WVARCHAR +#define SQL_UNICODE_LONGVARCHAR SQL_WLONGVARCHAR +#define SQL_UNICODE_CHAR SQL_WCHAR +#endif + +#if (ODBCVER >= 0x0201) && (ODBCVER < 0x0300) +#define SQL_OJ_CAPABILITIES 65003 +#endif /* ODBCVER < 0x0300 */ + +#if (ODBCVER >= 0x0250) +#define SQL_NO_ACTION 3 +#define SQL_SET_DEFAULT 4 +#endif /* ODBCVER >= 0x0250 */ + +#if (ODBCVER >= 0x0300) +#define SQL_ACTIVE_ENVIRONMENTS 116 +#define SQL_AD_ADD_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_AD_ADD_DOMAIN_CONSTRAINT 0x00000002L +#define SQL_AD_ADD_DOMAIN_DEFAULT 0x00000008L +#define SQL_AD_CONSTRAINT_NAME_DEFINITION 0x00000001L +#define SQL_AD_DROP_DOMAIN_CONSTRAINT 0x00000004L +#define SQL_AD_DROP_DOMAIN_DEFAULT 0x00000010L +#define SQL_AF_ALL 0x00000040L +#define SQL_AF_AVG 0x00000001L +#define SQL_AF_COUNT 0x00000002L +#define SQL_AF_DISTINCT 0x00000020L +#define SQL_AF_MAX 0x00000004L +#define SQL_AF_MIN 0x00000008L +#define SQL_AF_SUM 0x00000010L +#define SQL_AGGREGATE_FUNCTIONS 169 +#define SQL_ALL_CATALOGS "%" +#define SQL_ALL_SCHEMAS "%" +#define SQL_ALL_TABLE_TYPES "%" +#define SQL_ALTER_DOMAIN 117 +#define SQL_AM_CONNECTION 1 +#define SQL_AM_NONE 0 +#define SQL_AM_STATEMENT 2 +#define SQL_API_ODBC3_ALL_FUNCTIONS 999 +#define SQL_API_ODBC3_ALL_FUNCTIONS_SIZE 250 +#define SQL_API_SQLALLOCHANDLESTD 73 +#define SQL_API_SQLBULKOPERATIONS 24 +#define SQL_ASYNC_MODE 10021 +#define SQL_AT_ADD_COLUMN_COLLATION 0x00000080L +#define SQL_AT_ADD_COLUMN_DEFAULT 0x00000040L +#define SQL_AT_ADD_COLUMN_SINGLE 0x00000020L +#define SQL_AT_ADD_TABLE_CONSTRAINT 0x00001000L +#define SQL_AT_CONSTRAINT_DEFERRABLE 0x00040000L +#define SQL_AT_CONSTRAINT_INITIALLY_DEFERRED 0x00010000L +#define SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE 0x00020000L +#define SQL_AT_CONSTRAINT_NAME_DEFINITION 0x00008000L +#define SQL_AT_CONSTRAINT_NON_DEFERRABLE 0x00080000L +#define SQL_AT_DROP_COLUMN_CASCADE 0x00000400L +#define SQL_AT_DROP_COLUMN_DEFAULT 0x00000200L +#define SQL_AT_DROP_COLUMN_RESTRICT 0x00000800L +#define SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE 0x00002000L +#define SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT 0x00004000L +#define SQL_AT_SET_COLUMN_DEFAULT 0x00000100L +#define SQL_ATTR_ACCESS_MODE SQL_ACCESS_MODE +#define SQL_ATTR_ASYNC_ENABLE 4 +#define SQL_ATTR_AUTOCOMMIT SQL_AUTOCOMMIT +#define SQL_ATTR_CONCURRENCY SQL_CONCURRENCY +#define SQL_ATTR_CONNECTION_POOLING 201 +#define SQL_ATTR_CONNECTION_TIMEOUT 113 +#define SQL_ATTR_CP_MATCH 202 +#define SQL_ATTR_CURRENT_CATALOG SQL_CURRENT_QUALIFIER +#define SQL_ATTR_CURSOR_TYPE SQL_CURSOR_TYPE +#define SQL_ATTR_DISCONNECT_BEHAVIOR 114 +#define SQL_ATTR_ENABLE_AUTO_IPD 15 +#define SQL_ATTR_ENLIST_IN_DTC 1207 +#define SQL_ATTR_ENLIST_IN_XA 1208 +#define SQL_ATTR_FETCH_BOOKMARK_PTR 16 +#define SQL_ATTR_KEYSET_SIZE SQL_KEYSET_SIZE +#define SQL_ATTR_LOGIN_TIMEOUT SQL_LOGIN_TIMEOUT +#define SQL_ATTR_MAX_LENGTH SQL_MAX_LENGTH +#define SQL_ATTR_MAX_ROWS SQL_MAX_ROWS +#define SQL_ATTR_NOSCAN SQL_NOSCAN +#define SQL_ATTR_ODBC_CURSORS SQL_ODBC_CURSORS +#define SQL_ATTR_ODBC_VERSION 200 +#define SQL_ATTR_PACKET_SIZE SQL_PACKET_SIZE +#define SQL_ATTR_PARAM_BIND_OFFSET_PTR 17 +#define SQL_ATTR_PARAM_BIND_TYPE 18 +#define SQL_ATTR_PARAM_OPERATION_PTR 19 +#define SQL_ATTR_PARAM_STATUS_PTR 20 +#define SQL_ATTR_PARAMS_PROCESSED_PTR 21 +#define SQL_ATTR_PARAMSET_SIZE 22 +#define SQL_ATTR_QUERY_TIMEOUT SQL_QUERY_TIMEOUT +#define SQL_ATTR_QUIET_MODE SQL_QUIET_MODE +#define SQL_ATTR_RETRIEVE_DATA SQL_RETRIEVE_DATA +#define SQL_ATTR_ROW_ARRAY_SIZE 27 +#define SQL_ATTR_ROW_BIND_OFFSET_PTR 23 +#define SQL_ATTR_ROW_BIND_TYPE SQL_BIND_TYPE +#define SQL_ATTR_ROW_NUMBER SQL_ROW_NUMBER +#define SQL_ATTR_ROW_OPERATION_PTR 24 +#define SQL_ATTR_ROW_STATUS_PTR 25 +#define SQL_ATTR_ROWS_FETCHED_PTR 26 +#define SQL_ATTR_SIMULATE_CURSOR SQL_SIMULATE_CURSOR +#define SQL_ATTR_TRACE SQL_OPT_TRACE +#define SQL_ATTR_TRACEFILE SQL_OPT_TRACEFILE +#define SQL_ATTR_TRANSLATE_LIB SQL_TRANSLATE_DLL +#define SQL_ATTR_TRANSLATE_OPTION SQL_TRANSLATE_OPTION +#define SQL_ATTR_TXN_ISOLATION SQL_TXN_ISOLATION +#define SQL_ATTR_USE_BOOKMARKS SQL_USE_BOOKMARKS +#define SQL_BATCH_ROW_COUNT 120 +#define SQL_BATCH_SUPPORT 121 +#define SQL_BRC_EXPLICIT 0x0000002 +#define SQL_BRC_PROCEDURES 0x0000001 +#define SQL_BRC_ROLLED_UP 0x0000004 +#define SQL_BS_ROW_COUNT_EXPLICIT 0x00000002L +#define SQL_BS_ROW_COUNT_PROC 0x00000008L +#define SQL_BS_SELECT_EXPLICIT 0x00000001L +#define SQL_BS_SELECT_PROC 0x00000004L +#define SQL_C_INTERVAL_DAY SQL_INTERVAL_DAY +#define SQL_C_INTERVAL_DAY_TO_HOUR SQL_INTERVAL_DAY_TO_HOUR +#define SQL_C_INTERVAL_DAY_TO_MINUTE SQL_INTERVAL_DAY_TO_MINUTE +#define SQL_C_INTERVAL_DAY_TO_SECOND SQL_INTERVAL_DAY_TO_SECOND +#define SQL_C_INTERVAL_HOUR SQL_INTERVAL_HOUR +#define SQL_C_INTERVAL_HOUR_TO_MINUTE SQL_INTERVAL_HOUR_TO_MINUTE +#define SQL_C_INTERVAL_HOUR_TO_SECOND SQL_INTERVAL_HOUR_TO_SECOND +#define SQL_C_INTERVAL_MINUTE SQL_INTERVAL_MINUTE +#define SQL_C_INTERVAL_MINUTE_TO_SECOND SQL_INTERVAL_MINUTE_TO_SECOND +#define SQL_C_INTERVAL_MONTH SQL_INTERVAL_MONTH +#define SQL_C_INTERVAL_SECOND SQL_INTERVAL_SECOND +#define SQL_C_INTERVAL_YEAR SQL_INTERVAL_YEAR +#define SQL_C_INTERVAL_YEAR_TO_MONTH SQL_INTERVAL_YEAR_TO_MONTH +#define SQL_C_NUMERIC SQL_NUMERIC +#define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) +#define SQL_C_TYPE_DATE SQL_TYPE_DATE +#define SQL_C_TYPE_TIME SQL_TYPE_TIME +#define SQL_C_TYPE_TIMESTAMP SQL_TYPE_TIMESTAMP +#define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) +#define SQL_C_VARBOOKMARK SQL_C_BINARY +#define SQL_CA_CONSTRAINT_DEFERRABLE 0x00000040L +#define SQL_CA_CONSTRAINT_INITIALLY_DEFERRED 0x00000010L +#define SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000020L +#define SQL_CA_CONSTRAINT_NON_DEFERRABLE 0x00000080L +#define SQL_CA_CREATE_ASSERTION 0x00000001L +#define SQL_CA1_ABSOLUTE 0x00000002L +#define SQL_CA1_BOOKMARK 0x00000008L +#define SQL_CA1_BULK_ADD 0x00010000L +#define SQL_CA1_BULK_DELETE_BY_BOOKMARK 0x00040000L +#define SQL_CA1_BULK_FETCH_BY_BOOKMARK 0x00080000L +#define SQL_CA1_BULK_UPDATE_BY_BOOKMARK 0x00020000L +#define SQL_CA1_LOCK_EXCLUSIVE 0x00000080L +#define SQL_CA1_LOCK_NO_CHANGE 0x00000040L +#define SQL_CA1_LOCK_UNLOCK 0x00000100L +#define SQL_CA1_NEXT 0x00000001L +#define SQL_CA1_POS_DELETE 0x00000800L +#define SQL_CA1_POS_POSITION 0x00000200L +#define SQL_CA1_POS_REFRESH 0x00001000L +#define SQL_CA1_POS_UPDATE 0x00000400L +#define SQL_CA1_POSITIONED_DELETE 0x00004000L +#define SQL_CA1_POSITIONED_UPDATE 0x00002000L +#define SQL_CA1_RELATIVE 0x00000004L +#define SQL_CA1_SELECT_FOR_UPDATE 0x00008000L +#define SQL_CA2_CRC_APPROXIMATE 0x00002000L +#define SQL_CA2_CRC_EXACT 0x00001000L +#define SQL_CA2_LOCK_CONCURRENCY 0x00000002L +#define SQL_CA2_MAX_ROWS_AFFECTS_ALL (SQL_CA2_MAX_ROWS_SELECT | SQL_CA2_MAX_ROWS_INSERT | \ + SQL_CA2_MAX_ROWS_DELETE | SQL_CA2_MAX_ROWS_UPDATE | SQL_CA2_MAX_ROWS_CATALOG) +#define SQL_CA2_MAX_ROWS_CATALOG 0x00000800L +#define SQL_CA2_MAX_ROWS_DELETE 0x00000200L +#define SQL_CA2_MAX_ROWS_INSERT 0x00000100L +#define SQL_CA2_MAX_ROWS_SELECT 0x00000080L +#define SQL_CA2_MAX_ROWS_UPDATE 0x00000400L +#define SQL_CA2_OPT_ROWVER_CONCURRENCY 0x00000004L +#define SQL_CA2_OPT_VALUES_CONCURRENCY 0x00000008L +#define SQL_CA2_READ_ONLY_CONCURRENCY 0x00000001L +#define SQL_CA2_SENSITIVITY_ADDITIONS 0x00000010L +#define SQL_CA2_SENSITIVITY_DELETIONS 0x00000020L +#define SQL_CA2_SENSITIVITY_UPDATES 0x00000040L +#define SQL_CA2_SIMULATE_NON_UNIQUE 0x00004000L +#define SQL_CA2_SIMULATE_TRY_UNIQUE 0x00008000L +#define SQL_CA2_SIMULATE_UNIQUE 0x00010000L +#define SQL_CATALOG_LOCATION SQL_QUALIFIER_LOCATION +#define SQL_CATALOG_NAME_SEPARATOR SQL_QUALIFIER_NAME_SEPARATOR +#define SQL_CATALOG_TERM SQL_QUALIFIER_TERM +#define SQL_CATALOG_USAGE SQL_QUALIFIER_USAGE +#define SQL_CCOL_CREATE_COLLATION 0x00000001L +#define SQL_CCS_COLLATE_CLAUSE 0x00000002L +#define SQL_CCS_CREATE_CHARACTER_SET 0x00000001L +#define SQL_CCS_LIMITED_COLLATION 0x00000004L +#define SQL_CDO_COLLATION 0x00000008L +#define SQL_CDO_CONSTRAINT 0x00000004L +#define SQL_CDO_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_CDO_CONSTRAINT_NAME_DEFINITION 0x00000010L +#define SQL_CDO_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_CDO_CREATE_DOMAIN 0x00000001L +#define SQL_CDO_DEFAULT 0x00000002L +#define SQL_CL_END SQL_QL_END +#define SQL_CL_START SQL_QL_START +#define SQL_COL_PRED_BASIC SQL_ALL_EXCEPT_LIKE +#define SQL_COL_PRED_CHAR SQL_LIKE_ONLY +#define SQL_COLUMN_DRIVER_START 1000 +#define SQL_COLUMN_IGNORE SQL_IGNORE +#define SQL_COLUMN_NUMBER_UNKNOWN (-2) +#define SQL_CONVERT_GUID 173 +#define SQL_CONVERT_INTERVAL_DAY_TIME 123 +#define SQL_CONVERT_INTERVAL_YEAR_MONTH 124 +#define SQL_CONVERT_WCHAR 122 +#define SQL_CONVERT_WLONGVARCHAR 125 +#define SQL_CONVERT_WVARCHAR 126 +#define SQL_CP_DEFAULT SQL_CP_OFF +#define SQL_CP_MATCH_DEFAULT SQL_CP_STRICT_MATCH +#define SQL_CP_OFF 0UL +#define SQL_CP_ONE_PER_DRIVER 1UL +#define SQL_CP_ONE_PER_HENV 2UL +#define SQL_CP_RELAXED_MATCH 1UL +#define SQL_CP_STRICT_MATCH 0UL +#define SQL_CREATE_ASSERTION 127 +#define SQL_CREATE_CHARACTER_SET 128 +#define SQL_CREATE_COLLATION 129 +#define SQL_CREATE_DOMAIN 130 +#define SQL_CREATE_SCHEMA 131 +#define SQL_CREATE_TABLE 132 +#define SQL_CREATE_TRANSLATION 133 +#define SQL_CREATE_VIEW 134 +#define SQL_CS_AUTHORIZATION 0x00000002L +#define SQL_CS_CREATE_SCHEMA 0x00000001L +#define SQL_CS_DEFAULT_CHARACTER_SET 0x00000004L +#define SQL_CT_COLUMN_COLLATION 0x00000800L +#define SQL_CT_COLUMN_CONSTRAINT 0x00000200L +#define SQL_CT_COLUMN_DEFAULT 0x00000400L +#define SQL_CT_COMMIT_DELETE 0x00000004L +#define SQL_CT_COMMIT_PRESERVE 0x00000002L +#define SQL_CT_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_CT_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_CT_CONSTRAINT_NAME_DEFINITION 0x00002000L +#define SQL_CT_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_CT_CREATE_TABLE 0x00000001L +#define SQL_CT_GLOBAL_TEMPORARY 0x00000008L +#define SQL_CT_LOCAL_TEMPORARY 0x00000010L +#define SQL_CT_TABLE_CONSTRAINT 0x00001000L +#define SQL_CTR_CREATE_TRANSLATION 0x00000001L +#define SQL_CU_DML_STATEMENTS SQL_QU_DML_STATEMENTS +#define SQL_CU_INDEX_DEFINITION SQL_QU_INDEX_DEFINITION +#define SQL_CU_PRIVILEGE_DEFINITION SQL_QU_PRIVILEGE_DEFINITION +#define SQL_CU_PROCEDURE_INVOCATION SQL_QU_PROCEDURE_INVOCATION +#define SQL_CU_TABLE_DEFINITION SQL_QU_TABLE_DEFINITION +#define SQL_CVT_GUID 0x1000000L +#define SQL_CVT_INTERVAL_DAY_TIME 0x00100000L +#define SQL_CVT_INTERVAL_YEAR_MONTH 0x00080000L +#define SQL_CVT_WCHAR 0x00200000L +#define SQL_CVT_WLONGVARCHAR 0x00400000L +#define SQL_CVT_WVARCHAR 0x00800000L +#define SQL_DA_DROP_ASSERTION 0x00000001L +#define SQL_DATETIME_LITERALS 119 +#define SQL_DB_DEFAULT SQL_DB_RETURN_TO_POOL +#define SQL_DB_DISCONNECT 1UL +#define SQL_DB_RETURN_TO_POOL 0UL +#define SQL_DC_DROP_COLLATION 0x00000001L +#define SQL_DCS_DROP_CHARACTER_SET 0x00000001L +#define SQL_DD_CASCADE 0x00000004L +#define SQL_DD_DROP_DOMAIN 0x00000001L +#define SQL_DD_RESTRICT 0x00000002L +#define SQL_DDL_INDEX 170 +#define SQL_DELETE_BY_BOOKMARK 6 +#define SQL_DESC_ARRAY_SIZE 20 +#define SQL_DESC_ARRAY_STATUS_PTR 21 +#define SQL_DESC_AUTO_UNIQUE_VALUE SQL_COLUMN_AUTO_INCREMENT +#define SQL_DESC_BASE_COLUMN_NAME 22 +#define SQL_DESC_BASE_TABLE_NAME 23 +#define SQL_DESC_BIND_OFFSET_PTR 24 +#define SQL_DESC_BIND_TYPE 25 +#define SQL_DESC_CASE_SENSITIVE SQL_COLUMN_CASE_SENSITIVE +#define SQL_DESC_CATALOG_NAME SQL_COLUMN_QUALIFIER_NAME +#define SQL_DESC_CONCISE_TYPE SQL_COLUMN_TYPE +#define SQL_DESC_DATETIME_INTERVAL_PRECISION 26 +#define SQL_DESC_DISPLAY_SIZE SQL_COLUMN_DISPLAY_SIZE +#define SQL_DESC_FIXED_PREC_SCALE SQL_COLUMN_MONEY +#define SQL_DESC_LABEL SQL_COLUMN_LABEL +#define SQL_DESC_LITERAL_PREFIX 27 +#define SQL_DESC_LITERAL_SUFFIX 28 +#define SQL_DESC_LOCAL_TYPE_NAME 29 +#define SQL_DESC_MAXIMUM_SCALE 30 +#define SQL_DESC_MINIMUM_SCALE 31 +#define SQL_DESC_NUM_PREC_RADIX 32 +#define SQL_DESC_PARAMETER_TYPE 33 +#define SQL_DESC_ROWS_PROCESSED_PTR 34 +#define SQL_DESC_SCHEMA_NAME SQL_COLUMN_OWNER_NAME +#define SQL_DESC_SEARCHABLE SQL_COLUMN_SEARCHABLE +#define SQL_DESC_TABLE_NAME SQL_COLUMN_TABLE_NAME +#define SQL_DESC_TYPE_NAME SQL_COLUMN_TYPE_NAME +#define SQL_DESC_UNSIGNED SQL_COLUMN_UNSIGNED +#define SQL_DESC_UPDATABLE SQL_COLUMN_UPDATABLE +#define SQL_DI_CREATE_INDEX 0x00000001L +#define SQL_DI_DROP_INDEX 0x00000002L +#define SQL_DIAG_COLUMN_NUMBER (-1247) +#define SQL_DIAG_CURSOR_ROW_COUNT (-1249) +#define SQL_DIAG_ROW_NUMBER (-1248) +#define SQL_DL_SQL92_DATE 0x00000001L +#define SQL_DL_SQL92_INTERVAL_DAY 0x00000020L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR 0x00000400L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE 0x00000800L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND 0x00001000L +#define SQL_DL_SQL92_INTERVAL_HOUR 0x00000040L +#define SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE 0x00002000L +#define SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND 0x00004000L +#define SQL_DL_SQL92_INTERVAL_MINUTE 0x00000080L +#define SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND 0x00008000L +#define SQL_DL_SQL92_INTERVAL_MONTH 0x00000010L +#define SQL_DL_SQL92_INTERVAL_SECOND 0x00000100L +#define SQL_DL_SQL92_INTERVAL_YEAR 0x00000008L +#define SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH 0x00000200L +#define SQL_DL_SQL92_TIME 0x00000002L +#define SQL_DL_SQL92_TIMESTAMP 0x00000004L +#define SQL_DM_VER 171 +#define SQL_DRIVER_HDESC 135 +#define SQL_DROP_ASSERTION 136 +#define SQL_DROP_CHARACTER_SET 137 +#define SQL_DROP_COLLATION 138 +#define SQL_DROP_DOMAIN 139 +#define SQL_DROP_SCHEMA 140 +#define SQL_DROP_TABLE 141 +#define SQL_DROP_TRANSLATION 142 +#define SQL_DROP_VIEW 143 +#define SQL_DS_CASCADE 0x00000004L +#define SQL_DS_DROP_SCHEMA 0x00000001L +#define SQL_DS_RESTRICT 0x00000002L +#define SQL_DT_CASCADE 0x00000004L +#define SQL_DT_DROP_TABLE 0x00000001L +#define SQL_DT_RESTRICT 0x00000002L +#define SQL_DTC_DONE 0L +#define SQL_DTR_DROP_TRANSLATION 0x00000001L +#define SQL_DV_CASCADE 0x00000004L +#define SQL_DV_DROP_VIEW 0x00000001L +#define SQL_DV_RESTRICT 0x00000002L +#define SQL_DYNAMIC_CURSOR_ATTRIBUTES1 144 +#define SQL_DYNAMIC_CURSOR_ATTRIBUTES2 145 +#define SQL_EXT_API_LAST SQL_API_SQLBINDPARAMETER +#define SQL_EXT_API_START 40 +#define SQL_FETCH_BY_BOOKMARK 7 +#define SQL_FETCH_FIRST_SYSTEM 32 +#define SQL_FETCH_FIRST_USER 31 +#define SQL_FN_CVT_CAST 0x00000002L +#define SQL_FN_STR_BIT_LENGTH 0x00080000L +#define SQL_FN_STR_CHAR_LENGTH 0x00100000L +#define SQL_FN_STR_CHARACTER_LENGTH 0x00200000L +#define SQL_FN_STR_OCTET_LENGTH 0x00400000L +#define SQL_FN_STR_POSITION 0x00800000L +#define SQL_FN_TD_CURRENT_DATE 0x00020000L +#define SQL_FN_TD_CURRENT_TIME 0x00040000L +#define SQL_FN_TD_CURRENT_TIMESTAMP 0x00080000L +#define SQL_FN_TD_EXTRACT 0x00100000L +#define SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 146 +#define SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 147 +#define SQL_FUNC_EXISTS(exists, api) \ + ((*(((UWORD*) (exists)) + ((api) >> 4)) & (1 << ((api) & 15)) ) ? \ + SQL_TRUE : SQL_FALSE ) +#define SQL_GB_COLLATE 0x0004 +#define SQL_HANDLE_SENV 5 +#define SQL_IK_ALL (SQL_IK_ASC | SQL_IK_DESC) +#define SQL_IK_ASC 1 +#define SQL_IK_DESC 2 +#define SQL_IK_NONE 0 +#define SQL_INDEX_KEYWORDS 148 +#define SQL_INFO_DRIVER_START 1000 +#define SQL_INFO_LAST SQL_QUALIFIER_LOCATION +#define SQL_INFO_SCHEMA_VIEWS 149 +#define SQL_INITIALLY_DEFERRED 5 +#define SQL_INITIALLY_IMMEDIATE 6 +#define SQL_INSERT_STATEMENT 172 +#define SQL_INTERVAL 10 +#define SQL_IS_INSERT_LITERALS 0x00000001L +#define SQL_IS_INSERT_SEARCHED 0x00000002L +#define SQL_IS_INTEGER (-6) +#define SQL_IS_POINTER (-4) +#define SQL_IS_SELECT_INTO 0x00000004L +#define SQL_IS_SMALLINT (-8) +#define SQL_IS_UINTEGER (-5) +#define SQL_IS_USMALLINT (-7) +#define SQL_ISV_ASSERTIONS 0x00000001L +#define SQL_ISV_CHARACTER_SETS 0x00000002L +#define SQL_ISV_CHECK_CONSTRAINTS 0x00000004L +#define SQL_ISV_COLLATIONS 0x00000008L +#define SQL_ISV_COLUMN_DOMAIN_USAGE 0x00000010L +#define SQL_ISV_COLUMN_PRIVILEGES 0x00000020L +#define SQL_ISV_COLUMNS 0x00000040L +#define SQL_ISV_CONSTRAINT_COLUMN_USAGE 0x00000080L +#define SQL_ISV_CONSTRAINT_TABLE_USAGE 0x00000100L +#define SQL_ISV_DOMAIN_CONSTRAINTS 0x00000200L +#define SQL_ISV_DOMAINS 0x00000400L +#define SQL_ISV_KEY_COLUMN_USAGE 0x00000800L +#define SQL_ISV_REFERENTIAL_CONSTRAINTS 0x00001000L +#define SQL_ISV_SCHEMATA 0x00002000L +#define SQL_ISV_SQL_LANGUAGES 0x00004000L +#define SQL_ISV_TABLE_CONSTRAINTS 0x00008000L +#define SQL_ISV_TABLE_PRIVILEGES 0x00010000L +#define SQL_ISV_TABLES 0x00020000L +#define SQL_ISV_TRANSLATIONS 0x00040000L +#define SQL_ISV_USAGE_PRIVILEGES 0x00080000L +#define SQL_ISV_VIEW_COLUMN_USAGE 0x00100000L +#define SQL_ISV_VIEW_TABLE_USAGE 0x00200000L +#define SQL_ISV_VIEWS 0x00400000L +#define SQL_KEYSET_CURSOR_ATTRIBUTES1 150 +#define SQL_KEYSET_CURSOR_ATTRIBUTES2 151 +#define SQL_MAX_ASYNC_CONCURRENT_STATEMENTS 10022 +#define SQL_NO_COLUMN_NUMBER (-1) +#define SQL_NO_ROW_NUMBER (-1) +#define SQL_NOT_DEFERRABLE 7 +#define SQL_NUM_EXTENSIONS (SQL_EXT_API_LAST-SQL_EXT_API_START+1) +#define SQL_NUM_FUNCTIONS 23 +#define SQL_ODBC_INTERFACE_CONFORMANCE 152 +#define SQL_OIC_CORE 1UL +#define SQL_OIC_LEVEL1 2UL +#define SQL_OIC_LEVEL2 3UL +#define SQL_OV_ODBC2 2UL +#define SQL_OV_ODBC3 3UL +#define SQL_PARAM_ARRAY_ROW_COUNTS 153 +#define SQL_PARAM_ARRAY_SELECTS 154 +#define SQL_PARAM_BIND_BY_COLUMN 0UL +#define SQL_PARAM_BIND_TYPE_DEFAULT SQL_PARAM_BIND_BY_COLUMN +#define SQL_PARAM_DIAG_UNAVAILABLE 1 +#define SQL_PARAM_ERROR 5 +#define SQL_PARAM_IGNORE 1 +#define SQL_PARAM_PROCEED 0 +#define SQL_PARAM_SUCCESS 0 +#define SQL_PARAM_SUCCESS_WITH_INFO 6 +#define SQL_PARAM_UNUSED 7 +#define SQL_PARC_BATCH 1 +#define SQL_PARC_NO_BATCH 2 +#define SQL_PAS_BATCH 1 +#define SQL_PAS_NO_BATCH 2 +#define SQL_PAS_NO_SELECT 3 +#define SQL_ROW_IGNORE 1 +#define SQL_ROW_NUMBER_UNKNOWN (-2) +#define SQL_ROW_PROCEED 0 +#define SQL_ROW_SUCCESS_WITH_INFO 6 +#define SQL_SC_FIPS127_2_TRANSITIONAL 0x00000002L +#define SQL_SC_SQL92_ENTRY 0x00000001L +#define SQL_SC_SQL92_FULL 0x00000008L +#define SQL_SC_SQL92_INTERMEDIATE 0x00000004L +#define SQL_SCC_ISO92_CLI 0x00000002L +#define SQL_SCC_XOPEN_CLI_VERSION1 0x00000001L +#define SQL_SCHEMA_TERM SQL_OWNER_TERM +#define SQL_SCHEMA_USAGE SQL_OWNER_USAGE +#define SQL_SDF_CURRENT_DATE 0x00000001L +#define SQL_SDF_CURRENT_TIME 0x00000002L +#define SQL_SDF_CURRENT_TIMESTAMP 0x00000004L +#define SQL_SFKD_CASCADE 0x00000001L +#define SQL_SFKD_NO_ACTION 0x00000002L +#define SQL_SFKD_SET_DEFAULT 0x00000004L +#define SQL_SFKD_SET_NULL 0x00000008L +#define SQL_SFKU_CASCADE 0x00000001L +#define SQL_SFKU_NO_ACTION 0x00000002L +#define SQL_SFKU_SET_DEFAULT 0x00000004L +#define SQL_SFKU_SET_NULL 0x00000008L +#define SQL_SG_DELETE_TABLE 0x00000020L +#define SQL_SG_INSERT_COLUMN 0x00000080L +#define SQL_SG_INSERT_TABLE 0x00000040L +#define SQL_SG_REFERENCES_COLUMN 0x00000200L +#define SQL_SG_REFERENCES_TABLE 0x00000100L +#define SQL_SG_SELECT_TABLE 0x00000400L +#define SQL_SG_UPDATE_COLUMN 0x00001000L +#define SQL_SG_UPDATE_TABLE 0x00000800L +#define SQL_SG_USAGE_ON_CHARACTER_SET 0x00000002L +#define SQL_SG_USAGE_ON_COLLATION 0x00000004L +#define SQL_SG_USAGE_ON_DOMAIN 0x00000001L +#define SQL_SG_USAGE_ON_TRANSLATION 0x00000008L +#define SQL_SG_WITH_GRANT_OPTION 0x00000010L +#define SQL_SNVF_BIT_LENGTH 0x00000001L +#define SQL_SNVF_CHAR_LENGTH 0x00000002L +#define SQL_SNVF_CHARACTER_LENGTH 0x00000004L +#define SQL_SNVF_EXTRACT 0x00000008L +#define SQL_SNVF_OCTET_LENGTH 0x00000010L +#define SQL_SNVF_POSITION 0x00000020L +#define SQL_SP_BETWEEN 0x00000800L +#define SQL_SP_COMPARISON 0x00001000L +#define SQL_SP_EXISTS 0x00000001L +#define SQL_SP_IN 0x00000400L +#define SQL_SP_ISNOTNULL 0x00000002L +#define SQL_SP_ISNULL 0x00000004L +#define SQL_SP_LIKE 0x00000200L +#define SQL_SP_MATCH_FULL 0x00000008L +#define SQL_SP_MATCH_PARTIAL 0x00000010L +#define SQL_SP_MATCH_UNIQUE_FULL 0x00000020L +#define SQL_SP_MATCH_UNIQUE_PARTIAL 0x00000040L +#define SQL_SP_OVERLAPS 0x00000080L +#define SQL_SP_QUANTIFIED_COMPARISON 0x00002000L +#define SQL_SP_UNIQUE 0x00000100L +#define SQL_SQL_CONFORMANCE 118 +#define SQL_SQL92_DATETIME_FUNCTIONS 155 +#define SQL_SQL92_FOREIGN_KEY_DELETE_RULE 156 +#define SQL_SQL92_FOREIGN_KEY_UPDATE_RULE 157 +#define SQL_SQL92_GRANT 158 +#define SQL_SQL92_NUMERIC_VALUE_FUNCTIONS 159 +#define SQL_SQL92_PREDICATES 160 +#define SQL_SQL92_RELATIONAL_JOIN_OPERATORS 161 +#define SQL_SQL92_REVOKE 162 +#define SQL_SQL92_ROW_VALUE_CONSTRUCTOR 163 +#define SQL_SQL92_STRING_FUNCTIONS 164 +#define SQL_SQL92_VALUE_EXPRESSIONS 165 +#define SQL_SR_CASCADE 0x00000020L +#define SQL_SR_DELETE_TABLE 0x00000080L +#define SQL_SR_GRANT_OPTION_FOR 0x00000010L +#define SQL_SR_INSERT_COLUMN 0x00000200L +#define SQL_SR_INSERT_TABLE 0x00000100L +#define SQL_SR_REFERENCES_COLUMN 0x00000800L +#define SQL_SR_REFERENCES_TABLE 0x00000400L +#define SQL_SR_RESTRICT 0x00000040L +#define SQL_SR_SELECT_TABLE 0x00001000L +#define SQL_SR_UPDATE_COLUMN 0x00004000L +#define SQL_SR_UPDATE_TABLE 0x00002000L +#define SQL_SR_USAGE_ON_CHARACTER_SET 0x00000002L +#define SQL_SR_USAGE_ON_COLLATION 0x00000004L +#define SQL_SR_USAGE_ON_DOMAIN 0x00000001L +#define SQL_SR_USAGE_ON_TRANSLATION 0x00000008L +#define SQL_SRJO_CORRESPONDING_CLAUSE 0x00000001L +#define SQL_SRJO_CROSS_JOIN 0x00000002L +#define SQL_SRJO_EXCEPT_JOIN 0x00000004L +#define SQL_SRJO_FULL_OUTER_JOIN 0x00000008L +#define SQL_SRJO_INNER_JOIN 0x00000010L +#define SQL_SRJO_INTERSECT_JOIN 0x00000020L +#define SQL_SRJO_LEFT_OUTER_JOIN 0x00000040L +#define SQL_SRJO_NATURAL_JOIN 0x00000080L +#define SQL_SRJO_RIGHT_OUTER_JOIN 0x00000100L +#define SQL_SRJO_UNION_JOIN 0x00000200L +#define SQL_SRVC_DEFAULT 0x00000004L +#define SQL_SRVC_NULL 0x00000002L +#define SQL_SRVC_ROW_SUBQUERY 0x00000008L +#define SQL_SRVC_VALUE_EXPRESSION 0x00000001L +#define SQL_SSF_CONVERT 0x00000001L +#define SQL_SSF_LOWER 0x00000002L +#define SQL_SSF_SUBSTRING 0x00000008L +#define SQL_SSF_TRANSLATE 0x00000010L +#define SQL_SSF_TRIM_BOTH 0x00000020L +#define SQL_SSF_TRIM_LEADING 0x00000040L +#define SQL_SSF_TRIM_TRAILING 0x00000080L +#define SQL_SSF_UPPER 0x00000004L +#define SQL_STANDARD_CLI_CONFORMANCE 166 +#define SQL_STATIC_CURSOR_ATTRIBUTES1 167 +#define SQL_STATIC_CURSOR_ATTRIBUTES2 168 +#define SQL_SU_DML_STATEMENTS SQL_OU_DML_STATEMENTS +#define SQL_SU_INDEX_DEFINITION SQL_OU_INDEX_DEFINITION +#define SQL_SU_PRIVILEGE_DEFINITION SQL_OU_PRIVILEGE_DEFINITION +#define SQL_SU_PROCEDURE_INVOCATION SQL_OU_PROCEDURE_INVOCATION +#define SQL_SU_TABLE_DEFINITION SQL_OU_TABLE_DEFINITION +#define SQL_SVE_CASE 0x00000001L +#define SQL_SVE_CAST 0x00000002L +#define SQL_SVE_COALESCE 0x00000004L +#define SQL_SVE_NULLIF 0x00000008L +#define SQL_UB_FIXED SQL_UB_ON +#define SQL_UB_VARIABLE 2UL +#define SQL_UNION_STATEMENT SQL_UNION +#define SQL_UPDATE_BY_BOOKMARK 5 +#define SQL_US_UNION SQL_U_UNION +#define SQL_US_UNION_ALL SQL_U_UNION_ALL +#endif /* ODBCVER >= 0x300 */ +#if (ODBCVER >= 0x0350) +#define SQL_DESC_ROWVER 35 +#define SQL_GUID (-11) +#define SQL_C_GUID SQL_GUID +#ifdef ODBC_STD +#define SQLAllocHandle SQLAllocHandleStd +#define SQLAllocEnv(p) SQLAllocHandleStd(SQL_HANDLE_ENV,SQL_NULL_HANDLE,p) +#define SQL_YEAR SQL_CODE_YEAR +#define SQL_MONTH SQL_CODE_MONTH +#define SQL_DAY SQL_CODE_DAY +#define SQL_HOUR SQL_CODE_HOUR +#define SQL_MINUTE SQL_CODE_MINUTE +#define SQL_SECOND SQL_CODE_SECOND +#define SQL_YEAR_TO_MONTH SQL_CODE_YEAR_TO_MONTH +#define SQL_DAY_TO_HOUR SQL_CODE_DAY_TO_HOUR +#define SQL_DAY_TO_MINUTE SQL_CODE_DAY_TO_MINUTE +#define SQL_DAY_TO_SECOND SQL_CODE_DAY_TO_SECOND +#define SQL_HOUR_TO_MINUTE SQL_CODE_HOUR_TO_MINUTE +#define SQL_HOUR_TO_SECOND SQL_CODE_HOUR_TO_SECOND +#define SQL_MINUTE_TO_SECOND SQL_CODE_MINUTE_TO_SECOND +#endif /* ODBC_STD */ +#endif /* ODBCVER >= 0x0350 */ +#if (ODBCVER >= 0x0351) +#define SQL_ATTR_ANSI_APP 115 +#define SQL_AA_TRUE 1L +#define SQL_AA_FALSE 0L +#endif + +#define TRACE_VERSION 1000 +#define TRACE_ON 1 + +#ifndef RC_INVOKED +#define SQL_ODBC_KEYWORDS \ +"ABSOLUTE,ACTION,ADA,ADD,ALL,ALLOCATE,ALTER,AND,ANY,ARE,AS,"\ +"ASC,ASSERTION,AT,AUTHORIZATION,AVG,"\ +"BEGIN,BETWEEN,BIT,BIT_LENGTH,BOTH,BY,CASCADE,CASCADED,CASE,CAST,CATALOG,"\ +"CHAR,CHAR_LENGTH,CHARACTER,CHARACTER_LENGTH,CHECK,CLOSE,COALESCE,"\ +"COLLATE,COLLATION,COLUMN,COMMIT,CONNECT,CONNECTION,CONSTRAINT,"\ +"CONSTRAINTS,CONTINUE,CONVERT,CORRESPONDING,COUNT,CREATE,CROSS,CURRENT,"\ +"CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,"\ +"DATE,DAY,DEALLOCATE,DEC,DECIMAL,DECLARE,DEFAULT,DEFERRABLE,"\ +"DEFERRED,DELETE,DESC,DESCRIBE,DESCRIPTOR,DIAGNOSTICS,DISCONNECT,"\ +"DISTINCT,DOMAIN,DOUBLE,DROP,"\ +"ELSE,END,END-EXEC,ESCAPE,EXCEPT,EXCEPTION,EXEC,EXECUTE,"\ +"EXISTS,EXTERNAL,EXTRACT,"\ +"FALSE,FETCH,FIRST,FLOAT,FOR,FOREIGN,FORTRAN,FOUND,FROM,FULL,"\ +"GET,GLOBAL,GO,GOTO,GRANT,GROUP,HAVING,HOUR,"\ +"IDENTITY,IMMEDIATE,IN,INCLUDE,INDEX,INDICATOR,INITIALLY,INNER,"\ +"INPUT,INSENSITIVE,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,IS,ISOLATION,"\ +"JOIN,KEY,LANGUAGE,LAST,LEADING,LEFT,LEVEL,LIKE,LOCAL,LOWER,"\ +"MATCH,MAX,MIN,MINUTE,MODULE,MONTH,"\ +"NAMES,NATIONAL,NATURAL,NCHAR,NEXT,NO,NONE,NOT,NULL,NULLIF,NUMERIC,"\ +"OCTET_LENGTH,OF,ON,ONLY,OPEN,OPTION,OR,ORDER,OUTER,OUTPUT,OVERLAPS,"\ +"PAD,PARTIAL,PASCAL,PLI,POSITION,PRECISION,PREPARE,PRESERVE,"\ +"PRIMARY,PRIOR,PRIVILEGES,PROCEDURE,PUBLIC,"\ +"READ,REAL,REFERENCES,RELATIVE,RESTRICT,REVOKE,RIGHT,ROLLBACK,ROWS"\ +"SCHEMA,SCROLL,SECOND,SECTION,SELECT,SESSION,SESSION_USER,SET,SIZE,"\ +"SMALLINT,SOME,SPACE,SQL,SQLCA,SQLCODE,SQLERROR,SQLSTATE,SQLWARNING,"\ +"SUBSTRING,SUM,SYSTEM_USER,"\ +"TABLE,TEMPORARY,THEN,TIME,TIMESTAMP,TIMEZONE_HOUR,TIMEZONE_MINUTE,"\ +"TO,TRAILING,TRANSACTION,TRANSLATE,TRANSLATION,TRIM,TRUE,"\ +"UNION,UNIQUE,UNKNOWN,UPDATE,UPPER,USAGE,USER,USING,"\ +"VALUE,VALUES,VARCHAR,VARYING,VIEW,WHEN,WHENEVER,WHERE,WITH,WORK,WRITE,"\ +"YEAR,ZONE" + +SQLRETURN SQL_API SQLDriverConnect(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLColAttributes(SQLHSTMT,SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLLEN*); +SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*); +SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLMoreResults(SQLHSTMT); +SQLRETURN SQL_API SQLNativeSql(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLNumParams(SQLHSTMT,SQLSMALLINT*); +SQLRETURN SQL_API SQLParamOptions(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*); +SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedures(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetPos(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDrivers(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLBindParameter(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLUSMALLINT); /* deprecated */ +DWORD SQL_API ODBCGetTryWaitValue(void); +BOOL SQL_API ODBCSetTryWaitValue(DWORD); +RETCODE SQL_API TraceOpenLogFile(LPWSTR,LPWSTR,DWORD); +RETCODE SQL_API TraceCloseLogFile(void); +VOID SQL_API TraceReturn(RETCODE,RETCODE); +DWORD SQL_API TraceVersion(void); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLAllocHandleStd( SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +#endif +#endif /* ndef RC_INVOKED */ +#include +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.24.orig/win32/include/sql.h tcc-0.9.24/win32/include/sql.h --- tcc-0.9.24.orig/win32/include/sql.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/sql.h 2007-07-22 16:04:55.000000000 +0200 @@ -0,0 +1,408 @@ +#ifndef _SQL_H +#define _SQL_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef ODBCVER +#define ODBCVER 0x0351 +#endif +#include +#define SQL_ACCESSIBLE_PROCEDURES 20 +#define SQL_ACCESSIBLE_TABLES 19 +#define SQL_ALL_TYPES 0 +#define SQL_ALTER_TABLE 86 +#define SQL_API_SQLALLOCCONNECT 1 +#define SQL_API_SQLALLOCENV 2 +#define SQL_API_SQLALLOCSTMT 3 +#define SQL_API_SQLBINDCOL 4 +#define SQL_API_SQLCANCEL 5 +#define SQL_API_SQLCOLUMNS 40 +#define SQL_API_SQLCONNECT 7 +#define SQL_API_SQLDATASOURCES 57 +#define SQL_API_SQLDESCRIBECOL 8 +#define SQL_API_SQLDISCONNECT 9 +#define SQL_API_SQLERROR 10 +#define SQL_API_SQLEXECDIRECT 11 +#define SQL_API_SQLEXECUTE 12 +#define SQL_API_SQLFETCH 13 +#define SQL_API_SQLFREECONNECT 14 +#define SQL_API_SQLFREEENV 15 +#define SQL_API_SQLFREESTMT 16 +#define SQL_API_SQLGETCONNECTOPTION 42 +#define SQL_API_SQLGETCURSORNAME 17 +#define SQL_API_SQLGETDATA 43 +#define SQL_API_SQLGETFUNCTIONS 44 +#define SQL_API_SQLGETINFO 45 +#define SQL_API_SQLGETSTMTOPTION 46 +#define SQL_API_SQLGETTYPEINFO 47 +#define SQL_API_SQLNUMRESULTCOLS 18 +#define SQL_API_SQLPARAMDATA 48 +#define SQL_API_SQLPREPARE 19 +#define SQL_API_SQLPUTDATA 49 +#define SQL_API_SQLROWCOUNT 20 +#define SQL_API_SQLSETCONNECTOPTION 50 +#define SQL_API_SQLSETCURSORNAME 21 +#define SQL_API_SQLSETPARAM 22 +#define SQL_API_SQLSETSTMTOPTION 51 +#define SQL_API_SQLSPECIALCOLUMNS 52 +#define SQL_API_SQLSTATISTICS 53 +#define SQL_API_SQLTABLES 54 +#define SQL_API_SQLTRANSACT 23 +#define SQL_CB_CLOSE 1 +#define SQL_CB_DELETE 0 +#define SQL_CB_PRESERVE 2 +#define SQL_CHAR 1 +#define SQL_CLOSE 0 +#define SQL_COMMIT 0 +#define SQL_CURSOR_COMMIT_BEHAVIOR 23 +#define SQL_DATA_AT_EXEC (-2) +#define SQL_DATA_SOURCE_NAME 2 +#define SQL_DATA_SOURCE_READ_ONLY 25 +#define SQL_DBMS_NAME 17 +#define SQL_DBMS_VER 18 +#define SQL_DECIMAL 3 +#define SQL_DEFAULT_TXN_ISOLATION 26 +#define SQL_DOUBLE 8 +#define SQL_DROP 1 +#define SQL_ERROR (-1) +#define SQL_FD_FETCH_ABSOLUTE 16 +#define SQL_FD_FETCH_FIRST 2 +#define SQL_FD_FETCH_LAST 4 +#define SQL_FD_FETCH_NEXT 1 +#define SQL_FD_FETCH_PRIOR 8 +#define SQL_FD_FETCH_RELATIVE 32 +#define SQL_FETCH_ABSOLUTE 5 +#define SQL_FETCH_DIRECTION 8 +#define SQL_FETCH_FIRST 2 +#define SQL_FETCH_LAST 3 +#define SQL_FETCH_NEXT 1 +#define SQL_FETCH_PRIOR 4 +#define SQL_FETCH_RELATIVE 6 +#define SQL_FLOAT 6 +#define SQL_GD_ANY_COLUMN 1 +#define SQL_GD_ANY_ORDER 2 +#define SQL_GETDATA_EXTENSIONS 81 +#define SQL_IC_LOWER 2 +#define SQL_IC_MIXED 4 +#define SQL_IC_SENSITIVE 3 +#define SQL_IC_UPPER 1 +#define SQL_IDENTIFIER_CASE 28 +#define SQL_IDENTIFIER_QUOTE_CHAR 29 +#define SQL_INDEX_ALL 1 +#define SQL_INDEX_CLUSTERED 1 +#define SQL_INDEX_HASHED 2 +#define SQL_INDEX_OTHER 3 +#define SQL_INDEX_UNIQUE 0 +#define SQL_INTEGER 4 +#define SQL_INTEGRITY 73 +#define SQL_INVALID_HANDLE (-2) +#define SQL_MAX_CATALOG_NAME_LEN 34 +#define SQL_MAX_COLUMN_NAME_LEN 30 +#define SQL_MAX_COLUMNS_IN_GROUP_BY 97 +#define SQL_MAX_COLUMNS_IN_INDEX 98 +#define SQL_MAX_COLUMNS_IN_ORDER_BY 99 +#define SQL_MAX_COLUMNS_IN_SELECT 100 +#define SQL_MAX_COLUMNS_IN_TABLE 101 +#define SQL_MAX_CURSOR_NAME_LEN 31 +#define SQL_MAX_INDEX_SIZE 102 +#define SQL_MAX_MESSAGE_LENGTH 512 +#define SQL_MAX_ROW_SIZE 104 +#define SQL_MAX_SCHEMA_NAME_LEN 32 +#define SQL_MAX_STATEMENT_LEN 105 +#define SQL_MAX_TABLE_NAME_LEN 35 +#define SQL_MAX_TABLES_IN_SELECT 106 +#define SQL_MAX_USER_NAME_LEN 107 +#define SQL_MAXIMUM_CATALOG_NAME_LENGTH SQL_MAX_CATALOG_NAME_LEN +#define SQL_MAXIMUM_COLUMN_NAME_LENGTH SQL_MAX_COLUMN_NAME_LEN +#define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY SQL_MAX_COLUMNS_IN_GROUP_BY +#define SQL_MAXIMUM_COLUMNS_IN_INDEX SQL_MAX_COLUMNS_IN_INDEX +#define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY SQL_MAX_COLUMNS_IN_ORDER_BY +#define SQL_MAXIMUM_COLUMNS_IN_SELECT SQL_MAX_COLUMNS_IN_SELECT +#define SQL_MAXIMUM_CURSOR_NAME_LENGTH SQL_MAX_CURSOR_NAME_LEN +#define SQL_MAXIMUM_INDEX_SIZE SQL_MAX_INDEX_SIZE +#define SQL_MAXIMUM_ROW_SIZE SQL_MAX_ROW_SIZE +#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH SQL_MAX_SCHEMA_NAME_LEN +#define SQL_MAXIMUM_STATEMENT_LENGTH SQL_MAX_STATEMENT_LEN +#define SQL_MAXIMUM_TABLES_IN_SELECT SQL_MAX_TABLES_IN_SELECT +#define SQL_MAXIMUM_USER_NAME_LENGTH SQL_MAX_USER_NAME_LEN +#define SQL_NC_HIGH 0 +#define SQL_NC_LOW 1 +#define SQL_NEED_DATA 99 +#define SQL_NO_NULLS 0 +#define SQL_NTS (-3) +#define SQL_NTSL (-3L) +#define SQL_NULL_COLLATION 85 +#define SQL_NULL_DATA (-1) +#define SQL_NULL_HDBC 0 +#define SQL_NULL_HENV 0 +#define SQL_NULL_HSTMT 0 +#define SQL_NULLABLE 1 +#define SQL_NULLABLE_UNKNOWN 2 +#define SQL_NUMERIC 2 +#define SQL_ORDER_BY_COLUMNS_IN_SELECT 90 +#define SQL_PC_PSEUDO 2 +#define SQL_PC_UNKNOWN 0 +#define SQL_REAL 7 +#define SQL_RESET_PARAMS 3 +#define SQL_ROLLBACK 1 +#define SQL_SCCO_LOCK 2 +#define SQL_SCCO_OPT_ROWVER 4 +#define SQL_SCCO_OPT_VALUES 8 +#define SQL_SCCO_READ_ONLY 1 +#define SQL_SCOPE_CURROW 0 +#define SQL_SCOPE_SESSION 2 +#define SQL_SCOPE_TRANSACTION 1 +#define SQL_SCROLL_CONCURRENCY 43 +#define SQL_SEARCH_PATTERN_ESCAPE 14 +#define SQL_SERVER_NAME 13 +#define SQL_SMALLINT 5 +#define SQL_SPECIAL_CHARACTERS 94 +#define SQL_STILL_EXECUTING 2 +#define SQL_SUCCEEDED(rc) (((rc)&(~1))==0) +#define SQL_SUCCESS 0 +#define SQL_SUCCESS_WITH_INFO 1 +#define SQL_TC_ALL 2 +#define SQL_TC_DDL_COMMIT 3 +#define SQL_TC_DDL_IGNORE 4 +#define SQL_TC_DML 1 +#define SQL_TC_NONE 0 +#define SQL_TRANSACTION_CAPABLE SQL_TXN_CAPABLE +#define SQL_TRANSACTION_ISOLATION_OPTION SQL_TXN_ISOLATION_OPTION +#define SQL_TRANSACTION_READ_COMMITTED SQL_TXN_READ_COMMITTED +#define SQL_TRANSACTION_READ_UNCOMMITTED SQL_TXN_READ_UNCOMMITTED +#define SQL_TRANSACTION_REPEATABLE_READ SQL_TXN_REPEATABLE_READ +#define SQL_TRANSACTION_SERIALIZABLE SQL_TXN_SERIALIZABLE +#define SQL_TXN_CAPABLE 46 +#define SQL_TXN_ISOLATION_OPTION 72 +#define SQL_TXN_READ_COMMITTED 2 +#define SQL_TXN_READ_UNCOMMITTED 1 +#define SQL_TXN_REPEATABLE_READ 4 +#define SQL_TXN_SERIALIZABLE 8 +#define SQL_UNBIND 2 +#define SQL_UNKNOWN_TYPE 0 +#define SQL_USER_NAME 47 +#define SQL_VARCHAR 12 +#if (ODBCVER >= 0x0200) +#define SQL_AT_ADD_COLUMN 1 +#define SQL_AT_DROP_COLUMN 2 +#endif /* ODBCVER >= 0x0200 */ +#if (ODBCVER >= 0x0201) +#define SQL_OJ_LEFT 1 +#define SQL_OJ_RIGHT 2 +#define SQL_OJ_FULL 4 +#define SQL_OJ_NESTED 8 +#define SQL_OJ_NOT_ORDERED 16 +#define SQL_OJ_INNER 32 +#define SQL_OJ_ALL_COMPARISON_OPS 64 +#endif /* ODBCVER >= 0x0201 */ +#if (ODBCVER >= 0x0300) +#define SQL_AM_CONNECTION 1 +#define SQL_AM_NONE 0 +#define SQL_AM_STATEMENT 2 +#define SQL_API_SQLALLOCHANDLE 1001 +#define SQL_API_SQLBINDPARAM 1002 +#define SQL_API_SQLCLOSECURSOR 1003 +#define SQL_API_SQLCOLATTRIBUTE 6 +#define SQL_API_SQLCOPYDESC 1004 +#define SQL_API_SQLENDTRAN 1005 +#define SQL_API_SQLFETCHSCROLL 1021 +#define SQL_API_SQLFREEHANDLE 1006 +#define SQL_API_SQLGETCONNECTATTR 1007 +#define SQL_API_SQLGETDESCFIELD 1008 +#define SQL_API_SQLGETDESCREC 1009 +#define SQL_API_SQLGETDIAGFIELD 1010 +#define SQL_API_SQLGETDIAGREC 1011 +#define SQL_API_SQLGETENVATTR 1012 +#define SQL_API_SQLGETSTMTATTR 1014 +#define SQL_API_SQLSETCONNECTATTR 1016 +#define SQL_API_SQLSETDESCFIELD 1017 +#define SQL_API_SQLSETDESCREC 1018 +#define SQL_API_SQLSETENVATTR 1019 +#define SQL_API_SQLSETSTMTATTR 1020 +#define SQL_ARD_TYPE (-99) +#define SQL_AT_ADD_CONSTRAINT 8 +#define SQL_ATTR_APP_PARAM_DESC 10011 +#define SQL_ATTR_APP_ROW_DESC 10010 +#define SQL_ATTR_AUTO_IPD 10001 +#define SQL_ATTR_CURSOR_SCROLLABLE (-1) +#define SQL_ATTR_CURSOR_SENSITIVITY (-2) +#define SQL_ATTR_IMP_PARAM_DESC 10013 +#define SQL_ATTR_IMP_ROW_DESC 10012 +#define SQL_ATTR_METADATA_ID 10014 +#define SQL_ATTR_OUTPUT_NTS 10001 +#define SQL_CATALOG_NAME 10003 +#define SQL_CODE_DATE 1 +#define SQL_CODE_TIME 2 +#define SQL_CODE_TIMESTAMP 3 +#define SQL_COLLATION_SEQ 10004 +#define SQL_CURSOR_SENSITIVITY 10001 +#define SQL_DATE_LEN 10 +#define SQL_DATETIME 9 +#define SQL_DEFAULT 99 +#define SQL_DESC_ALLOC_AUTO 1 +#define SQL_DESC_ALLOC_TYPE 1099 +#define SQL_DESC_ALLOC_USER 2 +#define SQL_DESC_COUNT 1001 +#define SQL_DESC_DATA_PTR 1010 +#define SQL_DESC_DATETIME_INTERVAL_CODE 1007 +#define SQL_DESC_INDICATOR_PTR 1009 +#define SQL_DESC_LENGTH 1003 +#define SQL_DESC_NAME 1011 +#define SQL_DESC_NULLABLE 1008 +#define SQL_DESC_OCTET_LENGTH 1013 +#define SQL_DESC_OCTET_LENGTH_PTR 1004 +#define SQL_DESC_PRECISION 1005 +#define SQL_DESC_SCALE 1006 +#define SQL_DESC_TYPE 1002 +#define SQL_DESC_UNNAMED 1012 +#define SQL_DESCRIBE_PARAMETER 10002 +#define SQL_DIAG_ALTER_DOMAIN 3 +#define SQL_DIAG_ALTER_TABLE 4 +#define SQL_DIAG_CALL 7 +#define SQL_DIAG_CLASS_ORIGIN 8 +#define SQL_DIAG_CONNECTION_NAME 10 +#define SQL_DIAG_CREATE_ASSERTION 6 +#define SQL_DIAG_CREATE_CHARACTER_SET 8 +#define SQL_DIAG_CREATE_COLLATION 10 +#define SQL_DIAG_CREATE_DOMAIN 23 +#define SQL_DIAG_CREATE_INDEX (-1) +#define SQL_DIAG_CREATE_SCHEMA 64 +#define SQL_DIAG_CREATE_TABLE 77 +#define SQL_DIAG_CREATE_TRANSLATION 79 +#define SQL_DIAG_CREATE_VIEW 84 +#define SQL_DIAG_DELETE_WHERE 19 +#define SQL_DIAG_DROP_ASSERTION 24 +#define SQL_DIAG_DROP_CHARACTER_SET 25 +#define SQL_DIAG_DROP_COLLATION 26 +#define SQL_DIAG_DROP_DOMAIN 27 +#define SQL_DIAG_DROP_INDEX (-2) +#define SQL_DIAG_DROP_SCHEMA 31 +#define SQL_DIAG_DROP_TABLE 32 +#define SQL_DIAG_DROP_TRANSLATION 33 +#define SQL_DIAG_DROP_VIEW 36 +#define SQL_DIAG_DYNAMIC_DELETE_CURSOR 38 +#define SQL_DIAG_DYNAMIC_FUNCTION 7 +#define SQL_DIAG_DYNAMIC_FUNCTION_CODE 12 +#define SQL_DIAG_DYNAMIC_UPDATE_CURSOR 81 +#define SQL_DIAG_GRANT 48 +#define SQL_DIAG_INSERT 50 +#define SQL_DIAG_MESSAGE_TEXT 6 +#define SQL_DIAG_NATIVE 5 +#define SQL_DIAG_NUMBER 2 +#define SQL_DIAG_RETURNCODE 1 +#define SQL_DIAG_REVOKE 59 +#define SQL_DIAG_ROW_COUNT 3 +#define SQL_DIAG_SELECT_CURSOR 85 +#define SQL_DIAG_SERVER_NAME 11 +#define SQL_DIAG_SQLSTATE 4 +#define SQL_DIAG_SUBCLASS_ORIGIN 9 +#define SQL_DIAG_UNKNOWN_STATEMENT 0 +#define SQL_DIAG_UPDATE_WHERE 82 +#define SQL_FALSE 0 +#define SQL_HANDLE_DBC 2 +#define SQL_HANDLE_DESC 4 +#define SQL_HANDLE_ENV 1 +#define SQL_HANDLE_STMT 3 +#define SQL_INSENSITIVE 1 +#define SQL_MAX_CONCURRENT_ACTIVITIES 1 +#define SQL_MAX_DRIVER_CONNECTIONS 0 +#define SQL_MAX_IDENTIFIER_LEN 10005 +#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES SQL_MAX_CONCURRENT_ACTIVITIES +#define SQL_MAXIMUM_DRIVER_CONNECTIONS SQL_MAX_DRIVER_CONNECTIONS +#define SQL_MAXIMUM_IDENTIFIER_LENGTH SQL_MAX_IDENTIFIER_LEN +#define SQL_NAMED 0 +#define SQL_NO_DATA 100 +#define SQL_NONSCROLLABLE 0 +#define SQL_NULL_HANDLE 0L +#define SQL_NULL_HDESC 0 +#define SQL_OJ_CAPABILITIES 115 +#define SQL_OUTER_JOIN_CAPABILITIES SQL_OJ_CAPABILITIES +#define SQL_PC_NON_PSEUDO 1 +#define SQL_PRED_BASIC 2 +#define SQL_PRED_CHAR 1 +#define SQL_PRED_NONE 0 +#define SQL_ROW_IDENTIFIER 1 +#define SQL_SCROLLABLE 1 +#define SQL_SENSITIVE 2 +#define SQL_TIME_LEN 8 +#define SQL_TIMESTAMP_LEN 19 +#define SQL_TRUE 1 +#define SQL_TYPE_DATE 91 +#define SQL_TYPE_TIME 92 +#define SQL_TYPE_TIMESTAMP 93 +#define SQL_UNNAMED 1 +#define SQL_UNSPECIFIED 0 +#define SQL_XOPEN_CLI_YEAR 10000 +#endif /* ODBCVER >= 0x0300 */ + +#ifndef RC_INVOKED +SQLRETURN SQL_API SQLAllocConnect(SQLHENV,SQLHDBC*); /* deprecated */ +SQLRETURN SQL_API SQLAllocEnv(SQLHENV*); /* deprecated */ +SQLRETURN SQL_API SQLAllocStmt(SQLHDBC,SQLHSTMT*); /* deprecated */ +SQLRETURN SQL_API SQLBindCol(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLCancel(SQLHSTMT); +SQLRETURN SQL_API SQLConnect(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDisconnect(SQLHDBC); +SQLRETURN SQL_API SQLError(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); /* deprecated */ +SQLRETURN SQL_API SQLExecDirect(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLExecute(SQLHSTMT); +SQLRETURN SQL_API SQLFetch(SQLHSTMT); +SQLRETURN SQL_API SQLFreeConnect(SQLHDBC); /* deprecated */ +SQLRETURN SQL_API SQLFreeEnv(SQLHENV); /* deprecated */ +SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT,SQLUSMALLINT); +SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT,SQLSMALLINT*); +SQLRETURN SQL_API SQLPrepare(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLRowCount(SQLHSTMT,SQLLEN*); +SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTransact(SQLHENV,SQLHDBC,SQLUSMALLINT); +SQLRETURN SQL_API SQLSetParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*); /* deprecated */ +SQLRETURN SQL_API SQLColumns(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC,SQLUSMALLINT,SQLPOINTER); /* deprecated */ +SQLRETURN SQL_API SQLGetData(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLGetFunctions(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*); +SQLRETURN SQL_API SQLGetInfo(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT,SQLUSMALLINT,SQLPOINTER); /* deprecated */ +SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLParamData(SQLHSTMT,SQLPOINTER*); +SQLRETURN SQL_API SQLPutData(SQLHSTMT,SQLPOINTER,SQLLEN); +SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC,SQLUSMALLINT,SQLULEN); /* deprecated */ +SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT,SQLUSMALLINT,SQLROWCOUNT); /* deprecated */ +SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatistics(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTables(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDataSources(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +SQLRETURN SQL_API SQLBindParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*); +SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT); +SQLRETURN SQL_API SQLColAttribute(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLCopyDesc(SQLHDESC,SQLHDESC); +SQLRETURN SQL_API SQLEndTran(SQLSMALLINT,SQLHANDLE,SQLSMALLINT); +SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT,SQLSMALLINT,SQLROWOFFSET); +SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT,SQLHANDLE); +SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescField(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescRec(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*, + SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescField(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescRec(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLLEN,SQLSMALLINT, + SQLSMALLINT,SQLPOINTER,SQLLEN*,SQLLEN*); +SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +#endif /* (ODBCVER >= 0x0300) */ +#endif /* ndef RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.24.orig/win32/include/sqltypes.h tcc-0.9.24/win32/include/sqltypes.h --- tcc-0.9.24.orig/win32/include/sqltypes.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/sqltypes.h 2007-07-22 16:04:55.000000000 +0200 @@ -0,0 +1,165 @@ +#ifndef _SQLTYPES_H +#define _SQLTYPES_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_API __stdcall +#ifndef RC_INVOKED +#define __need_wchar_t +#include +typedef signed char SCHAR; +typedef long SDWORD; +typedef short SWORD; +typedef ULONG UDWORD; +typedef USHORT UWORD; +typedef signed long SLONG; +typedef signed short SSHORT; +typedef double SDOUBLE; +typedef double LDOUBLE; +typedef float SFLOAT; +typedef PVOID PTR; +typedef PVOID HENV; +typedef PVOID HDBC; +typedef PVOID HSTMT; +typedef short RETCODE; +typedef UCHAR SQLCHAR; +typedef SCHAR SQLSCHAR; +typedef SDWORD SQLINTEGER; +typedef SWORD SQLSMALLINT; +#ifndef __WIN64 +typedef UDWORD SQLUINTEGER; +#endif +typedef UWORD SQLUSMALLINT; +typedef PVOID SQLPOINTER; +#if (ODBCVER >= 0x0300) +typedef void* SQLHANDLE; +typedef SQLHANDLE SQLHENV; +typedef SQLHANDLE SQLHDBC; +typedef SQLHANDLE SQLHSTMT; +typedef SQLHANDLE SQLHDESC; +#else +typedef void* SQLHENV; +typedef void* SQLHDBC; +typedef void* SQLHSTMT; +#endif +typedef SQLSMALLINT SQLRETURN; +typedef HWND SQLHWND; +typedef ULONG BOOKMARK; +#ifdef _WIN64 +typedef INT64 SQLLEN; +typedef INT64 SQLROWOFFSET; +typedef UINT64 SQLROWCOUNT; +typedef UINT64 SQLULEN; +typedef UINT64 SQLTRANSID; +typedef unsigned long SQLSETPOSIROW; +#else +#define SQLLEN SQLINTEGER +#define SQLROWOFFSET SQLINTEGER +#define SQLROWCOUNT SQLUINTEGER +#define SQLULEN SQLUINTEGER +#define SQLTRANSID DWORD +#define SQLSETPOSIROW SQLUSMALLINT +#endif +typedef wchar_t SQLWCHAR; +#ifdef UNICODE +typedef SQLWCHAR SQLTCHAR; +#else +typedef SQLCHAR SQLTCHAR; +#endif /* UNICODE */ +#if (ODBCVER >= 0x0300) +typedef unsigned char SQLDATE; +typedef unsigned char SQLDECIMAL; +typedef double SQLDOUBLE; +typedef double SQLFLOAT; +typedef unsigned char SQLNUMERIC; +typedef float SQLREAL; +typedef unsigned char SQLTIME; +typedef unsigned char SQLTIMESTAMP; +typedef unsigned char SQLVARCHAR; +#define ODBCINT64 __int64 +typedef __int64 SQLBIGINT; +typedef unsigned __int64 SQLUBIGINT; +#endif + +typedef struct tagDATE_STRUCT { + SQLSMALLINT year; + SQLUSMALLINT month; + SQLUSMALLINT day; +} DATE_STRUCT; +typedef struct tagTIME_STRUCT { + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; +} TIME_STRUCT; +typedef struct tagTIMESTAMP_STRUCT { + SQLSMALLINT year; + SQLUSMALLINT month; + SQLUSMALLINT day; + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; + SQLUINTEGER fraction; +} TIMESTAMP_STRUCT; +#if (ODBCVER >= 0x0300) +typedef DATE_STRUCT SQL_DATE_STRUCT; +typedef TIME_STRUCT SQL_TIME_STRUCT; +typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT; +typedef enum { + SQL_IS_YEAR = 1,SQL_IS_MONTH,SQL_IS_DAY,SQL_IS_HOUR, + SQL_IS_MINUTE,SQL_IS_SECOND,SQL_IS_YEAR_TO_MONTH,SQL_IS_DAY_TO_HOUR, + SQL_IS_DAY_TO_MINUTE,SQL_IS_DAY_TO_SECOND,SQL_IS_HOUR_TO_MINUTE, + SQL_IS_HOUR_TO_SECOND,SQL_IS_MINUTE_TO_SECOND +} SQLINTERVAL; +typedef struct tagSQL_YEAR_MONTH { + SQLUINTEGER year; + SQLUINTEGER month; +} SQL_YEAR_MONTH_STRUCT; +typedef struct tagSQL_DAY_SECOND { + SQLUINTEGER day; + SQLUINTEGER hour; + SQLUINTEGER minute; + SQLUINTEGER second; + SQLUINTEGER fraction; +} SQL_DAY_SECOND_STRUCT; +typedef struct tagSQL_INTERVAL_STRUCT { + SQLINTERVAL interval_type; + SQLSMALLINT interval_sign; + union { + SQL_YEAR_MONTH_STRUCT year_month; + SQL_DAY_SECOND_STRUCT day_second; + } intval; +} SQL_INTERVAL_STRUCT; +#define SQL_MAX_NUMERIC_LEN 16 +typedef struct tagSQL_NUMERIC_STRUCT { + SQLCHAR precision; + SQLSCHAR scale; + SQLCHAR sign; + SQLCHAR val[SQL_MAX_NUMERIC_LEN]; +} SQL_NUMERIC_STRUCT; +#endif /* ODBCVER >= 0x0300 */ +#if (ODBCVER >= 0x0350) + +#ifdef _GUID_DEFINED +# warning _GUID_DEFINED is deprecated, use GUID_DEFINED instead +#endif + +#if defined _GUID_DEFINED || defined GUID_DEFINED +typedef GUID SQLGUID; +#else +typedef struct tagSQLGUID{ + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[ 8 ]; +} SQLGUID; +#endif /* GUID_DEFINED */ +#endif /* ODBCVER >= 0x0350 */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.24.orig/win32/include/sqlucode.h tcc-0.9.24/win32/include/sqlucode.h --- tcc-0.9.24.orig/win32/include/sqlucode.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/sqlucode.h 2007-07-22 16:04:55.000000000 +0200 @@ -0,0 +1,142 @@ +#ifndef _SQLUCODE_H +#define _SQLUCODE_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#include +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_WCHAR (-8) +#define SQL_WVARCHAR (-9) +#define SQL_WLONGVARCHAR (-10) +#define SQL_C_WCHAR SQL_WCHAR +#define SQL_SQLSTATE_SIZEW 10 +#ifdef UNICODE +#define SQL_C_TCHAR SQL_C_WCHAR +#else +#define SQL_C_TCHAR SQL_C_CHAR +#endif +#ifndef RC_INVOKED +SQLRETURN SQL_API SQLBrowseConnectA(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLBrowseConnectW(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLColAttributeA(SQLHSTMT,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLColAttributesA(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*); +SQLRETURN SQL_API SQLColAttributesW(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*); +SQLRETURN SQL_API SQLColumnPrivilegesA( SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnPrivilegesW( SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLConnectA(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLConnectW(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDataSourcesA(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDataSourcesW(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDescribeColA(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDescribeColW(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDriverConnectA(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLDriverConnectW(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLDriversA(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDriversW(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLErrorA(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLErrorW(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLExecDirectA(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLForeignKeysA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLForeignKeysW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLGetConnectAttrA(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetConnectAttrW(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetConnectOptionA(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +SQLRETURN SQL_API SQLGetConnectOptionW(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +SQLRETURN SQL_API SQLGetCursorNameA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetCursorNameW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetInfoA(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetInfoW(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetTypeInfoA(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLGetTypeInfoW(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLNativeSqlA(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLNativeSqlW(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLPrepareA(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLPrepareW(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLPrimaryKeysA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLPrimaryKeysW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumnsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumnsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProceduresA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProceduresW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetConnectAttrA(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetConnectAttrW(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetConnectOptionA(SQLHDBC,SQLUSMALLINT,SQLULEN); +SQLRETURN SQL_API SQLSetConnectOptionW(SQLHDBC,SQLUSMALLINT,SQLULEN); +SQLRETURN SQL_API SQLSetCursorNameA(SQLHSTMT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetCursorNameW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSpecialColumnsA(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLSpecialColumnsW(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatisticsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatisticsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTablePrivilegesA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLTablesA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTablesW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLGetDescFieldA(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescFieldW(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetDescFieldA(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescFieldW(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLGetDescRecA(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDescRecW(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagFieldA(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagFieldW(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRecA(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRecW(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetStmtAttrA(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetStmtAttrW(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetStmtAttrA(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetStmtAttrW(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +#endif /* (ODBCVER >= 0x0300) */ + +#if defined (UNICODE) && !defined (SQL_NOUNICODEMAP) +#define SQLBrowseConnect SQLBrowseConnectW +#define SQLColAttribute SQLColAttributeW +#define SQLColAttributes SQLColAttributesW +#define SQLColumnPrivileges SQLColumnPrivilegesW +#define SQLColumns SQLColumnsW +#define SQLConnect SQLConnectW +#define SQLDataSources SQLDataSourcesW +#define SQLDescribeCol SQLDescribeColW +#define SQLDriverConnect SQLDriverConnectW +#define SQLDrivers SQLDriversW +#define SQLError SQLErrorW +#define SQLExecDirect SQLExecDirectW +#define SQLForeignKeys SQLForeignKeysW +#define SQLGetConnectAttr SQLGetConnectAttrW +#define SQLGetConnectOption SQLGetConnectOptionW +#define SQLGetCursorName SQLGetCursorNameW +#define SQLGetDescField SQLGetDescFieldW +#define SQLGetDescRec SQLGetDescRecW +#define SQLGetDiagField SQLGetDiagFieldW +#define SQLGetDiagRec SQLGetDiagRecW +#define SQLGetInfo SQLGetInfoW +#define SQLGetStmtAttr SQLGetStmtAttrW +#define SQLGetTypeInfo SQLGetTypeInfoW +#define SQLNativeSql SQLNativeSqlW +#define SQLPrepare SQLPrepareW +#define SQLPrimaryKeys SQLPrimaryKeysW +#define SQLProcedureColumns SQLProcedureColumnsW +#define SQLProcedures SQLProceduresW +#define SQLSetConnectAttr SQLSetConnectAttrW +#define SQLSetConnectOption SQLSetConnectOptionW +#define SQLSetCursorName SQLSetCursorNameW +#define SQLSetDescField SQLSetDescFieldW +#define SQLSetStmtAttr SQLSetStmtAttrW +#define SQLSpecialColumns SQLSpecialColumnsW +#define SQLStatistics SQLStatisticsW +#define SQLTablePrivileges SQLTablePrivilegesW +#define SQLTables SQLTablesW +#endif /* UNICODE && ! SQL_NOUNICODEMAP */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif /* __cplusplus*/ +#endif /* ndef _SQLUCODE_H */ diff -Nur tcc-0.9.24.orig/win32/include/winapi/basetsd.h tcc-0.9.24/win32/include/winapi/basetsd.h --- tcc-0.9.24.orig/win32/include/winapi/basetsd.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/win32/include/winapi/basetsd.h 2008-08-24 07:30:07.000000000 +0200 @@ -4,7 +4,7 @@ #pragma GCC system_header #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #ifndef __int64 #define __int64 long long #endif diff -Nur tcc-0.9.24.orig/win32/include/winapi/basetyps.h tcc-0.9.24/win32/include/winapi/basetyps.h --- tcc-0.9.24.orig/win32/include/winapi/basetyps.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/win32/include/winapi/basetyps.h 2008-08-24 07:30:07.000000000 +0200 @@ -124,7 +124,7 @@ #ifndef GUID_SECTION #define GUID_SECTION ".text" #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define GUID_SECT __attribute__ ((section (GUID_SECTION))) #else #define GUID_SECT diff -Nur tcc-0.9.24.orig/win32/include/winapi/mswsock.h tcc-0.9.24/win32/include/winapi/mswsock.h --- tcc-0.9.24.orig/win32/include/winapi/mswsock.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/winapi/mswsock.h 2008-08-24 07:30:07.000000000 +0200 @@ -0,0 +1,113 @@ +/* + * mswsock.h + * MS-specific extensions to Windows Sockets, exported from mswsock.dll. + * These functions are N/A on Windows9x. + * + * This file is part of a free library for the Win32 API. + * This library 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. + */ + +#ifndef _MSWSOCK_H +#define _MSWSOCK_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif +#ifdef __cplusplus +extern "C" { +#endif + +#define SO_CONNDATA 0x7000 +#define SO_CONNOPT 0x7001 +#define SO_DISCDATA 0x7002 +#define SO_DISCOPT 0x7003 +#define SO_CONNDATALEN 0x7004 +#define SO_CONNOPTLEN 0x7005 +#define SO_DISCDATALEN 0x7006 +#define SO_DISCOPTLEN 0x7007 +#define SO_OPENTYPE 0x7008 +#define SO_SYNCHRONOUS_ALERT 0x10 +#define SO_SYNCHRONOUS_NONALERT 0x20 +#define SO_MAXDG 0x7009 +#define SO_MAXPATHDG 0x700A +#define SO_UPDATE_ACCEPT_CONTEXT 0x700B +#define SO_CONNECT_TIME 0x700C +#define TCP_BSDURGENT 0x7000 + +#define TF_DISCONNECT 1 +#define TF_REUSE_SOCKET 2 +#define TF_WRITE_BEHIND 4 +#define TF_USE_DEFAULT_WORKER 0 +#define TF_USE_SYSTEM_THREAD 16 +#define TF_USE_KERNEL_APC 32 + +typedef struct _TRANSMIT_FILE_BUFFERS { + PVOID Head; + DWORD HeadLength; + PVOID Tail; + DWORD TailLength; +} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS; + +int PASCAL WSARecvEx(SOCKET,char*,int,int*); +BOOL PASCAL TransmitFile(SOCKET,HANDLE,DWORD,DWORD,LPOVERLAPPED,LPTRANSMIT_FILE_BUFFERS,DWORD); +BOOL PASCAL AcceptEx(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED); +VOID PASCAL GetAcceptExSockaddrs(PVOID,DWORD,DWORD,DWORD,struct sockaddr**, LPINT, struct sockaddr**, LPINT); + +#ifdef _WINSOCK2_H /* These require the winsock2 interface. */ + +#define TP_ELEMENT_FILE 1 +#define TP_ELEMENT_MEMORY 2 +#define TP_ELEMENT_EOP 4 + +typedef struct _TRANSMIT_PACKETS_ELEMENT { + ULONG dwElFlags; + ULONG cLength; + _ANONYMOUS_UNION + union { + struct { + LARGE_INTEGER nFileOffset; + HANDLE hFile; + }; + PVOID pBuffer; + }; +} TRANSMIT_PACKETS_ELEMENT; + +typedef struct _WSAMSG { + LPSOCKADDR name; + INT namelen; + LPWSABUF lpBuffers; + DWORD dwBufferCount; + WSABUF Control; + DWORD dwFlags; +} WSAMSG, *PWSAMSG, *LPWSAMSG; + + +/* According to MSDN docs, the WSAMSG.Control buffer starts with a + cmsghdr header of the following form. See also RFC 2292. */ + +typedef struct wsacmsghdr { + UINT cmsg_len; + INT cmsg_level; + INT cmsg_type; + /* followed by UCHAR cmsg_data[]; */ +} WSACMSGHDR; + +/* TODO: Standard Posix.1g macros as per RFC 2292, with WSA_uglification. */ +#if 0 +#define WSA_CMSG_FIRSTHDR(mhdr) +#define WSA_CMSG_NXTHDR(mhdr, cmsg) +#define WSA_CMSG_SPACE(length) +#define WSA_CMSG_LEN(length) +#endif + +BOOL PASCAL DisconnectEx(SOCKET,LPOVERLAPPED,DWORD,DWORD); +int PASCAL WSARecvMsg(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE); + +#endif /* _WINSOCK2_H */ + +#ifdef __cplusplus +} +#endif +#endif /* _MSWSOCK_H */ + diff -Nur tcc-0.9.24.orig/win32/include/winapi/wincon.h tcc-0.9.24/win32/include/winapi/wincon.h --- tcc-0.9.24.orig/win32/include/winapi/wincon.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/win32/include/winapi/wincon.h 2008-08-24 07:30:07.000000000 +0200 @@ -92,7 +92,7 @@ } uChar; DWORD dwControlKeyState; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) /* gcc's alignment is not what win32 expects */ PACKED #endif diff -Nur tcc-0.9.24.orig/win32/include/winapi/windef.h tcc-0.9.24/win32/include/winapi/windef.h --- tcc-0.9.24.orig/win32/include/winapi/windef.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/win32/include/winapi/windef.h 2008-08-24 07:30:07.000000000 +0200 @@ -49,7 +49,7 @@ #define OPTIONAL #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define PACKED __attribute__((packed)) #ifndef _stdcall #define _stdcall __attribute__((stdcall)) @@ -92,7 +92,7 @@ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_EXPORT __declspec(dllexport) -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define DECLSPEC_NORETURN __declspec(noreturn) #define DECLARE_STDCALL_P( type ) __stdcall type #elif defined(__WATCOMC__) diff -Nur tcc-0.9.24.orig/win32/include/winapi/winnt.h tcc-0.9.24/win32/include/winapi/winnt.h --- tcc-0.9.24.orig/win32/include/winapi/winnt.h 2008-03-31 09:24:00.000000000 +0200 +++ tcc-0.9.24/win32/include/winapi/winnt.h 2008-08-24 07:30:07.000000000 +0200 @@ -118,7 +118,7 @@ typedef DWORD LCID; typedef PDWORD PLCID; typedef WORD LANGID; -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define _HAVE_INT64 #define _INTEGRAL_MAX_BITS 64 #undef __int64 @@ -2612,7 +2612,7 @@ typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX; #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__TINYC__) PVOID GetCurrentFiber(void); PVOID GetFiberData(void); diff -Nur tcc-0.9.24.orig/win32/include/winapi/winsock.h tcc-0.9.24/win32/include/winapi/winsock.h --- tcc-0.9.24.orig/win32/include/winapi/winsock.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/include/winapi/winsock.h 2008-08-24 07:30:07.000000000 +0200 @@ -0,0 +1,535 @@ +/* + + Definitions for winsock 1.1 + + Portions Copyright (c) 1980, 1983, 1988, 1993 + The Regents of the University of California. All rights reserved. + + Portions Copyright (c) 1993 by Digital Equipment Corporation. + */ + +#ifndef _WINSOCK_H +#define _WINSOCK_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#define _GNU_H_WINDOWS32_SOCKETS +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined ( _BSDTYPES_DEFINED ) +/* also defined in gmon.h and in cygwin's sys/types */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#define _BSDTYPES_DEFINED +#endif /* !defined _BSDTYPES_DEFINED */ +typedef u_int SOCKET; +#ifndef FD_SETSIZE +#define FD_SETSIZE 64 +#endif + +/* shutdown() how types */ +#define SD_RECEIVE 0x00 +#define SD_SEND 0x01 +#define SD_BOTH 0x02 + +#ifndef _SYS_TYPES_FD_SET +/* fd_set may have be defined by the newlib + * if __USE_W32_SOCKETS not defined. + */ +#ifdef fd_set +#undef fd_set +#endif +typedef struct fd_set { + u_int fd_count; + SOCKET fd_array[FD_SETSIZE]; +} fd_set; +int PASCAL __WSAFDIsSet(SOCKET,fd_set*); +#ifndef FD_CLR +#define FD_CLR(fd,set) do { u_int __i;\ +for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\ + if (((fd_set *)(set))->fd_array[__i] == (fd)) {\ + while (__i < ((fd_set *)(set))->fd_count-1) {\ + ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i+1];\ + __i++;\ + }\ + ((fd_set*)(set))->fd_count--;\ + break;\ + }\ +}\ +} while (0) +#endif +#ifndef FD_SET +#define FD_SET(fd, set) do { \ + if (((fd_set *)(set))->fd_count < FD_SETSIZE) \ + ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\ +}while (0) +#endif +#ifndef FD_ZERO +#define FD_ZERO(set) (((fd_set *)(set))->fd_count=0) +#endif +#ifndef FD_ISSET +#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set)) +#endif +#elif !defined(USE_SYS_TYPES_FD_SET) +#warning "fd_set and associated macros have been defined in sys/types. \ + This can cause runtime problems with W32 sockets" +#endif /* ndef _SYS_TYPES_FD_SET */ + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#ifndef _TIMEVAL_DEFINED /* also in sys/time.h */ +#define _TIMEVAL_DEFINED +struct timeval { + long tv_sec; + long tv_usec; +}; +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec != (uvp)->tv_sec) ? \ + ((tvp)->tv_sec cmp (uvp)->tv_sec) : \ + ((tvp)->tv_usec cmp (uvp)->tv_usec)) +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif /* _TIMEVAL_DEFINED */ +struct hostent { + char *h_name; + char **h_aliases; + short h_addrtype; + short h_length; + char **h_addr_list; +#define h_addr h_addr_list[0] +}; +struct linger { + u_short l_onoff; + u_short l_linger; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +#define IOCPARM_MASK 0x7f +#define IOC_VOID 0x20000000 +#define IOC_OUT 0x40000000 +#define IOC_IN 0x80000000 +#define IOC_INOUT (IOC_IN|IOC_OUT) + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#define FIONBIO _IOW('f', 126, u_long) +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define FIONREAD _IOR('f', 127, u_long) +#define FIOASYNC _IOW('f', 125, u_long) +#define SIOCSHIWAT _IOW('s', 0, u_long) +#define SIOCGHIWAT _IOR('s', 1, u_long) +#define SIOCSLOWAT _IOW('s', 2, u_long) +#define SIOCGLOWAT _IOR('s', 3, u_long) +#define SIOCATMARK _IOR('s', 7, u_long) + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +struct netent { + char * n_name; + char **n_aliases; + short n_addrtype; + u_long n_net; +}; +struct servent { + char *s_name; + char **s_aliases; + short s_port; + char *s_proto; +}; +struct protoent { + char *p_name; + char **p_aliases; + short p_proto; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define IPPROTO_IP 0 +#define IPPROTO_ICMP 1 +#define IPPROTO_IGMP 2 +#define IPPROTO_GGP 3 +#define IPPROTO_TCP 6 +#define IPPROTO_PUP 12 +#define IPPROTO_UDP 17 +#define IPPROTO_IDP 22 +#define IPPROTO_ND 77 +#define IPPROTO_RAW 255 +#define IPPROTO_MAX 256 +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_MTP 57 +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_EFSSERVER 520 +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_ROUTESERVER 520 +#define IPPORT_RESERVED 1024 +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 +struct in_addr { + union { + struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; + struct { u_short s_w1,s_w2; } S_un_w; + u_long S_addr; + } S_un; +#define s_addr S_un.S_addr +#define s_host S_un.S_un_b.s_b2 +#define s_net S_un.S_un_b.s_b1 +#define s_imp S_un.S_un_w.s_w2 +#define s_impno S_un.S_un_b.s_b4 +#define s_lh S_un.S_un_b.s_b3 +}; +#define IN_CLASSA(i) (((long)(i)&0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 +#define IN_CLASSB(i) (((long)(i)&0xc0000000)==0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 +#define IN_CLASSC(i) (((long)(i)&0xe0000000)==0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0xff +#define INADDR_ANY (u_long)0 +#define INADDR_LOOPBACK 0x7f000001 +#define INADDR_BROADCAST (u_long)0xffffffff +#define INADDR_NONE 0xffffffff +struct sockaddr_in { + short sin_family; + u_short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; +#define WSADESCRIPTION_LEN 256 +#define WSASYS_STATUS_LEN 128 +typedef struct WSAData { + WORD wVersion; + WORD wHighVersion; + char szDescription[WSADESCRIPTION_LEN+1]; + char szSystemStatus[WSASYS_STATUS_LEN+1]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char * lpVendorInfo; +} WSADATA; +typedef WSADATA *LPWSADATA; + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define IP_OPTIONS 1 +#define SO_DEBUG 1 +#define SO_ACCEPTCONN 2 +#define SO_REUSEADDR 4 +#define SO_KEEPALIVE 8 +#define SO_DONTROUTE 16 +#define SO_BROADCAST 32 +#define SO_USELOOPBACK 64 +#define SO_LINGER 128 +#define SO_OOBINLINE 256 +#define SO_DONTLINGER (u_int)(~SO_LINGER) +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_SNDLOWAT 0x1003 +#define SO_RCVLOWAT 0x1004 +#define SO_SNDTIMEO 0x1005 +#define SO_RCVTIMEO 0x1006 +#define SO_ERROR 0x1007 +#define SO_TYPE 0x1008 +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +/* + * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll). + * They will cause errors or unexpected results if used with the + * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h. + */ +#define IP_MULTICAST_IF 2 +#define IP_MULTICAST_TTL 3 +#define IP_MULTICAST_LOOP 4 +#define IP_ADD_MEMBERSHIP 5 +#define IP_DROP_MEMBERSHIP 6 + +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 +#define IP_MAX_MEMBERSHIPS 20 +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR (-1) +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 +#define SOCK_RDM 4 +#define SOCK_SEQPACKET 5 +#define TCP_NODELAY 0x0001 +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 2 +#define AF_IMPLINK 3 +#define AF_PUP 4 +#define AF_CHAOS 5 +#define AF_IPX 6 +#define AF_NS 6 +#define AF_ISO 7 +#define AF_OSI AF_ISO +#define AF_ECMA 8 +#define AF_DATAKIT 9 +#define AF_CCITT 10 +#define AF_SNA 11 +#define AF_DECnet 12 +#define AF_DLI 13 +#define AF_LAT 14 +#define AF_HYLINK 15 +#define AF_APPLETALK 16 +#define AF_NETBIOS 17 +#define AF_VOICEVIEW 18 +#define AF_FIREFOX 19 +#define AF_UNKNOWN1 20 +#define AF_BAN 21 +#define AF_ATM 22 +#define AF_INET6 23 +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define AF_MAX 24 +struct sockaddr { + u_short sa_family; + char sa_data[14]; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +struct sockproto { + u_short sp_family; + u_short sp_protocol; +}; +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_IPX AF_IPX +#define PF_ISO AF_ISO +#define PF_OSI AF_OSI +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_VOICEVIEW AF_VOICEVIEW +#define PF_FIREFOX AF_FIREFOX +#define PF_UNKNOWN1 AF_UNKNOWN1 +#define PF_BAN AF_BAN +#define PF_ATM AF_ATM +#define PF_INET6 AF_INET6 +#define PF_MAX AF_MAX +#define SOL_SOCKET 0xffff +#define SOMAXCONN 5 +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +#define MSG_MAXIOVLEN 16 +#define MSG_PARTIAL 0x8000 +#define MAXGETHOSTSTRUCT 1024 +#define FD_READ 1 +#define FD_WRITE 2 +#define FD_OOB 4 +#define FD_ACCEPT 8 +#define FD_CONNECT 16 +#define FD_CLOSE 32 +#ifndef WSABASEERR +#define WSABASEERR 10000 +#define WSAEINTR (WSABASEERR+4) +#define WSAEBADF (WSABASEERR+9) +#define WSAEACCES (WSABASEERR+13) +#define WSAEFAULT (WSABASEERR+14) +#define WSAEINVAL (WSABASEERR+22) +#define WSAEMFILE (WSABASEERR+24) +#define WSAEWOULDBLOCK (WSABASEERR+35) +#define WSAEINPROGRESS (WSABASEERR+36) +#define WSAEALREADY (WSABASEERR+37) +#define WSAENOTSOCK (WSABASEERR+38) +#define WSAEDESTADDRREQ (WSABASEERR+39) +#define WSAEMSGSIZE (WSABASEERR+40) +#define WSAEPROTOTYPE (WSABASEERR+41) +#define WSAENOPROTOOPT (WSABASEERR+42) +#define WSAEPROTONOSUPPORT (WSABASEERR+43) +#define WSAESOCKTNOSUPPORT (WSABASEERR+44) +#define WSAEOPNOTSUPP (WSABASEERR+45) +#define WSAEPFNOSUPPORT (WSABASEERR+46) +#define WSAEAFNOSUPPORT (WSABASEERR+47) +#define WSAEADDRINUSE (WSABASEERR+48) +#define WSAEADDRNOTAVAIL (WSABASEERR+49) +#define WSAENETDOWN (WSABASEERR+50) +#define WSAENETUNREACH (WSABASEERR+51) +#define WSAENETRESET (WSABASEERR+52) +#define WSAECONNABORTED (WSABASEERR+53) +#define WSAECONNRESET (WSABASEERR+54) +#define WSAENOBUFS (WSABASEERR+55) +#define WSAEISCONN (WSABASEERR+56) +#define WSAENOTCONN (WSABASEERR+57) +#define WSAESHUTDOWN (WSABASEERR+58) +#define WSAETOOMANYREFS (WSABASEERR+59) +#define WSAETIMEDOUT (WSABASEERR+60) +#define WSAECONNREFUSED (WSABASEERR+61) +#define WSAELOOP (WSABASEERR+62) +#define WSAENAMETOOLONG (WSABASEERR+63) +#define WSAEHOSTDOWN (WSABASEERR+64) +#define WSAEHOSTUNREACH (WSABASEERR+65) +#define WSAENOTEMPTY (WSABASEERR+66) +#define WSAEPROCLIM (WSABASEERR+67) +#define WSAEUSERS (WSABASEERR+68) +#define WSAEDQUOT (WSABASEERR+69) +#define WSAESTALE (WSABASEERR+70) +#define WSAEREMOTE (WSABASEERR+71) +#define WSAEDISCON (WSABASEERR+101) +#define WSASYSNOTREADY (WSABASEERR+91) +#define WSAVERNOTSUPPORTED (WSABASEERR+92) +#define WSANOTINITIALISED (WSABASEERR+93) +#define WSAHOST_NOT_FOUND (WSABASEERR+1001) +#define WSATRY_AGAIN (WSABASEERR+1002) +#define WSANO_RECOVERY (WSABASEERR+1003) +#define WSANO_DATA (WSABASEERR+1004) +#endif /* !WSABASEERR */ + +#define WSANO_ADDRESS WSANO_DATA +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define h_errno WSAGetLastError() +#define HOST_NOT_FOUND WSAHOST_NOT_FOUND +#define TRY_AGAIN WSATRY_AGAIN +#define NO_RECOVERY WSANO_RECOVERY +#define NO_DATA WSANO_DATA +#define NO_ADDRESS WSANO_ADDRESS +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +SOCKET PASCAL accept(SOCKET,struct sockaddr*,int*); +int PASCAL bind(SOCKET,const struct sockaddr*,int); +int PASCAL closesocket(SOCKET); +int PASCAL connect(SOCKET,const struct sockaddr*,int); +int PASCAL ioctlsocket(SOCKET,long,u_long *); +int PASCAL getpeername(SOCKET,struct sockaddr*,int*); +int PASCAL getsockname(SOCKET,struct sockaddr*,int*); +int PASCAL getsockopt(SOCKET,int,int,char*,int*); +unsigned long PASCAL inet_addr(const char*); +DECLARE_STDCALL_P(char *) inet_ntoa(struct in_addr); +int PASCAL listen(SOCKET,int); +int PASCAL recv(SOCKET,char*,int,int); +int PASCAL recvfrom(SOCKET,char*,int,int,struct sockaddr*,int*); +int PASCAL send(SOCKET,const char*,int,int); +int PASCAL sendto(SOCKET,const char*,int,int,const struct sockaddr*,int); +int PASCAL setsockopt(SOCKET,int,int,const char*,int); +int PASCAL shutdown(SOCKET,int); +SOCKET PASCAL socket(int,int,int); +DECLARE_STDCALL_P(struct hostent *) gethostbyaddr(const char*,int,int); +DECLARE_STDCALL_P(struct hostent *) gethostbyname(const char*); +DECLARE_STDCALL_P(struct servent *) getservbyport(int,const char*); +DECLARE_STDCALL_P(struct servent *) getservbyname(const char*,const char*); +DECLARE_STDCALL_P(struct protoent *) getprotobynumber(int); +DECLARE_STDCALL_P(struct protoent *) getprotobyname(const char*); +int PASCAL WSAStartup(WORD,LPWSADATA); +int PASCAL WSACleanup(void); +void PASCAL WSASetLastError(int); +int PASCAL WSAGetLastError(void); +BOOL PASCAL WSAIsBlocking(void); +int PASCAL WSAUnhookBlockingHook(void); +FARPROC PASCAL WSASetBlockingHook(FARPROC); +int PASCAL WSACancelBlockingCall(void); +HANDLE PASCAL WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int); +HANDLE PASCAL WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int); +int PASCAL WSACancelAsyncRequest(HANDLE); +int PASCAL WSAAsyncSelect(SOCKET,HWND,u_int,long); +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +u_long PASCAL htonl(u_long); +u_long PASCAL ntohl(u_long); +u_short PASCAL htons(u_short); +u_short PASCAL ntohs(u_short); +int PASCAL select(int nfds,fd_set*,fd_set*,fd_set*,const struct timeval*); +int PASCAL gethostname(char*,int); +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e) +#define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error) +#define WSAGETASYNCBUFLEN(l) LOWORD(l) +#define WSAGETASYNCERROR(l) HIWORD(l) +#define WSAGETSELECTEVENT(l) LOWORD(l) +#define WSAGETSELECTERROR(l) HIWORD(l) + +typedef struct sockaddr SOCKADDR; +typedef struct sockaddr *PSOCKADDR; +typedef struct sockaddr *LPSOCKADDR; +typedef struct sockaddr_in SOCKADDR_IN; +typedef struct sockaddr_in *PSOCKADDR_IN; +typedef struct sockaddr_in *LPSOCKADDR_IN; +typedef struct linger LINGER; +typedef struct linger *PLINGER; +typedef struct linger *LPLINGER; +typedef struct in_addr IN_ADDR; +typedef struct in_addr *PIN_ADDR; +typedef struct in_addr *LPIN_ADDR; +typedef struct fd_set FD_SET; +typedef struct fd_set *PFD_SET; +typedef struct fd_set *LPFD_SET; +typedef struct hostent HOSTENT; +typedef struct hostent *PHOSTENT; +typedef struct hostent *LPHOSTENT; +typedef struct servent SERVENT; +typedef struct servent *PSERVENT; +typedef struct servent *LPSERVENT; +typedef struct protoent PROTOENT; +typedef struct protoent *PPROTOENT; +typedef struct protoent *LPPROTOENT; +typedef struct timeval TIMEVAL; +typedef struct timeval *PTIMEVAL; +typedef struct timeval *LPTIMEVAL; + +#ifdef __cplusplus +} +#endif +/* + * Recent MSDN docs indicate that the MS-specific extensions exported from + * mswsock.dll (AcceptEx, TransmitFile. WSARecEx and GetAcceptExSockaddrs) are + * declared in mswsock.h. These extensions are not supported on W9x or WinCE. + * However, code using WinSock 1.1 API may expect the declarations and + * associated defines to be in this header. Thus we include mswsock.h here. + * + * When linking against the WinSock 1.1 lib, wsock32.dll, the mswsock functions + * are automatically routed to mswsock.dll (on platforms with support). + * The WinSock 2 lib, ws2_32.dll, does not contain any references to + * the mswsock extensions. + */ + +#include + +#endif diff -Nur tcc-0.9.24.orig/win32/lib/odbc32.def tcc-0.9.24/win32/lib/odbc32.def --- tcc-0.9.24.orig/win32/lib/odbc32.def 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/lib/odbc32.def 2008-08-24 07:37:40.000000000 +0200 @@ -0,0 +1,118 @@ +LIBRARY odbc32.dll + +EXPORTS +SQLAllocConnect +SQLAllocEnv +SQLAllocStmt +SQLBindCol +SQLCancel +SQLColAttributes +SQLConnect +SQLDescribeCol +SQLDisconnect +SQLError +SQLExecDirect +SQLExecute +SQLFetch +SQLFreeConnect +SQLFreeEnv +SQLFreeStmt +SQLGetCursorName +SQLNumResultCols +SQLPrepare +SQLRowCount +SQLSetCursorName +SQLSetParam +SQLTransact +SQLAllocHandle +SQLBindParam +SQLCloseCursor +SQLColAttribute +SQLCopyDesc +SQLEndTran +SQLFetchScroll +SQLFreeHandle +SQLGetConnectAttr +SQLGetDescField +SQLGetDescRec +SQLGetDiagField +SQLGetDiagRec +SQLGetEnvAttr +SQLGetStmtAttr +SQLSetConnectAttr +SQLColumns +SQLDriverConnect +SQLGetConnectOption +SQLGetData +SQLGetFunctions +SQLGetInfo +SQLGetStmtOption +SQLGetTypeInfo +SQLParamData +SQLPutData +SQLSetConnectOption +SQLSetStmtOption +SQLSpecialColumns +SQLStatistics +SQLTables +SQLBrowseConnect +SQLColumnPrivileges +SQLDataSources +SQLDescribeParam +SQLExtendedFetch +SQLForeignKeys +SQLMoreResults +SQLNativeSql +SQLNumParams +SQLParamOptions +SQLPrimaryKeys +SQLProcedureColumns +SQLProcedures +SQLSetPos +SQLSetScrollOptions +SQLTablePrivileges +SQLDrivers +SQLBindParameter +SQLSetDescField +SQLSetDescRec +SQLSetEnvAttr +SQLSetStmtAttr +SQLAllocHandleStd +SQLBulkOperations +SQLColAttributesW +SQLConnectW +SQLDescribeColW +SQLErrorW +SQLExecDirectW +SQLGetCursorNameW +SQLPrepareW +SQLSetCursorNameW +SQLColAttributeW +SQLGetConnectAttrW +SQLGetDescFieldW +SQLGetDescRecW +SQLGetDiagFieldW +SQLGetDiagRecW +SQLGetStmtAttrW +SQLSetConnectAttrW +SQLColumnsW +SQLDriverConnectW +SQLGetConnectOptionW +SQLGetInfoW +SQLGetTypeInfoW +SQLSetConnectOptionW +SQLSpecialColumnsW +SQLStatisticsW +SQLTablesW +SQLBrowseConnectW +SQLColumnPrivilegesW +SQLDataSourcesW +SQLForeignKeysW +SQLNativeSqlW +SQLPrimaryKeysW +SQLProcedureColumnsW +SQLProceduresW +SQLTablePrivilegesW +SQLDriversW +SQLSetDescFieldW +SQLSetStmtAttrW diff -Nur tcc-0.9.24.orig/win32/lib/wsock32.def tcc-0.9.24/win32/lib/wsock32.def --- tcc-0.9.24.orig/win32/lib/wsock32.def 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.24/win32/lib/wsock32.def 2008-08-20 16:50:53.000000000 +0200 @@ -0,0 +1,76 @@ +LIBRARY wsock32.dll + +EXPORTS +AcceptEx +EnumProtocolsA +EnumProtocolsW +GetAcceptExSockaddrs +GetAddressByNameA +GetAddressByNameW +GetNameByTypeA +GetNameByTypeW +GetServiceA +GetServiceW +GetTypeByNameA +GetTypeByNameW +NPLoadNameSpaces +SetServiceA +SetServiceW +TransmitFile +WSAAsyncGetHostByAddr +WSAAsyncGetHostByName +WSAAsyncGetProtoByName +WSAAsyncGetProtoByNumber +WSAAsyncGetServByName +WSAAsyncGetServByPort +WSAAsyncSelect +WSACancelAsyncRequest +WSACancelBlockingCall +WSACleanup +WSAGetLastError +WSAIsBlocking +WSARecvEx +WSASetBlockingHook +WSASetLastError +WSAStartup +WSAUnhookBlockingHook +WSApSetPostRoutine +__WSAFDIsSet +accept +bind +closesocket +connect +dn_expand +gethostbyaddr +gethostbyname +gethostname +getnetbyname +getpeername +getprotobyname +getprotobynumber +getservbyname +getservbyport +getsockname +getsockopt +htonl +htons +inet_addr +inet_network +inet_ntoa +ioctlsocket +listen +ntohl +ntohs +rcmd +recv +recvfrom +rexec +rresvport +s_perror +select +send +sendto +sethostname +setsockopt +shutdown +socket ./sqliteodbc-0.992/tcc-0.9.25.patch0100644000076400001440000035643612110103173015061 0ustar chwusersdiff -Nur tcc-0.9.25.orig/configure tcc-0.9.25/configure --- tcc-0.9.25.orig/configure 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/configure 2011-06-07 08:01:41.000000000 +0200 @@ -124,7 +124,7 @@ ;; --enable-gprof) gprof="yes" ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" + --enable-mingw32) mingw32="yes" ; cross_prefix="x86_64-w64-mingw32-" ;; --enable-cross) build_cross="yes" ;; diff -Nur tcc-0.9.25.orig/cross-configure.sh tcc-0.9.25/cross-configure.sh --- tcc-0.9.25.orig/cross-configure.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/cross-configure.sh 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh + +CONFIG_SHELL=/bin/sh +export CONFIG_SHELL +PREFIX=/opt/mingw64 +TARGET=x86_64-w64-mingw32 +PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" +export PATH +cache=cross-config.cache +sh configure --cache-file="$cache" \ + --target=$TARGET --host=$TARGET --build=i386-linux \ + "$@" +status=$? +rm -f "$cache" +exit $status diff -Nur tcc-0.9.25.orig/cross-make.sh tcc-0.9.25/cross-make.sh --- tcc-0.9.25.orig/cross-make.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/cross-make.sh 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,7 @@ +#!/bin/sh + +PREFIX=/opt/mingw64 +TARGET=x86_64-w64-mingw32 +PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH" +export PATH +exec make "$@" diff -Nur tcc-0.9.25.orig/libtcc.c tcc-0.9.25/libtcc.c --- tcc-0.9.25.orig/libtcc.c 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/libtcc.c 2011-06-07 08:25:05.000000000 +0200 @@ -395,6 +395,15 @@ *p = 0; tcc_set_lib_path(s, path); } + +void tcc_set_lib_path_mod(TCCState *s, void *module_handle) +{ + char path[1024], *p; + GetModuleFileNameA(module_handle, path, sizeof path); + p = tcc_basename(normalize_slashes(strlwr(path))); + if (p) *p = 0; + tcc_set_lib_path(s, path); +} #endif void set_pages_executable(void *ptr, unsigned long length) diff -Nur tcc-0.9.25.orig/libtcc.h tcc-0.9.25/libtcc.h --- tcc-0.9.25.orig/libtcc.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/libtcc.h 2011-06-07 08:25:22.000000000 +0200 @@ -18,6 +18,11 @@ /* create a new TCC compilation context */ LIBTCCAPI TCCState *tcc_new(void); +#ifdef _WIN32 +/* when libtcc linked to DLL, use this from DllMain() */ +void tcc_set_lib_path_mod(TCCState *s, void *module_handle); +#endif + /* free a TCC compilation context */ LIBTCCAPI void tcc_delete(TCCState *s); diff -Nur tcc-0.9.25.orig/Makefile tcc-0.9.25/Makefile --- tcc-0.9.25.orig/Makefile 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/Makefile 2011-06-07 08:19:53.000000000 +0200 @@ -172,7 +172,7 @@ ifdef CONFIG_WIN32 # for windows, we must use TCC because we generate ELF objects LIBTCC1_OBJS+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o -LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE +LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE -DWIN32 VPATH+=win32/lib endif ifeq ($(ARCH),i386) @@ -197,48 +197,48 @@ ifndef CONFIG_WIN32 install: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc.1 tcc-doc.html - mkdir -p "$(bindir)" - $(INSTALL) -s -m755 $(PROGS) "$(bindir)" - mkdir -p "$(mandir)/man1" - $(INSTALL) tcc.1 "$(mandir)/man1" - mkdir -p "$(tccdir)" - mkdir -p "$(tccdir)/include" + mkdir -p "$(DESTDIR)/$(bindir)" + $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)/$(bindir)" + mkdir -p "$(DESTDIR)/$(mandir)/man1" + $(INSTALL) tcc.1 "$(DESTDIR)/$(mandir)/man1" + mkdir -p "$(DESTDIR)/$(tccdir)" + mkdir -p "$(DESTDIR)/$(tccdir)/include" ifneq ($(LIBTCC1),) - $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)" + $(INSTALL) -m644 $(LIBTCC1) "$(DESTDIR)/$(tccdir)" endif ifneq ($(BCHECK_O),) - $(INSTALL) -m644 $(BCHECK_O) "$(tccdir)" + $(INSTALL) -m644 $(BCHECK_O) "$(DESTDIR)/$(tccdir)" endif - $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include" - mkdir -p "$(docdir)" - $(INSTALL) -m644 tcc-doc.html "$(docdir)" - mkdir -p "$(libdir)" - $(INSTALL) -m644 libtcc.a "$(libdir)" - mkdir -p "$(includedir)" - $(INSTALL) -m644 libtcc.h "$(includedir)" + $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(DESTDIR)/$(tccdir)/include" + mkdir -p "$(DESTDIR)/$(docdir)" + $(INSTALL) -m644 tcc-doc.html "$(DESTDIR)/$(docdir)" + mkdir -p "$(DESTDIR)/$(libdir)" + $(INSTALL) -m644 libtcc.a "$(DESTDIR)/$(libdir)" + mkdir -p "$(DESTDIR)/$(includedir)" + $(INSTALL) -m644 libtcc.h "$(DESTDIR)/$(includedir)" uninstall: - rm -fv $(foreach P,$(PROGS),"$(bindir)/$P") - rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(tccdir)/$P") - rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P") - rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" - rm -fv "$(libdir)/libtcc.a" "$(includedir)/libtcc.h" + rm -fv $(foreach P,$(PROGS),"$(DESTDIR)/$(bindir)/$P") + rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(DESTDIR)/$(tccdir)/$P") + rm -fv $(foreach P,$(TCC_INCLUDES),"$(DESTDIR)/$(tccdir)/include/$P") + rm -fv "$(docdir)/tcc-doc.html" "$(DESTDIR)/$(mandir)/man1/tcc.1" + rm -fv "$(libdir)/libtcc.a" "$(DESTDIR)/$(includedir)/libtcc.h" else install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html - mkdir -p "$(tccdir)" - mkdir -p "$(tccdir)/lib" - mkdir -p "$(tccdir)/include" - mkdir -p "$(tccdir)/examples" - mkdir -p "$(tccdir)/doc" - mkdir -p "$(tccdir)/libtcc" - $(INSTALL) -s -m755 $(PROGS) "$(tccdir)" - $(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib" - cp -r win32/include/. "$(tccdir)/include" - cp -r win32/examples/. "$(tccdir)/examples" -# $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include" - $(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc" - $(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc" + mkdir -p "$(DESTDIR)/$(tccdir)" + mkdir -p "$(DESTDIR)/$(tccdir)/lib" + mkdir -p "$(DESTDIR)/$(tccdir)/include" + mkdir -p "$(DESTDIR)/$(tccdir)/examples" + mkdir -p "$(DESTDIR)/$(tccdir)/doc" + mkdir -p "$(DESTDIR)/$(tccdir)/libtcc" + $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)/$(tccdir)" + $(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(DESTDIR)/$(tccdir)/lib" + cp -r win32/include/. "$(DESTDIR)/$(tccdir)/include" + cp -r win32/examples/. "$(DESTDIR)/$(tccdir)/examples" +# $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(DESTDIR)/$(tccdir)/include" + $(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(DESTDIR)/$(tccdir)/doc" + $(INSTALL) -m644 libtcc.a libtcc.h "$(DESTDIR)/$(tccdir)/libtcc" endif # documentation and man page diff -Nur tcc-0.9.25.orig/mingw-cross-build.sh tcc-0.9.25/mingw-cross-build.sh --- tcc-0.9.25.orig/mingw-cross-build.sh 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/mingw-cross-build.sh 2012-01-21 08:01:41.000000000 +0200 @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Build script for cross compiling TCC for Win32 +# for integration into SQLite ODBC driver. +# Tested on Fedora Core 3 and 5. +# +# Cross toolchain and NSIS for Linux/i386/x86_64 can be fetched from +# http://www.ch-werner.de/xtools/crossmingw64-0.3-1.i386.rpm +# http://www.ch-werner.de/xtools/crossmingw64-0.3.i386.tar.bz2 +# http://www.ch-werner.de/xtools/crossmingw64-0.3-1.x86_64.rpm +# http://www.ch-werner.de/xtools/crossmingw64-0.3.x86_64.tar.bz2 +# http://www.ch-werner.de/xtools/nsis-2.37-1.i386.rpm + +set -e + +rm -rf ../TCC +sh cross-configure.sh --prefix=/TCC --enable-mingw32 --extra-cflags="-m32 -march=i386 -mtune=i386" +sh cross-make.sh clean all +sh cross-make.sh DESTDIR=.. install +sh cross-make.sh distclean diff -Nur tcc-0.9.25.orig/tccgen.c tcc-0.9.25/tccgen.c --- tcc-0.9.25.orig/tccgen.c 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/tccgen.c 2011-06-07 08:05:26.000000000 +0200 @@ -207,7 +207,7 @@ #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) /* x86 specific: need to pop fp register ST0 if saved */ if (r == TREG_ST0) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(1) */ } #endif #ifndef TCC_TARGET_X86_64 @@ -686,7 +686,7 @@ #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) /* for x86, we need to pop the FP stack */ if (v == TREG_ST0 && !nocode_wanted) { - o(0xd9dd); /* fstp %st(1) */ + o(0xd8dd); /* fstp %st(1) */ } else #endif if (v == VT_JMP || v == VT_JMPI) { --- tcc-0.9.25.orig/tccpp.c 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/tccpp.c 2012-01-22 14:58:50.000000000 +0100 @@ -129,7 +129,11 @@ case TOK_CLLONG: case TOK_CULLONG: /* XXX: not quite exact, but only useful for testing */ - sprintf(p, "%Lu", cv->ull); +#if defined(_WIN32) || defined(_WIN64) + sprintf(p, "%I64u", cv->ull); +#else + sprintf(p, "%llu", cv->ull); +#endif break; case TOK_LCHAR: cstr_ccat(&cstr_buf, 'L'); diff -Nur tcc-0.9.25.orig/win32/include/odbcinst.h tcc-0.9.25/win32/include/odbcinst.h --- tcc-0.9.25.orig/win32/include/odbcinst.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/odbcinst.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,148 @@ +#ifndef _ODBCINST_H +#define _ODBCINST_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif +#ifndef ODBCVER +#define ODBCVER 0x0351 +#endif +#define INSTAPI __stdcall +#define ODBC_ADD_DSN 1 +#define ODBC_CONFIG_DSN 2 +#define ODBC_REMOVE_DSN 3 +#if (ODBCVER >= 0x0250) +#define ODBC_ADD_SYS_DSN 4 +#define ODBC_CONFIG_SYS_DSN 5 +#define ODBC_REMOVE_SYS_DSN 6 +#define ODBC_INSTALL_INQUIRY 1 +#define ODBC_INSTALL_COMPLETE 2 +#define ODBC_INSTALL_DRIVER 1 +#define ODBC_REMOVE_DRIVER 2 +#define ODBC_CONFIG_DRIVER 3 +#define ODBC_CONFIG_DRIVER_MAX 100 +#endif /* (ODBCVER >= 0x0250) */ +#if (ODBCVER >= 0x0300) +#define ODBC_REMOVE_DEFAULT_DSN 7 +#define ODBC_BOTH_DSN 0 +#define ODBC_USER_DSN 1 +#define ODBC_SYSTEM_DSN 2 +#define ODBC_ERROR_GENERAL_ERR 1 +#define ODBC_ERROR_INVALID_BUFF_LEN 2 +#define ODBC_ERROR_INVALID_HWND 3 +#define ODBC_ERROR_INVALID_STR 4 +#define ODBC_ERROR_INVALID_REQUEST_TYPE 5 +#define ODBC_ERROR_COMPONENT_NOT_FOUND 6 +#define ODBC_ERROR_INVALID_NAME 7 +#define ODBC_ERROR_INVALID_KEYWORD_VALUE 8 +#define ODBC_ERROR_INVALID_DSN 9 +#define ODBC_ERROR_INVALID_INF 10 +#define ODBC_ERROR_REQUEST_FAILED 11 +#define ODBC_ERROR_INVALID_PATH 12 +#define ODBC_ERROR_LOAD_LIB_FAILED 13 +#define ODBC_ERROR_INVALID_PARAM_SEQUENCE 14 +#define ODBC_ERROR_INVALID_LOG_FILE 15 +#define ODBC_ERROR_USER_CANCELED 16 +#define ODBC_ERROR_USAGE_UPDATE_FAILED 17 +#define ODBC_ERROR_CREATE_DSN_FAILED 18 +#define ODBC_ERROR_WRITING_SYSINFO_FAILED 19 +#define ODBC_ERROR_REMOVE_DSN_FAILED 20 +#define ODBC_ERROR_OUT_OF_MEM 21 +#define ODBC_ERROR_OUTPUT_STRING_TRUNCATED 22 +#endif /* ODBCVER >= 0x0300 */ + +#ifndef RC_INVOKED +BOOL INSTAPI ConfigDSN(HWND,WORD,LPCSTR,LPCSTR); +BOOL INSTAPI ConfigDSNW(HWND,WORD,LPCWSTR,LPCWSTR); +BOOL INSTAPI ConfigTranslator(HWND,DWORD*); +BOOL INSTAPI SQLConfigDataSource(HWND,WORD,LPCSTR,LPCSTR); +BOOL INSTAPI SQLConfigDataSourceW(HWND,WORD,LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLCreateDataSource(HWND,LPCSTR); +BOOL INSTAPI SQLCreateDataSourceW(HWND,LPCWSTR); +BOOL INSTAPI SQLGetAvailableDrivers(LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLGetAvailableDriversW(LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLGetInstalledDrivers(LPSTR,WORD,WORD*); +BOOL INSTAPI SQLGetInstalledDriversW(LPWSTR,WORD,WORD*); +int INSTAPI SQLGetPrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,int,LPCSTR); +int INSTAPI SQLGetPrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int,LPCWSTR); +BOOL INSTAPI SQLGetTranslator(HWND,LPSTR,WORD,WORD*,LPSTR,WORD,WORD*,DWORD*); +BOOL INSTAPI SQLGetTranslatorW(HWND,LPWSTR,WORD,WORD*,LPWSTR,WORD,WORD*,DWORD*); +BOOL INSTAPI SQLInstallDriver(LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverManager(LPSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverManagerW(LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallDriverW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallODBC(HWND,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLInstallODBCW(HWND,LPCWSTR,LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLManageDataSources(HWND); +BOOL INSTAPI SQLRemoveDefaultDataSource(void); +BOOL INSTAPI SQLRemoveDSNFromIni(LPCSTR); +BOOL INSTAPI SQLRemoveDSNFromIniW(LPCWSTR); +BOOL INSTAPI SQLValidDSN(LPCSTR); +BOOL INSTAPI SQLValidDSNW(LPCWSTR); +BOOL INSTAPI SQLWriteDSNToIni(LPCSTR,LPCSTR); +BOOL INSTAPI SQLWriteDSNToIniW(LPCWSTR,LPCWSTR); +BOOL INSTAPI SQLWritePrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLWritePrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR); +#if(ODBCVER >= 0x0250) +BOOL INSTAPI ConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI ConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallTranslator(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallTranslatorW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLRemoveDriver(LPCSTR,BOOL,LPDWORD); +BOOL INSTAPI SQLRemoveDriverManager(LPDWORD); +BOOL INSTAPI SQLRemoveDriverW(LPCWSTR,BOOL,LPDWORD); +BOOL INSTAPI SQLRemoveTranslator(LPCSTR,LPDWORD); +BOOL INSTAPI SQLRemoveTranslatorW(LPCWSTR,LPDWORD); +#endif /* ODBCVER >= 0x0250 */ +#if (ODBCVER >= 0x0300) +BOOL INSTAPI SQLGetConfigMode(UWORD*); +BOOL INSTAPI SQLInstallDriverEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallDriverExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +SQLRETURN INSTAPI SQLInstallerError(WORD,DWORD*,LPSTR,WORD,WORD*); +SQLRETURN INSTAPI SQLInstallerErrorW(WORD,DWORD*,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLInstallTranslatorEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD); +BOOL INSTAPI SQLInstallTranslatorExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD); +SQLRETURN INSTAPI SQLPostInstallerError(DWORD,LPCSTR); +SQLRETURN INSTAPI SQLPostInstallerErrorW(DWORD,LPCWSTR); +BOOL INSTAPI SQLReadFileDSN(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*); +BOOL INSTAPI SQLReadFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*); +BOOL INSTAPI SQLSetConfigMode(UWORD); +BOOL INSTAPI SQLWriteFileDSN(LPCSTR,LPCSTR,LPCSTR,LPCSTR); +BOOL INSTAPI SQLWriteFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR); +#endif /* ODBCVER >= 0x0300 */ + +#if defined (UNICODE) && !defined (SQL_NOUNICODEMAP) +#define SQLConfigDataSource SQLConfigDataSourceW +#define SQLConfigDriver SQLConfigDriverW +#define SQLCreateDataSource SQLCreateDataSourceW +#define SQLGetAvailableDrivers SQLGetAvailableDriversW +#define SQLGetInstalledDrivers SQLGetInstalledDriversW +#define SQLGetPrivateProfileString SQLGetPrivateProfileStringW +#define SQLGetTranslator SQLGetTranslatorW +#define SQLInstallDriver SQLInstallDriverW +#define SQLInstallDriverEx SQLInstallDriverExW +#define SQLInstallDriverManager SQLInstallDriverManagerW +#define SQLInstallerError SQLInstallerErrorW +#define SQLInstallODBC SQLInstallODBCW +#define SQLInstallTranslator SQLInstallTranslatorW +#define SQLInstallTranslatorEx SQLInstallTranslatorExW +#define SQLPostInstallerError SQLPostInstallerErrorW +#define SQLReadFileDSN SQLReadFileDSNW +#define SQLRemoveDriver SQLRemoveDriverW +#define SQLRemoveDSNFromIni SQLRemoveDSNFromIniW +#define SQLRemoveTranslator SQLRemoveTranslatorW +#define SQLValidDSN SQLValidDSNW +#define SQLWriteDSNToIni SQLWriteDSNToIniW +#define SQLWriteFileDSN SQLWriteFileDSNW +#define SQLWritePrivateProfileString SQLWritePrivateProfileStringW +#endif /* UNICODE && !SQL_NOUNICODEMAP */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif /* _ODBCINST_H */ diff -Nur tcc-0.9.25.orig/win32/include/sqlext.h tcc-0.9.25/win32/include/sqlext.h --- tcc-0.9.25.orig/win32/include/sqlext.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/sqlext.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,1218 @@ +#ifndef _SQLEXT_H +#define _SQLEXT_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#include +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_SPEC_MAJOR 3 +#define SQL_SPEC_MINOR 51 +#define SQL_SPEC_STRING "03.51" +#define SQL_ACCESS_MODE 101 +#define SQL_ACTIVE_CONNECTIONS 0 +#define SQL_ACTIVE_STATEMENTS 1 +#define SQL_ADD 4 +#define SQL_ALL_EXCEPT_LIKE 2 +#define SQL_API_ALL_FUNCTIONS 0 +#define SQL_API_LOADBYORDINAL 199 +#define SQL_API_SQLBINDPARAMETER 72 +#define SQL_API_SQLBROWSECONNECT 55 +#define SQL_API_SQLCOLATTRIBUTES 6 +#define SQL_API_SQLCOLUMNPRIVILEGES 56 +#define SQL_API_SQLDESCRIBEPARAM 58 +#define SQL_API_SQLDRIVERCONNECT 41 +#define SQL_API_SQLDRIVERS 71 +#define SQL_API_SQLEXTENDEDFETCH 59 +#define SQL_API_SQLFOREIGNKEYS 60 +#define SQL_API_SQLMORERESULTS 61 +#define SQL_API_SQLNATIVESQL 62 +#define SQL_API_SQLNUMPARAMS 63 +#define SQL_API_SQLPARAMOPTIONS 64 +#define SQL_API_SQLPRIMARYKEYS 65 +#define SQL_API_SQLPROCEDURECOLUMNS 66 +#define SQL_API_SQLPROCEDURES 67 +#define SQL_API_SQLSETPOS 68 +#define SQL_API_SQLSETSCROLLOPTIONS 69 +#define SQL_API_SQLTABLEPRIVILEGES 70 +#define SQL_ASYNC_ENABLE 4 +#define SQL_ASYNC_ENABLE_DEFAULT SQL_ASYNC_ENABLE_OFF +#define SQL_ASYNC_ENABLE_OFF 0UL +#define SQL_ASYNC_ENABLE_ON 1UL +#define SQL_ATTR_CONNECTION_DEAD 1209 +#define SQL_ATTR_READONLY 0 +#define SQL_ATTR_READWRITE_UNKNOWN 2 +#define SQL_ATTR_WRITE 1 +#define SQL_AUTOCOMMIT 102 +#define SQL_AUTOCOMMIT_DEFAULT SQL_AUTOCOMMIT_ON +#define SQL_AUTOCOMMIT_OFF 0UL +#define SQL_AUTOCOMMIT_ON 1UL +#define SQL_BEST_ROWID 1 +#define SQL_BIGINT (-5) +#define SQL_BINARY (-2) +#define SQL_BIND_BY_COLUMN 0UL +#define SQL_BIND_TYPE 5 +#define SQL_BIND_TYPE_DEFAULT SQL_BIND_BY_COLUMN +#define SQL_BIT (-7) +#define SQL_BOOKMARK_PERSISTENCE 82 +#define SQL_BP_CLOSE 1 +#define SQL_BP_DELETE 2 +#define SQL_BP_DROP 4 +#define SQL_BP_OTHER_HSTMT 32 +#define SQL_BP_SCROLL 64 +#define SQL_BP_TRANSACTION 8 +#define SQL_BP_UPDATE 16 +#define SQL_C_BINARY SQL_BINARY +#define SQL_C_BIT SQL_BIT +#define SQL_C_BOOKMARK SQL_C_ULONG +#define SQL_C_CHAR SQL_CHAR +#define SQL_C_DATE SQL_DATE +#define SQL_C_DEFAULT 99 +#define SQL_C_DOUBLE SQL_DOUBLE +#define SQL_C_FLOAT SQL_REAL +#define SQL_C_LONG SQL_INTEGER +#define SQL_C_SHORT SQL_SMALLINT +#define SQL_C_SLONG (SQL_C_LONG+SQL_SIGNED_OFFSET) +#define SQL_C_SSHORT (SQL_C_SHORT+SQL_SIGNED_OFFSET) +#define SQL_C_STINYINT (SQL_TINYINT+SQL_SIGNED_OFFSET) +#define SQL_C_TIME SQL_TIME +#define SQL_C_TIMESTAMP SQL_TIMESTAMP +#define SQL_C_TINYINT SQL_TINYINT +#define SQL_C_ULONG (SQL_C_LONG+SQL_UNSIGNED_OFFSET) +#define SQL_C_USHORT (SQL_C_SHORT+SQL_UNSIGNED_OFFSET) +#define SQL_C_UTINYINT (SQL_TINYINT+SQL_UNSIGNED_OFFSET) +#define SQL_CASCADE 0 +#define SQL_CB_NON_NULL 1 +#define SQL_CB_NULL 0 +#define SQL_CC_CLOSE SQL_CB_CLOSE /* deprecated */ +#define SQL_CC_DELETE SQL_CB_DELETE /* deprecated */ +#define SQL_CC_PRESERVE SQL_CB_PRESERVE /* deprecated */ +#define SQL_CD_FALSE 0L +#define SQL_CD_TRUE 1L +#define SQL_CN_ANY 2 +#define SQL_CN_DIFFERENT 1 +#define SQL_CN_NONE 0 +#define SQL_COLATT_OPT_MAX SQL_COLUMN_LABEL +#define SQL_COLATT_OPT_MIN SQL_COLUMN_COUNT +#define SQL_COLUMN_ALIAS 87 +#define SQL_COLUMN_AUTO_INCREMENT 11 +#define SQL_COLUMN_CASE_SENSITIVE 12 +#define SQL_COLUMN_COUNT 0 +#define SQL_COLUMN_DISPLAY_SIZE 6 +#define SQL_COLUMN_LABEL 18 +#define SQL_COLUMN_LENGTH 3 +#define SQL_COLUMN_MONEY 9 +#define SQL_COLUMN_NAME 1 +#define SQL_COLUMN_NULLABLE 7 +#define SQL_COLUMN_OWNER_NAME 16 +#define SQL_COLUMN_PRECISION 4 +#define SQL_COLUMN_QUALIFIER_NAME 17 +#define SQL_COLUMN_SCALE 5 +#define SQL_COLUMN_SEARCHABLE 13 +#define SQL_COLUMN_TABLE_NAME 15 +#define SQL_COLUMN_TYPE 2 +#define SQL_COLUMN_TYPE_NAME 14 +#define SQL_COLUMN_UNSIGNED 8 +#define SQL_COLUMN_UPDATABLE 10 +#define SQL_CONCAT_NULL_BEHAVIOR 22 +#define SQL_CONCUR_DEFAULT SQL_CONCUR_READ_ONLY +#define SQL_CONCUR_LOCK 2 +#define SQL_CONCUR_READ_ONLY 1 +#define SQL_CONCUR_ROWVER 3 +#define SQL_CONCUR_TIMESTAMP SQL_CONCUR_ROWVER /* deprecated */ +#define SQL_CONCUR_VALUES 4 +#define SQL_CONCURRENCY 7 +#define SQL_CONVERT_BIGINT 53 +#define SQL_CONVERT_BINARY 54 +#define SQL_CONVERT_BIT 55 +#define SQL_CONVERT_CHAR 56 +#define SQL_CONVERT_DATE 57 +#define SQL_CONVERT_DECIMAL 58 +#define SQL_CONVERT_DOUBLE 59 +#define SQL_CONVERT_FLOAT 60 +#define SQL_CONVERT_FUNCTIONS 48 +#define SQL_CONVERT_INTEGER 61 +#define SQL_CONVERT_LONGVARBINARY 71 +#define SQL_CONVERT_LONGVARCHAR 62 +#define SQL_CONVERT_NUMERIC 63 +#define SQL_CONVERT_REAL 64 +#define SQL_CONVERT_SMALLINT 65 +#define SQL_CONVERT_TIME 66 +#define SQL_CONVERT_TIMESTAMP 67 +#define SQL_CONVERT_TINYINT 68 +#define SQL_CONVERT_VARBINARY 69 +#define SQL_CONVERT_VARCHAR 70 +#define SQL_CORRELATION_NAME 74 +#define SQL_CR_CLOSE SQL_CB_CLOSE /* deprecated */ +#define SQL_CR_DELETE SQL_CB_DELETE /* deprecated */ +#define SQL_CR_PRESERVE SQL_CB_PRESERVE /* deprecated */ +#define SQL_CUR_DEFAULT SQL_CUR_USE_DRIVER +#define SQL_CUR_USE_DRIVER 2UL +#define SQL_CUR_USE_IF_NEEDED 0UL +#define SQL_CUR_USE_ODBC 1UL +#define SQL_CURRENT_QUALIFIER 109 +#define SQL_CURSOR_DYNAMIC 2UL +#define SQL_CURSOR_FORWARD_ONLY 0UL +#define SQL_CURSOR_KEYSET_DRIVEN 1UL +#define SQL_CURSOR_ROLLBACK_BEHAVIOR 24 +#define SQL_CURSOR_STATIC 3UL +#define SQL_CURSOR_TYPE 6 +#define SQL_CURSOR_TYPE_DEFAULT SQL_CURSOR_FORWARD_ONLY +#define SQL_CV_CASCADED 0x00000004L +#define SQL_CV_CHECK_OPTION 0x00000002L +#define SQL_CV_CREATE_VIEW 0x00000001L +#define SQL_CV_LOCAL 0x00000008L +#define SQL_CVT_BIGINT 0x00004000L +#define SQL_CVT_BINARY 0x00000400L +#define SQL_CVT_BIT 0x00001000L +#define SQL_CVT_CHAR 0x00000001L +#define SQL_CVT_DATE 0x00008000L +#define SQL_CVT_DECIMAL 0x00000004L +#define SQL_CVT_DOUBLE 0x00000080L +#define SQL_CVT_FLOAT 0x00000020L +#define SQL_CVT_INTEGER 0x00000008L +#define SQL_CVT_LONGVARBINARY 0x00040000L +#define SQL_CVT_LONGVARCHAR 0x00000200L +#define SQL_CVT_NUMERIC 0x00000002L +#define SQL_CVT_REAL 0x00000040L +#define SQL_CVT_SMALLINT 0x00000010L +#define SQL_CVT_TIME 0x00010000L +#define SQL_CVT_TIMESTAMP 0x00020000L +#define SQL_CVT_TINYINT 0x00002000L +#define SQL_CVT_VARBINARY 0x00000800L +#define SQL_CVT_VARCHAR 0x00000100L +#define SQL_DATABASE_NAME 16 /* deprecated */ +#define SQL_DATE 9 +#define SQL_DEFAULT_PARAM (-5) +#define SQL_DELETE 3 +#define SQL_DRIVER_COMPLETE 1 +#define SQL_DRIVER_COMPLETE_REQUIRED 3 +#define SQL_DRIVER_HDBC 3 +#define SQL_DRIVER_HENV 4 +#define SQL_DRIVER_HLIB 76 +#define SQL_DRIVER_HSTMT 5 +#define SQL_DRIVER_NAME 6 +#define SQL_DRIVER_NOPROMPT 0 +#define SQL_DRIVER_ODBC_VER 77 +#define SQL_DRIVER_PROMPT 2 +#define SQL_DRIVER_VER 7 +#define SQL_DTC_ENLIST_EXPENSIVE 1 +#define SQL_DTC_TRANSITION_COST 1750 +#define SQL_DTC_UNENLIST_EXPENSIVE 2 +#define SQL_ENSURE 1 +#define SQL_ENTIRE_ROWSET 0 +#define SQL_EXPRESSIONS_IN_ORDERBY 27 +#define SQL_FD_FETCH_BOOKMARK 128 +#define SQL_FD_FETCH_PREV SQL_FD_FETCH_PRIOR /* deprecated */ +#define SQL_FD_FETCH_RESUME 64 +#define SQL_FETCH_BOOKMARK 8 +#define SQL_FETCH_PREV SQL_FETCH_PRIOR /* deprecated */ +#define SQL_FETCH_RESUME 7 /* deprecated */ +#define SQL_FILE_CATALOG SQL_FILE_QUALIFIER +#define SQL_FILE_NOT_SUPPORTED 0x0000 +#define SQL_FILE_QUALIFIER 0x0002 +#define SQL_FILE_TABLE 0x0001 +#define SQL_FILE_USAGE 84 +#define SQL_FN_CVT_CONVERT 0x00000001L +#define SQL_FN_NUM_ABS 0x00000001L +#define SQL_FN_NUM_ACOS 0x00000002L +#define SQL_FN_NUM_ASIN 0x00000004L +#define SQL_FN_NUM_ATAN 0x00000008L +#define SQL_FN_NUM_ATAN2 0x00000010L +#define SQL_FN_NUM_CEILING 0x00000020L +#define SQL_FN_NUM_COS 0x00000040L +#define SQL_FN_NUM_COT 0x00000080L +#define SQL_FN_NUM_DEGREES 0x00040000L +#define SQL_FN_NUM_EXP 0x00000100L +#define SQL_FN_NUM_FLOOR 0x00000200L +#define SQL_FN_NUM_LOG 0x00000400L +#define SQL_FN_NUM_LOG10 0x00080000L +#define SQL_FN_NUM_MOD 0x00000800L +#define SQL_FN_NUM_PI 0x00010000L +#define SQL_FN_NUM_POWER 0x00100000L +#define SQL_FN_NUM_RADIANS 0x00200000L +#define SQL_FN_NUM_RAND 0x00020000L +#define SQL_FN_NUM_ROUND 0x00400000L +#define SQL_FN_NUM_SIGN 0x00001000L +#define SQL_FN_NUM_SIN 0x00002000L +#define SQL_FN_NUM_SQRT 0x00004000L +#define SQL_FN_NUM_TAN 0x00008000L +#define SQL_FN_NUM_TRUNCATE 0x00800000L +#define SQL_FN_STR_ASCII 0x00002000L +#define SQL_FN_STR_CHAR 0x00004000L +#define SQL_FN_STR_CONCAT 0x00000001L +#define SQL_FN_STR_DIFFERENCE 0x00008000L +#define SQL_FN_STR_INSERT 0x00000002L +#define SQL_FN_STR_LCASE 0x00000040L +#define SQL_FN_STR_LEFT 0x00000004L +#define SQL_FN_STR_LENGTH 0x00000010L +#define SQL_FN_STR_LOCATE 0x00000020L +#define SQL_FN_STR_LOCATE_2 0x00010000L +#define SQL_FN_STR_LTRIM 0x00000008L +#define SQL_FN_STR_REPEAT 0x00000080L +#define SQL_FN_STR_REPLACE 0x00000100L +#define SQL_FN_STR_RIGHT 0x00000200L +#define SQL_FN_STR_RTRIM 0x00000400L +#define SQL_FN_STR_SOUNDEX 0x00020000L +#define SQL_FN_STR_SPACE 0x00040000L +#define SQL_FN_STR_SUBSTRING 0x00000800L +#define SQL_FN_STR_UCASE 0x00001000L +#define SQL_FN_SYS_DBNAME 0x00000002L +#define SQL_FN_SYS_IFNULL 0x00000004L +#define SQL_FN_SYS_USERNAME 0x00000001L +#define SQL_FN_TD_CURDATE 0x00000002L +#define SQL_FN_TD_CURTIME 0x00000200L +#define SQL_FN_TD_DAYNAME 0x00008000L +#define SQL_FN_TD_DAYOFMONTH 0x00000004L +#define SQL_FN_TD_DAYOFWEEK 0x00000008L +#define SQL_FN_TD_DAYOFYEAR 0x00000010L +#define SQL_FN_TD_HOUR 0x00000400L +#define SQL_FN_TD_MINUTE 0x00000800L +#define SQL_FN_TD_MONTH 0x00000020L +#define SQL_FN_TD_MONTHNAME 0x00010000L +#define SQL_FN_TD_NOW 0x00000001L +#define SQL_FN_TD_QUARTER 0x00000040L +#define SQL_FN_TD_SECOND 0x00001000L +#define SQL_FN_TD_TIMESTAMPADD 0x00002000L +#define SQL_FN_TD_TIMESTAMPDIFF 0x00004000L +#define SQL_FN_TD_WEEK 0x00000080L +#define SQL_FN_TD_YEAR 0x00000100L +#define SQL_FN_TSI_DAY 0x00000010L +#define SQL_FN_TSI_FRAC_SECOND 0x00000001L +#define SQL_FN_TSI_HOUR 0x00000008L +#define SQL_FN_TSI_MINUTE 0x00000004L +#define SQL_FN_TSI_MONTH 0x00000040L +#define SQL_FN_TSI_QUARTER 0x00000080L +#define SQL_FN_TSI_SECOND 0x00000002L +#define SQL_FN_TSI_WEEK 0x00000020L +#define SQL_FN_TSI_YEAR 0x00000100L +#define SQL_GB_GROUP_BY_CONTAINS_SELECT 2 +#define SQL_GB_GROUP_BY_EQUALS_SELECT 1 +#define SQL_GB_NO_RELATION 3 +#define SQL_GB_NOT_SUPPORTED 0 +#define SQL_GD_BLOCK 4 +#define SQL_GD_BOUND 8 +#define SQL_GET_BOOKMARK 13 +#define SQL_GROUP_BY 88 +#define SQL_IGNORE (-6) +#define SQL_INFO_FIRST 0 +#define SQL_KEYSET_SIZE 8 +#define SQL_KEYSET_SIZE_DEFAULT 0UL +#define SQL_KEYWORDS 89 +#define SQL_LCK_EXCLUSIVE 2 +#define SQL_LCK_NO_CHANGE 1 +#define SQL_LCK_UNLOCK 4 +#define SQL_LEN_BINARY_ATTR(length) (-(length)+SQL_LEN_BINARY_ATTR_OFFSET) +#define SQL_LEN_BINARY_ATTR_OFFSET (-100) +#define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET) +#define SQL_LEN_DATA_AT_EXEC_OFFSET (-100) +#define SQL_LIKE_ESCAPE_CLAUSE 113 +#define SQL_LIKE_ONLY 1 +#define SQL_LOCK_EXCLUSIVE 1 +#define SQL_LOCK_NO_CHANGE 0 +#define SQL_LOCK_TYPES 78 +#define SQL_LOCK_UNLOCK 2 +#define SQL_LOGIN_TIMEOUT 103 +#define SQL_LOGIN_TIMEOUT_DEFAULT 15UL +#define SQL_LONGVARBINARY (-4) +#define SQL_LONGVARCHAR (-1) +#define SQL_MAX_BINARY_LITERAL_LEN 112 +#define SQL_MAX_CHAR_LITERAL_LEN 108 +#define SQL_MAX_DSN_LENGTH 32 +#define SQL_MAX_LENGTH 3 +#define SQL_MAX_LENGTH_DEFAULT 0UL +#define SQL_MAX_OPTION_STRING_LENGTH 256 +#define SQL_MAX_OWNER_NAME_LEN 32 +#define SQL_MAX_PROCEDURE_NAME_LEN 33 +#define SQL_MAX_QUALIFIER_NAME_LEN 34 +#define SQL_MAX_ROW_SIZE_INCLUDES_LONG 103 +#define SQL_MAX_ROWS 1 +#define SQL_MAX_ROWS_DEFAULT 0UL +#define SQL_MODE_DEFAULT SQL_MODE_READ_WRITE +#define SQL_MODE_READ_ONLY 1UL +#define SQL_MODE_READ_WRITE 0UL +#define SQL_MULT_RESULT_SETS 36 +#define SQL_MULTIPLE_ACTIVE_TXN 37 +#define SQL_NC_END 0x0004 +#define SQL_NC_START 0x0002 +#define SQL_NEED_LONG_DATA_LEN 111 +#define SQL_NNC_NON_NULL 0x0001 +#define SQL_NNC_NULL 0x0000 +#define SQL_NO_TOTAL (-4) +#define SQL_NON_NULLABLE_COLUMNS 75 +#define SQL_NOSCAN 2 +#define SQL_NOSCAN_DEFAULT SQL_NOSCAN_OFF +#define SQL_NOSCAN_OFF 0UL +#define SQL_NOSCAN_ON 1UL +#define SQL_NUMERIC_FUNCTIONS 49 +#define SQL_OAC_LEVEL1 0x0001 +#define SQL_OAC_LEVEL2 0x0002 +#define SQL_OAC_NONE 0x0000 +#define SQL_ODBC_API_CONFORMANCE 9 +#define SQL_ODBC_CURSORS 110 +#define SQL_ODBC_SAG_CLI_CONFORMANCE 12 +#define SQL_ODBC_SQL_CONFORMANCE 15 +#define SQL_ODBC_SQL_OPT_IEF 73 +#define SQL_ODBC_VER 10 +#define SQL_OPT_TRACE 104 +#define SQL_OPT_TRACE_DEFAULT SQL_OPT_TRACE_OFF +#define SQL_OPT_TRACE_FILE_DEFAULT "\\SQL.LOG" +#define SQL_OPT_TRACE_OFF 0UL +#define SQL_OPT_TRACE_ON 1UL +#define SQL_OPT_TRACEFILE 105 +#define SQL_OSC_CORE 1 +#define SQL_OSC_EXTENDED 2 +#define SQL_OSC_MINIMUM 0 +#define SQL_OSCC_COMPLIANT 1 +#define SQL_OSCC_NOT_COMPLIANT 0 +#define SQL_OU_DML_STATEMENTS 1 +#define SQL_OU_INDEX_DEFINITION 8 +#define SQL_OU_PRIVILEGE_DEFINITION 16 +#define SQL_OU_PROCEDURE_INVOCATION 2 +#define SQL_OU_TABLE_DEFINITION 4 +#define SQL_OUTER_JOINS 38 +#define SQL_OWNER_TERM 39 +#define SQL_OWNER_USAGE 91 +#define SQL_PACKET_SIZE 112 +#define SQL_PARAM_INPUT 1 +#define SQL_PARAM_INPUT_OUTPUT 2 +#define SQL_PARAM_OUTPUT 4 +#define SQL_PARAM_TYPE_DEFAULT SQL_PARAM_INPUT_OUTPUT +#define SQL_PARAM_TYPE_UNKNOWN 0 +#define SQL_PC_NOT_PSEUDO 1 +#define SQL_POS_ADD 16 +#define SQL_POS_DELETE 8 +#define SQL_POS_OPERATIONS 79 +#define SQL_POS_POSITION 1 +#define SQL_POS_REFRESH 2 +#define SQL_POS_UPDATE 4 +#define SQL_POSITION 0 +#define SQL_POSITIONED_STATEMENTS 80 +#define SQL_PRED_SEARCHABLE SQL_SEARCHABLE +#define SQL_PROCEDURE_TERM 40 +#define SQL_PROCEDURES 21 +#define SQL_PS_POSITIONED_DELETE 1 +#define SQL_PS_POSITIONED_UPDATE 2 +#define SQL_PS_SELECT_FOR_UPDATE 4 +#define SQL_PT_FUNCTION 2 +#define SQL_PT_PROCEDURE 1 +#define SQL_PT_UNKNOWN 0 +#define SQL_QL_END 0x0002 +#define SQL_QL_START 0x0001 +#define SQL_QU_DML_STATEMENTS 1 +#define SQL_QU_INDEX_DEFINITION 8 +#define SQL_QU_PRIVILEGE_DEFINITION 16 +#define SQL_QU_PROCEDURE_INVOCATION 2 +#define SQL_QU_TABLE_DEFINITION 4 +#define SQL_QUALIFIER_LOCATION 114 +#define SQL_QUALIFIER_NAME_SEPARATOR 41 +#define SQL_QUALIFIER_TERM 42 +#define SQL_QUALIFIER_USAGE 92 +#define SQL_QUERY_TIMEOUT 0 +#define SQL_QUERY_TIMEOUT_DEFAULT 0UL +#define SQL_QUICK 0 +#define SQL_QUIET_MODE 111 +#define SQL_QUOTED_IDENTIFIER_CASE 93 +#define SQL_RD_DEFAULT SQL_RD_ON +#define SQL_RD_OFF 0UL +#define SQL_RD_ON 1UL +#define SQL_REFRESH 1 +#define SQL_RESTRICT 1 +#define SQL_RESULT_COL 3 +#define SQL_RETRIEVE_DATA 11 +#define SQL_RETURN_VALUE 5 +#define SQL_ROW_ADDED 4 +#define SQL_ROW_DELETED 1 +#define SQL_ROW_ERROR 5 +#define SQL_ROW_NOROW 3 +#define SQL_ROW_NUMBER 14 +#define SQL_ROW_SUCCESS 0 +#define SQL_ROW_UPDATED 2 +#define SQL_ROW_UPDATES 11 +#define SQL_ROWSET_SIZE 9 +#define SQL_ROWSET_SIZE_DEFAULT 1UL +#define SQL_ROWVER 2 +#define SQL_SC_NON_UNIQUE 0UL +#define SQL_SC_TRY_UNIQUE 1UL +#define SQL_SC_UNIQUE 2UL +#define SQL_SCCO_OPT_TIMESTAMP SQL_SCCO_OPT_ROWVER /* deprecated */ +#define SQL_SCROLL_DYNAMIC (-2L) /* deprecated */ +#define SQL_SCROLL_FORWARD_ONLY 0L /* deprecated */ +#define SQL_SCROLL_KEYSET_DRIVEN (-1L) /* deprecated */ +#define SQL_SCROLL_OPTIONS 44 +#define SQL_SCROLL_STATIC (-3L) /* deprecated */ +#define SQL_SEARCHABLE 3 +#define SQL_SET_NULL 2 +#define SQL_SETPARAM_VALUE_MAX (-1L) +#define SQL_SETPOS_MAX_LOCK_VALUE SQL_LOCK_UNLOCK +#define SQL_SETPOS_MAX_OPTION_VALUE SQL_ADD +#define SQL_SIGNED_OFFSET (-20) +#define SQL_SIMULATE_CURSOR 10 +#define SQL_SO_DYNAMIC 4 +#define SQL_SO_FORWARD_ONLY 1 +#define SQL_SO_KEYSET_DRIVEN 2 +#define SQL_SO_MIXED 8 +#define SQL_SO_STATIC 16 +#define SQL_SQ_COMPARISON 1 +#define SQL_SQ_CORRELATED_SUBQUERIES 16 +#define SQL_SQ_EXISTS 2 +#define SQL_SQ_IN 4 +#define SQL_SQ_QUANTIFIED 8 +#define SQL_SQLSTATE_SIZE 5 +#define SQL_SS_ADDITIONS 1 +#define SQL_SS_DELETIONS 2 +#define SQL_SS_UPDATES 4 +#define SQL_STATIC_SENSITIVITY 83 +#define SQL_STRING_FUNCTIONS 50 +#define SQL_SUBQUERIES 95 +#define SQL_SYSTEM_FUNCTIONS 51 +#define SQL_TABLE_STAT 0 +#define SQL_TABLE_TERM 45 +#define SQL_TIME 10 +#define SQL_TIMEDATE_ADD_INTERVALS 109 +#define SQL_TIMEDATE_DIFF_INTERVALS 110 +#define SQL_TIMEDATE_FUNCTIONS 52 +#define SQL_TIMESTAMP 11 +#define SQL_TINYINT (-6) +#define SQL_TRANSLATE_DLL 106 +#define SQL_TRANSLATE_OPTION 107 +#define SQL_TXN_ISOLATION 108 +#define SQL_TXN_VERSIONING 16 +#define SQL_TYPE_NULL 0 +#define SQL_U_UNION 1 +#define SQL_U_UNION_ALL 2 +#define SQL_UB_DEFAULT SQL_UB_OFF +#define SQL_UB_OFF 0UL +#define SQL_UB_ON 01UL +#define SQL_UNION 96 +#define SQL_UNSEARCHABLE 0 +#define SQL_UNSIGNED_OFFSET (-22) +#define SQL_UPDATE 2 +#define SQL_USE_BOOKMARKS 12 +#define SQL_VARBINARY (-3) +#define SQL_POSITION_TO(s,r) SQLSetPos(s,r,SQL_POSITION,SQL_LOCK_NO_CHANGE) +#define SQL_LOCK_RECORD(s,r,l) SQLSetPos(s,r,SQL_POSITION,l) +#define SQL_REFRESH_RECORD(s,r,l) SQLSetPos(s,r,SQL_REFRESH,l) +#define SQL_UPDATE_RECORD(s,r) SQLSetPos(s,r,SQL_UPDATE,SQL_LOCK_NO_CHANGE) +#define SQL_DELETE_RECORD(s,r) SQLSetPos(s,r,SQL_DELETE,SQL_LOCK_NO_CHANGE) +#define SQL_ADD_RECORD(s,r) SQLSetPos(s,r,SQL_ADD,SQL_LOCK_NO_CHANGE) + +#if (ODBCVER < 0x0300) +#define SQL_CONNECT_OPT_DRVR_START 1000 +#define SQL_CONN_OPT_MAX SQL_PACKET_SIZE +#define SQL_CONN_OPT_MIN SQL_ACCESS_MODE +#define SQL_STMT_OPT_MAX SQL_ROW_NUMBER +#define SQL_STMT_OPT_MIN SQL_QUERY_TIMEOUT +#define SQL_TYPE_DRIVER_START SQL_INTERVAL_YEAR +#define SQL_TYPE_DRIVER_END SQL_UNICODE_LONGVARCHAR +#define SQL_TYPE_MIN SQL_BIT +#define SQL_TYPE_MAX SQL_VARCHAR +#endif + +#if (ODBCVER < 0x0300) +#define SQL_NO_DATA_FOUND 100 +#define SQL_INTERVAL_YEAR (-80) +#define SQL_INTERVAL_MONTH (-81) +#define SQL_INTERVAL_YEAR_TO_MONTH (-82) +#define SQL_INTERVAL_DAY (-83) +#define SQL_INTERVAL_HOUR (-84) +#define SQL_INTERVAL_MINUTE (-85) +#define SQL_INTERVAL_SECOND (-86) +#define SQL_INTERVAL_DAY_TO_HOUR (-87) +#define SQL_INTERVAL_DAY_TO_MINUTE (-88) +#define SQL_INTERVAL_DAY_TO_SECOND (-89) +#define SQL_INTERVAL_HOUR_TO_MINUTE (-90) +#define SQL_INTERVAL_HOUR_TO_SECOND (-91) +#define SQL_INTERVAL_MINUTE_TO_SECOND (-92) +#else +#define SQL_NO_DATA_FOUND SQL_NO_DATA +#define SQL_CODE_YEAR 1 +#define SQL_CODE_MONTH 2 +#define SQL_CODE_DAY 3 +#define SQL_CODE_HOUR 4 +#define SQL_CODE_MINUTE 5 +#define SQL_CODE_SECOND 6 +#define SQL_CODE_YEAR_TO_MONTH 7 +#define SQL_CODE_DAY_TO_HOUR 8 +#define SQL_CODE_DAY_TO_MINUTE 9 +#define SQL_CODE_DAY_TO_SECOND 10 +#define SQL_CODE_HOUR_TO_MINUTE 11 +#define SQL_CODE_HOUR_TO_SECOND 12 +#define SQL_CODE_MINUTE_TO_SECOND 13 +#define SQL_INTERVAL_YEAR (100 + SQL_CODE_YEAR) +#define SQL_INTERVAL_MONTH (100 + SQL_CODE_MONTH) +#define SQL_INTERVAL_DAY (100 + SQL_CODE_DAY) +#define SQL_INTERVAL_HOUR (100 + SQL_CODE_HOUR) +#define SQL_INTERVAL_MINUTE (100 + SQL_CODE_MINUTE) +#define SQL_INTERVAL_SECOND (100 + SQL_CODE_SECOND) +#define SQL_INTERVAL_YEAR_TO_MONTH (100 + SQL_CODE_YEAR_TO_MONTH) +#define SQL_INTERVAL_DAY_TO_HOUR (100 + SQL_CODE_DAY_TO_HOUR) +#define SQL_INTERVAL_DAY_TO_MINUTE (100 + SQL_CODE_DAY_TO_MINUTE) +#define SQL_INTERVAL_DAY_TO_SECOND (100 + SQL_CODE_DAY_TO_SECOND) +#define SQL_INTERVAL_HOUR_TO_MINUTE (100 + SQL_CODE_HOUR_TO_MINUTE) +#define SQL_INTERVAL_HOUR_TO_SECOND (100 + SQL_CODE_HOUR_TO_SECOND) +#define SQL_INTERVAL_MINUTE_TO_SECOND (100 + SQL_CODE_MINUTE_TO_SECOND) +#endif + +#if (ODBCVER <= 0x0300) +#define SQL_UNICODE (-95) +#define SQL_UNICODE_VARCHAR (-96) +#define SQL_UNICODE_LONGVARCHAR (-97) +#define SQL_UNICODE_CHAR SQL_UNICODE +#else +#define SQL_UNICODE SQL_WCHAR +#define SQL_UNICODE_VARCHAR SQL_WVARCHAR +#define SQL_UNICODE_LONGVARCHAR SQL_WLONGVARCHAR +#define SQL_UNICODE_CHAR SQL_WCHAR +#endif + +#if (ODBCVER >= 0x0201) && (ODBCVER < 0x0300) +#define SQL_OJ_CAPABILITIES 65003 +#endif /* ODBCVER < 0x0300 */ + +#if (ODBCVER >= 0x0250) +#define SQL_NO_ACTION 3 +#define SQL_SET_DEFAULT 4 +#endif /* ODBCVER >= 0x0250 */ + +#if (ODBCVER >= 0x0300) +#define SQL_ACTIVE_ENVIRONMENTS 116 +#define SQL_AD_ADD_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_AD_ADD_DOMAIN_CONSTRAINT 0x00000002L +#define SQL_AD_ADD_DOMAIN_DEFAULT 0x00000008L +#define SQL_AD_CONSTRAINT_NAME_DEFINITION 0x00000001L +#define SQL_AD_DROP_DOMAIN_CONSTRAINT 0x00000004L +#define SQL_AD_DROP_DOMAIN_DEFAULT 0x00000010L +#define SQL_AF_ALL 0x00000040L +#define SQL_AF_AVG 0x00000001L +#define SQL_AF_COUNT 0x00000002L +#define SQL_AF_DISTINCT 0x00000020L +#define SQL_AF_MAX 0x00000004L +#define SQL_AF_MIN 0x00000008L +#define SQL_AF_SUM 0x00000010L +#define SQL_AGGREGATE_FUNCTIONS 169 +#define SQL_ALL_CATALOGS "%" +#define SQL_ALL_SCHEMAS "%" +#define SQL_ALL_TABLE_TYPES "%" +#define SQL_ALTER_DOMAIN 117 +#define SQL_AM_CONNECTION 1 +#define SQL_AM_NONE 0 +#define SQL_AM_STATEMENT 2 +#define SQL_API_ODBC3_ALL_FUNCTIONS 999 +#define SQL_API_ODBC3_ALL_FUNCTIONS_SIZE 250 +#define SQL_API_SQLALLOCHANDLESTD 73 +#define SQL_API_SQLBULKOPERATIONS 24 +#define SQL_ASYNC_MODE 10021 +#define SQL_AT_ADD_COLUMN_COLLATION 0x00000080L +#define SQL_AT_ADD_COLUMN_DEFAULT 0x00000040L +#define SQL_AT_ADD_COLUMN_SINGLE 0x00000020L +#define SQL_AT_ADD_TABLE_CONSTRAINT 0x00001000L +#define SQL_AT_CONSTRAINT_DEFERRABLE 0x00040000L +#define SQL_AT_CONSTRAINT_INITIALLY_DEFERRED 0x00010000L +#define SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE 0x00020000L +#define SQL_AT_CONSTRAINT_NAME_DEFINITION 0x00008000L +#define SQL_AT_CONSTRAINT_NON_DEFERRABLE 0x00080000L +#define SQL_AT_DROP_COLUMN_CASCADE 0x00000400L +#define SQL_AT_DROP_COLUMN_DEFAULT 0x00000200L +#define SQL_AT_DROP_COLUMN_RESTRICT 0x00000800L +#define SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE 0x00002000L +#define SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT 0x00004000L +#define SQL_AT_SET_COLUMN_DEFAULT 0x00000100L +#define SQL_ATTR_ACCESS_MODE SQL_ACCESS_MODE +#define SQL_ATTR_ASYNC_ENABLE 4 +#define SQL_ATTR_AUTOCOMMIT SQL_AUTOCOMMIT +#define SQL_ATTR_CONCURRENCY SQL_CONCURRENCY +#define SQL_ATTR_CONNECTION_POOLING 201 +#define SQL_ATTR_CONNECTION_TIMEOUT 113 +#define SQL_ATTR_CP_MATCH 202 +#define SQL_ATTR_CURRENT_CATALOG SQL_CURRENT_QUALIFIER +#define SQL_ATTR_CURSOR_TYPE SQL_CURSOR_TYPE +#define SQL_ATTR_DISCONNECT_BEHAVIOR 114 +#define SQL_ATTR_ENABLE_AUTO_IPD 15 +#define SQL_ATTR_ENLIST_IN_DTC 1207 +#define SQL_ATTR_ENLIST_IN_XA 1208 +#define SQL_ATTR_FETCH_BOOKMARK_PTR 16 +#define SQL_ATTR_KEYSET_SIZE SQL_KEYSET_SIZE +#define SQL_ATTR_LOGIN_TIMEOUT SQL_LOGIN_TIMEOUT +#define SQL_ATTR_MAX_LENGTH SQL_MAX_LENGTH +#define SQL_ATTR_MAX_ROWS SQL_MAX_ROWS +#define SQL_ATTR_NOSCAN SQL_NOSCAN +#define SQL_ATTR_ODBC_CURSORS SQL_ODBC_CURSORS +#define SQL_ATTR_ODBC_VERSION 200 +#define SQL_ATTR_PACKET_SIZE SQL_PACKET_SIZE +#define SQL_ATTR_PARAM_BIND_OFFSET_PTR 17 +#define SQL_ATTR_PARAM_BIND_TYPE 18 +#define SQL_ATTR_PARAM_OPERATION_PTR 19 +#define SQL_ATTR_PARAM_STATUS_PTR 20 +#define SQL_ATTR_PARAMS_PROCESSED_PTR 21 +#define SQL_ATTR_PARAMSET_SIZE 22 +#define SQL_ATTR_QUERY_TIMEOUT SQL_QUERY_TIMEOUT +#define SQL_ATTR_QUIET_MODE SQL_QUIET_MODE +#define SQL_ATTR_RETRIEVE_DATA SQL_RETRIEVE_DATA +#define SQL_ATTR_ROW_ARRAY_SIZE 27 +#define SQL_ATTR_ROW_BIND_OFFSET_PTR 23 +#define SQL_ATTR_ROW_BIND_TYPE SQL_BIND_TYPE +#define SQL_ATTR_ROW_NUMBER SQL_ROW_NUMBER +#define SQL_ATTR_ROW_OPERATION_PTR 24 +#define SQL_ATTR_ROW_STATUS_PTR 25 +#define SQL_ATTR_ROWS_FETCHED_PTR 26 +#define SQL_ATTR_SIMULATE_CURSOR SQL_SIMULATE_CURSOR +#define SQL_ATTR_TRACE SQL_OPT_TRACE +#define SQL_ATTR_TRACEFILE SQL_OPT_TRACEFILE +#define SQL_ATTR_TRANSLATE_LIB SQL_TRANSLATE_DLL +#define SQL_ATTR_TRANSLATE_OPTION SQL_TRANSLATE_OPTION +#define SQL_ATTR_TXN_ISOLATION SQL_TXN_ISOLATION +#define SQL_ATTR_USE_BOOKMARKS SQL_USE_BOOKMARKS +#define SQL_BATCH_ROW_COUNT 120 +#define SQL_BATCH_SUPPORT 121 +#define SQL_BRC_EXPLICIT 0x0000002 +#define SQL_BRC_PROCEDURES 0x0000001 +#define SQL_BRC_ROLLED_UP 0x0000004 +#define SQL_BS_ROW_COUNT_EXPLICIT 0x00000002L +#define SQL_BS_ROW_COUNT_PROC 0x00000008L +#define SQL_BS_SELECT_EXPLICIT 0x00000001L +#define SQL_BS_SELECT_PROC 0x00000004L +#define SQL_C_INTERVAL_DAY SQL_INTERVAL_DAY +#define SQL_C_INTERVAL_DAY_TO_HOUR SQL_INTERVAL_DAY_TO_HOUR +#define SQL_C_INTERVAL_DAY_TO_MINUTE SQL_INTERVAL_DAY_TO_MINUTE +#define SQL_C_INTERVAL_DAY_TO_SECOND SQL_INTERVAL_DAY_TO_SECOND +#define SQL_C_INTERVAL_HOUR SQL_INTERVAL_HOUR +#define SQL_C_INTERVAL_HOUR_TO_MINUTE SQL_INTERVAL_HOUR_TO_MINUTE +#define SQL_C_INTERVAL_HOUR_TO_SECOND SQL_INTERVAL_HOUR_TO_SECOND +#define SQL_C_INTERVAL_MINUTE SQL_INTERVAL_MINUTE +#define SQL_C_INTERVAL_MINUTE_TO_SECOND SQL_INTERVAL_MINUTE_TO_SECOND +#define SQL_C_INTERVAL_MONTH SQL_INTERVAL_MONTH +#define SQL_C_INTERVAL_SECOND SQL_INTERVAL_SECOND +#define SQL_C_INTERVAL_YEAR SQL_INTERVAL_YEAR +#define SQL_C_INTERVAL_YEAR_TO_MONTH SQL_INTERVAL_YEAR_TO_MONTH +#define SQL_C_NUMERIC SQL_NUMERIC +#define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) +#define SQL_C_TYPE_DATE SQL_TYPE_DATE +#define SQL_C_TYPE_TIME SQL_TYPE_TIME +#define SQL_C_TYPE_TIMESTAMP SQL_TYPE_TIMESTAMP +#define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) +#define SQL_C_VARBOOKMARK SQL_C_BINARY +#define SQL_CA_CONSTRAINT_DEFERRABLE 0x00000040L +#define SQL_CA_CONSTRAINT_INITIALLY_DEFERRED 0x00000010L +#define SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000020L +#define SQL_CA_CONSTRAINT_NON_DEFERRABLE 0x00000080L +#define SQL_CA_CREATE_ASSERTION 0x00000001L +#define SQL_CA1_ABSOLUTE 0x00000002L +#define SQL_CA1_BOOKMARK 0x00000008L +#define SQL_CA1_BULK_ADD 0x00010000L +#define SQL_CA1_BULK_DELETE_BY_BOOKMARK 0x00040000L +#define SQL_CA1_BULK_FETCH_BY_BOOKMARK 0x00080000L +#define SQL_CA1_BULK_UPDATE_BY_BOOKMARK 0x00020000L +#define SQL_CA1_LOCK_EXCLUSIVE 0x00000080L +#define SQL_CA1_LOCK_NO_CHANGE 0x00000040L +#define SQL_CA1_LOCK_UNLOCK 0x00000100L +#define SQL_CA1_NEXT 0x00000001L +#define SQL_CA1_POS_DELETE 0x00000800L +#define SQL_CA1_POS_POSITION 0x00000200L +#define SQL_CA1_POS_REFRESH 0x00001000L +#define SQL_CA1_POS_UPDATE 0x00000400L +#define SQL_CA1_POSITIONED_DELETE 0x00004000L +#define SQL_CA1_POSITIONED_UPDATE 0x00002000L +#define SQL_CA1_RELATIVE 0x00000004L +#define SQL_CA1_SELECT_FOR_UPDATE 0x00008000L +#define SQL_CA2_CRC_APPROXIMATE 0x00002000L +#define SQL_CA2_CRC_EXACT 0x00001000L +#define SQL_CA2_LOCK_CONCURRENCY 0x00000002L +#define SQL_CA2_MAX_ROWS_AFFECTS_ALL (SQL_CA2_MAX_ROWS_SELECT | SQL_CA2_MAX_ROWS_INSERT | \ + SQL_CA2_MAX_ROWS_DELETE | SQL_CA2_MAX_ROWS_UPDATE | SQL_CA2_MAX_ROWS_CATALOG) +#define SQL_CA2_MAX_ROWS_CATALOG 0x00000800L +#define SQL_CA2_MAX_ROWS_DELETE 0x00000200L +#define SQL_CA2_MAX_ROWS_INSERT 0x00000100L +#define SQL_CA2_MAX_ROWS_SELECT 0x00000080L +#define SQL_CA2_MAX_ROWS_UPDATE 0x00000400L +#define SQL_CA2_OPT_ROWVER_CONCURRENCY 0x00000004L +#define SQL_CA2_OPT_VALUES_CONCURRENCY 0x00000008L +#define SQL_CA2_READ_ONLY_CONCURRENCY 0x00000001L +#define SQL_CA2_SENSITIVITY_ADDITIONS 0x00000010L +#define SQL_CA2_SENSITIVITY_DELETIONS 0x00000020L +#define SQL_CA2_SENSITIVITY_UPDATES 0x00000040L +#define SQL_CA2_SIMULATE_NON_UNIQUE 0x00004000L +#define SQL_CA2_SIMULATE_TRY_UNIQUE 0x00008000L +#define SQL_CA2_SIMULATE_UNIQUE 0x00010000L +#define SQL_CATALOG_LOCATION SQL_QUALIFIER_LOCATION +#define SQL_CATALOG_NAME_SEPARATOR SQL_QUALIFIER_NAME_SEPARATOR +#define SQL_CATALOG_TERM SQL_QUALIFIER_TERM +#define SQL_CATALOG_USAGE SQL_QUALIFIER_USAGE +#define SQL_CCOL_CREATE_COLLATION 0x00000001L +#define SQL_CCS_COLLATE_CLAUSE 0x00000002L +#define SQL_CCS_CREATE_CHARACTER_SET 0x00000001L +#define SQL_CCS_LIMITED_COLLATION 0x00000004L +#define SQL_CDO_COLLATION 0x00000008L +#define SQL_CDO_CONSTRAINT 0x00000004L +#define SQL_CDO_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_CDO_CONSTRAINT_NAME_DEFINITION 0x00000010L +#define SQL_CDO_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_CDO_CREATE_DOMAIN 0x00000001L +#define SQL_CDO_DEFAULT 0x00000002L +#define SQL_CL_END SQL_QL_END +#define SQL_CL_START SQL_QL_START +#define SQL_COL_PRED_BASIC SQL_ALL_EXCEPT_LIKE +#define SQL_COL_PRED_CHAR SQL_LIKE_ONLY +#define SQL_COLUMN_DRIVER_START 1000 +#define SQL_COLUMN_IGNORE SQL_IGNORE +#define SQL_COLUMN_NUMBER_UNKNOWN (-2) +#define SQL_CONVERT_GUID 173 +#define SQL_CONVERT_INTERVAL_DAY_TIME 123 +#define SQL_CONVERT_INTERVAL_YEAR_MONTH 124 +#define SQL_CONVERT_WCHAR 122 +#define SQL_CONVERT_WLONGVARCHAR 125 +#define SQL_CONVERT_WVARCHAR 126 +#define SQL_CP_DEFAULT SQL_CP_OFF +#define SQL_CP_MATCH_DEFAULT SQL_CP_STRICT_MATCH +#define SQL_CP_OFF 0UL +#define SQL_CP_ONE_PER_DRIVER 1UL +#define SQL_CP_ONE_PER_HENV 2UL +#define SQL_CP_RELAXED_MATCH 1UL +#define SQL_CP_STRICT_MATCH 0UL +#define SQL_CREATE_ASSERTION 127 +#define SQL_CREATE_CHARACTER_SET 128 +#define SQL_CREATE_COLLATION 129 +#define SQL_CREATE_DOMAIN 130 +#define SQL_CREATE_SCHEMA 131 +#define SQL_CREATE_TABLE 132 +#define SQL_CREATE_TRANSLATION 133 +#define SQL_CREATE_VIEW 134 +#define SQL_CS_AUTHORIZATION 0x00000002L +#define SQL_CS_CREATE_SCHEMA 0x00000001L +#define SQL_CS_DEFAULT_CHARACTER_SET 0x00000004L +#define SQL_CT_COLUMN_COLLATION 0x00000800L +#define SQL_CT_COLUMN_CONSTRAINT 0x00000200L +#define SQL_CT_COLUMN_DEFAULT 0x00000400L +#define SQL_CT_COMMIT_DELETE 0x00000004L +#define SQL_CT_COMMIT_PRESERVE 0x00000002L +#define SQL_CT_CONSTRAINT_DEFERRABLE 0x00000080L +#define SQL_CT_CONSTRAINT_INITIALLY_DEFERRED 0x00000020L +#define SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE 0x00000040L +#define SQL_CT_CONSTRAINT_NAME_DEFINITION 0x00002000L +#define SQL_CT_CONSTRAINT_NON_DEFERRABLE 0x00000100L +#define SQL_CT_CREATE_TABLE 0x00000001L +#define SQL_CT_GLOBAL_TEMPORARY 0x00000008L +#define SQL_CT_LOCAL_TEMPORARY 0x00000010L +#define SQL_CT_TABLE_CONSTRAINT 0x00001000L +#define SQL_CTR_CREATE_TRANSLATION 0x00000001L +#define SQL_CU_DML_STATEMENTS SQL_QU_DML_STATEMENTS +#define SQL_CU_INDEX_DEFINITION SQL_QU_INDEX_DEFINITION +#define SQL_CU_PRIVILEGE_DEFINITION SQL_QU_PRIVILEGE_DEFINITION +#define SQL_CU_PROCEDURE_INVOCATION SQL_QU_PROCEDURE_INVOCATION +#define SQL_CU_TABLE_DEFINITION SQL_QU_TABLE_DEFINITION +#define SQL_CVT_GUID 0x1000000L +#define SQL_CVT_INTERVAL_DAY_TIME 0x00100000L +#define SQL_CVT_INTERVAL_YEAR_MONTH 0x00080000L +#define SQL_CVT_WCHAR 0x00200000L +#define SQL_CVT_WLONGVARCHAR 0x00400000L +#define SQL_CVT_WVARCHAR 0x00800000L +#define SQL_DA_DROP_ASSERTION 0x00000001L +#define SQL_DATETIME_LITERALS 119 +#define SQL_DB_DEFAULT SQL_DB_RETURN_TO_POOL +#define SQL_DB_DISCONNECT 1UL +#define SQL_DB_RETURN_TO_POOL 0UL +#define SQL_DC_DROP_COLLATION 0x00000001L +#define SQL_DCS_DROP_CHARACTER_SET 0x00000001L +#define SQL_DD_CASCADE 0x00000004L +#define SQL_DD_DROP_DOMAIN 0x00000001L +#define SQL_DD_RESTRICT 0x00000002L +#define SQL_DDL_INDEX 170 +#define SQL_DELETE_BY_BOOKMARK 6 +#define SQL_DESC_ARRAY_SIZE 20 +#define SQL_DESC_ARRAY_STATUS_PTR 21 +#define SQL_DESC_AUTO_UNIQUE_VALUE SQL_COLUMN_AUTO_INCREMENT +#define SQL_DESC_BASE_COLUMN_NAME 22 +#define SQL_DESC_BASE_TABLE_NAME 23 +#define SQL_DESC_BIND_OFFSET_PTR 24 +#define SQL_DESC_BIND_TYPE 25 +#define SQL_DESC_CASE_SENSITIVE SQL_COLUMN_CASE_SENSITIVE +#define SQL_DESC_CATALOG_NAME SQL_COLUMN_QUALIFIER_NAME +#define SQL_DESC_CONCISE_TYPE SQL_COLUMN_TYPE +#define SQL_DESC_DATETIME_INTERVAL_PRECISION 26 +#define SQL_DESC_DISPLAY_SIZE SQL_COLUMN_DISPLAY_SIZE +#define SQL_DESC_FIXED_PREC_SCALE SQL_COLUMN_MONEY +#define SQL_DESC_LABEL SQL_COLUMN_LABEL +#define SQL_DESC_LITERAL_PREFIX 27 +#define SQL_DESC_LITERAL_SUFFIX 28 +#define SQL_DESC_LOCAL_TYPE_NAME 29 +#define SQL_DESC_MAXIMUM_SCALE 30 +#define SQL_DESC_MINIMUM_SCALE 31 +#define SQL_DESC_NUM_PREC_RADIX 32 +#define SQL_DESC_PARAMETER_TYPE 33 +#define SQL_DESC_ROWS_PROCESSED_PTR 34 +#define SQL_DESC_SCHEMA_NAME SQL_COLUMN_OWNER_NAME +#define SQL_DESC_SEARCHABLE SQL_COLUMN_SEARCHABLE +#define SQL_DESC_TABLE_NAME SQL_COLUMN_TABLE_NAME +#define SQL_DESC_TYPE_NAME SQL_COLUMN_TYPE_NAME +#define SQL_DESC_UNSIGNED SQL_COLUMN_UNSIGNED +#define SQL_DESC_UPDATABLE SQL_COLUMN_UPDATABLE +#define SQL_DI_CREATE_INDEX 0x00000001L +#define SQL_DI_DROP_INDEX 0x00000002L +#define SQL_DIAG_COLUMN_NUMBER (-1247) +#define SQL_DIAG_CURSOR_ROW_COUNT (-1249) +#define SQL_DIAG_ROW_NUMBER (-1248) +#define SQL_DL_SQL92_DATE 0x00000001L +#define SQL_DL_SQL92_INTERVAL_DAY 0x00000020L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR 0x00000400L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE 0x00000800L +#define SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND 0x00001000L +#define SQL_DL_SQL92_INTERVAL_HOUR 0x00000040L +#define SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE 0x00002000L +#define SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND 0x00004000L +#define SQL_DL_SQL92_INTERVAL_MINUTE 0x00000080L +#define SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND 0x00008000L +#define SQL_DL_SQL92_INTERVAL_MONTH 0x00000010L +#define SQL_DL_SQL92_INTERVAL_SECOND 0x00000100L +#define SQL_DL_SQL92_INTERVAL_YEAR 0x00000008L +#define SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH 0x00000200L +#define SQL_DL_SQL92_TIME 0x00000002L +#define SQL_DL_SQL92_TIMESTAMP 0x00000004L +#define SQL_DM_VER 171 +#define SQL_DRIVER_HDESC 135 +#define SQL_DROP_ASSERTION 136 +#define SQL_DROP_CHARACTER_SET 137 +#define SQL_DROP_COLLATION 138 +#define SQL_DROP_DOMAIN 139 +#define SQL_DROP_SCHEMA 140 +#define SQL_DROP_TABLE 141 +#define SQL_DROP_TRANSLATION 142 +#define SQL_DROP_VIEW 143 +#define SQL_DS_CASCADE 0x00000004L +#define SQL_DS_DROP_SCHEMA 0x00000001L +#define SQL_DS_RESTRICT 0x00000002L +#define SQL_DT_CASCADE 0x00000004L +#define SQL_DT_DROP_TABLE 0x00000001L +#define SQL_DT_RESTRICT 0x00000002L +#define SQL_DTC_DONE 0L +#define SQL_DTR_DROP_TRANSLATION 0x00000001L +#define SQL_DV_CASCADE 0x00000004L +#define SQL_DV_DROP_VIEW 0x00000001L +#define SQL_DV_RESTRICT 0x00000002L +#define SQL_DYNAMIC_CURSOR_ATTRIBUTES1 144 +#define SQL_DYNAMIC_CURSOR_ATTRIBUTES2 145 +#define SQL_EXT_API_LAST SQL_API_SQLBINDPARAMETER +#define SQL_EXT_API_START 40 +#define SQL_FETCH_BY_BOOKMARK 7 +#define SQL_FETCH_FIRST_SYSTEM 32 +#define SQL_FETCH_FIRST_USER 31 +#define SQL_FN_CVT_CAST 0x00000002L +#define SQL_FN_STR_BIT_LENGTH 0x00080000L +#define SQL_FN_STR_CHAR_LENGTH 0x00100000L +#define SQL_FN_STR_CHARACTER_LENGTH 0x00200000L +#define SQL_FN_STR_OCTET_LENGTH 0x00400000L +#define SQL_FN_STR_POSITION 0x00800000L +#define SQL_FN_TD_CURRENT_DATE 0x00020000L +#define SQL_FN_TD_CURRENT_TIME 0x00040000L +#define SQL_FN_TD_CURRENT_TIMESTAMP 0x00080000L +#define SQL_FN_TD_EXTRACT 0x00100000L +#define SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 146 +#define SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 147 +#define SQL_FUNC_EXISTS(exists, api) \ + ((*(((UWORD*) (exists)) + ((api) >> 4)) & (1 << ((api) & 15)) ) ? \ + SQL_TRUE : SQL_FALSE ) +#define SQL_GB_COLLATE 0x0004 +#define SQL_HANDLE_SENV 5 +#define SQL_IK_ALL (SQL_IK_ASC | SQL_IK_DESC) +#define SQL_IK_ASC 1 +#define SQL_IK_DESC 2 +#define SQL_IK_NONE 0 +#define SQL_INDEX_KEYWORDS 148 +#define SQL_INFO_DRIVER_START 1000 +#define SQL_INFO_LAST SQL_QUALIFIER_LOCATION +#define SQL_INFO_SCHEMA_VIEWS 149 +#define SQL_INITIALLY_DEFERRED 5 +#define SQL_INITIALLY_IMMEDIATE 6 +#define SQL_INSERT_STATEMENT 172 +#define SQL_INTERVAL 10 +#define SQL_IS_INSERT_LITERALS 0x00000001L +#define SQL_IS_INSERT_SEARCHED 0x00000002L +#define SQL_IS_INTEGER (-6) +#define SQL_IS_POINTER (-4) +#define SQL_IS_SELECT_INTO 0x00000004L +#define SQL_IS_SMALLINT (-8) +#define SQL_IS_UINTEGER (-5) +#define SQL_IS_USMALLINT (-7) +#define SQL_ISV_ASSERTIONS 0x00000001L +#define SQL_ISV_CHARACTER_SETS 0x00000002L +#define SQL_ISV_CHECK_CONSTRAINTS 0x00000004L +#define SQL_ISV_COLLATIONS 0x00000008L +#define SQL_ISV_COLUMN_DOMAIN_USAGE 0x00000010L +#define SQL_ISV_COLUMN_PRIVILEGES 0x00000020L +#define SQL_ISV_COLUMNS 0x00000040L +#define SQL_ISV_CONSTRAINT_COLUMN_USAGE 0x00000080L +#define SQL_ISV_CONSTRAINT_TABLE_USAGE 0x00000100L +#define SQL_ISV_DOMAIN_CONSTRAINTS 0x00000200L +#define SQL_ISV_DOMAINS 0x00000400L +#define SQL_ISV_KEY_COLUMN_USAGE 0x00000800L +#define SQL_ISV_REFERENTIAL_CONSTRAINTS 0x00001000L +#define SQL_ISV_SCHEMATA 0x00002000L +#define SQL_ISV_SQL_LANGUAGES 0x00004000L +#define SQL_ISV_TABLE_CONSTRAINTS 0x00008000L +#define SQL_ISV_TABLE_PRIVILEGES 0x00010000L +#define SQL_ISV_TABLES 0x00020000L +#define SQL_ISV_TRANSLATIONS 0x00040000L +#define SQL_ISV_USAGE_PRIVILEGES 0x00080000L +#define SQL_ISV_VIEW_COLUMN_USAGE 0x00100000L +#define SQL_ISV_VIEW_TABLE_USAGE 0x00200000L +#define SQL_ISV_VIEWS 0x00400000L +#define SQL_KEYSET_CURSOR_ATTRIBUTES1 150 +#define SQL_KEYSET_CURSOR_ATTRIBUTES2 151 +#define SQL_MAX_ASYNC_CONCURRENT_STATEMENTS 10022 +#define SQL_NO_COLUMN_NUMBER (-1) +#define SQL_NO_ROW_NUMBER (-1) +#define SQL_NOT_DEFERRABLE 7 +#define SQL_NUM_EXTENSIONS (SQL_EXT_API_LAST-SQL_EXT_API_START+1) +#define SQL_NUM_FUNCTIONS 23 +#define SQL_ODBC_INTERFACE_CONFORMANCE 152 +#define SQL_OIC_CORE 1UL +#define SQL_OIC_LEVEL1 2UL +#define SQL_OIC_LEVEL2 3UL +#define SQL_OV_ODBC2 2UL +#define SQL_OV_ODBC3 3UL +#define SQL_PARAM_ARRAY_ROW_COUNTS 153 +#define SQL_PARAM_ARRAY_SELECTS 154 +#define SQL_PARAM_BIND_BY_COLUMN 0UL +#define SQL_PARAM_BIND_TYPE_DEFAULT SQL_PARAM_BIND_BY_COLUMN +#define SQL_PARAM_DIAG_UNAVAILABLE 1 +#define SQL_PARAM_ERROR 5 +#define SQL_PARAM_IGNORE 1 +#define SQL_PARAM_PROCEED 0 +#define SQL_PARAM_SUCCESS 0 +#define SQL_PARAM_SUCCESS_WITH_INFO 6 +#define SQL_PARAM_UNUSED 7 +#define SQL_PARC_BATCH 1 +#define SQL_PARC_NO_BATCH 2 +#define SQL_PAS_BATCH 1 +#define SQL_PAS_NO_BATCH 2 +#define SQL_PAS_NO_SELECT 3 +#define SQL_ROW_IGNORE 1 +#define SQL_ROW_NUMBER_UNKNOWN (-2) +#define SQL_ROW_PROCEED 0 +#define SQL_ROW_SUCCESS_WITH_INFO 6 +#define SQL_SC_FIPS127_2_TRANSITIONAL 0x00000002L +#define SQL_SC_SQL92_ENTRY 0x00000001L +#define SQL_SC_SQL92_FULL 0x00000008L +#define SQL_SC_SQL92_INTERMEDIATE 0x00000004L +#define SQL_SCC_ISO92_CLI 0x00000002L +#define SQL_SCC_XOPEN_CLI_VERSION1 0x00000001L +#define SQL_SCHEMA_TERM SQL_OWNER_TERM +#define SQL_SCHEMA_USAGE SQL_OWNER_USAGE +#define SQL_SDF_CURRENT_DATE 0x00000001L +#define SQL_SDF_CURRENT_TIME 0x00000002L +#define SQL_SDF_CURRENT_TIMESTAMP 0x00000004L +#define SQL_SFKD_CASCADE 0x00000001L +#define SQL_SFKD_NO_ACTION 0x00000002L +#define SQL_SFKD_SET_DEFAULT 0x00000004L +#define SQL_SFKD_SET_NULL 0x00000008L +#define SQL_SFKU_CASCADE 0x00000001L +#define SQL_SFKU_NO_ACTION 0x00000002L +#define SQL_SFKU_SET_DEFAULT 0x00000004L +#define SQL_SFKU_SET_NULL 0x00000008L +#define SQL_SG_DELETE_TABLE 0x00000020L +#define SQL_SG_INSERT_COLUMN 0x00000080L +#define SQL_SG_INSERT_TABLE 0x00000040L +#define SQL_SG_REFERENCES_COLUMN 0x00000200L +#define SQL_SG_REFERENCES_TABLE 0x00000100L +#define SQL_SG_SELECT_TABLE 0x00000400L +#define SQL_SG_UPDATE_COLUMN 0x00001000L +#define SQL_SG_UPDATE_TABLE 0x00000800L +#define SQL_SG_USAGE_ON_CHARACTER_SET 0x00000002L +#define SQL_SG_USAGE_ON_COLLATION 0x00000004L +#define SQL_SG_USAGE_ON_DOMAIN 0x00000001L +#define SQL_SG_USAGE_ON_TRANSLATION 0x00000008L +#define SQL_SG_WITH_GRANT_OPTION 0x00000010L +#define SQL_SNVF_BIT_LENGTH 0x00000001L +#define SQL_SNVF_CHAR_LENGTH 0x00000002L +#define SQL_SNVF_CHARACTER_LENGTH 0x00000004L +#define SQL_SNVF_EXTRACT 0x00000008L +#define SQL_SNVF_OCTET_LENGTH 0x00000010L +#define SQL_SNVF_POSITION 0x00000020L +#define SQL_SP_BETWEEN 0x00000800L +#define SQL_SP_COMPARISON 0x00001000L +#define SQL_SP_EXISTS 0x00000001L +#define SQL_SP_IN 0x00000400L +#define SQL_SP_ISNOTNULL 0x00000002L +#define SQL_SP_ISNULL 0x00000004L +#define SQL_SP_LIKE 0x00000200L +#define SQL_SP_MATCH_FULL 0x00000008L +#define SQL_SP_MATCH_PARTIAL 0x00000010L +#define SQL_SP_MATCH_UNIQUE_FULL 0x00000020L +#define SQL_SP_MATCH_UNIQUE_PARTIAL 0x00000040L +#define SQL_SP_OVERLAPS 0x00000080L +#define SQL_SP_QUANTIFIED_COMPARISON 0x00002000L +#define SQL_SP_UNIQUE 0x00000100L +#define SQL_SQL_CONFORMANCE 118 +#define SQL_SQL92_DATETIME_FUNCTIONS 155 +#define SQL_SQL92_FOREIGN_KEY_DELETE_RULE 156 +#define SQL_SQL92_FOREIGN_KEY_UPDATE_RULE 157 +#define SQL_SQL92_GRANT 158 +#define SQL_SQL92_NUMERIC_VALUE_FUNCTIONS 159 +#define SQL_SQL92_PREDICATES 160 +#define SQL_SQL92_RELATIONAL_JOIN_OPERATORS 161 +#define SQL_SQL92_REVOKE 162 +#define SQL_SQL92_ROW_VALUE_CONSTRUCTOR 163 +#define SQL_SQL92_STRING_FUNCTIONS 164 +#define SQL_SQL92_VALUE_EXPRESSIONS 165 +#define SQL_SR_CASCADE 0x00000020L +#define SQL_SR_DELETE_TABLE 0x00000080L +#define SQL_SR_GRANT_OPTION_FOR 0x00000010L +#define SQL_SR_INSERT_COLUMN 0x00000200L +#define SQL_SR_INSERT_TABLE 0x00000100L +#define SQL_SR_REFERENCES_COLUMN 0x00000800L +#define SQL_SR_REFERENCES_TABLE 0x00000400L +#define SQL_SR_RESTRICT 0x00000040L +#define SQL_SR_SELECT_TABLE 0x00001000L +#define SQL_SR_UPDATE_COLUMN 0x00004000L +#define SQL_SR_UPDATE_TABLE 0x00002000L +#define SQL_SR_USAGE_ON_CHARACTER_SET 0x00000002L +#define SQL_SR_USAGE_ON_COLLATION 0x00000004L +#define SQL_SR_USAGE_ON_DOMAIN 0x00000001L +#define SQL_SR_USAGE_ON_TRANSLATION 0x00000008L +#define SQL_SRJO_CORRESPONDING_CLAUSE 0x00000001L +#define SQL_SRJO_CROSS_JOIN 0x00000002L +#define SQL_SRJO_EXCEPT_JOIN 0x00000004L +#define SQL_SRJO_FULL_OUTER_JOIN 0x00000008L +#define SQL_SRJO_INNER_JOIN 0x00000010L +#define SQL_SRJO_INTERSECT_JOIN 0x00000020L +#define SQL_SRJO_LEFT_OUTER_JOIN 0x00000040L +#define SQL_SRJO_NATURAL_JOIN 0x00000080L +#define SQL_SRJO_RIGHT_OUTER_JOIN 0x00000100L +#define SQL_SRJO_UNION_JOIN 0x00000200L +#define SQL_SRVC_DEFAULT 0x00000004L +#define SQL_SRVC_NULL 0x00000002L +#define SQL_SRVC_ROW_SUBQUERY 0x00000008L +#define SQL_SRVC_VALUE_EXPRESSION 0x00000001L +#define SQL_SSF_CONVERT 0x00000001L +#define SQL_SSF_LOWER 0x00000002L +#define SQL_SSF_SUBSTRING 0x00000008L +#define SQL_SSF_TRANSLATE 0x00000010L +#define SQL_SSF_TRIM_BOTH 0x00000020L +#define SQL_SSF_TRIM_LEADING 0x00000040L +#define SQL_SSF_TRIM_TRAILING 0x00000080L +#define SQL_SSF_UPPER 0x00000004L +#define SQL_STANDARD_CLI_CONFORMANCE 166 +#define SQL_STATIC_CURSOR_ATTRIBUTES1 167 +#define SQL_STATIC_CURSOR_ATTRIBUTES2 168 +#define SQL_SU_DML_STATEMENTS SQL_OU_DML_STATEMENTS +#define SQL_SU_INDEX_DEFINITION SQL_OU_INDEX_DEFINITION +#define SQL_SU_PRIVILEGE_DEFINITION SQL_OU_PRIVILEGE_DEFINITION +#define SQL_SU_PROCEDURE_INVOCATION SQL_OU_PROCEDURE_INVOCATION +#define SQL_SU_TABLE_DEFINITION SQL_OU_TABLE_DEFINITION +#define SQL_SVE_CASE 0x00000001L +#define SQL_SVE_CAST 0x00000002L +#define SQL_SVE_COALESCE 0x00000004L +#define SQL_SVE_NULLIF 0x00000008L +#define SQL_UB_FIXED SQL_UB_ON +#define SQL_UB_VARIABLE 2UL +#define SQL_UNION_STATEMENT SQL_UNION +#define SQL_UPDATE_BY_BOOKMARK 5 +#define SQL_US_UNION SQL_U_UNION +#define SQL_US_UNION_ALL SQL_U_UNION_ALL +#endif /* ODBCVER >= 0x300 */ +#if (ODBCVER >= 0x0350) +#define SQL_DESC_ROWVER 35 +#define SQL_GUID (-11) +#define SQL_C_GUID SQL_GUID +#ifdef ODBC_STD +#define SQLAllocHandle SQLAllocHandleStd +#define SQLAllocEnv(p) SQLAllocHandleStd(SQL_HANDLE_ENV,SQL_NULL_HANDLE,p) +#define SQL_YEAR SQL_CODE_YEAR +#define SQL_MONTH SQL_CODE_MONTH +#define SQL_DAY SQL_CODE_DAY +#define SQL_HOUR SQL_CODE_HOUR +#define SQL_MINUTE SQL_CODE_MINUTE +#define SQL_SECOND SQL_CODE_SECOND +#define SQL_YEAR_TO_MONTH SQL_CODE_YEAR_TO_MONTH +#define SQL_DAY_TO_HOUR SQL_CODE_DAY_TO_HOUR +#define SQL_DAY_TO_MINUTE SQL_CODE_DAY_TO_MINUTE +#define SQL_DAY_TO_SECOND SQL_CODE_DAY_TO_SECOND +#define SQL_HOUR_TO_MINUTE SQL_CODE_HOUR_TO_MINUTE +#define SQL_HOUR_TO_SECOND SQL_CODE_HOUR_TO_SECOND +#define SQL_MINUTE_TO_SECOND SQL_CODE_MINUTE_TO_SECOND +#endif /* ODBC_STD */ +#endif /* ODBCVER >= 0x0350 */ +#if (ODBCVER >= 0x0351) +#define SQL_ATTR_ANSI_APP 115 +#define SQL_AA_TRUE 1L +#define SQL_AA_FALSE 0L +#endif + +#define TRACE_VERSION 1000 +#define TRACE_ON 1 + +#ifndef RC_INVOKED +#define SQL_ODBC_KEYWORDS \ +"ABSOLUTE,ACTION,ADA,ADD,ALL,ALLOCATE,ALTER,AND,ANY,ARE,AS,"\ +"ASC,ASSERTION,AT,AUTHORIZATION,AVG,"\ +"BEGIN,BETWEEN,BIT,BIT_LENGTH,BOTH,BY,CASCADE,CASCADED,CASE,CAST,CATALOG,"\ +"CHAR,CHAR_LENGTH,CHARACTER,CHARACTER_LENGTH,CHECK,CLOSE,COALESCE,"\ +"COLLATE,COLLATION,COLUMN,COMMIT,CONNECT,CONNECTION,CONSTRAINT,"\ +"CONSTRAINTS,CONTINUE,CONVERT,CORRESPONDING,COUNT,CREATE,CROSS,CURRENT,"\ +"CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,"\ +"DATE,DAY,DEALLOCATE,DEC,DECIMAL,DECLARE,DEFAULT,DEFERRABLE,"\ +"DEFERRED,DELETE,DESC,DESCRIBE,DESCRIPTOR,DIAGNOSTICS,DISCONNECT,"\ +"DISTINCT,DOMAIN,DOUBLE,DROP,"\ +"ELSE,END,END-EXEC,ESCAPE,EXCEPT,EXCEPTION,EXEC,EXECUTE,"\ +"EXISTS,EXTERNAL,EXTRACT,"\ +"FALSE,FETCH,FIRST,FLOAT,FOR,FOREIGN,FORTRAN,FOUND,FROM,FULL,"\ +"GET,GLOBAL,GO,GOTO,GRANT,GROUP,HAVING,HOUR,"\ +"IDENTITY,IMMEDIATE,IN,INCLUDE,INDEX,INDICATOR,INITIALLY,INNER,"\ +"INPUT,INSENSITIVE,INSERT,INT,INTEGER,INTERSECT,INTERVAL,INTO,IS,ISOLATION,"\ +"JOIN,KEY,LANGUAGE,LAST,LEADING,LEFT,LEVEL,LIKE,LOCAL,LOWER,"\ +"MATCH,MAX,MIN,MINUTE,MODULE,MONTH,"\ +"NAMES,NATIONAL,NATURAL,NCHAR,NEXT,NO,NONE,NOT,NULL,NULLIF,NUMERIC,"\ +"OCTET_LENGTH,OF,ON,ONLY,OPEN,OPTION,OR,ORDER,OUTER,OUTPUT,OVERLAPS,"\ +"PAD,PARTIAL,PASCAL,PLI,POSITION,PRECISION,PREPARE,PRESERVE,"\ +"PRIMARY,PRIOR,PRIVILEGES,PROCEDURE,PUBLIC,"\ +"READ,REAL,REFERENCES,RELATIVE,RESTRICT,REVOKE,RIGHT,ROLLBACK,ROWS"\ +"SCHEMA,SCROLL,SECOND,SECTION,SELECT,SESSION,SESSION_USER,SET,SIZE,"\ +"SMALLINT,SOME,SPACE,SQL,SQLCA,SQLCODE,SQLERROR,SQLSTATE,SQLWARNING,"\ +"SUBSTRING,SUM,SYSTEM_USER,"\ +"TABLE,TEMPORARY,THEN,TIME,TIMESTAMP,TIMEZONE_HOUR,TIMEZONE_MINUTE,"\ +"TO,TRAILING,TRANSACTION,TRANSLATE,TRANSLATION,TRIM,TRUE,"\ +"UNION,UNIQUE,UNKNOWN,UPDATE,UPPER,USAGE,USER,USING,"\ +"VALUE,VALUES,VARCHAR,VARYING,VIEW,WHEN,WHENEVER,WHERE,WITH,WORK,WRITE,"\ +"YEAR,ZONE" + +SQLRETURN SQL_API SQLDriverConnect(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLColAttributes(SQLHSTMT,SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLLEN*); +SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*); +SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLMoreResults(SQLHSTMT); +SQLRETURN SQL_API SQLNativeSql(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLNumParams(SQLHSTMT,SQLSMALLINT*); +SQLRETURN SQL_API SQLParamOptions(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*); +SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedures(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetPos(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDrivers(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLBindParameter(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLUSMALLINT); /* deprecated */ +DWORD SQL_API ODBCGetTryWaitValue(void); +BOOL SQL_API ODBCSetTryWaitValue(DWORD); +RETCODE SQL_API TraceOpenLogFile(LPWSTR,LPWSTR,DWORD); +RETCODE SQL_API TraceCloseLogFile(void); +VOID SQL_API TraceReturn(RETCODE,RETCODE); +DWORD SQL_API TraceVersion(void); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLAllocHandleStd( SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +#endif +#endif /* ndef RC_INVOKED */ +#include +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.25.orig/win32/include/sql.h tcc-0.9.25/win32/include/sql.h --- tcc-0.9.25.orig/win32/include/sql.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/sql.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,408 @@ +#ifndef _SQL_H +#define _SQL_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef ODBCVER +#define ODBCVER 0x0351 +#endif +#include +#define SQL_ACCESSIBLE_PROCEDURES 20 +#define SQL_ACCESSIBLE_TABLES 19 +#define SQL_ALL_TYPES 0 +#define SQL_ALTER_TABLE 86 +#define SQL_API_SQLALLOCCONNECT 1 +#define SQL_API_SQLALLOCENV 2 +#define SQL_API_SQLALLOCSTMT 3 +#define SQL_API_SQLBINDCOL 4 +#define SQL_API_SQLCANCEL 5 +#define SQL_API_SQLCOLUMNS 40 +#define SQL_API_SQLCONNECT 7 +#define SQL_API_SQLDATASOURCES 57 +#define SQL_API_SQLDESCRIBECOL 8 +#define SQL_API_SQLDISCONNECT 9 +#define SQL_API_SQLERROR 10 +#define SQL_API_SQLEXECDIRECT 11 +#define SQL_API_SQLEXECUTE 12 +#define SQL_API_SQLFETCH 13 +#define SQL_API_SQLFREECONNECT 14 +#define SQL_API_SQLFREEENV 15 +#define SQL_API_SQLFREESTMT 16 +#define SQL_API_SQLGETCONNECTOPTION 42 +#define SQL_API_SQLGETCURSORNAME 17 +#define SQL_API_SQLGETDATA 43 +#define SQL_API_SQLGETFUNCTIONS 44 +#define SQL_API_SQLGETINFO 45 +#define SQL_API_SQLGETSTMTOPTION 46 +#define SQL_API_SQLGETTYPEINFO 47 +#define SQL_API_SQLNUMRESULTCOLS 18 +#define SQL_API_SQLPARAMDATA 48 +#define SQL_API_SQLPREPARE 19 +#define SQL_API_SQLPUTDATA 49 +#define SQL_API_SQLROWCOUNT 20 +#define SQL_API_SQLSETCONNECTOPTION 50 +#define SQL_API_SQLSETCURSORNAME 21 +#define SQL_API_SQLSETPARAM 22 +#define SQL_API_SQLSETSTMTOPTION 51 +#define SQL_API_SQLSPECIALCOLUMNS 52 +#define SQL_API_SQLSTATISTICS 53 +#define SQL_API_SQLTABLES 54 +#define SQL_API_SQLTRANSACT 23 +#define SQL_CB_CLOSE 1 +#define SQL_CB_DELETE 0 +#define SQL_CB_PRESERVE 2 +#define SQL_CHAR 1 +#define SQL_CLOSE 0 +#define SQL_COMMIT 0 +#define SQL_CURSOR_COMMIT_BEHAVIOR 23 +#define SQL_DATA_AT_EXEC (-2) +#define SQL_DATA_SOURCE_NAME 2 +#define SQL_DATA_SOURCE_READ_ONLY 25 +#define SQL_DBMS_NAME 17 +#define SQL_DBMS_VER 18 +#define SQL_DECIMAL 3 +#define SQL_DEFAULT_TXN_ISOLATION 26 +#define SQL_DOUBLE 8 +#define SQL_DROP 1 +#define SQL_ERROR (-1) +#define SQL_FD_FETCH_ABSOLUTE 16 +#define SQL_FD_FETCH_FIRST 2 +#define SQL_FD_FETCH_LAST 4 +#define SQL_FD_FETCH_NEXT 1 +#define SQL_FD_FETCH_PRIOR 8 +#define SQL_FD_FETCH_RELATIVE 32 +#define SQL_FETCH_ABSOLUTE 5 +#define SQL_FETCH_DIRECTION 8 +#define SQL_FETCH_FIRST 2 +#define SQL_FETCH_LAST 3 +#define SQL_FETCH_NEXT 1 +#define SQL_FETCH_PRIOR 4 +#define SQL_FETCH_RELATIVE 6 +#define SQL_FLOAT 6 +#define SQL_GD_ANY_COLUMN 1 +#define SQL_GD_ANY_ORDER 2 +#define SQL_GETDATA_EXTENSIONS 81 +#define SQL_IC_LOWER 2 +#define SQL_IC_MIXED 4 +#define SQL_IC_SENSITIVE 3 +#define SQL_IC_UPPER 1 +#define SQL_IDENTIFIER_CASE 28 +#define SQL_IDENTIFIER_QUOTE_CHAR 29 +#define SQL_INDEX_ALL 1 +#define SQL_INDEX_CLUSTERED 1 +#define SQL_INDEX_HASHED 2 +#define SQL_INDEX_OTHER 3 +#define SQL_INDEX_UNIQUE 0 +#define SQL_INTEGER 4 +#define SQL_INTEGRITY 73 +#define SQL_INVALID_HANDLE (-2) +#define SQL_MAX_CATALOG_NAME_LEN 34 +#define SQL_MAX_COLUMN_NAME_LEN 30 +#define SQL_MAX_COLUMNS_IN_GROUP_BY 97 +#define SQL_MAX_COLUMNS_IN_INDEX 98 +#define SQL_MAX_COLUMNS_IN_ORDER_BY 99 +#define SQL_MAX_COLUMNS_IN_SELECT 100 +#define SQL_MAX_COLUMNS_IN_TABLE 101 +#define SQL_MAX_CURSOR_NAME_LEN 31 +#define SQL_MAX_INDEX_SIZE 102 +#define SQL_MAX_MESSAGE_LENGTH 512 +#define SQL_MAX_ROW_SIZE 104 +#define SQL_MAX_SCHEMA_NAME_LEN 32 +#define SQL_MAX_STATEMENT_LEN 105 +#define SQL_MAX_TABLE_NAME_LEN 35 +#define SQL_MAX_TABLES_IN_SELECT 106 +#define SQL_MAX_USER_NAME_LEN 107 +#define SQL_MAXIMUM_CATALOG_NAME_LENGTH SQL_MAX_CATALOG_NAME_LEN +#define SQL_MAXIMUM_COLUMN_NAME_LENGTH SQL_MAX_COLUMN_NAME_LEN +#define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY SQL_MAX_COLUMNS_IN_GROUP_BY +#define SQL_MAXIMUM_COLUMNS_IN_INDEX SQL_MAX_COLUMNS_IN_INDEX +#define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY SQL_MAX_COLUMNS_IN_ORDER_BY +#define SQL_MAXIMUM_COLUMNS_IN_SELECT SQL_MAX_COLUMNS_IN_SELECT +#define SQL_MAXIMUM_CURSOR_NAME_LENGTH SQL_MAX_CURSOR_NAME_LEN +#define SQL_MAXIMUM_INDEX_SIZE SQL_MAX_INDEX_SIZE +#define SQL_MAXIMUM_ROW_SIZE SQL_MAX_ROW_SIZE +#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH SQL_MAX_SCHEMA_NAME_LEN +#define SQL_MAXIMUM_STATEMENT_LENGTH SQL_MAX_STATEMENT_LEN +#define SQL_MAXIMUM_TABLES_IN_SELECT SQL_MAX_TABLES_IN_SELECT +#define SQL_MAXIMUM_USER_NAME_LENGTH SQL_MAX_USER_NAME_LEN +#define SQL_NC_HIGH 0 +#define SQL_NC_LOW 1 +#define SQL_NEED_DATA 99 +#define SQL_NO_NULLS 0 +#define SQL_NTS (-3) +#define SQL_NTSL (-3L) +#define SQL_NULL_COLLATION 85 +#define SQL_NULL_DATA (-1) +#define SQL_NULL_HDBC 0 +#define SQL_NULL_HENV 0 +#define SQL_NULL_HSTMT 0 +#define SQL_NULLABLE 1 +#define SQL_NULLABLE_UNKNOWN 2 +#define SQL_NUMERIC 2 +#define SQL_ORDER_BY_COLUMNS_IN_SELECT 90 +#define SQL_PC_PSEUDO 2 +#define SQL_PC_UNKNOWN 0 +#define SQL_REAL 7 +#define SQL_RESET_PARAMS 3 +#define SQL_ROLLBACK 1 +#define SQL_SCCO_LOCK 2 +#define SQL_SCCO_OPT_ROWVER 4 +#define SQL_SCCO_OPT_VALUES 8 +#define SQL_SCCO_READ_ONLY 1 +#define SQL_SCOPE_CURROW 0 +#define SQL_SCOPE_SESSION 2 +#define SQL_SCOPE_TRANSACTION 1 +#define SQL_SCROLL_CONCURRENCY 43 +#define SQL_SEARCH_PATTERN_ESCAPE 14 +#define SQL_SERVER_NAME 13 +#define SQL_SMALLINT 5 +#define SQL_SPECIAL_CHARACTERS 94 +#define SQL_STILL_EXECUTING 2 +#define SQL_SUCCEEDED(rc) (((rc)&(~1))==0) +#define SQL_SUCCESS 0 +#define SQL_SUCCESS_WITH_INFO 1 +#define SQL_TC_ALL 2 +#define SQL_TC_DDL_COMMIT 3 +#define SQL_TC_DDL_IGNORE 4 +#define SQL_TC_DML 1 +#define SQL_TC_NONE 0 +#define SQL_TRANSACTION_CAPABLE SQL_TXN_CAPABLE +#define SQL_TRANSACTION_ISOLATION_OPTION SQL_TXN_ISOLATION_OPTION +#define SQL_TRANSACTION_READ_COMMITTED SQL_TXN_READ_COMMITTED +#define SQL_TRANSACTION_READ_UNCOMMITTED SQL_TXN_READ_UNCOMMITTED +#define SQL_TRANSACTION_REPEATABLE_READ SQL_TXN_REPEATABLE_READ +#define SQL_TRANSACTION_SERIALIZABLE SQL_TXN_SERIALIZABLE +#define SQL_TXN_CAPABLE 46 +#define SQL_TXN_ISOLATION_OPTION 72 +#define SQL_TXN_READ_COMMITTED 2 +#define SQL_TXN_READ_UNCOMMITTED 1 +#define SQL_TXN_REPEATABLE_READ 4 +#define SQL_TXN_SERIALIZABLE 8 +#define SQL_UNBIND 2 +#define SQL_UNKNOWN_TYPE 0 +#define SQL_USER_NAME 47 +#define SQL_VARCHAR 12 +#if (ODBCVER >= 0x0200) +#define SQL_AT_ADD_COLUMN 1 +#define SQL_AT_DROP_COLUMN 2 +#endif /* ODBCVER >= 0x0200 */ +#if (ODBCVER >= 0x0201) +#define SQL_OJ_LEFT 1 +#define SQL_OJ_RIGHT 2 +#define SQL_OJ_FULL 4 +#define SQL_OJ_NESTED 8 +#define SQL_OJ_NOT_ORDERED 16 +#define SQL_OJ_INNER 32 +#define SQL_OJ_ALL_COMPARISON_OPS 64 +#endif /* ODBCVER >= 0x0201 */ +#if (ODBCVER >= 0x0300) +#define SQL_AM_CONNECTION 1 +#define SQL_AM_NONE 0 +#define SQL_AM_STATEMENT 2 +#define SQL_API_SQLALLOCHANDLE 1001 +#define SQL_API_SQLBINDPARAM 1002 +#define SQL_API_SQLCLOSECURSOR 1003 +#define SQL_API_SQLCOLATTRIBUTE 6 +#define SQL_API_SQLCOPYDESC 1004 +#define SQL_API_SQLENDTRAN 1005 +#define SQL_API_SQLFETCHSCROLL 1021 +#define SQL_API_SQLFREEHANDLE 1006 +#define SQL_API_SQLGETCONNECTATTR 1007 +#define SQL_API_SQLGETDESCFIELD 1008 +#define SQL_API_SQLGETDESCREC 1009 +#define SQL_API_SQLGETDIAGFIELD 1010 +#define SQL_API_SQLGETDIAGREC 1011 +#define SQL_API_SQLGETENVATTR 1012 +#define SQL_API_SQLGETSTMTATTR 1014 +#define SQL_API_SQLSETCONNECTATTR 1016 +#define SQL_API_SQLSETDESCFIELD 1017 +#define SQL_API_SQLSETDESCREC 1018 +#define SQL_API_SQLSETENVATTR 1019 +#define SQL_API_SQLSETSTMTATTR 1020 +#define SQL_ARD_TYPE (-99) +#define SQL_AT_ADD_CONSTRAINT 8 +#define SQL_ATTR_APP_PARAM_DESC 10011 +#define SQL_ATTR_APP_ROW_DESC 10010 +#define SQL_ATTR_AUTO_IPD 10001 +#define SQL_ATTR_CURSOR_SCROLLABLE (-1) +#define SQL_ATTR_CURSOR_SENSITIVITY (-2) +#define SQL_ATTR_IMP_PARAM_DESC 10013 +#define SQL_ATTR_IMP_ROW_DESC 10012 +#define SQL_ATTR_METADATA_ID 10014 +#define SQL_ATTR_OUTPUT_NTS 10001 +#define SQL_CATALOG_NAME 10003 +#define SQL_CODE_DATE 1 +#define SQL_CODE_TIME 2 +#define SQL_CODE_TIMESTAMP 3 +#define SQL_COLLATION_SEQ 10004 +#define SQL_CURSOR_SENSITIVITY 10001 +#define SQL_DATE_LEN 10 +#define SQL_DATETIME 9 +#define SQL_DEFAULT 99 +#define SQL_DESC_ALLOC_AUTO 1 +#define SQL_DESC_ALLOC_TYPE 1099 +#define SQL_DESC_ALLOC_USER 2 +#define SQL_DESC_COUNT 1001 +#define SQL_DESC_DATA_PTR 1010 +#define SQL_DESC_DATETIME_INTERVAL_CODE 1007 +#define SQL_DESC_INDICATOR_PTR 1009 +#define SQL_DESC_LENGTH 1003 +#define SQL_DESC_NAME 1011 +#define SQL_DESC_NULLABLE 1008 +#define SQL_DESC_OCTET_LENGTH 1013 +#define SQL_DESC_OCTET_LENGTH_PTR 1004 +#define SQL_DESC_PRECISION 1005 +#define SQL_DESC_SCALE 1006 +#define SQL_DESC_TYPE 1002 +#define SQL_DESC_UNNAMED 1012 +#define SQL_DESCRIBE_PARAMETER 10002 +#define SQL_DIAG_ALTER_DOMAIN 3 +#define SQL_DIAG_ALTER_TABLE 4 +#define SQL_DIAG_CALL 7 +#define SQL_DIAG_CLASS_ORIGIN 8 +#define SQL_DIAG_CONNECTION_NAME 10 +#define SQL_DIAG_CREATE_ASSERTION 6 +#define SQL_DIAG_CREATE_CHARACTER_SET 8 +#define SQL_DIAG_CREATE_COLLATION 10 +#define SQL_DIAG_CREATE_DOMAIN 23 +#define SQL_DIAG_CREATE_INDEX (-1) +#define SQL_DIAG_CREATE_SCHEMA 64 +#define SQL_DIAG_CREATE_TABLE 77 +#define SQL_DIAG_CREATE_TRANSLATION 79 +#define SQL_DIAG_CREATE_VIEW 84 +#define SQL_DIAG_DELETE_WHERE 19 +#define SQL_DIAG_DROP_ASSERTION 24 +#define SQL_DIAG_DROP_CHARACTER_SET 25 +#define SQL_DIAG_DROP_COLLATION 26 +#define SQL_DIAG_DROP_DOMAIN 27 +#define SQL_DIAG_DROP_INDEX (-2) +#define SQL_DIAG_DROP_SCHEMA 31 +#define SQL_DIAG_DROP_TABLE 32 +#define SQL_DIAG_DROP_TRANSLATION 33 +#define SQL_DIAG_DROP_VIEW 36 +#define SQL_DIAG_DYNAMIC_DELETE_CURSOR 38 +#define SQL_DIAG_DYNAMIC_FUNCTION 7 +#define SQL_DIAG_DYNAMIC_FUNCTION_CODE 12 +#define SQL_DIAG_DYNAMIC_UPDATE_CURSOR 81 +#define SQL_DIAG_GRANT 48 +#define SQL_DIAG_INSERT 50 +#define SQL_DIAG_MESSAGE_TEXT 6 +#define SQL_DIAG_NATIVE 5 +#define SQL_DIAG_NUMBER 2 +#define SQL_DIAG_RETURNCODE 1 +#define SQL_DIAG_REVOKE 59 +#define SQL_DIAG_ROW_COUNT 3 +#define SQL_DIAG_SELECT_CURSOR 85 +#define SQL_DIAG_SERVER_NAME 11 +#define SQL_DIAG_SQLSTATE 4 +#define SQL_DIAG_SUBCLASS_ORIGIN 9 +#define SQL_DIAG_UNKNOWN_STATEMENT 0 +#define SQL_DIAG_UPDATE_WHERE 82 +#define SQL_FALSE 0 +#define SQL_HANDLE_DBC 2 +#define SQL_HANDLE_DESC 4 +#define SQL_HANDLE_ENV 1 +#define SQL_HANDLE_STMT 3 +#define SQL_INSENSITIVE 1 +#define SQL_MAX_CONCURRENT_ACTIVITIES 1 +#define SQL_MAX_DRIVER_CONNECTIONS 0 +#define SQL_MAX_IDENTIFIER_LEN 10005 +#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES SQL_MAX_CONCURRENT_ACTIVITIES +#define SQL_MAXIMUM_DRIVER_CONNECTIONS SQL_MAX_DRIVER_CONNECTIONS +#define SQL_MAXIMUM_IDENTIFIER_LENGTH SQL_MAX_IDENTIFIER_LEN +#define SQL_NAMED 0 +#define SQL_NO_DATA 100 +#define SQL_NONSCROLLABLE 0 +#define SQL_NULL_HANDLE 0L +#define SQL_NULL_HDESC 0 +#define SQL_OJ_CAPABILITIES 115 +#define SQL_OUTER_JOIN_CAPABILITIES SQL_OJ_CAPABILITIES +#define SQL_PC_NON_PSEUDO 1 +#define SQL_PRED_BASIC 2 +#define SQL_PRED_CHAR 1 +#define SQL_PRED_NONE 0 +#define SQL_ROW_IDENTIFIER 1 +#define SQL_SCROLLABLE 1 +#define SQL_SENSITIVE 2 +#define SQL_TIME_LEN 8 +#define SQL_TIMESTAMP_LEN 19 +#define SQL_TRUE 1 +#define SQL_TYPE_DATE 91 +#define SQL_TYPE_TIME 92 +#define SQL_TYPE_TIMESTAMP 93 +#define SQL_UNNAMED 1 +#define SQL_UNSPECIFIED 0 +#define SQL_XOPEN_CLI_YEAR 10000 +#endif /* ODBCVER >= 0x0300 */ + +#ifndef RC_INVOKED +SQLRETURN SQL_API SQLAllocConnect(SQLHENV,SQLHDBC*); /* deprecated */ +SQLRETURN SQL_API SQLAllocEnv(SQLHENV*); /* deprecated */ +SQLRETURN SQL_API SQLAllocStmt(SQLHDBC,SQLHSTMT*); /* deprecated */ +SQLRETURN SQL_API SQLBindCol(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLCancel(SQLHSTMT); +SQLRETURN SQL_API SQLConnect(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDisconnect(SQLHDBC); +SQLRETURN SQL_API SQLError(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); /* deprecated */ +SQLRETURN SQL_API SQLExecDirect(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLExecute(SQLHSTMT); +SQLRETURN SQL_API SQLFetch(SQLHSTMT); +SQLRETURN SQL_API SQLFreeConnect(SQLHDBC); /* deprecated */ +SQLRETURN SQL_API SQLFreeEnv(SQLHENV); /* deprecated */ +SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT,SQLUSMALLINT); +SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT,SQLSMALLINT*); +SQLRETURN SQL_API SQLPrepare(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLRowCount(SQLHSTMT,SQLLEN*); +SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTransact(SQLHENV,SQLHDBC,SQLUSMALLINT); +SQLRETURN SQL_API SQLSetParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*); /* deprecated */ +SQLRETURN SQL_API SQLColumns(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC,SQLUSMALLINT,SQLPOINTER); /* deprecated */ +SQLRETURN SQL_API SQLGetData(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); +SQLRETURN SQL_API SQLGetFunctions(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*); +SQLRETURN SQL_API SQLGetInfo(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT,SQLUSMALLINT,SQLPOINTER); /* deprecated */ +SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLParamData(SQLHSTMT,SQLPOINTER*); +SQLRETURN SQL_API SQLPutData(SQLHSTMT,SQLPOINTER,SQLLEN); +SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC,SQLUSMALLINT,SQLULEN); /* deprecated */ +SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT,SQLUSMALLINT,SQLROWCOUNT); /* deprecated */ +SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatistics(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTables(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDataSources(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); +SQLRETURN SQL_API SQLBindParam(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*); +SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT); +SQLRETURN SQL_API SQLColAttribute(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLCopyDesc(SQLHDESC,SQLHDESC); +SQLRETURN SQL_API SQLEndTran(SQLSMALLINT,SQLHANDLE,SQLSMALLINT); +SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT,SQLSMALLINT,SQLROWOFFSET); +SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT,SQLHANDLE); +SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescField(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescRec(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*, + SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescField(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescRec(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLLEN,SQLSMALLINT, + SQLSMALLINT,SQLPOINTER,SQLLEN*,SQLLEN*); +SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +#endif /* (ODBCVER >= 0x0300) */ +#endif /* ndef RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.25.orig/win32/include/sqltypes.h tcc-0.9.25/win32/include/sqltypes.h --- tcc-0.9.25.orig/win32/include/sqltypes.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/sqltypes.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,165 @@ +#ifndef _SQLTYPES_H +#define _SQLTYPES_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_API __stdcall +#ifndef RC_INVOKED +#define __need_wchar_t +#include +typedef signed char SCHAR; +typedef long SDWORD; +typedef short SWORD; +typedef ULONG UDWORD; +typedef USHORT UWORD; +typedef signed long SLONG; +typedef signed short SSHORT; +typedef double SDOUBLE; +typedef double LDOUBLE; +typedef float SFLOAT; +typedef PVOID PTR; +typedef PVOID HENV; +typedef PVOID HDBC; +typedef PVOID HSTMT; +typedef short RETCODE; +typedef UCHAR SQLCHAR; +typedef SCHAR SQLSCHAR; +typedef SDWORD SQLINTEGER; +typedef SWORD SQLSMALLINT; +#ifndef __WIN64 +typedef UDWORD SQLUINTEGER; +#endif +typedef UWORD SQLUSMALLINT; +typedef PVOID SQLPOINTER; +#if (ODBCVER >= 0x0300) +typedef void* SQLHANDLE; +typedef SQLHANDLE SQLHENV; +typedef SQLHANDLE SQLHDBC; +typedef SQLHANDLE SQLHSTMT; +typedef SQLHANDLE SQLHDESC; +#else +typedef void* SQLHENV; +typedef void* SQLHDBC; +typedef void* SQLHSTMT; +#endif +typedef SQLSMALLINT SQLRETURN; +typedef HWND SQLHWND; +typedef ULONG BOOKMARK; +#ifdef _WIN64 +typedef INT64 SQLLEN; +typedef INT64 SQLROWOFFSET; +typedef UINT64 SQLROWCOUNT; +typedef UINT64 SQLULEN; +typedef UINT64 SQLTRANSID; +typedef unsigned long SQLSETPOSIROW; +#else +#define SQLLEN SQLINTEGER +#define SQLROWOFFSET SQLINTEGER +#define SQLROWCOUNT SQLUINTEGER +#define SQLULEN SQLUINTEGER +#define SQLTRANSID DWORD +#define SQLSETPOSIROW SQLUSMALLINT +#endif +typedef wchar_t SQLWCHAR; +#ifdef UNICODE +typedef SQLWCHAR SQLTCHAR; +#else +typedef SQLCHAR SQLTCHAR; +#endif /* UNICODE */ +#if (ODBCVER >= 0x0300) +typedef unsigned char SQLDATE; +typedef unsigned char SQLDECIMAL; +typedef double SQLDOUBLE; +typedef double SQLFLOAT; +typedef unsigned char SQLNUMERIC; +typedef float SQLREAL; +typedef unsigned char SQLTIME; +typedef unsigned char SQLTIMESTAMP; +typedef unsigned char SQLVARCHAR; +#define ODBCINT64 __int64 +typedef __int64 SQLBIGINT; +typedef unsigned __int64 SQLUBIGINT; +#endif + +typedef struct tagDATE_STRUCT { + SQLSMALLINT year; + SQLUSMALLINT month; + SQLUSMALLINT day; +} DATE_STRUCT; +typedef struct tagTIME_STRUCT { + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; +} TIME_STRUCT; +typedef struct tagTIMESTAMP_STRUCT { + SQLSMALLINT year; + SQLUSMALLINT month; + SQLUSMALLINT day; + SQLUSMALLINT hour; + SQLUSMALLINT minute; + SQLUSMALLINT second; + SQLUINTEGER fraction; +} TIMESTAMP_STRUCT; +#if (ODBCVER >= 0x0300) +typedef DATE_STRUCT SQL_DATE_STRUCT; +typedef TIME_STRUCT SQL_TIME_STRUCT; +typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT; +typedef enum { + SQL_IS_YEAR = 1,SQL_IS_MONTH,SQL_IS_DAY,SQL_IS_HOUR, + SQL_IS_MINUTE,SQL_IS_SECOND,SQL_IS_YEAR_TO_MONTH,SQL_IS_DAY_TO_HOUR, + SQL_IS_DAY_TO_MINUTE,SQL_IS_DAY_TO_SECOND,SQL_IS_HOUR_TO_MINUTE, + SQL_IS_HOUR_TO_SECOND,SQL_IS_MINUTE_TO_SECOND +} SQLINTERVAL; +typedef struct tagSQL_YEAR_MONTH { + SQLUINTEGER year; + SQLUINTEGER month; +} SQL_YEAR_MONTH_STRUCT; +typedef struct tagSQL_DAY_SECOND { + SQLUINTEGER day; + SQLUINTEGER hour; + SQLUINTEGER minute; + SQLUINTEGER second; + SQLUINTEGER fraction; +} SQL_DAY_SECOND_STRUCT; +typedef struct tagSQL_INTERVAL_STRUCT { + SQLINTERVAL interval_type; + SQLSMALLINT interval_sign; + union { + SQL_YEAR_MONTH_STRUCT year_month; + SQL_DAY_SECOND_STRUCT day_second; + } intval; +} SQL_INTERVAL_STRUCT; +#define SQL_MAX_NUMERIC_LEN 16 +typedef struct tagSQL_NUMERIC_STRUCT { + SQLCHAR precision; + SQLSCHAR scale; + SQLCHAR sign; + SQLCHAR val[SQL_MAX_NUMERIC_LEN]; +} SQL_NUMERIC_STRUCT; +#endif /* ODBCVER >= 0x0300 */ +#if (ODBCVER >= 0x0350) + +#ifdef _GUID_DEFINED +# warning _GUID_DEFINED is deprecated, use GUID_DEFINED instead +#endif + +#if defined _GUID_DEFINED || defined GUID_DEFINED +typedef GUID SQLGUID; +#else +typedef struct tagSQLGUID{ + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[ 8 ]; +} SQLGUID; +#endif /* GUID_DEFINED */ +#endif /* ODBCVER >= 0x0350 */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif +#endif diff -Nur tcc-0.9.25.orig/win32/include/sqlucode.h tcc-0.9.25/win32/include/sqlucode.h --- tcc-0.9.25.orig/win32/include/sqlucode.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/sqlucode.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,142 @@ +#ifndef _SQLUCODE_H +#define _SQLUCODE_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#include +#ifdef __cplusplus +extern "C" { +#endif +#define SQL_WCHAR (-8) +#define SQL_WVARCHAR (-9) +#define SQL_WLONGVARCHAR (-10) +#define SQL_C_WCHAR SQL_WCHAR +#define SQL_SQLSTATE_SIZEW 10 +#ifdef UNICODE +#define SQL_C_TCHAR SQL_C_WCHAR +#else +#define SQL_C_TCHAR SQL_C_CHAR +#endif +#ifndef RC_INVOKED +SQLRETURN SQL_API SQLBrowseConnectA(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLBrowseConnectW(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLColAttributeA(SQLHSTMT,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLColAttributeW(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER); +SQLRETURN SQL_API SQLColAttributesA(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*); +SQLRETURN SQL_API SQLColAttributesW(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*); +SQLRETURN SQL_API SQLColumnPrivilegesA( SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnPrivilegesW( SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLColumnsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLConnectA(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLConnectW(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLDataSourcesA(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDataSourcesW(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDescribeColA(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDescribeColW(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLDriverConnectA(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLDriverConnectW(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT); +SQLRETURN SQL_API SQLDriversA(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLDriversW(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLErrorA(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLErrorW(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLExecDirectA(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLForeignKeysA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLForeignKeysW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLGetConnectAttrA(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetConnectAttrW(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetConnectOptionA(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +SQLRETURN SQL_API SQLGetConnectOptionW(SQLHDBC,SQLUSMALLINT,SQLPOINTER); +SQLRETURN SQL_API SQLGetCursorNameA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetCursorNameW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetInfoA(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetInfoW(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetTypeInfoA(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLGetTypeInfoW(SQLHSTMT,SQLSMALLINT); +SQLRETURN SQL_API SQLNativeSqlA(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLNativeSqlW(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLPrepareA(SQLHSTMT,SQLCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLPrepareW(SQLHSTMT,SQLWCHAR*,SQLINTEGER); +SQLRETURN SQL_API SQLPrimaryKeysA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLPrimaryKeysW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumnsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProcedureColumnsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProceduresA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLProceduresW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetConnectAttrA(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetConnectAttrW(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetConnectOptionA(SQLHDBC,SQLUSMALLINT,SQLULEN); +SQLRETURN SQL_API SQLSetConnectOptionW(SQLHDBC,SQLUSMALLINT,SQLULEN); +SQLRETURN SQL_API SQLSetCursorNameA(SQLHSTMT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSetCursorNameW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLSpecialColumnsA(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLSpecialColumnsW(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatisticsA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLStatisticsW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLUSMALLINT,SQLUSMALLINT); +SQLRETURN SQL_API SQLTablePrivilegesA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ); +SQLRETURN SQL_API SQLTablesA(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT); +SQLRETURN SQL_API SQLTablesW(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT); +#if (ODBCVER >= 0x0300) +SQLRETURN SQL_API SQLGetDescFieldA(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetDescFieldW(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetDescFieldA(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetDescFieldW(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLGetDescRecA(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDescRecW(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagFieldA(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagFieldW(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRecA(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetDiagRecW(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*); +SQLRETURN SQL_API SQLGetStmtAttrA(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLGetStmtAttrW(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*); +SQLRETURN SQL_API SQLSetStmtAttrA(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +SQLRETURN SQL_API SQLSetStmtAttrW(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER); +#endif /* (ODBCVER >= 0x0300) */ + +#if defined (UNICODE) && !defined (SQL_NOUNICODEMAP) +#define SQLBrowseConnect SQLBrowseConnectW +#define SQLColAttribute SQLColAttributeW +#define SQLColAttributes SQLColAttributesW +#define SQLColumnPrivileges SQLColumnPrivilegesW +#define SQLColumns SQLColumnsW +#define SQLConnect SQLConnectW +#define SQLDataSources SQLDataSourcesW +#define SQLDescribeCol SQLDescribeColW +#define SQLDriverConnect SQLDriverConnectW +#define SQLDrivers SQLDriversW +#define SQLError SQLErrorW +#define SQLExecDirect SQLExecDirectW +#define SQLForeignKeys SQLForeignKeysW +#define SQLGetConnectAttr SQLGetConnectAttrW +#define SQLGetConnectOption SQLGetConnectOptionW +#define SQLGetCursorName SQLGetCursorNameW +#define SQLGetDescField SQLGetDescFieldW +#define SQLGetDescRec SQLGetDescRecW +#define SQLGetDiagField SQLGetDiagFieldW +#define SQLGetDiagRec SQLGetDiagRecW +#define SQLGetInfo SQLGetInfoW +#define SQLGetStmtAttr SQLGetStmtAttrW +#define SQLGetTypeInfo SQLGetTypeInfoW +#define SQLNativeSql SQLNativeSqlW +#define SQLPrepare SQLPrepareW +#define SQLPrimaryKeys SQLPrimaryKeysW +#define SQLProcedureColumns SQLProcedureColumnsW +#define SQLProcedures SQLProceduresW +#define SQLSetConnectAttr SQLSetConnectAttrW +#define SQLSetConnectOption SQLSetConnectOptionW +#define SQLSetCursorName SQLSetCursorNameW +#define SQLSetDescField SQLSetDescFieldW +#define SQLSetStmtAttr SQLSetStmtAttrW +#define SQLSpecialColumns SQLSpecialColumnsW +#define SQLStatistics SQLStatisticsW +#define SQLTablePrivileges SQLTablePrivilegesW +#define SQLTables SQLTablesW +#endif /* UNICODE && ! SQL_NOUNICODEMAP */ +#endif /* RC_INVOKED */ +#ifdef __cplusplus +} +#endif /* __cplusplus*/ +#endif /* ndef _SQLUCODE_H */ diff -Nur tcc-0.9.25.orig/win32/include/winapi/basetsd.h tcc-0.9.25/win32/include/winapi/basetsd.h --- tcc-0.9.25.orig/win32/include/winapi/basetsd.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/win32/include/winapi/basetsd.h 2011-06-07 08:01:41.000000000 +0200 @@ -4,7 +4,7 @@ #pragma GCC system_header #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #ifndef __int64 #define __int64 long long #endif diff -Nur tcc-0.9.25.orig/win32/include/winapi/basetyps.h tcc-0.9.25/win32/include/winapi/basetyps.h --- tcc-0.9.25.orig/win32/include/winapi/basetyps.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/win32/include/winapi/basetyps.h 2011-06-07 08:01:41.000000000 +0200 @@ -124,7 +124,7 @@ #ifndef GUID_SECTION #define GUID_SECTION ".text" #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define GUID_SECT __attribute__ ((section (GUID_SECTION))) #else #define GUID_SECT diff -Nur tcc-0.9.25.orig/win32/include/winapi/mswsock.h tcc-0.9.25/win32/include/winapi/mswsock.h --- tcc-0.9.25.orig/win32/include/winapi/mswsock.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/winapi/mswsock.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,113 @@ +/* + * mswsock.h + * MS-specific extensions to Windows Sockets, exported from mswsock.dll. + * These functions are N/A on Windows9x. + * + * This file is part of a free library for the Win32 API. + * This library 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. + */ + +#ifndef _MSWSOCK_H +#define _MSWSOCK_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif +#ifdef __cplusplus +extern "C" { +#endif + +#define SO_CONNDATA 0x7000 +#define SO_CONNOPT 0x7001 +#define SO_DISCDATA 0x7002 +#define SO_DISCOPT 0x7003 +#define SO_CONNDATALEN 0x7004 +#define SO_CONNOPTLEN 0x7005 +#define SO_DISCDATALEN 0x7006 +#define SO_DISCOPTLEN 0x7007 +#define SO_OPENTYPE 0x7008 +#define SO_SYNCHRONOUS_ALERT 0x10 +#define SO_SYNCHRONOUS_NONALERT 0x20 +#define SO_MAXDG 0x7009 +#define SO_MAXPATHDG 0x700A +#define SO_UPDATE_ACCEPT_CONTEXT 0x700B +#define SO_CONNECT_TIME 0x700C +#define TCP_BSDURGENT 0x7000 + +#define TF_DISCONNECT 1 +#define TF_REUSE_SOCKET 2 +#define TF_WRITE_BEHIND 4 +#define TF_USE_DEFAULT_WORKER 0 +#define TF_USE_SYSTEM_THREAD 16 +#define TF_USE_KERNEL_APC 32 + +typedef struct _TRANSMIT_FILE_BUFFERS { + PVOID Head; + DWORD HeadLength; + PVOID Tail; + DWORD TailLength; +} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS; + +int PASCAL WSARecvEx(SOCKET,char*,int,int*); +BOOL PASCAL TransmitFile(SOCKET,HANDLE,DWORD,DWORD,LPOVERLAPPED,LPTRANSMIT_FILE_BUFFERS,DWORD); +BOOL PASCAL AcceptEx(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED); +VOID PASCAL GetAcceptExSockaddrs(PVOID,DWORD,DWORD,DWORD,struct sockaddr**, LPINT, struct sockaddr**, LPINT); + +#ifdef _WINSOCK2_H /* These require the winsock2 interface. */ + +#define TP_ELEMENT_FILE 1 +#define TP_ELEMENT_MEMORY 2 +#define TP_ELEMENT_EOP 4 + +typedef struct _TRANSMIT_PACKETS_ELEMENT { + ULONG dwElFlags; + ULONG cLength; + _ANONYMOUS_UNION + union { + struct { + LARGE_INTEGER nFileOffset; + HANDLE hFile; + }; + PVOID pBuffer; + }; +} TRANSMIT_PACKETS_ELEMENT; + +typedef struct _WSAMSG { + LPSOCKADDR name; + INT namelen; + LPWSABUF lpBuffers; + DWORD dwBufferCount; + WSABUF Control; + DWORD dwFlags; +} WSAMSG, *PWSAMSG, *LPWSAMSG; + + +/* According to MSDN docs, the WSAMSG.Control buffer starts with a + cmsghdr header of the following form. See also RFC 2292. */ + +typedef struct wsacmsghdr { + UINT cmsg_len; + INT cmsg_level; + INT cmsg_type; + /* followed by UCHAR cmsg_data[]; */ +} WSACMSGHDR; + +/* TODO: Standard Posix.1g macros as per RFC 2292, with WSA_uglification. */ +#if 0 +#define WSA_CMSG_FIRSTHDR(mhdr) +#define WSA_CMSG_NXTHDR(mhdr, cmsg) +#define WSA_CMSG_SPACE(length) +#define WSA_CMSG_LEN(length) +#endif + +BOOL PASCAL DisconnectEx(SOCKET,LPOVERLAPPED,DWORD,DWORD); +int PASCAL WSARecvMsg(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE); + +#endif /* _WINSOCK2_H */ + +#ifdef __cplusplus +} +#endif +#endif /* _MSWSOCK_H */ + diff -Nur tcc-0.9.25.orig/win32/include/winapi/wincon.h tcc-0.9.25/win32/include/winapi/wincon.h --- tcc-0.9.25.orig/win32/include/winapi/wincon.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/win32/include/winapi/wincon.h 2011-06-07 08:01:41.000000000 +0200 @@ -92,7 +92,7 @@ } uChar; DWORD dwControlKeyState; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) /* gcc's alignment is not what win32 expects */ PACKED #endif diff -Nur tcc-0.9.25.orig/win32/include/winapi/windef.h tcc-0.9.25/win32/include/winapi/windef.h --- tcc-0.9.25.orig/win32/include/winapi/windef.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/win32/include/winapi/windef.h 2011-06-07 08:01:41.000000000 +0200 @@ -49,7 +49,7 @@ #define OPTIONAL #endif -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define PACKED __attribute__((packed)) #ifndef _stdcall #define _stdcall __attribute__((stdcall)) @@ -92,7 +92,7 @@ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_EXPORT __declspec(dllexport) -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define DECLSPEC_NORETURN __declspec(noreturn) #define DECLARE_STDCALL_P( type ) __stdcall type #elif defined(__WATCOMC__) diff -Nur tcc-0.9.25.orig/win32/include/winapi/winnt.h tcc-0.9.25/win32/include/winapi/winnt.h --- tcc-0.9.25.orig/win32/include/winapi/winnt.h 2009-05-18 16:27:06.000000000 +0200 +++ tcc-0.9.25/win32/include/winapi/winnt.h 2011-06-07 08:01:41.000000000 +0200 @@ -118,7 +118,7 @@ typedef DWORD LCID; typedef PDWORD PLCID; typedef WORD LANGID; -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__TINYC__) #define _HAVE_INT64 #define _INTEGRAL_MAX_BITS 64 #undef __int64 @@ -2612,7 +2612,7 @@ typedef OSVERSIONINFOEXA OSVERSIONINFOEX,*POSVERSIONINFOEX,*LPOSVERSIONINFOEX; #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__TINYC__) PVOID GetCurrentFiber(void); PVOID GetFiberData(void); diff -Nur tcc-0.9.25.orig/win32/include/winapi/winsock.h tcc-0.9.25/win32/include/winapi/winsock.h --- tcc-0.9.25.orig/win32/include/winapi/winsock.h 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/include/winapi/winsock.h 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,535 @@ +/* + + Definitions for winsock 1.1 + + Portions Copyright (c) 1980, 1983, 1988, 1993 + The Regents of the University of California. All rights reserved. + + Portions Copyright (c) 1993 by Digital Equipment Corporation. + */ + +#ifndef _WINSOCK_H +#define _WINSOCK_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#define _GNU_H_WINDOWS32_SOCKETS +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined ( _BSDTYPES_DEFINED ) +/* also defined in gmon.h and in cygwin's sys/types */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#define _BSDTYPES_DEFINED +#endif /* !defined _BSDTYPES_DEFINED */ +typedef u_int SOCKET; +#ifndef FD_SETSIZE +#define FD_SETSIZE 64 +#endif + +/* shutdown() how types */ +#define SD_RECEIVE 0x00 +#define SD_SEND 0x01 +#define SD_BOTH 0x02 + +#ifndef _SYS_TYPES_FD_SET +/* fd_set may have be defined by the newlib + * if __USE_W32_SOCKETS not defined. + */ +#ifdef fd_set +#undef fd_set +#endif +typedef struct fd_set { + u_int fd_count; + SOCKET fd_array[FD_SETSIZE]; +} fd_set; +int PASCAL __WSAFDIsSet(SOCKET,fd_set*); +#ifndef FD_CLR +#define FD_CLR(fd,set) do { u_int __i;\ +for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\ + if (((fd_set *)(set))->fd_array[__i] == (fd)) {\ + while (__i < ((fd_set *)(set))->fd_count-1) {\ + ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i+1];\ + __i++;\ + }\ + ((fd_set*)(set))->fd_count--;\ + break;\ + }\ +}\ +} while (0) +#endif +#ifndef FD_SET +#define FD_SET(fd, set) do { \ + if (((fd_set *)(set))->fd_count < FD_SETSIZE) \ + ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\ +}while (0) +#endif +#ifndef FD_ZERO +#define FD_ZERO(set) (((fd_set *)(set))->fd_count=0) +#endif +#ifndef FD_ISSET +#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set)) +#endif +#elif !defined(USE_SYS_TYPES_FD_SET) +#warning "fd_set and associated macros have been defined in sys/types. \ + This can cause runtime problems with W32 sockets" +#endif /* ndef _SYS_TYPES_FD_SET */ + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#ifndef _TIMEVAL_DEFINED /* also in sys/time.h */ +#define _TIMEVAL_DEFINED +struct timeval { + long tv_sec; + long tv_usec; +}; +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec != (uvp)->tv_sec) ? \ + ((tvp)->tv_sec cmp (uvp)->tv_sec) : \ + ((tvp)->tv_usec cmp (uvp)->tv_usec)) +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif /* _TIMEVAL_DEFINED */ +struct hostent { + char *h_name; + char **h_aliases; + short h_addrtype; + short h_length; + char **h_addr_list; +#define h_addr h_addr_list[0] +}; +struct linger { + u_short l_onoff; + u_short l_linger; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +#define IOCPARM_MASK 0x7f +#define IOC_VOID 0x20000000 +#define IOC_OUT 0x40000000 +#define IOC_IN 0x80000000 +#define IOC_INOUT (IOC_IN|IOC_OUT) + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#define FIONBIO _IOW('f', 126, u_long) +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define FIONREAD _IOR('f', 127, u_long) +#define FIOASYNC _IOW('f', 125, u_long) +#define SIOCSHIWAT _IOW('s', 0, u_long) +#define SIOCGHIWAT _IOR('s', 1, u_long) +#define SIOCSLOWAT _IOW('s', 2, u_long) +#define SIOCGLOWAT _IOR('s', 3, u_long) +#define SIOCATMARK _IOR('s', 7, u_long) + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +struct netent { + char * n_name; + char **n_aliases; + short n_addrtype; + u_long n_net; +}; +struct servent { + char *s_name; + char **s_aliases; + short s_port; + char *s_proto; +}; +struct protoent { + char *p_name; + char **p_aliases; + short p_proto; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define IPPROTO_IP 0 +#define IPPROTO_ICMP 1 +#define IPPROTO_IGMP 2 +#define IPPROTO_GGP 3 +#define IPPROTO_TCP 6 +#define IPPROTO_PUP 12 +#define IPPROTO_UDP 17 +#define IPPROTO_IDP 22 +#define IPPROTO_ND 77 +#define IPPROTO_RAW 255 +#define IPPROTO_MAX 256 +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_MTP 57 +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_EFSSERVER 520 +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_ROUTESERVER 520 +#define IPPORT_RESERVED 1024 +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 +struct in_addr { + union { + struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; + struct { u_short s_w1,s_w2; } S_un_w; + u_long S_addr; + } S_un; +#define s_addr S_un.S_addr +#define s_host S_un.S_un_b.s_b2 +#define s_net S_un.S_un_b.s_b1 +#define s_imp S_un.S_un_w.s_w2 +#define s_impno S_un.S_un_b.s_b4 +#define s_lh S_un.S_un_b.s_b3 +}; +#define IN_CLASSA(i) (((long)(i)&0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 +#define IN_CLASSB(i) (((long)(i)&0xc0000000)==0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 +#define IN_CLASSC(i) (((long)(i)&0xe0000000)==0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0xff +#define INADDR_ANY (u_long)0 +#define INADDR_LOOPBACK 0x7f000001 +#define INADDR_BROADCAST (u_long)0xffffffff +#define INADDR_NONE 0xffffffff +struct sockaddr_in { + short sin_family; + u_short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; +#define WSADESCRIPTION_LEN 256 +#define WSASYS_STATUS_LEN 128 +typedef struct WSAData { + WORD wVersion; + WORD wHighVersion; + char szDescription[WSADESCRIPTION_LEN+1]; + char szSystemStatus[WSASYS_STATUS_LEN+1]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char * lpVendorInfo; +} WSADATA; +typedef WSADATA *LPWSADATA; + +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define IP_OPTIONS 1 +#define SO_DEBUG 1 +#define SO_ACCEPTCONN 2 +#define SO_REUSEADDR 4 +#define SO_KEEPALIVE 8 +#define SO_DONTROUTE 16 +#define SO_BROADCAST 32 +#define SO_USELOOPBACK 64 +#define SO_LINGER 128 +#define SO_OOBINLINE 256 +#define SO_DONTLINGER (u_int)(~SO_LINGER) +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_SNDLOWAT 0x1003 +#define SO_RCVLOWAT 0x1004 +#define SO_SNDTIMEO 0x1005 +#define SO_RCVTIMEO 0x1006 +#define SO_ERROR 0x1007 +#define SO_TYPE 0x1008 +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +/* + * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll). + * They will cause errors or unexpected results if used with the + * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h. + */ +#define IP_MULTICAST_IF 2 +#define IP_MULTICAST_TTL 3 +#define IP_MULTICAST_LOOP 4 +#define IP_ADD_MEMBERSHIP 5 +#define IP_DROP_MEMBERSHIP 6 + +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 +#define IP_MAX_MEMBERSHIPS 20 +struct ip_mreq { + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR (-1) +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 +#define SOCK_RDM 4 +#define SOCK_SEQPACKET 5 +#define TCP_NODELAY 0x0001 +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 2 +#define AF_IMPLINK 3 +#define AF_PUP 4 +#define AF_CHAOS 5 +#define AF_IPX 6 +#define AF_NS 6 +#define AF_ISO 7 +#define AF_OSI AF_ISO +#define AF_ECMA 8 +#define AF_DATAKIT 9 +#define AF_CCITT 10 +#define AF_SNA 11 +#define AF_DECnet 12 +#define AF_DLI 13 +#define AF_LAT 14 +#define AF_HYLINK 15 +#define AF_APPLETALK 16 +#define AF_NETBIOS 17 +#define AF_VOICEVIEW 18 +#define AF_FIREFOX 19 +#define AF_UNKNOWN1 20 +#define AF_BAN 21 +#define AF_ATM 22 +#define AF_INET6 23 +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define AF_MAX 24 +struct sockaddr { + u_short sa_family; + char sa_data[14]; +}; +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +struct sockproto { + u_short sp_family; + u_short sp_protocol; +}; +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_IPX AF_IPX +#define PF_ISO AF_ISO +#define PF_OSI AF_OSI +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_VOICEVIEW AF_VOICEVIEW +#define PF_FIREFOX AF_FIREFOX +#define PF_UNKNOWN1 AF_UNKNOWN1 +#define PF_BAN AF_BAN +#define PF_ATM AF_ATM +#define PF_INET6 AF_INET6 +#define PF_MAX AF_MAX +#define SOL_SOCKET 0xffff +#define SOMAXCONN 5 +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +#define MSG_MAXIOVLEN 16 +#define MSG_PARTIAL 0x8000 +#define MAXGETHOSTSTRUCT 1024 +#define FD_READ 1 +#define FD_WRITE 2 +#define FD_OOB 4 +#define FD_ACCEPT 8 +#define FD_CONNECT 16 +#define FD_CLOSE 32 +#ifndef WSABASEERR +#define WSABASEERR 10000 +#define WSAEINTR (WSABASEERR+4) +#define WSAEBADF (WSABASEERR+9) +#define WSAEACCES (WSABASEERR+13) +#define WSAEFAULT (WSABASEERR+14) +#define WSAEINVAL (WSABASEERR+22) +#define WSAEMFILE (WSABASEERR+24) +#define WSAEWOULDBLOCK (WSABASEERR+35) +#define WSAEINPROGRESS (WSABASEERR+36) +#define WSAEALREADY (WSABASEERR+37) +#define WSAENOTSOCK (WSABASEERR+38) +#define WSAEDESTADDRREQ (WSABASEERR+39) +#define WSAEMSGSIZE (WSABASEERR+40) +#define WSAEPROTOTYPE (WSABASEERR+41) +#define WSAENOPROTOOPT (WSABASEERR+42) +#define WSAEPROTONOSUPPORT (WSABASEERR+43) +#define WSAESOCKTNOSUPPORT (WSABASEERR+44) +#define WSAEOPNOTSUPP (WSABASEERR+45) +#define WSAEPFNOSUPPORT (WSABASEERR+46) +#define WSAEAFNOSUPPORT (WSABASEERR+47) +#define WSAEADDRINUSE (WSABASEERR+48) +#define WSAEADDRNOTAVAIL (WSABASEERR+49) +#define WSAENETDOWN (WSABASEERR+50) +#define WSAENETUNREACH (WSABASEERR+51) +#define WSAENETRESET (WSABASEERR+52) +#define WSAECONNABORTED (WSABASEERR+53) +#define WSAECONNRESET (WSABASEERR+54) +#define WSAENOBUFS (WSABASEERR+55) +#define WSAEISCONN (WSABASEERR+56) +#define WSAENOTCONN (WSABASEERR+57) +#define WSAESHUTDOWN (WSABASEERR+58) +#define WSAETOOMANYREFS (WSABASEERR+59) +#define WSAETIMEDOUT (WSABASEERR+60) +#define WSAECONNREFUSED (WSABASEERR+61) +#define WSAELOOP (WSABASEERR+62) +#define WSAENAMETOOLONG (WSABASEERR+63) +#define WSAEHOSTDOWN (WSABASEERR+64) +#define WSAEHOSTUNREACH (WSABASEERR+65) +#define WSAENOTEMPTY (WSABASEERR+66) +#define WSAEPROCLIM (WSABASEERR+67) +#define WSAEUSERS (WSABASEERR+68) +#define WSAEDQUOT (WSABASEERR+69) +#define WSAESTALE (WSABASEERR+70) +#define WSAEREMOTE (WSABASEERR+71) +#define WSAEDISCON (WSABASEERR+101) +#define WSASYSNOTREADY (WSABASEERR+91) +#define WSAVERNOTSUPPORTED (WSABASEERR+92) +#define WSANOTINITIALISED (WSABASEERR+93) +#define WSAHOST_NOT_FOUND (WSABASEERR+1001) +#define WSATRY_AGAIN (WSABASEERR+1002) +#define WSANO_RECOVERY (WSABASEERR+1003) +#define WSANO_DATA (WSABASEERR+1004) +#endif /* !WSABASEERR */ + +#define WSANO_ADDRESS WSANO_DATA +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +#define h_errno WSAGetLastError() +#define HOST_NOT_FOUND WSAHOST_NOT_FOUND +#define TRY_AGAIN WSATRY_AGAIN +#define NO_RECOVERY WSANO_RECOVERY +#define NO_DATA WSANO_DATA +#define NO_ADDRESS WSANO_ADDRESS +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ +SOCKET PASCAL accept(SOCKET,struct sockaddr*,int*); +int PASCAL bind(SOCKET,const struct sockaddr*,int); +int PASCAL closesocket(SOCKET); +int PASCAL connect(SOCKET,const struct sockaddr*,int); +int PASCAL ioctlsocket(SOCKET,long,u_long *); +int PASCAL getpeername(SOCKET,struct sockaddr*,int*); +int PASCAL getsockname(SOCKET,struct sockaddr*,int*); +int PASCAL getsockopt(SOCKET,int,int,char*,int*); +unsigned long PASCAL inet_addr(const char*); +DECLARE_STDCALL_P(char *) inet_ntoa(struct in_addr); +int PASCAL listen(SOCKET,int); +int PASCAL recv(SOCKET,char*,int,int); +int PASCAL recvfrom(SOCKET,char*,int,int,struct sockaddr*,int*); +int PASCAL send(SOCKET,const char*,int,int); +int PASCAL sendto(SOCKET,const char*,int,int,const struct sockaddr*,int); +int PASCAL setsockopt(SOCKET,int,int,const char*,int); +int PASCAL shutdown(SOCKET,int); +SOCKET PASCAL socket(int,int,int); +DECLARE_STDCALL_P(struct hostent *) gethostbyaddr(const char*,int,int); +DECLARE_STDCALL_P(struct hostent *) gethostbyname(const char*); +DECLARE_STDCALL_P(struct servent *) getservbyport(int,const char*); +DECLARE_STDCALL_P(struct servent *) getservbyname(const char*,const char*); +DECLARE_STDCALL_P(struct protoent *) getprotobynumber(int); +DECLARE_STDCALL_P(struct protoent *) getprotobyname(const char*); +int PASCAL WSAStartup(WORD,LPWSADATA); +int PASCAL WSACleanup(void); +void PASCAL WSASetLastError(int); +int PASCAL WSAGetLastError(void); +BOOL PASCAL WSAIsBlocking(void); +int PASCAL WSAUnhookBlockingHook(void); +FARPROC PASCAL WSASetBlockingHook(FARPROC); +int PASCAL WSACancelBlockingCall(void); +HANDLE PASCAL WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int); +HANDLE PASCAL WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int); +HANDLE PASCAL WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int); +int PASCAL WSACancelAsyncRequest(HANDLE); +int PASCAL WSAAsyncSelect(SOCKET,HWND,u_int,long); +#if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) +u_long PASCAL htonl(u_long); +u_long PASCAL ntohl(u_long); +u_short PASCAL htons(u_short); +u_short PASCAL ntohs(u_short); +int PASCAL select(int nfds,fd_set*,fd_set*,fd_set*,const struct timeval*); +int PASCAL gethostname(char*,int); +#endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */ + +#define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e) +#define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error) +#define WSAGETASYNCBUFLEN(l) LOWORD(l) +#define WSAGETASYNCERROR(l) HIWORD(l) +#define WSAGETSELECTEVENT(l) LOWORD(l) +#define WSAGETSELECTERROR(l) HIWORD(l) + +typedef struct sockaddr SOCKADDR; +typedef struct sockaddr *PSOCKADDR; +typedef struct sockaddr *LPSOCKADDR; +typedef struct sockaddr_in SOCKADDR_IN; +typedef struct sockaddr_in *PSOCKADDR_IN; +typedef struct sockaddr_in *LPSOCKADDR_IN; +typedef struct linger LINGER; +typedef struct linger *PLINGER; +typedef struct linger *LPLINGER; +typedef struct in_addr IN_ADDR; +typedef struct in_addr *PIN_ADDR; +typedef struct in_addr *LPIN_ADDR; +typedef struct fd_set FD_SET; +typedef struct fd_set *PFD_SET; +typedef struct fd_set *LPFD_SET; +typedef struct hostent HOSTENT; +typedef struct hostent *PHOSTENT; +typedef struct hostent *LPHOSTENT; +typedef struct servent SERVENT; +typedef struct servent *PSERVENT; +typedef struct servent *LPSERVENT; +typedef struct protoent PROTOENT; +typedef struct protoent *PPROTOENT; +typedef struct protoent *LPPROTOENT; +typedef struct timeval TIMEVAL; +typedef struct timeval *PTIMEVAL; +typedef struct timeval *LPTIMEVAL; + +#ifdef __cplusplus +} +#endif +/* + * Recent MSDN docs indicate that the MS-specific extensions exported from + * mswsock.dll (AcceptEx, TransmitFile. WSARecEx and GetAcceptExSockaddrs) are + * declared in mswsock.h. These extensions are not supported on W9x or WinCE. + * However, code using WinSock 1.1 API may expect the declarations and + * associated defines to be in this header. Thus we include mswsock.h here. + * + * When linking against the WinSock 1.1 lib, wsock32.dll, the mswsock functions + * are automatically routed to mswsock.dll (on platforms with support). + * The WinSock 2 lib, ws2_32.dll, does not contain any references to + * the mswsock extensions. + */ + +#include + +#endif diff -Nur tcc-0.9.25.orig/win32/lib/odbc32.def tcc-0.9.25/win32/lib/odbc32.def --- tcc-0.9.25.orig/win32/lib/odbc32.def 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/lib/odbc32.def 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,118 @@ +LIBRARY odbc32.dll + +EXPORTS +SQLAllocConnect +SQLAllocEnv +SQLAllocStmt +SQLBindCol +SQLCancel +SQLColAttributes +SQLConnect +SQLDescribeCol +SQLDisconnect +SQLError +SQLExecDirect +SQLExecute +SQLFetch +SQLFreeConnect +SQLFreeEnv +SQLFreeStmt +SQLGetCursorName +SQLNumResultCols +SQLPrepare +SQLRowCount +SQLSetCursorName +SQLSetParam +SQLTransact +SQLAllocHandle +SQLBindParam +SQLCloseCursor +SQLColAttribute +SQLCopyDesc +SQLEndTran +SQLFetchScroll +SQLFreeHandle +SQLGetConnectAttr +SQLGetDescField +SQLGetDescRec +SQLGetDiagField +SQLGetDiagRec +SQLGetEnvAttr +SQLGetStmtAttr +SQLSetConnectAttr +SQLColumns +SQLDriverConnect +SQLGetConnectOption +SQLGetData +SQLGetFunctions +SQLGetInfo +SQLGetStmtOption +SQLGetTypeInfo +SQLParamData +SQLPutData +SQLSetConnectOption +SQLSetStmtOption +SQLSpecialColumns +SQLStatistics +SQLTables +SQLBrowseConnect +SQLColumnPrivileges +SQLDataSources +SQLDescribeParam +SQLExtendedFetch +SQLForeignKeys +SQLMoreResults +SQLNativeSql +SQLNumParams +SQLParamOptions +SQLPrimaryKeys +SQLProcedureColumns +SQLProcedures +SQLSetPos +SQLSetScrollOptions +SQLTablePrivileges +SQLDrivers +SQLBindParameter +SQLSetDescField +SQLSetDescRec +SQLSetEnvAttr +SQLSetStmtAttr +SQLAllocHandleStd +SQLBulkOperations +SQLColAttributesW +SQLConnectW +SQLDescribeColW +SQLErrorW +SQLExecDirectW +SQLGetCursorNameW +SQLPrepareW +SQLSetCursorNameW +SQLColAttributeW +SQLGetConnectAttrW +SQLGetDescFieldW +SQLGetDescRecW +SQLGetDiagFieldW +SQLGetDiagRecW +SQLGetStmtAttrW +SQLSetConnectAttrW +SQLColumnsW +SQLDriverConnectW +SQLGetConnectOptionW +SQLGetInfoW +SQLGetTypeInfoW +SQLSetConnectOptionW +SQLSpecialColumnsW +SQLStatisticsW +SQLTablesW +SQLBrowseConnectW +SQLColumnPrivilegesW +SQLDataSourcesW +SQLForeignKeysW +SQLNativeSqlW +SQLPrimaryKeysW +SQLProcedureColumnsW +SQLProceduresW +SQLTablePrivilegesW +SQLDriversW +SQLSetDescFieldW +SQLSetStmtAttrW diff -Nur tcc-0.9.25.orig/win32/lib/wsock32.def tcc-0.9.25/win32/lib/wsock32.def --- tcc-0.9.25.orig/win32/lib/wsock32.def 1970-01-01 01:00:00.000000000 +0100 +++ tcc-0.9.25/win32/lib/wsock32.def 2011-06-07 08:01:41.000000000 +0200 @@ -0,0 +1,76 @@ +LIBRARY wsock32.dll + +EXPORTS +AcceptEx +EnumProtocolsA +EnumProtocolsW +GetAcceptExSockaddrs +GetAddressByNameA +GetAddressByNameW +GetNameByTypeA +GetNameByTypeW +GetServiceA +GetServiceW +GetTypeByNameA +GetTypeByNameW +NPLoadNameSpaces +SetServiceA +SetServiceW +TransmitFile +WSAAsyncGetHostByAddr +WSAAsyncGetHostByName +WSAAsyncGetProtoByName +WSAAsyncGetProtoByNumber +WSAAsyncGetServByName +WSAAsyncGetServByPort +WSAAsyncSelect +WSACancelAsyncRequest +WSACancelBlockingCall +WSACleanup +WSAGetLastError +WSAIsBlocking +WSARecvEx +WSASetBlockingHook +WSASetLastError +WSAStartup +WSAUnhookBlockingHook +WSApSetPostRoutine +__WSAFDIsSet +accept +bind +closesocket +connect +dn_expand +gethostbyaddr +gethostbyname +gethostname +getnetbyname +getpeername +getprotobyname +getprotobynumber +getservbyname +getservbyport +getsockname +getsockopt +htonl +htons +inet_addr +inet_network +inet_ntoa +ioctlsocket +listen +ntohl +ntohs +rcmd +recv +recvfrom +rexec +rresvport +s_perror +select +send +sendto +sethostname +setsockopt +shutdown +socket ./sqliteodbc-0.992/extfunc.patch0100644000076400001440000001634611357555212015245 0ustar chwusers--- extfunc.c.orig 2010-04-09 09:30:28.000000000 +0200 +++ extfunc.c 2010-04-09 09:24:27.000000000 +0200 @@ -116,7 +116,6 @@ #define HAVE_COSH 1 #define HAVE_TANH 1 #define HAVE_LOG10 1 -#define HAVE_ISBLANK 1 #define SQLITE_SOUNDEX 1 #define HAVE_TRIM 1 /* LMH 2007-03-25 if sqlite has trim functions */ @@ -127,7 +126,6 @@ #include "sqlite3.h" #endif -#include /* relicoder */ #include #include @@ -160,40 +158,39 @@ typedef struct map{ node *base; cmp_func cmp; - short free; } map; /* ** creates a map given a comparison function */ -map map_make(cmp_func cmp); +static map map_make(cmp_func cmp); /* ** inserts the element e into map m */ -void map_insert(map *m, void *e); +static void map_insert(map *m, void *e); /* ** executes function iter over all elements in the map, in key increasing order */ -void map_iterate(map *m, map_iterator iter, void* p); +static void map_iterate(map *m, map_iterator iter, void* p); /* ** frees all memory used by a map */ -void map_destroy(map *m); +static void map_destroy(map *m); /* ** compares 2 integers ** to use with map_make */ -int int_cmp(const void *a, const void *b); +static int int_cmp(const void *a, const void *b); /* ** compares 2 doubles ** to use with map_make */ -int double_cmp(const void *a, const void *b); +static int double_cmp(const void *a, const void *b); #endif /* _MAP_H_ */ @@ -244,6 +241,26 @@ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, }; +/* +** Own (ASCII only) implementation of toupper(), tolower(), +** and isalpha() +*/ + +static int toupper(int c){ + if ((c>='a') && (c<='z')) return c-0x20; + return c; +} + +static int tolower(int c){ + if ((c>='A') && (c<='Z')) return c+0x20; + return c; +} + +static int isalpha(int c){ + if ((c>='A') && (c<='Z')) return 1; + if ((c>='a') && (c<='z')) return 1; + return 0; +} /* ** This table maps from the number of trailing bytes in a UTF-8 character @@ -360,7 +377,7 @@ if (errno == 0) {\ sqlite3_result_double(context, val);\ } else {\ - sqlite3_result_error(context, strerror(errno), errno);\ + sqlite3_result_error(context, "domain error", -1); \ }\ break;\ }\ @@ -555,7 +572,7 @@ if (errno == 0) { sqlite3_result_double(context, val); } else { - sqlite3_result_error(context, strerror(errno), errno); + sqlite3_result_error(context, "domain error", -1); } } } @@ -620,7 +637,7 @@ assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { - i64 iVal = sqlite3_value_int64(argv[0]); + iVal = sqlite3_value_int64(argv[0]); sqlite3_result_int64(context, iVal); break; } @@ -645,7 +662,7 @@ assert( argc==1 ); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { - i64 iVal = sqlite3_value_int64(argv[0]); + iVal = sqlite3_value_int64(argv[0]); sqlite3_result_int64(context, iVal); break; } @@ -704,16 +721,6 @@ } } -/* -** Some systems (win32 among others) don't have an isblank function, this will emulate it. -** This function is not UFT-8 safe since it only analyses a byte character. -*/ -#ifndef HAVE_ISBLANK -int isblank(char c){ - return( ' '==c || '\t'==c ); -} -#endif - static void properFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ const unsigned char *z; /* input string */ unsigned char *zo; /* output string */ @@ -736,7 +743,7 @@ zt = zo; while( (r = *(z++))!=0 ){ - if( isblank(r) ){ + if( (r==' ') || (r=='\t') ){ c=1; }else{ if( c==1 ){ @@ -1349,6 +1356,15 @@ sqlite3_free(rz); } +static void* xcalloc(size_t nmemb, size_t size){ + void* ret = calloc(nmemb, size); + return ret; +} + +static void xfree(void* p){ + free(p); +} + /* ** An instance of the following structure holds the context of a ** stdev() or variance() aggregate computation. @@ -1424,7 +1440,7 @@ p = sqlite3_aggregate_context(context, sizeof(*p)); if( 0==(p->m) ){ - p->m = calloc(1, sizeof(map)); + p->m = xcalloc(1, sizeof(map)); if( type==SQLITE_INTEGER ){ /* map will be used for integers */ *(p->m) = map_make(int_cmp); @@ -1440,12 +1456,12 @@ if( 0==p->is_double ){ xi = sqlite3_value_int64(argv[0]); - iptr = (i64*)calloc(1,sizeof(i64)); + iptr = (i64*)xcalloc(1,sizeof(i64)); *iptr = xi; map_insert(p->m, iptr); }else{ xd = sqlite3_value_double(argv[0]); - dptr = (double*)calloc(1,sizeof(double)); + dptr = (double*)xcalloc(1,sizeof(double)); *dptr = xd; map_insert(p->m, dptr); } @@ -1531,7 +1547,7 @@ if( p && p->m ){ map_iterate(p->m, modeIterate, p); map_destroy(p->m); - free(p->m); + xfree(p->m); if( 1==p->mn ){ if( 0==p->is_double ) @@ -1552,7 +1568,7 @@ p->done=0; map_iterate(p->m, medianIterate, p); map_destroy(p->m); - free(p->m); + xfree(p->m); if( 0==p->is_double ) if( 1==p->mn ) @@ -1705,7 +1721,7 @@ ** functions. This should be the only routine in this file with ** external linkage. */ -int RegisterExtensionFunctions(sqlite3 *db){ +static int RegisterExtensionFunctions(sqlite3 *db){ static const struct FuncDef { char *zName; signed char nArg; @@ -1843,28 +1859,18 @@ } #endif /* COMPILE_SQLITE_EXTENSIONS_AS_LOADABLE_MODULE */ -map map_make(cmp_func cmp){ +static map map_make(cmp_func cmp){ map r; r.cmp=cmp; r.base = 0; - return r; } -void* xcalloc(size_t nmemb, size_t size, char* s){ - void* ret = calloc(nmemb, size); - return ret; -} - -void xfree(void* p){ - free(p); -} - -void node_insert(node** n, cmp_func cmp, void *e){ +static void node_insert(node** n, cmp_func cmp, void *e){ int c; node* nn; if(*n==0){ - nn = (node*)xcalloc(1,sizeof(node), "for node"); + nn = (node*)xcalloc(1,sizeof(node)); nn->data = e; nn->count = 1; *n=nn; @@ -1882,11 +1888,11 @@ } } -void map_insert(map *m, void *e){ +static void map_insert(map *m, void *e){ node_insert(&(m->base), m->cmp, e); } -void node_iterate(node *n, map_iterator iter, void* p){ +static void node_iterate(node *n, map_iterator iter, void* p){ if(n){ if(n->l) node_iterate(n->l, iter, p); @@ -1896,11 +1902,11 @@ } } -void map_iterate(map *m, map_iterator iter, void* p){ +static void map_iterate(map *m, map_iterator iter, void* p){ node_iterate(m->base, iter, p); } -void node_destroy(node *n){ +static void node_destroy(node *n){ if(0!=n){ xfree(n->data); if(n->l) @@ -1912,11 +1918,11 @@ } } -void map_destroy(map *m){ +static void map_destroy(map *m){ node_destroy(m->base); } -int int_cmp(const void *a, const void *b){ +static int int_cmp(const void *a, const void *b){ int64_t aa = *(int64_t *)(a); int64_t bb = *(int64_t *)(b); /* printf("cmp %d <=> %d\n",aa,bb); */ @@ -1928,7 +1934,7 @@ return 1; } -int double_cmp(const void *a, const void *b){ +static int double_cmp(const void *a, const void *b){ double aa = *(double *)(a); double bb = *(double *)(b); /* printf("cmp %d <=> %d\n",aa,bb); */ @@ -1940,8 +1946,4 @@ return 1; } -void print_elem(void *e, int64_t c, void* p){ - int ee = *(int*)(e); - printf("%d => %lld\n", ee,c); -} ./sqliteodbc-0.992/README.sqlite+tcc0100644000076400001440000000115410566075700015464 0ustar chwusersExperimental combination of SQLite 3.3.x and TinyCC 0.9.23 using the new SQLite loadable extension mechanism. An extension module creates an SQLite scalar function 'tcc_compile' which takes an argument which is a string made up of C source code to be on-the-fly compiled using TinyCC (www.tinycc.org). The SQLite API is visible during compilation when 'sqlite3.h' is included. See the file 'strict_typing.sql' for a working example. Caution: So far, only partially tested on Linux i386 and Win32. Win32 notes: The sqlite+tcc.dll module must be kept in the same path as the TCC include and lib directories. ./sqliteodbc-0.992/strict_typing.sql0100644000076400001440000002632210557076577016203 0ustar chwusers-- Example for SQLite + TinyCC taken from the book -- "The Definitive Guide to SQLite" by Mike Owen, Chapter 7, p. 267-278 .echo on -- Loading sqlite+tcc.dll ... .load 'sqlite+tcc.dll' -- Compiling code (SQL not shown) ... .echo off select tcc_compile(' #include /* Installs type validation triggers on column. It first looks the column''s ** declared type in the schema and attempts find the matching validation ** function (validate_xxx()). If on exists, it creates INSERT/UPDATE triggers ** to call validation function. */ void add_strict_type_check_udf(sqlite3_context* ctx, int nargs, sqlite3_value **values); /* Helper function. Installs validation trigger on column */ int install_type_trigger(sqlite3 *db, sqlite3_context *ctx, char *table, char *column); /* Drops validation triggers on column */ void drop_strict_type_check_udf(sqlite3_context *ctx, int nargs, sqlite3_value **values); /* Helper function. Drops validation trigger on column */ int uninstall_type_trigger(sqlite3 *db, sqlite3_context *ctx, char *table, char *column); /* User-defined integer validation function. Use for integers, longs, etc. */ void validate_int_udf(sqlite3_context *ctx, int nargs, sqlite3_value **values); /* User-defined float validation function. Use for floats, doubles, etc. */ void validate_double_udf(sqlite3_context *ctx, int nargs, sqlite3_value **values); /* User-defined column type function. Given a table name and column name, ** returns a column''s declared type. */ void column_type_udf(sqlite3_context *ctx, int nargs, sqlite3_value **values); /* C Function: Lookup column''s declared type in sqlite_master. */ char* column_type(sqlite3 *db, char *table, char *column); /* Initializer for this module */ void init( sqlite3 *db ){ sqlite3_create_function(db, "add_strict_type_check", 2, SQLITE_UTF8, db, add_strict_type_check_udf, 0, 0); sqlite3_create_function(db, "drop_strict_type_check", 2, SQLITE_UTF8, db, drop_strict_type_check_udf, 0, 0); sqlite3_create_function(db, "column_type", 2, SQLITE_UTF8, db, column_type_udf, 0, 0); sqlite3_create_function(db, "validate_int", 1, SQLITE_UTF8, db, validate_int_udf, 0, 0); sqlite3_create_function(db, "validate_long", 1, SQLITE_UTF8, db, validate_int_udf, 0, 0); sqlite3_create_function(db, "validate_double", 1, SQLITE_UTF8, db, validate_double_udf, 0, 0); sqlite3_create_function(db, "validate_float", 1, SQLITE_UTF8, db, validate_double_udf, 0, 0); } void add_strict_type_check_udf( sqlite3_context *ctx, int nargs, sqlite3_value **values ){ sqlite3 *db; sqlite3_stmt *stmt; int rc; char *table, *column, *sql, *tmp; db = (sqlite3*) sqlite3_user_data(ctx); table = (char*) sqlite3_value_text(values[0]); column = (char*) sqlite3_value_text(values[1]); if( strncmp(column, "*", 1) == 0 ){ /* Install on all columns */ sql = "pragma table_info(%s)"; tmp = sqlite3_mprintf(sql, table); rc = sqlite3_prepare(db, tmp, -1, &stmt, 0); sqlite3_free(tmp); if( rc != SQLITE_OK ){ sqlite3_result_error(ctx, sqlite3_errmsg(db), -1); return; } rc = sqlite3_step(stmt); while( rc == SQLITE_ROW ){ /* If not primary key */ if( sqlite3_column_int(stmt, 5) != 1 ){ column = (char*) sqlite3_column_text(stmt, 1); install_type_trigger(db, ctx, table, column); } rc = sqlite3_step(stmt); } sqlite3_finalize(stmt); }else{ /* Just installing on a single column */ if( install_type_trigger(db, ctx, table, column) != 0 ){ return; } } sqlite3_result_int(ctx, 0); } int install_type_trigger( sqlite3 *db, sqlite3_context *ctx, char *table, char *column ){ int rc; char buf[256]; char *err, *sql, *type, *tmp; type = column_type(db, table, column); if( type == 0 ){ sqlite3_result_error(ctx, "column has no declared type", -1); sqlite3_free(type); return 1; } /* Check to see if corresponding validation function exists */ sql = "select validate_%s(null)"; tmp = sqlite3_mprintf(sql, type); rc = sqlite3_exec(db, tmp, 0, 0, &err); sqlite3_free(tmp); if( rc != SQLITE_OK && err != 0 ){ sqlite3_result_error(ctx, "no validator exists for column type", -1); sqlite3_free(type); sqlite3_free(err); return 1; } /* Create INSERT trigger */ sql = "CREATE TRIGGER %s_insert_%s_typecheck_tr \n" "BEFORE INSERT ON %s \n" "BEGIN \n" " SELECT CASE \n" " WHEN(SELECT validate_%s(new.%s) != 1) \n" " THEN RAISE(ABORT, ''invalid %s value for %s.%s'') \n" " END; \n" "END;"; tmp = sqlite3_mprintf(sql, table, column, table, type, column, type, table, column); rc = sqlite3_exec(db, tmp, 0, 0, &err); sqlite3_free(tmp); if( rc != SQLITE_OK && err != 0 ){ strncpy(&buf[0], err, 255); buf[255] = ''\0''; sqlite3_result_error(ctx, &buf[0], -1); sqlite3_free(type); return 1; } /* Create UPDATE trigger */ sql = "CREATE TRIGGER %s_update_%s_typecheck_tr \n" "BEFORE UPDATE OF %s ON %s \n" "FOR EACH ROW BEGIN \n" " SELECT CASE \n" " WHEN(SELECT validate_%s(new.%s) != 1) \n" " THEN RAISE(ABORT, ''invalid %s value for %s.%s'') \n" " END; \n" "END;"; tmp = sqlite3_mprintf(sql, table, column, column, table, type, column, type, table, column); rc = sqlite3_exec(db, tmp, 0, 0, &err); sqlite3_free(tmp); sqlite3_free(type); if( rc != SQLITE_OK && err != 0 ) { strncpy(&buf[0], err, 255); buf[255] = ''\0''; sqlite3_result_error(ctx, &buf[0], -1); sqlite3_free(err); return 1; } return 0; } void drop_strict_type_check_udf( sqlite3_context *ctx, int nargs, sqlite3_value **values ){ sqlite3 *db; sqlite3_stmt *stmt; int rc; char *table, *column, *sql, *tmp; db = (sqlite3*) sqlite3_user_data(ctx); table = (char*) sqlite3_value_text(values[0]); column = (char*) sqlite3_value_text(values[1]); if( strncmp(column,"*",1) == 0 ){ /* Install on all columns */ sql = "pragma table_info(%s)"; tmp = sqlite3_mprintf(sql, table); rc = sqlite3_prepare(db, tmp, -1, &stmt, 0); sqlite3_free(tmp); if( rc != SQLITE_OK ){ sqlite3_result_error(ctx, sqlite3_errmsg(db), -1); return; } rc = sqlite3_step(stmt); while( rc == SQLITE_ROW ){ /* If not primary key */ if( sqlite3_column_int(stmt, 5) != 1 ){ column = (char*) sqlite3_column_text(stmt, 1); uninstall_type_trigger(db, ctx, table, column); } rc = sqlite3_step(stmt); } sqlite3_finalize(stmt); }else{ /* Just installing on a single column */ if( uninstall_type_trigger(db, ctx, table, column) != 0 ){ return; } } sqlite3_result_int(ctx, 0); } /* Helper function. Drops validation trigger on column */ int uninstall_type_trigger( sqlite3 *db, sqlite3_context *ctx, char *table, char *column ){ int rc; char buf[256]; char *tmp, *err, *sql; /* Drop INSERT trigger */ sql = "DROP TRIGGER %s_insert_%s_typecheck_tr"; tmp = sqlite3_mprintf(sql, table, column); rc = sqlite3_exec(db, tmp, 0, 0, &err); sqlite3_free(tmp); if( rc != SQLITE_OK && err != 0 ){ strncpy(&buf[0], err, 255); buf[255] = ''\0''; sqlite3_result_error(ctx, &buf[0], -1); return 1; } /* Drop UPDATE trigger */ sql = "DROP TRIGGER %s_update_%s_typecheck_tr"; tmp = sqlite3_mprintf(sql, table, column); rc = sqlite3_exec(db, tmp, 0, 0, &err); sqlite3_free(tmp); if( rc != SQLITE_OK && err != 0 ){ strncpy(&buf[0], err, 255); buf[255] = ''\0''; sqlite3_result_error(ctx, &buf[0], -1); return 1; } return 0; } void validate_int_udf( sqlite3_context *ctx, int nargs, sqlite3_value **values ){ sqlite3 *db; char *value; char *tmp; db = (sqlite3*) sqlite3_user_data(ctx); value = (char*) sqlite3_value_text(values[0]); /* Assuming NULL values for type checked columns not allowed */ if( value == 0 ){ sqlite3_result_int(ctx, 0); return; } /* Validate type: */ tmp = 0; strtol(value, &tmp, 0); if( *tmp != ''\0'' ){ /* Value does not conform to type */ sqlite3_result_int(ctx, 0); return; } /* If we got this far value is valid. */ sqlite3_result_int(ctx, 1); } void validate_double_udf( sqlite3_context* ctx, int nargs, sqlite3_value** values ){ sqlite3 *db; char *value; char *tmp; db = (sqlite3*) sqlite3_user_data(ctx); value = (char*) sqlite3_value_text(values[0]); /* Assuming NULL values for type checked columns not allowed */ if( value == 0 ){ sqlite3_result_int(ctx, 0); return; } /* Validate type: */ tmp = 0; strtod(value, &tmp); if( *tmp != ''\0'' ){ /* Value does not conform to type */ sqlite3_result_int(ctx, 0); return; } /* If we got this far value is valid. */ sqlite3_result_int(ctx, 1); } void column_type_udf( sqlite3_context *ctx, int nargs, sqlite3_value **values ){ sqlite3 *db; char *table, *column, *type; db = (sqlite3*) sqlite3_user_data(ctx); table = (char*) sqlite3_value_text(values[0]); column = (char*) sqlite3_value_text(values[1]); /* Get declared type from schema */ type = column_type(db, table, column); /* Return type */ sqlite3_result_text(ctx, type, -1, SQLITE_TRANSIENT); } char *column_type( sqlite3* db, char *table, char *column ){ sqlite3_stmt *stmt; int i, len, rc; char *sql, *tmp, *type, *p, *sql_type; sql = "select %s from %s;"; tmp = sqlite3_mprintf(sql, column, table); rc = sqlite3_prepare(db, tmp, -1, &stmt, 0); if( rc != SQLITE_OK ){ sqlite3_free(tmp); return 0; } sql_type = (char*) sqlite3_column_decltype(stmt, 0); /* Convert type to lower case */ i = 0; p = sql_type; len = strlen(sql_type); type = sqlite3_malloc(len + 1); while( i < len ) { type[i] = tolower(*p); p++;i++; } type[len] = ''\0''; /* Free statement handle and tmp sql string */ sqlite3_finalize(stmt); sqlite3_free(tmp); return type; } '); .echo on -- Creating table types. create table types( id integer primary key, x int not null default 0, y float not null default 0.0 ); -- Populating table types. insert into types(x,y) values(1,1.1); insert into types(x,y) values(2,2.1); insert into types(x,y) values(3,3.1); -- 1. Add strict typing: select add_strict_type_check('types', '*'); -- 2. Insert integer value -- should succeed: insert into types (x) values (1); -- 3. Update with invalid values -- should fail: update types set x = 'abc'; update types set y = 'abc'; -- 4. Remove strict typing select drop_strict_type_check('types', '*'); -- 5. Update with non-integer value -- should succeed: update types set x = 'not an int'; -- 6. Select records: .header on select * from types; -- 7. Test column_type() UDF select column_type('types', 'id') as 'id', column_type('types', 'x') as 'x', column_type('types', 'y') as 'y'; ./sqliteodbc-0.992/mkall.sh0100644000076400001440000000146512107272353014174 0ustar chwusers#!/bin/sh # # Build everything for Win32/Win64 rm -rf dist mkdir dist exec >mkall.log 2>&1 set -x if test -r VERSION ; then VER32=$(tr -d '.' */ #define INI_MAX_LINE 1000 #define INI_MAX_PROPERTY_NAME INI_MAX_LINE #define INI_MAX_PROPERTY_VALUE INI_MAX_LINE typedef void *HINI; #endif ./sqliteodbc-0.992/missing/log.h0100644000076400001440000000017110033634512015127 0ustar chwusers#ifndef _LOG_H #define _LOG_H /* * Missing in most unixODBC installations but * needed by */ #endif ./sqliteodbc-0.992/tccex/0040755000076400001440000000000012126210177013640 5ustar chwusers./sqliteodbc-0.992/tccex/README.bench0100644000076400001440000000055011054173467015604 0ustar chwusersBenchmarking SQLite/ODBC using TCC on Win32 sbench.c -- SQLite 3.x standalone test ..\tcc -run -lsqlite3 sbench.c -- -dbname \TEMP\BENCH.DB \ -init -v -tpc 200 -clients 4 obench.c -- ODBC based test ..\tcc -run -lodbc32 obench.c -- \ -dsn "Driver={SQLite3 ODBC Driver};Database=\TEMP\BENCH.DB" \ -init -v -tpc 200 -clients 4 ./sqliteodbc-0.992/tccex/a10n/0040755000076400001440000000000010613326415014401 5ustar chwusers./sqliteodbc-0.992/tccex/a10n/README.txt0100644000076400001440000000064210613326414016075 0ustar chwusersThis folder contains the amalgamation (a10n) of SQLite3 >= 3.3.14 In order to use tcc to on-the-fly compile and execute it, do tcc -Dsqlite3_main=main sqlite3.c -run [db_file_name [sql_text]] Unfortunately, this bombs on Win32, but it is possible to build a self-contained SQLite3 shell with this command line ..\..\tcc -Dsqlite3_main=main -o sqlite3.exe sqlite3.c -lkernel32 ./sqliteodbc-0.992/tccex/obench.c0100644000076400001440000004501411054165655015254 0ustar chwusers/* * Adapted from JDBCBench.java */ #ifdef _WIN32 #include #include #else #include #include #include #include #include #include #endif #include #include #include #include #include #include /* tpc bm b scaling rules */ static int tps = 1; /* the tps scaling factor: here it is 1 */ static int nbranches = 1; /* number of branches in 1 tps db */ static int ntellers = 10; /* number of tellers in 1 tps db */ static int naccounts = 100000; /* number of accounts in 1 tps db */ static char *dsn = NULL; #define TELLER 0 #define BRANCH 1 #define ACCOUNT 2 static int *failed_transactions = NULL; static int *transaction_count = NULL; static int n_clients = 10; static int n_txn_per_client = 10; #ifdef _WIN32 static int start_time; #else static struct timeval start_time; #endif static int transactions = 0; static int verbose = 0; #ifdef _WIN32 static int shm[200]; #else static int shmid; static int *shm = NULL; #endif static void incrementTransactionCount() { if (transaction_count) { (*transaction_count)++; } } static void incrementFailedTransactionCount() { if (failed_transactions) { (*failed_transactions)++; } } static int getRandomInt(int lo, int hi) { int ret = 0; ret = rand() % (hi - lo + 1); ret += lo; return ret; } static int getRandomID(int type) { int min, max, num; max = min = 0; num = naccounts; switch(type) { case TELLER: min += nbranches; num = ntellers; /* FALLTHROUGH */ case BRANCH: if (type == BRANCH) { num = nbranches; } min += naccounts; /* FALLTHROUGH */ case ACCOUNT: max = min + num - 1; } return (getRandomInt(min, max)); } static void reportDone() { #ifdef _WIN32 int end_time; #else struct timeval end_time; #endif double completion_time; double rate; #ifdef _WIN32 end_time = GetTickCount(); completion_time = (double) (end_time - start_time) * 0.001; #else gettimeofday(&end_time, NULL); completion_time = (double) end_time.tv_sec + 0.000001 * end_time.tv_usec - ((double) start_time.tv_sec + 0.000001 * start_time.tv_usec); #endif fprintf(stdout, "Benchmark Report\n"); fprintf(stdout, "Featuring "); fprintf(stdout, " "); if (transactions < -1) { fprintf(stdout, " "); } else if (transactions < 0) { fprintf(stdout, " "); } else if (transactions > 0) { fprintf(stdout, " "); } else { fprintf(stdout, " "); } fprintf(stdout, "\n--------------------\n"); fprintf(stdout, "Time to execute %d transactions: %g seconds.\n", *transaction_count, completion_time); fprintf(stdout, "%d/%d failed complete.\n", *failed_transactions, *transaction_count); rate = (*transaction_count - *failed_transactions) / completion_time; fprintf(stdout, "Transaction rate: %g txn/sec.\n", rate); fflush(stdout); *transaction_count = 0; *failed_transactions = 0; } static void createDatabase() { int dotrans = 0, i; long accountsnb = 0; SQLHENV env; SQLHDBC dbc; SQLRETURN rc; SQLHSTMT s; char sqlbuf[1024]; rc = SQLAllocEnv(&env); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "AllocEnv failed\n"); exit(1); } rc = SQLAllocConnect(env, &dbc); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "AllocConnect failed\n"); exit(1); } rc = SQLDriverConnect(dbc, NULL, (SQLCHAR *) dsn, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE | SQL_DRIVER_NOPROMPT); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "DriverConnect failed\n"); exit(1); } rc = SQLSetConnectOption(dbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); if (SQL_SUCCEEDED(rc)) { dotrans = 1; } rc = SQLAllocStmt(dbc, &s); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "AllocStmt failed\n"); exit(1); } rc = SQLExecDirect(s, (SQLCHAR *) "SELECT count(*) FROM accounts", SQL_NTS); if (SQL_SUCCEEDED(rc)) { rc = SQLFetch(s); if (SQL_SUCCEEDED(rc)) { rc = SQLGetData(s, 1, SQL_C_LONG, &accountsnb, sizeof (accountsnb), NULL); if (SQL_SUCCEEDED(rc)) { if (dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } SQLFreeStmt(s, SQL_DROP); if (accountsnb == naccounts * tps) { fprintf(stdout, "Already initialized\n"); fflush(stdout); goto done; } } } SQLTransact(NULL, dbc, SQL_COMMIT); } SQLFreeStmt(s, SQL_CLOSE); fprintf(stdout, "Drop old tables if they exist\n"); fflush(stdout); rc = SQLExecDirect(s, (SQLCHAR *) "DROP TABLE history", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (SQL_SUCCEEDED(rc) && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } rc = SQLExecDirect(s, (SQLCHAR *) "DROP TABLE accounts", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (SQL_SUCCEEDED(rc) && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } rc = SQLExecDirect(s, (SQLCHAR *) "DROP TABLE tellers", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (SQL_SUCCEEDED(rc) && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } rc = SQLExecDirect(s, (SQLCHAR *) "DROP TABLE branches", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (SQL_SUCCEEDED(rc) && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } fprintf(stdout, "Create tables\n"); fflush(stdout); rc = SQLExecDirect(s, (SQLCHAR *) "CREATE TABLE branches (" "Bid INTEGER NOT NULL PRIMARY KEY, " "Bbalance INTEGER, " "filler CHAR(88))", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "CREATE TABLE tellers (" "Tid INTEGER NOT NULL PRIMARY KEY, " "Bid INTEGER, " "Tbalance INTEGER, " "filler CHAR(84))", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "CREATE TABLE accounts (" "Aid INTEGER NOT NULL PRIMARY KEY, " "Bid INTEGER, " "Abalance INTEGER, " "filler CHAR(84))", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "CREATE TABLE history (" "Tid INTEGER, " "Bid INTEGER, " "Aid INTEGER, " "delta INTEGER, " "tstime TIMESTAMP, " "filler CHAR(22))", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); fprintf(stdout, "Delete elements in table in case DROP didn't work\n"); fflush(stdout); rc = SQLExecDirect(s, (SQLCHAR *) "DELETE FROM history", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "DELETE FROM accounts", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "DELETE FROM tellers", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); rc = SQLExecDirect(s, (SQLCHAR *) "DELETE FROM branches", SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } fprintf(stdout, "Insert data in branches table\n"); fflush(stdout); for (i = 0; i < nbranches * tps; i++) { sprintf(sqlbuf, "INSERT INTO branches(Bid,Bbalance) " "VALUES (%d,0)", i); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (i % 100 == 0 && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } } if (dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } fprintf(stdout, "Insert data in tellers table\n"); fflush(stdout); for (i = 0; i < ntellers * tps; i++) { sprintf(sqlbuf, "INSERT INTO tellers(Tid,Bid,Tbalance) " "VALUES (%d,%d,0)", i, i / ntellers); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (i % 100 == 0 && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } } if (dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } fprintf(stdout, "Insert data in accounts table\n"); fflush(stdout); for (i = 0; i < naccounts * tps; i++) { sprintf(sqlbuf, "INSERT INTO accounts(Aid,Bid,Abalance) " "VALUES (%d,%d,0)", i, i / naccounts); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); SQLFreeStmt(s, SQL_CLOSE); if (i % 10000 == 0 && dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } if (i > 0 && i % 10000 == 0) { fprintf(stdout,"\t%d\trecords inserted\n", i); fflush(stdout); } } if (dotrans) { SQLTransact(NULL, dbc, SQL_COMMIT); } fprintf(stdout, "\t%d\trecords inserted\n", naccounts * tps); fflush(stdout); SQLFreeStmt(s, SQL_DROP); done: SQLDisconnect(dbc); SQLFreeConnect(dbc); SQLFreeEnv(env); } static void doOne(HDBC dbc, int bid, int tid, int aid, int delta) { long aBalance = 0; SQLRETURN rc; SQLHSTMT s; SQLSMALLINT ncols; char sqlbuf[1024]; if (dbc == SQL_NULL_HDBC) { incrementFailedTransactionCount(); return; } rc = SQLAllocStmt(dbc, &s); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#1 rc=%d\n", rc); } return; } sprintf(sqlbuf, "UPDATE accounts " "SET Abalance = Abalance + %d WHERE Aid = %d", delta, aid); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#2 rc=%d\n", rc); } goto transfail; } SQLFreeStmt(s, SQL_CLOSE); sprintf(sqlbuf, "SELECT Abalance " "FROM accounts WHERE Aid = %d", aid); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#3 rc=%d\n", rc); } goto transfail; } rc = SQLNumResultCols(s, &ncols); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#4 rc=%d\n", rc); } goto transfail; } rc = SQLFetch(s); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#5 rc=%d\n", rc); } goto transfail; } rc = SQLGetData(s, 1, SQL_C_LONG, &aBalance, sizeof (aBalance), NULL); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#6 rc=%d\n", rc); } goto transfail; } SQLFreeStmt(s, SQL_CLOSE); sprintf(sqlbuf, "UPDATE tellers " "SET Tbalance = Tbalance + %d WHERE Tid = %d", delta, tid); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#7 rc=%d\n", rc); } goto transfail; } SQLFreeStmt(s, SQL_CLOSE); sprintf(sqlbuf, "UPDATE branches " "SET Bbalance = Bbalance + %d WHERE Bid = %d", delta, bid); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#8 rc=%d\n", rc); } goto transfail; } SQLFreeStmt(s, SQL_CLOSE); sprintf(sqlbuf, "INSERT INTO history" "(Tid, Bid, Aid, delta) VALUES" "(%d, %d, %d, %d)", tid, bid, aid, delta); rc = SQLExecDirect(s, (SQLCHAR *) sqlbuf, SQL_NTS); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#9 rc=%d\n", rc); } goto transfail; } SQLFreeStmt(s, SQL_CLOSE); if (transactions > 0) { rc = SQLTransact(NULL, dbc, SQL_COMMIT); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "doOne: fail#10 rc=%d\n", rc); } goto transfail; } } SQLFreeStmt(s, SQL_DROP); return; transfail: incrementFailedTransactionCount(); SQLTransact(NULL, dbc, SQL_ROLLBACK); SQLFreeStmt(s, SQL_DROP); } #ifdef _WIN32 static unsigned __stdcall runClientThread(void *args) #else static int runClientThread(void *args) #endif { SQLHENV env; SQLHDBC dbc; SQLRETURN rc; int ntrans = n_txn_per_client; rc = SQLAllocEnv(&env); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "AllocEnv failed\n"); return 1; } rc = SQLAllocConnect(env, &dbc); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "AllocConnect failed\n"); return 1; } rc = SQLDriverConnect(dbc, NULL, (SQLCHAR *) dsn, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE | SQL_DRIVER_NOPROMPT); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "DriverConnect failed\n"); return 1; } if (transactions) { rc = SQLSetConnectOption(dbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); if (!SQL_SUCCEEDED(rc)) { fprintf(stderr, "SetConnectOption(autocommit=off) failed\n"); return 1; } } while (ntrans-- > 0) { int account = getRandomID(ACCOUNT); int branch = getRandomID(BRANCH); int teller = getRandomID(TELLER); int delta = getRandomInt(0,1000); doOne(dbc, branch, teller, account, delta); if (transactions < -1 && ntrans > 0 && ntrans % 100 == 0) { rc = SQLTransact(NULL, dbc, SQL_COMMIT); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "runClientThread: COMMIT failed rc=%d\n", rc); } incrementFailedTransactionCount(); SQLTransact(NULL, dbc, SQL_ROLLBACK); } } incrementTransactionCount(); } if (transactions < 0) { rc = SQLTransact(NULL, dbc, SQL_COMMIT); if (!SQL_SUCCEEDED(rc)) { if (verbose) { fprintf(stderr, "runClientThread: final COMMIT failed rc=%d\n", rc); } incrementFailedTransactionCount(); SQLTransact(NULL, dbc, SQL_ROLLBACK); } } SQLDisconnect(dbc); SQLFreeConnect(dbc); SQLFreeEnv(env); return 0; } int main(int argc, char **argv) { int init_db = 0, i; #ifdef _WIN32 HANDLE *pids; #else pid_t *pids; #endif for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-clients") == 0) { if (i + 1 < argc) { i++; n_clients = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-dsn") == 0) { if (i + 1 < argc) { i++; dsn = argv[i]; } } else if (strcmp(argv[i], "-tpc") == 0) { if (i + 1 < argc) { i++; n_txn_per_client = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-init") == 0) { init_db = 1; } else if (strcmp(argv[i], "-tps") == 0) { if (i + 1 < argc) { i++; tps = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-v") == 0) { verbose++; } } if (dsn == NULL) { fprintf(stderr, "usage: %s -dsn DSN [-v] [-init] " "[-tpc n] [-clients]\n\n", argv[0]); fprintf(stderr, "-v verbose error messages\n"); fprintf(stderr, "-init initialize the tables\n"); fprintf(stderr, "-tpc transactions per client\n"); fprintf(stderr, "-clients number of simultaneous clients\n"); exit(1); } fprintf(stdout, "Scale factor value: %d\n", tps); fprintf(stdout, "Number of clients: %d\n", n_clients); fprintf(stdout, "Number of transactions per client: %d\n\n", n_txn_per_client); fflush(stdout); if (init_db) { fprintf(stdout, "Initializing dataset...\n"); createDatabase(); fprintf(stdout, "done.\n\n"); fflush(stdout); } #ifndef _WIN32 shmid = shmget(IPC_PRIVATE, 2 * sizeof (int), IPC_CREAT | 0666); shm = shmat(shmid, NULL, 0); #endif transaction_count = &shm[0]; failed_transactions = &shm[1]; *transaction_count = 0; *failed_transactions = 0; #ifdef _WIN32 pids = malloc(n_clients * sizeof (HANDLE)); #else pids = malloc(n_clients * sizeof (pid_t)); #endif if (pids == NULL) { fprintf(stderr, "malloc failed\n"); exit(2); } fprintf(stdout, "Starting Benchmark Run\n"); transactions = 0; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0,runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); switch (child) { case 0: return runClientThread(NULL); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); transactions = 1; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0,runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); switch (child) { case 0: return runClientThread(NULL); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); transactions = -1; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0,runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); switch (child) { case 0: return runClientThread(NULL); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); transactions = -2; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0,runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); switch (child) { case 0: return runClientThread(NULL); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); return 0; } ./sqliteodbc-0.992/tccex/samplext.c0100644000076400001440000000165010557214507015647 0ustar chwusers/* * SQLite3 example extension from wiki * http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions * * Compile with * tcc -rdynamic -shared -o samplext.dll samplext.c */ #include SQLITE_EXTENSION_INIT1 /* * The half() SQL function returns half of its input value. */ static void halfFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_double(context, 0.5 * sqlite3_value_double(argv[0])); } /* * SQLite invokes this routine once when it loads the extension. * Create new functions, collating sequences, and virtual table * modules here. This is usually the only exported symbol in * the shared library. */ int sqlite3_extension_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi) sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0); return 0; } ./sqliteodbc-0.992/tccex/sbench.c0100644000076400001440000003612411054165734015260 0ustar chwusers/* * Adapted from JDBCBench.java */ #ifdef _WIN32 #include #include #else #include #include #include #include #include #include #endif #include #include #include #include /* tpc bm b scaling rules */ static int tps = 1; /* the tps scaling factor: here it is 1 */ static int nbranches = 1; /* number of branches in 1 tps db */ static int ntellers = 10; /* number of tellers in 1 tps db */ static int naccounts = 100000; /* number of accounts in 1 tps db */ static char *dbname = NULL; static char *combegtrans = "COMMIT TRANSACTION ; BEGIN TRANSACTION"; static char *begtrans = "BEGIN TRANSACTION"; #define TELLER 0 #define BRANCH 1 #define ACCOUNT 2 static int *failed_transactions = NULL; static int *transaction_count = NULL; static int *stat_counts = NULL; static int n_clients = 10; static int n_txn_per_client = 10; #ifdef _WIN32 static int start_time; #else static struct timeval start_time; #endif static int transactions = 1; static int verbose = 0; static int useexcl = 0; #ifdef _WIN32 static int shm[200]; #else static int shmid; static int *shm = NULL; #endif static void incrementTransactionCount() { if (transaction_count) { (*transaction_count)++; } } static void incrementFailedTransactionCount() { if (failed_transactions) { (*failed_transactions)++; } } static int getRandomInt(int lo, int hi) { int ret = 0; ret = rand() % (hi - lo + 1); ret += lo; return ret; } static int getRandomID(int type) { int min, max, num; max = min = 0; num = naccounts; switch(type) { case TELLER: min += nbranches; num = ntellers; /* FALLTHROUGH */ case BRANCH: if (type == BRANCH) { num = nbranches; } min += naccounts; /* FALLTHROUGH */ case ACCOUNT: max = min + num - 1; } return (getRandomInt(min, max)); } static void reportDone() { #ifdef _WIN32 int end_time; #else struct timeval end_time; #endif double completion_time; double rate; #ifdef _WIN32 end_time = GetTickCount(); completion_time = (double) (end_time - start_time) * 0.001; #else gettimeofday(&end_time, NULL); completion_time = (double) end_time.tv_sec + 0.000001 * end_time.tv_usec - ((double) start_time.tv_sec + 0.000001 * start_time.tv_usec); #endif fprintf(stdout, "Benchmark Report\n"); fprintf(stdout, "Featuring "); fprintf(stdout, " "); if (transactions) { fprintf(stdout, " "); } else { fprintf(stdout, " "); } fprintf(stdout, "\n--------------------\n"); fprintf(stdout, "Time to execute %d transactions: %g seconds.\n", *transaction_count, completion_time); fprintf(stdout, "%d/%d failed complete.\n", *failed_transactions, *transaction_count); rate = (*transaction_count - *failed_transactions) / completion_time; fprintf(stdout, "Transaction rate: %g txn/sec.\n", rate); fflush(stdout); *transaction_count = 0; *failed_transactions = 0; } #ifdef TRACE_DBINIT static void dbtrace(void *arg, const char *msg) { if (msg) { fprintf(stderr, "%s\n", msg); } } #endif static void createDatabase() { sqlite3 *sqlite; int dotrans = 0; int accountsnb = 0; int i, nrows, ncols; char **rows; if (sqlite3_open(dbname, &sqlite) != SQLITE_OK) { fprintf(stderr, "unable to connect to %s\n", dbname); exit(1); } #ifdef TRACE_DBINIT sqlite3_trace(sqlite, dbtrace, NULL); #endif if (sqlite3_exec(sqlite, begtrans, NULL, NULL, NULL) == SQLITE_OK) { dotrans = 1; } if (sqlite3_get_table(sqlite, "SELECT count(*) FROM accounts", &rows, &ncols, &nrows, NULL) == SQLITE_OK) { if (rows && ncols == 1 && nrows == 1 && rows[1]) { accountsnb = strtol(rows[1], NULL, 0); } if (rows) { sqlite3_free_table(rows); } if (dotrans) { sqlite3_exec(sqlite, "COMMIT TRANSACTION", NULL, NULL, NULL); } if (accountsnb == naccounts * tps) { fprintf(stdout, "Already initialized\n"); fflush(stdout); sqlite3_close(sqlite); return; } } fprintf(stdout, "Drop old tables if they exist\n"); fflush(stdout); if (sqlite3_exec(sqlite, "DROP TABLE history; " "DROP TABLE accounts; " "DROP TABLE tellers; " "DROP TABLE branches; ", NULL, NULL, NULL) == SQLITE_OK) { if (dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } } fprintf(stdout, "Create tables\n"); fflush(stdout); sqlite3_exec(sqlite, "CREATE TABLE branches (" "Bid INTEGER NOT NULL PRIMARY KEY, " "Bbalance INTEGER, " "filler CHAR(88))", NULL, NULL, NULL); sqlite3_exec(sqlite, "CREATE TABLE tellers (" "Tid INTEGER NOT NULL PRIMARY KEY, " "Bid INTEGER, " "Tbalance INTEGER, " "filler CHAR(84))", NULL, NULL, NULL); sqlite3_exec(sqlite, "CREATE TABLE accounts (" "Aid INTEGER NOT NULL PRIMARY KEY, " "Bid INTEGER, " "Abalance INTEGER, " "filler CHAR(84))", NULL, NULL, NULL); sqlite3_exec(sqlite, "CREATE TABLE history (" "Tid INTEGER, " "Bid INTEGER, " "Aid INTEGER, " "delta INTEGER, " "tstime TIMESTAMP, " "filler CHAR(22))", NULL, NULL, NULL); fprintf(stdout, "Delete elements in table in case DROP didn't work\n"); fflush(stdout); sqlite3_exec(sqlite, "DELETE FROM history; " "DELETE FROM accounts; " "DELETE FROM tellers; " "DELETE FROM branches ", NULL, NULL, NULL); if (dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } fprintf(stdout, "Insert data in branches table\n"); fflush(stdout); for (i = 0; i < nbranches * tps; i++) { char *sql = sqlite3_mprintf("INSERT INTO branches(Bid,Bbalance) " "VALUES (%d,0)", i); sqlite3_exec(sqlite, sql, NULL, NULL, NULL); sqlite3_free(sql); if (i % 100 == 0 && dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } } if (dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } fprintf(stdout, "Insert data in tellers table\n"); fflush(stdout); for (i = 0; i < ntellers * tps; i++) { char *sql = sqlite3_mprintf("INSERT INTO tellers(Tid,Bid,Tbalance) " "VALUES (%d,%d,0)", i, i / ntellers); sqlite3_exec(sqlite, sql, NULL, NULL, NULL); sqlite3_free(sql); if (i % 100 == 0 && dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } } if (dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } fprintf(stdout, "Insert data in accounts table\n"); fflush(stdout); for (i = 0; i < naccounts * tps; i++) { char *sql = sqlite3_mprintf("INSERT INTO accounts(Aid,Bid,Abalance) " "VALUES (%d,%d,0)", i, i / naccounts); sqlite3_exec(sqlite, sql, NULL, NULL, NULL); sqlite3_free(sql); if (i % 10000 == 0 && dotrans) { sqlite3_exec(sqlite, combegtrans, NULL, NULL, NULL); } if (i > 0 && i % 10000 == 0) { fprintf(stdout,"\t%d\trecords inserted\n", i); fflush(stdout); } } if (dotrans) { sqlite3_exec(sqlite, "COMMIT TRANSACTION", NULL, NULL, NULL); } fprintf(stdout, "\t%d\trecords inserted\n", naccounts * tps); fflush(stdout); sqlite3_close(sqlite); } static void doOne(sqlite3 *sqlite, int bid, int tid, int aid, int delta) { int aBalance = 0; int nrows, ncols, rc, retries = 500, intrans; char **rows, *sql = 0; if (sqlite == NULL) { incrementFailedTransactionCount(); return; } again: intrans = 0; if (transactions) { rc = sqlite3_exec(sqlite, begtrans, NULL, NULL, NULL); if (rc != SQLITE_OK) { stat_counts[0] += 1; goto transfail; } intrans = 1; } sql = sqlite3_mprintf("UPDATE accounts " "SET Abalance = Abalance + %d WHERE Aid = %d", delta, aid); rc = sqlite3_exec(sqlite, sql, NULL, NULL, NULL); if (rc != SQLITE_OK) { stat_counts[1] += 1; goto transfail; } sqlite3_free(sql); sql = sqlite3_mprintf("SELECT Abalance " "FROM accounts WHERE Aid = %d", aid); rc = sqlite3_get_table(sqlite, sql, &rows, &nrows, &ncols, NULL); if (rc != SQLITE_OK) { stat_counts[2] += 1; goto transfail; } sqlite3_free(sql); if (nrows == 1 && ncols == 1 && rows && rows[1]) { aBalance = strtol(rows[1], NULL, 0); } if (rows) { sqlite3_free_table(rows); } sql = sqlite3_mprintf("UPDATE tellers " "SET Tbalance = Tbalance + %d WHERE Tid = %d", delta, tid); rc = sqlite3_exec(sqlite, sql, NULL, NULL, NULL); if (rc != SQLITE_OK) { stat_counts[3] += 1; goto transfail; } sqlite3_free(sql); sql = sqlite3_mprintf("UPDATE branches " "SET Bbalance = Bbalance + %d WHERE Bid = %d", delta, bid); rc = sqlite3_exec(sqlite, sql, NULL, NULL, NULL); if (rc != SQLITE_OK) { stat_counts[4] += 1; goto transfail; } sqlite3_free(sql); sql = sqlite3_mprintf("INSERT INTO history" "(Tid, Bid, Aid, delta) VALUES" "(%d, %d, %d, %d)", tid, bid, aid, delta); rc = sqlite3_exec(sqlite, sql, NULL, NULL, NULL); if (rc != SQLITE_OK) { stat_counts[5] += 1; goto transfail; } sqlite3_free(sql); sql = 0; if (transactions) { try_commit: rc = sqlite3_exec(sqlite, "COMMIT TRANSACTION", NULL, NULL, NULL); if (rc == SQLITE_BUSY && --retries > 0) { stat_counts[9] += 1; #ifdef _WIN32 Sleep(10); #else usleep(10000); #endif goto try_commit; } if (rc != SQLITE_OK) { stat_counts[6] += 1; goto transfail; } } return; transfail: if (sql) { sqlite3_free(sql); sql = 0; } if (rc == SQLITE_BUSY && --retries > 0) { if (intrans) { sqlite3_exec(sqlite, "ROLLBACK TRANSACTION", NULL, NULL, NULL); stat_counts[7] += 1; } stat_counts[8] += 1; #ifdef _WIN32 Sleep(10); #else usleep(10000); #endif goto again; } incrementFailedTransactionCount(); if (intrans) { stat_counts[10] += 1; sqlite3_exec(sqlite, "ROLLBACK TRANSACTION", NULL, NULL, NULL); } } #ifdef _WIN32 static unsigned __stdcall runClientThread(void *args) #else static int runClientThread(void *args) #endif { sqlite3 *sqlite; int ntrans = n_txn_per_client; if (sqlite3_open(dbname, &sqlite) != SQLITE_OK) { return 0; } sqlite3_busy_timeout(sqlite, 100000); while (ntrans-- > 0) { int account = getRandomID(ACCOUNT); int branch = getRandomID(BRANCH); int teller = getRandomID(TELLER); int delta = getRandomInt(0,1000); doOne(sqlite, branch, teller, account, delta); incrementTransactionCount(); } sqlite3_close(sqlite); return 0; } int main(int argc, char **argv) { int init_db = 0, i; #ifdef _WIN32 HANDLE *pids; #else pid_t *pids; #endif for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-clients") == 0) { if (i + 1 < argc) { i++; n_clients = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-dbname") == 0) { if (i + 1 < argc) { i++; dbname = argv[i]; } } else if (strcmp(argv[i], "-tpc") == 0) { if (i + 1 < argc) { i++; n_txn_per_client = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-init") == 0) { init_db = 1; } else if (strcmp(argv[i], "-tps") == 0) { if (i + 1 < argc) { i++; tps = strtol(argv[i], NULL, 0); } } else if (strcmp(argv[i], "-v") == 0) { verbose++; } else if (strcmp(argv[i], "-excl") == 0) { useexcl++; } } if (dbname == NULL) { fprintf(stderr, "usage: %s -dbame DBFILE [-v] [-init] " "[-tpc n] [-clients c] [-excl\n\n", argv[0]); fprintf(stderr, "-v verbose error messages\n"); fprintf(stderr, "-init initialize the tables\n"); fprintf(stderr, "-tpc transactions per client\n"); fprintf(stderr, "-clients number of simultaneous clients\n"); fprintf(stderr, "-excl use EXCLUSIVE transactions\n"); exit(1); } fprintf(stdout, "Scale factor value: %d\n", tps); fprintf(stdout, "Number of clients: %d\n", n_clients); fprintf(stdout, "Number of transactions per client: %d\n\n", n_txn_per_client); fflush(stdout); if (useexcl) { combegtrans = "COMMIT TRANSACTION ; BEGIN EXCLUSIVE TRANSACTION"; begtrans = "BEGIN EXCLUSIVE TRANSACTION"; } if (init_db) { fprintf(stdout, "Initializing dataset...\n"); createDatabase(); fprintf(stdout, "done.\n\n"); fflush(stdout); } #ifndef _WIN32 shmid = shmget(IPC_PRIVATE, 200 * sizeof (int), IPC_CREAT | 0666); shm = shmat(shmid, NULL, 0); #endif transaction_count = &shm[0]; failed_transactions = &shm[1]; stat_counts = &shm[2]; *transaction_count = 0; *failed_transactions = 0; memset(stat_counts, 0, 198 * sizeof (int)); #ifdef _WIN32 pids = malloc(n_clients * sizeof (HANDLE)); #else pids = malloc(n_clients * sizeof (pid_t)); #endif if (pids == NULL) { fprintf(stderr, "malloc failed\n"); exit(2); } fprintf(stdout, "Starting Benchmark Run\n"); transactions = 0; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0, runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); int rc; switch (child) { case 0: rc = runClientThread(NULL); exit(rc); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); transactions = 1; #ifdef _WIN32 start_time = GetTickCount(); #else gettimeofday(&start_time, NULL); #endif if (n_clients < 2) { runClientThread(NULL); } else { #ifdef _WIN32 for (i = 0; i < n_clients; i++) { unsigned tid; pids[i] = (HANDLE) _beginthreadex(NULL, 0,runClientThread, NULL, 0, &tid); } for (i = 0; i < n_clients; i++) { WaitForSingleObject(pids[i], INFINITE); CloseHandle(pids[i]); } #else for (i = 0; i < n_clients; i++) { pid_t child = fork(); int rc; switch (child) { case 0: rc = runClientThread(NULL); exit(rc); default: pids[i] = child; } } for (i = 0; i < n_clients; i++) { int status; waitpid(pids[i], &status, 0); } #endif } reportDone(); fprintf(stdout, "--------------------\n"); fprintf(stdout, "Error counters, consult source for stat_counts[].\n"); for (i = 0; i < 16; i++) { if (i == 0) { fprintf(stdout, "stat_counts[0..7]: "); } fprintf(stdout, " %d", stat_counts[i]); if (i == 7) { fprintf(stdout, "\nstat_counts[8..15]:"); } } fprintf(stdout, "\n\n"); return 0; } ./sqliteodbc-0.992/tccex/sqlite.c0100644000076400001440000000050210557104767015314 0ustar chwusers/* * Use sqlite_main() entry point in sqliteodbc.dll/sqliteodbcu.dll * to provide an SQLite shell, compile with * * tcc -o sqlite.exe -lsqlite sqlite.c * tcc -o sqliteu.exe -lsqliteu sqlite.c */ extern int sqlite_main(int, char **); int main(int argc, char **argv) { return sqlite_main(argc, argv); } ./sqliteodbc-0.992/tccex/sqlite3.c0100644000076400001440000000041710557105034015370 0ustar chwusers/* * Use sqlite3_main() entry point in sqlite3odbc.dll * to provide an SQLite3 shell, compile with * * tcc -o sqlite3.exe -lsqlite3 sqlite3.c */ extern int sqlite3_main(int, char **); int main(int argc, char **argv) { return sqlite3_main(argc, argv); } ./sqliteodbc-0.992/debian/0040755000076400001440000000000012126210177013754 5ustar chwusers./sqliteodbc-0.992/debian/changelog0100644000076400001440000000024012126210134015610 0ustar chwuserssqliteodbc (0.992-1) unstable; urgency=low * automatically recreated by configure -- Christian Werner Mon, 01 Apr 2013 06:43:07 +0200 ./sqliteodbc-0.992/debian/changelog.in0100644000076400001440000000023011573726701016235 0ustar chwuserssqliteodbc (@VER_INFO@-1) unstable; urgency=low * automatically recreated by configure -- Christian Werner @DEB_CHANGELOG_TS@ ./sqliteodbc-0.992/debian/compat0100644000076400001440000000000211573722655015165 0ustar chwusers5 ./sqliteodbc-0.992/debian/control0100644000076400001440000000115011573723224015360 0ustar chwusersSource: sqliteodbc Priority: optional Maintainer: Sam Clegg Build-Depends: debhelper (>= 5), autotools-dev, cdbs, libsqlite-dev, unixodbc-dev, libsqlite3-dev Standards-Version: 3.7.2 Section: libs Package: libsqliteodbc Section: libs Architecture: any Depends: ${shlibs:Depends} Suggests: unixodbc-bin Enhances: unixodbc Description: ODBC driver for SQLite embedded database This package allows you to connect to an SQLite database using ODBC, the Open Database Connectivity abstraction layer which is understood by a variety of database tools that may not be able to talk to SQLite directly. ./sqliteodbc-0.992/debian/copyright0100644000076400001440000000366011624156343015717 0ustar chwusersThis package was debianized by Sam Clegg on Tue, 25 Jul 2006 11:43:45 +0100. It was downloaded from Upstream Author: Christian Werner Copyright: Copyright (c) 2001-2011 Christian Werner OS/2 Port Copyright (c) 2004 Lorne R. Sunley License: This software is copyrighted by Christian Werner and other authors. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. The Debian packaging is (C) 2006, Sam Clegg and is licensed under the GPL-3, see `/usr/share/common-licenses/GPL-3'. ./sqliteodbc-0.992/debian/dirs0100644000076400001440000000004211573722655014647 0ustar chwusersusr/lib/odbc usr/share/sqliteodbc ./sqliteodbc-0.992/debian/docs0100644000076400001440000000000711573722655014637 0ustar chwusersREADME ./sqliteodbc-0.992/debian/install0100644000076400001440000000005211573723644015354 0ustar chwusersdebian/unixodbc.ini /usr/share/sqliteodbc ./sqliteodbc-0.992/debian/postinst0100644000076400001440000000017611573722655015601 0ustar chwusers#!/bin/sh set -e if [ -x /usr/bin/odbcinst ]; then odbcinst -i -d -f /usr/share/sqliteodbc/unixodbc.ini fi #DEBHELPER# ./sqliteodbc-0.992/debian/prerm0100644000076400001440000000020011574116123015013 0ustar chwusers#!/bin/sh set -e if [ -x /usr/bin/odbcinst ]; then odbcinst -u -d -n SQLITE odbcinst -u -d -n SQLITE3 fi #DEBHELPER# ./sqliteodbc-0.992/debian/rules0100755000076400001440000000030511574116462015037 0ustar chwusers#!/usr/bin/make -f DEB_DH_MAKESHLIBS_ARGS_ALL=--noscripts include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/autotools.mk DEB_CONFIGURE_EXTRA_FLAGS := --disable-static ./sqliteodbc-0.992/debian/unixodbc.ini0100644000076400001440000000045511636117020016267 0ustar chwusers[SQLITE] Description = SQLite ODBC Driver Driver = /usr/lib/odbc/libsqliteodbc.so Setup = /usr/lib/odbc/libsqliteodbc.so Threading = 2 [SQLITE3] Description = SQLite3 ODBC Driver Driver = /usr/lib/odbc/libsqlite3odbc.so Setup = /usr/lib/odbc/libsqlite3odbc.so Threading = 2 ./sqliteodbc-0.992/source0120777000076400001440000000000012126210177014031 2.ustar chwusers