/* Verify sqlite3 runtime version */ static svn_error_t * test_sqlite_version(apr_pool_t *scratch_pool) { printf("DBG: Using Sqlite %s\n", sqlite3_libversion()); if (sqlite3_libversion_number() != SQLITE_VERSION_NUMBER) printf("DBG: Compiled against Sqlite %s\n", SQLITE_VERSION); if (sqlite3_libversion_number() < SQLITE_VERSION_NUMBER) return svn_error_createf(SVN_ERR_TEST_FAILED, NULL, "Compiled against Sqlite %s (at runtime we have Sqlite %s)", SQLITE_VERSION, sqlite3_libversion()); #if !SQLITE_VERSION_AT_LEAST(3, 7, 9) return svn_error_create(SVN_ERR_TEST_FAILED, NULL, "Sqlite upgrade recommended:\n" "****************************************************************\n" "* Subversion needs at least SQLite 3.7.9 to work optimally *\n" "* *\n" "* With older versions, at least some queries that are expected *\n" "* to be using an index are not. This makes some operations use *\n" "* every node in the working copy instead of just one. *\n" "* *\n" "* While Subversion works correctly in this case, you may see *\n" "* slowdowns of WELL MORE THAN 1000* in some cases! *\n" "* *\n" "* *\n" "* SQLITE UPGRADE RECOMMENDED *\n" "****************************************************************\n"); #else return SVN_NO_ERROR; #endif }
int main(int argc, char *argv[]) { sqlite3 *db = NULL; int res = 0; if (argc != 2) { fprintf(stderr, "Usage: %s <database name>\n", argv[0]); exit(EXIT_FAILURE); } // Inizializzazione della libreria if (sqlite3_initialize() != SQLITE_OK) { fprintf(stderr, "Err. Unable to initialize the library\n"); exit(EXIT_FAILURE); } // Creazione della connessione al database res = sqlite3_open(argv[1], &db); if (res != SQLITE_OK) { fprintf(stderr, "Err. can't create database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); exit(EXIT_FAILURE); } printf("Library \'%s\' successfully initialized..\n", sqlite3_libversion()); printf("Database \'%s\' successfully created.\n", argv[1]); // Close database connection if (sqlite3_close(db) == SQLITE_OK) puts("Closed database connection"); sqlite3_shutdown(); return(EXIT_SUCCESS); }
//' RSQLite version //' //' @return A character vector containing header and library versions of //' RSQLite. //' @export //' @examples //' RSQLite::rsqliteVersion() // [[Rcpp::export]] CharacterVector rsqliteVersion() { return CharacterVector::create( _["header"] = SQLITE_VERSION, _["library"] = sqlite3_libversion() ); }
int cSQLiteDatabase::initialize(){ int ret; const char* dbdir = (cUPnPConfig::get()->mDatabaseFolder) ? cUPnPConfig::get()->mDatabaseFolder : cPluginUpnp::getConfigDirectory(); cString File = cString::sprintf("%s/%s", dbdir, SQLITE_DB_FILE); if ((ret = sqlite3_open(File, &this->mDatabase))){ ERROR("Unable to open database file %s (Error code: %d)!", *File, ret); sqlite3_close(this->mDatabase); return -1; } char* Error; if (sqlite3_exec(this->mDatabase, "PRAGMA synchronous = OFF", NULL, NULL, &Error)){ ERROR("Error while setting PRAGMA OFF: %s", Error); } if (sqlite3_exec(this->mDatabase, "PRAGMA journal_mode = MEMORY", NULL, NULL, &Error)){ ERROR("Error while setting journal mode to memory: %s", Error); } MESSAGE(VERBOSE_SDK,"Database file %s opened. SQLITE version: %s", *File, sqlite3_libversion()); if (this->initializeTables()){ ERROR("Error while creating tables"); return -1; } else if(this->initializeTriggers()){ ERROR("Error while setting triggers"); return -1; } return 0; }
string WrapperSpatialite::versions(void) const { return string("SQLite3 version ") + sqlite3_libversion() + "\n" + "Spatialite version " + spatialite_version() + "\n"; // "Proj4 version " + proj4_version() + "\n" + // "Geos version " + geos_version() + "\n"; }
Array c_SQLite3::t_version() { INSTANCE_METHOD_INJECTION_BUILTIN(SQLite3, SQLite3::version); Array ret; ret.set("versionString", String((char*)sqlite3_libversion(), CopyString)); ret.set("versionNumber", (int64)sqlite3_libversion_number()); return ret; }
BOOL CAboutTabDlg::OnInitDialog() { CBBTabPanel::OnInitDialog(); CVersion lVersion; CString lStr; GetDlgItemText(IDC_ABOUT_VERSION_STATIC, lStr); lVersion.GetVersionString(lStr); #ifdef _FREE //lStr = "Benubird PDF Version"; #endif // ---------------------- // Add the version number for QPL // KDA: 07/07/2009 // ---------------------- DebenuPDFLibraryAX0912 QP; // Update to version 7.19 || June 05, 2010 QP.UnlockKey(_T(QUICKPDF_LICENSE_KEY)); lStr = CString("Quick PDF Library Version: ") + QP.LibraryVersion().c_str(); SetDlgItemText(IDC_QPL_VERSION_STATIC, lStr); // ---------------------- // Add the version number for sqlite // KDA: 09/06/2010 SetDlgItemText(IDC_SQL_VERSION_STATIC, CString("SQLite Version: ") + CString(sqlite3_libversion())); m_DebenuURLBtn.SizeToContent(); return TRUE; }
// sqlite3 wrappers __declspec(dllexport) const char * WINAPI sqlite3_libversion_interop(int *plen) { const char *val = sqlite3_libversion(); *plen = (val != 0) ? strlen(val) : 0; return val; }
/* Don't call this function directly! Use svn_atomic__init_once(). */ static svn_error_t * init_sqlite(void *baton, apr_pool_t *pool) { if (sqlite3_libversion_number() < SQLITE_VERSION_NUMBER) { return svn_error_createf(SVN_ERR_SQLITE_ERROR, NULL, _("SQLite compiled for %s, but running with %s"), SQLITE_VERSION, sqlite3_libversion()); } #if APR_HAS_THREADS #if SQLITE_VERSION_AT_LEAST(3,5,0) /* SQLite 3.5 allows verification of its thread-safety at runtime. Older versions are simply expected to have been configured with --enable-threadsafe, which compiles with -DSQLITE_THREADSAFE=1 (or -DTHREADSAFE, for older versions). */ if (! sqlite3_threadsafe()) return svn_error_create(SVN_ERR_SQLITE_ERROR, NULL, _("SQLite is required to be compiled and run in " "thread-safe mode")); #endif #if SQLITE_VERSION_AT_LEAST(3,6,0) /* If SQLite has been already initialized, sqlite3_config() returns SQLITE_MISUSE. */ { int err = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if (err != SQLITE_OK && err != SQLITE_MISUSE) return svn_error_create(SQLITE_ERROR_CODE(err), NULL, "Could not configure SQLite"); } SQLITE_ERR_MSG(sqlite3_initialize(), "Could not initialize SQLite"); #endif #endif /* APR_HAS_THRADS */ return SVN_NO_ERROR; }
int proxy_db_init(pool *p) { const char *version; if (p == NULL) { errno = EINVAL; return -1; } if (db_pool != NULL) { return 0; } /* Check that the SQLite headers used match the version of the SQLite * library used. * * For now, we only log if there is a difference. */ version = sqlite3_libversion(); if (strcmp(version, SQLITE_VERSION) != 0) { (void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION, "compiled using SQLite version '%s' headers, but linked to " "SQLite version '%s' library", SQLITE_VERSION, version); } pr_trace_msg(trace_channel, 9, "using SQLite %s", version); db_pool = make_sub_pool(p); pr_pool_tag(db_pool, "Proxy Database Pool"); return 0; }
int print_version(void) { printf("%s %s (%s)\n", progname, SUUID_VERSION, SUUID_DATE); #ifndef NO_SQLITE printf("Linked against SQLite %s\n", sqlite3_libversion()); #endif #if defined(FAKE_HOST) || defined(TEST_FUNC) printf("\nThis version is compiled with the following conditional " "directives:\n"); #endif #ifdef FAKE_HOST printf("\nFAKE_HOST: Always return \"fake\" as hostname. This is to " "make sure it \n" "doesn't write to the real log file.\n"); #endif #ifdef TEST_FUNC printf("\nTEST_FUNC: Send non-option command line arguments to " "various functions \n" "for testing. This doesn't break anything, as the program only " "checks for \n" "options. Non-option arguments are ignored.\n"); #endif return EXIT_SUCCESS; }
void print_version(const std::string& pgmname) { std::cout << pgmname << " v0.0.0 - blah blah" << std::endl << "SQLite version " << sqlite3_libversion() << std::endl << "SQLite source ID " << sqlite3_sourceid() << std::endl; std::exit(EXIT_SUCCESS); }
PCSTR SqlVersion( VOID ) { PCSTR Version; Version = sqlite3_libversion(); return Version; }
/* ** Implementation of the sqlite_version() function. The result is the version ** of the SQLite library that is running. */ static void versionFunc( sqlite3_context *context, int NotUsed, sqlite3_value **NotUsed2 ){ UNUSED_PARAMETER2(NotUsed, NotUsed2); /* IMP: R-48699-48617 This function is an SQL wrapper around the ** sqlite3_libversion() C-interface. */ sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC); }
SWIGEXPORT jstring JNICALL Java_com_almworks_sqlite4java__1SQLiteSwiggedJNI_sqlite3_1libversion(JNIEnv *jenv, jclass jcls) { jstring jresult = 0 ; char *result = 0 ; (void)jenv; (void)jcls; result = (char *)sqlite3_libversion(); if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); return jresult; }
void sqlite_version_report(FILE *f) { fprintf(f, "Library version: SQLite: Compile: %s\n" " Runtime: %s\n", SQLITE_VERSION, sqlite3_libversion()); #ifdef DYNLOOKUP fprintf(f, " Exim version %s\n", EXIM_VERSION_STR); #endif }
TEST(Versions, SQLite) { // http://www.sqlite.org/capi3ref.html#sqlite3_libversion assert(sqlite3_libversion_number() == SQLITE_VERSION_NUMBER ); assert(strcmp(sqlite3_sourceid(), SQLITE_SOURCE_ID) == 0); assert(strcmp(sqlite3_libversion(), SQLITE_VERSION) == 0); // Ensure that the SQLite version is above 3.7.0. // "sqlite3_create_function_v2" is not defined in previous versions. ASSERT_GE(SQLITE_VERSION_NUMBER, 3007000); }
/* Displays some pieces of version information which might be useful. */ int doVersion(){ printf( "App Version: %s\n" "DB Version: %d\n" "SQLite Version: %s\n", VERSION, getDbVersion(), sqlite3_libversion()); return SUCCESS; }
int PDOSqliteConnection::getAttribute(int64_t attr, Variant &value) { switch (attr) { case PDO_ATTR_CLIENT_VERSION: case PDO_ATTR_SERVER_VERSION: value = String((char *)sqlite3_libversion(), CopyString); return true; default: return false; } return true; }
static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value) { switch (attr) { case PDO_ATTR_CLIENT_VERSION: case PDO_ATTR_SERVER_VERSION: ZVAL_STRING(return_value, (char *)sqlite3_libversion()); break; default: return 0; } return 1; }
int main(void) { /* Determina l'opzione di configurazione relativa al multithreading, che non necessita peraltro di ulteriore argomento */ sqlite3_config(SQLITE_CONFIG_MULTITHREAD); // Inizializzazione della libreria if (sqlite3_initialize() == SQLITE_OK) printf("Library: \'%s\' initialized\n", sqlite3_libversion()); // Rilascio delle risorse if (sqlite3_shutdown() == SQLITE_OK) printf("Library: freed\n"); return(EXIT_SUCCESS); }
int main(int argc , char * argv[]) { int status; char * str_err_msg= NULL; db_report = stdout; printf("sqlite version : %s\n%s\n",sqlite3_libversion(),sqlite3_sourceid()); //_hdb db; connect_db("demo.db"); // /** PREPARE("create table usrpwd(usr QString, pwd QString)"); status = sqlite3_exec(db, QUERY, 0, 0, &str_err_msg); printf("c->status: %d ~ %s \n",status,str_err_msg); /* */ // /** PREPARE("insert into usrpwd values('hkkk','khhh')"); status = sqlite3_exec(db, QUERY, 0, 0, &str_err_msg); printf("c->status: %d ~ %s \n",status,str_err_msg); //**/ PREPARE("select * from usrpwd "); status = sqlite3_exec(db, QUERY, result_handle, // int (*callback)(void*,int,char**,char**), 0, &str_err_msg); printf("c->status: %d ~ %s \n",status,str_err_msg); status = sqlite3_close(db); if(status != SQLITE_OK ) printf("error:%d\n",sqlite3_errcode(db)); printf("%s",sqlite3_mprintf("%q","it's example")); return 0; }
wxString GetDependencyVersion(dependency::type d) { switch (d) { case dependency::wxwidgets: return wxVERSION_NUM_DOT_STRING_T; case dependency::gnutls: { const char* v = gnutls_check_version(0); if (!v || !*v) return _T("unknown"); return wxString(v, wxConvLibc); } case dependency::sqlite: return wxString::FromUTF8(sqlite3_libversion()); default: return wxString(); } }
SpatialiteBackend::SpatialiteBackend() : SpatialiteBase(), p(new SpatialBackendPrivate) { /* VERY IMPORTANT: you must initialize the SpatiaLite extension [and related] BEFORE attempting to perform any other SQLite call */ spatialite_init (0); /* showing the SQLite version */ qDebug ("SQLite version: %s", sqlite3_libversion ()); /* showing the SpatiaLite version */ qDebug ("SpatiaLite version: %s", spatialite_version ()); isTemp = true; theFilename = HOMEDIR + "/" + QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz") + ".spatialite"; open(HOMEDIR + "/temDb.spatialite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); InitializeNew(); }
SpatialiteBackend::SpatialiteBackend(const QString& filename) : SpatialiteBase(), p(new SpatialBackendPrivate) { /* VERY IMPORTANT: you must initialize the SpatiaLite extension [and related] BEFORE attempting to perform any other SQLite call */ spatialite_init (0); /* showing the SQLite version */ qDebug ("SQLite version: %s", sqlite3_libversion ()); /* showing the SpatiaLite version */ qDebug ("SpatiaLite version: %s", spatialite_version ()); isTemp = false; theFilename = filename; open(theFilename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); InitializeNew(); }
SqliteDriver::SqliteDriver(QObject *parent, const QVariantList &args) : KDbDriver(parent, args) , dp(new SqliteDriverPrivate) { beh->features = SingleTransactions | CursorForward | CompactingDatabaseSupported; //special method for autoincrement definition beh->SPECIAL_AUTO_INCREMENT_DEF = true; beh->AUTO_INCREMENT_FIELD_OPTION = QString(); //not available beh->AUTO_INCREMENT_TYPE = QLatin1String("INTEGER"); beh->AUTO_INCREMENT_PK_FIELD_OPTION = QLatin1String("PRIMARY KEY"); beh->AUTO_INCREMENT_REQUIRES_PK = true; beh->ROW_ID_FIELD_NAME = QLatin1String("OID"); beh->IS_DB_OPEN_AFTER_CREATE = true; beh->_1ST_ROW_READ_AHEAD_REQUIRED_TO_KNOW_IF_THE_RESULT_IS_EMPTY = true; beh->QUOTATION_MARKS_FOR_IDENTIFIER = '"'; beh->SELECT_1_SUBQUERY_SUPPORTED = true; beh->CONNECTION_REQUIRED_TO_CHECK_DB_EXISTENCE = false; beh->CONNECTION_REQUIRED_TO_CREATE_DB = false; beh->CONNECTION_REQUIRED_TO_DROP_DB = false; initDriverSpecificKeywords(keywords); // internal properties beh->properties.insert("client_library_version", QLatin1String(sqlite3_libversion())); beh->properties.insert("default_server_encoding", QLatin1String("UTF8")); //OK? beh->typeNames[KDbField::Byte] = QLatin1String("Byte"); beh->typeNames[KDbField::ShortInteger] = QLatin1String("ShortInteger"); beh->typeNames[KDbField::Integer] = QLatin1String("Integer"); beh->typeNames[KDbField::BigInteger] = QLatin1String("BigInteger"); beh->typeNames[KDbField::Boolean] = QLatin1String("Boolean"); beh->typeNames[KDbField::Date] = QLatin1String("Date"); // In fact date/time types could be declared as datetext etc. beh->typeNames[KDbField::DateTime] = QLatin1String("DateTime"); // to force text affinity..., see http://sqlite.org/datatype3.html beh->typeNames[KDbField::Time] = QLatin1String("Time"); beh->typeNames[KDbField::Float] = QLatin1String("Float"); beh->typeNames[KDbField::Double] = QLatin1String("Double"); beh->typeNames[KDbField::Text] = QLatin1String("Text"); beh->typeNames[KDbField::LongText] = QLatin1String("CLOB"); beh->typeNames[KDbField::BLOB] = QLatin1String("BLOB"); }
char *ncdc_version() { static GString *ver = NULL; static char *msg = "%s %s (built %s %s)\n" "Sendfile support: " #ifdef HAVE_SENDFILE "yes (%s)\n" #else "no\n" #endif "Libraries:\n" " GLib %d.%d.%d (%d.%d.%d)\n" " GnuTLS %s (%s)\n" " SQLite %s (%s)" #ifdef NCURSES_VERSION "\n ncurses %s" #endif ; if(ver) return ver->str; ver = g_string_new(""); g_string_printf(ver, msg, PACKAGE_NAME, main_version, __DATE__, __TIME__, #ifdef HAVE_LINUX_SENDFILE "Linux", #elif HAVE_BSD_SENDFILE "BSD", #endif GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION, glib_major_version, glib_minor_version, glib_micro_version, GNUTLS_VERSION, gnutls_check_version(NULL), SQLITE_VERSION, sqlite3_libversion() #ifdef NCURSES_VERSION , NCURSES_VERSION #endif ); return ver->str; }
PyMODINIT_FUNC init_sqlightning(void) { PyObject *module, *dict; PyObject *tmp_obj; int i; module = Py_InitModule("pysqlightning._sqlightning", module_methods); if (!module || (pysqlite_row_setup_types() < 0) || (pysqlite_cursor_setup_types() < 0) || (pysqlite_connection_setup_types() < 0) || (pysqlite_cache_setup_types() < 0) || (pysqlite_statement_setup_types() < 0) || #ifdef PYSQLITE_EXPERIMENTAL (pysqlite_backup_setup_types() < 0) || #endif (pysqlite_prepare_protocol_setup_types() < 0) ) { return; } Py_INCREF(&pysqlite_ConnectionType); PyModule_AddObject(module, "Connection", (PyObject*) &pysqlite_ConnectionType); Py_INCREF(&pysqlite_CursorType); PyModule_AddObject(module, "Cursor", (PyObject*) &pysqlite_CursorType); Py_INCREF(&pysqlite_CacheType); PyModule_AddObject(module, "Statement", (PyObject*)&pysqlite_StatementType); Py_INCREF(&pysqlite_StatementType); PyModule_AddObject(module, "Cache", (PyObject*) &pysqlite_CacheType); Py_INCREF(&pysqlite_PrepareProtocolType); PyModule_AddObject(module, "PrepareProtocol", (PyObject*) &pysqlite_PrepareProtocolType); Py_INCREF(&pysqlite_RowType); PyModule_AddObject(module, "Row", (PyObject*) &pysqlite_RowType); if (!(dict = PyModule_GetDict(module))) { goto error; } /*** Create DB-API Exception hierarchy */ if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_StandardError, NULL))) { goto error; } PyDict_SetItemString(dict, "Error", pysqlite_Error); if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_StandardError, NULL))) { goto error; } PyDict_SetItemString(dict, "Warning", pysqlite_Warning); /* Error subclasses */ if (!(pysqlite_InterfaceError = PyErr_NewException(MODULE_NAME ".InterfaceError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "InterfaceError", pysqlite_InterfaceError); if (!(pysqlite_DatabaseError = PyErr_NewException(MODULE_NAME ".DatabaseError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "DatabaseError", pysqlite_DatabaseError); /* pysqlite_DatabaseError subclasses */ if (!(pysqlite_InternalError = PyErr_NewException(MODULE_NAME ".InternalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "InternalError", pysqlite_InternalError); if (!(pysqlite_OperationalError = PyErr_NewException(MODULE_NAME ".OperationalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "OperationalError", pysqlite_OperationalError); if (!(pysqlite_ProgrammingError = PyErr_NewException(MODULE_NAME ".ProgrammingError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "ProgrammingError", pysqlite_ProgrammingError); if (!(pysqlite_IntegrityError = PyErr_NewException(MODULE_NAME ".IntegrityError", pysqlite_DatabaseError,NULL))) { goto error; } PyDict_SetItemString(dict, "IntegrityError", pysqlite_IntegrityError); if (!(pysqlite_DataError = PyErr_NewException(MODULE_NAME ".DataError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "DataError", pysqlite_DataError); if (!(pysqlite_NotSupportedError = PyErr_NewException(MODULE_NAME ".NotSupportedError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "NotSupportedError", pysqlite_NotSupportedError); /* We just need "something" unique for pysqlite_OptimizedUnicode. It does not really * need to be a string subclass. Just anything that can act as a special * marker for us. So I pulled PyCell_Type out of my magic hat. */ Py_INCREF((PyObject*)&PyCell_Type); pysqlite_OptimizedUnicode = (PyObject*)&PyCell_Type; PyDict_SetItemString(dict, "OptimizedUnicode", pysqlite_OptimizedUnicode); /* Set integer constants */ for (i = 0; _int_constants[i].constant_name != 0; i++) { tmp_obj = PyInt_FromLong(_int_constants[i].constant_value); if (!tmp_obj) { goto error; } PyDict_SetItemString(dict, _int_constants[i].constant_name, tmp_obj); Py_DECREF(tmp_obj); } if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) { goto error; } PyDict_SetItemString(dict, "version", tmp_obj); Py_DECREF(tmp_obj); if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) { goto error; } PyDict_SetItemString(dict, "sqlite_version", tmp_obj); Py_DECREF(tmp_obj); /* initialize microprotocols layer */ pysqlite_microprotocols_init(dict); /* initialize the default converters */ converters_init(dict); _enable_callback_tracebacks = 0; pysqlite_BaseTypeAdapted = 0; /* Original comment from _bsddb.c in the Python core. This is also still * needed nowadays for Python 2.3/2.4. * * PyEval_InitThreads is called here due to a quirk in python 1.5 * - 2.2.1 (at least) according to Russell Williamson <*****@*****.**>: * The global interpreter lock is not initialized until the first * thread is created using thread.start_new_thread() or fork() is * called. that would cause the ALLOW_THREADS here to segfault due * to a null pointer reference if no threads or child processes * have been created. This works around that and is a no-op if * threads have already been initialized. * (see pybsddb-users mailing list post on 2002-08-07) */ #ifdef WITH_THREAD PyEval_InitThreads(); #endif error: if (PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "pysqlightning._sqlightning: init failed"); } }
static void bug_information_generate_message(GtkTextBuffer * buffer) { int i; gchar *temp; GtkTextIter iter; GtkTextTag *bold_tag, *larger_tag; GtkTextTagTable *table; /* get buffer's tag table */ table = gtk_text_buffer_get_tag_table(buffer); /* Create bold tag */ bold_tag = gtk_text_tag_new("bold"); g_object_set(G_OBJECT(bold_tag), "weight", PANGO_WEIGHT_BOLD, NULL); /* add bold_tag to tag table */ gtk_text_tag_table_add(table, bold_tag); /* Create bold tag */ larger_tag = gtk_text_tag_new("larger"); g_object_set(G_OBJECT(larger_tag), "scale", PANGO_SCALE_X_LARGE, NULL); /* add larger_tag to tag table */ gtk_text_tag_table_add(table, larger_tag); /* Get the start */ gtk_text_buffer_get_start_iter(buffer, &iter); /* insert program name */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Gnome Music Player Client\n", -1, bold_tag, larger_tag, NULL); /* insert copyright */ gtk_text_buffer_insert_with_tags(buffer, &iter, GMPC_COPYRIGHT "\n\n", -1, bold_tag, NULL); /* insert tagline */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Tagline:\t", -1, bold_tag, NULL); gtk_text_buffer_insert(buffer, &iter, GMPC_TAGLINE "\n", -1); /* insert version */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Version:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i.%i.%i\n", GMPC_MAJOR_VERSION, GMPC_MINOR_VERSION, GMPC_MICRO_VERSION); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* insert revision */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Revision:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%s\n", revision); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /** support libs */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nSupport libraries:\n", -1, bold_tag, larger_tag, NULL); /* libmpd */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Libmpd:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i.%i.%i\n", LIBMPD_MAJOR_VERSION, LIBMPD_MINOR_VERSION, LIBMPD_MICRO_VERSION); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* gtk+-2.0 */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Compile time Gtk+-2.0:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i.%i.%i\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); gtk_text_buffer_insert_with_tags(buffer, &iter, "Runtime Gtk+-2.0:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i.%i.%i\n", gtk_major_version, gtk_minor_version, gtk_micro_version); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* glib-2.0 */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Glib-2.0:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i.%i.%i\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* glib-2.0 */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Runtime sqlite3:\t", -1, bold_tag, NULL); gtk_text_buffer_insert(buffer, &iter, sqlite3_libversion(), -1); gtk_text_buffer_insert_with_tags(buffer, &iter, "\nCompile time sqlite3:\t", -1, bold_tag, NULL); gtk_text_buffer_insert(buffer, &iter, SQLITE_VERSION, -1); #ifdef HAVE_UNIQUE gtk_text_buffer_insert_with_tags(buffer, &iter, "\nLibunique:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%s\n", UNIQUE_VERSION_S); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); #endif /* platform */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nPlatform:\t", -1, bold_tag, NULL); #ifdef WIN32 gtk_text_buffer_insert(buffer, &iter, "Windows\n", -1); gtk_text_buffer_insert_with_tags(buffer, &iter, "Windows version:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i\n", g_win32_get_windows_version()); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); #else #ifdef OSX gtk_text_buffer_insert(buffer, &iter, "Mac OsX\n", -1); #else gtk_text_buffer_insert(buffer, &iter, "*nix\n", -1); #endif #endif /** compile flags*/ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nCompile flags:\n", -1, bold_tag, larger_tag, NULL); gtk_text_buffer_insert_with_tags(buffer, &iter, "\nNLS Support:\t", -1, bold_tag, NULL); #ifdef ENABLE_NLS gtk_text_buffer_insert(buffer, &iter, "Enabled", -1); #else gtk_text_buffer_insert(buffer, &iter, "Disabled", -1); #endif gtk_text_buffer_insert_with_tags(buffer, &iter, "\nMultimedia Keys:\t", -1, bold_tag, NULL); #ifdef ENABLE_MMKEYS gtk_text_buffer_insert(buffer, &iter, "Enabled", -1); #else gtk_text_buffer_insert(buffer, &iter, "Disabled", -1); #endif gtk_text_buffer_insert_with_tags(buffer, &iter, "\nAppIndicator Support:\t", -1, bold_tag, NULL); #ifdef HAVE_APP_INDICATOR gtk_text_buffer_insert(buffer, &iter, "Enabled", -1); #else gtk_text_buffer_insert(buffer, &iter, "Disabled", -1); #endif gtk_text_buffer_insert_with_tags(buffer, &iter, "\nLibspiff support:\t", -1, bold_tag, NULL); #ifdef SPIFF gtk_text_buffer_insert(buffer, &iter, "Enabled", -1); #else gtk_text_buffer_insert(buffer, &iter, "Disabled", -1); #endif gtk_text_buffer_insert_with_tags(buffer, &iter, "\nLibunique support:\t", -1, bold_tag, NULL); #ifdef HAVE_UNIQUE gtk_text_buffer_insert(buffer, &iter, "Enabled", -1); #else gtk_text_buffer_insert(buffer, &iter, "Disabled", -1); #endif /** Plugins */ if (num_plugins > 0) { gtk_text_buffer_insert_with_tags(buffer, &iter, "\n\nExternal Plugins:\n", -1, bold_tag, larger_tag, NULL); for (i = 0; i < num_plugins; i++) { if (!gmpc_plugin_is_internal(plugins[i])) { const gchar *name = gmpc_plugin_get_name(plugins[i]); const int *version = gmpc_plugin_get_version(plugins[i]); if(gmpc_plugin_get_enabled(plugins[i])) { gtk_text_buffer_insert(buffer, &iter, "☑ ", -1); }else { gtk_text_buffer_insert(buffer, &iter, "☐ ", -1); } gtk_text_buffer_insert_with_tags(buffer, &iter, name, -1, bold_tag, NULL); temp = g_strdup_printf("\t%i.%i.%i\n", version[0], version[1], version[2]); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); } } } if (num_plugins > 0) { gtk_text_buffer_insert_with_tags(buffer, &iter, "\n\nMetadata Plugins:\n", -1, bold_tag, larger_tag, NULL); for (i = 0; i < num_plugins; i++) { if (gmpc_plugin_is_metadata(plugins[i])) { const gchar *name = gmpc_plugin_get_name(plugins[i]); const int *version = gmpc_plugin_get_version(plugins[i]); if(gmpc_plugin_get_enabled(plugins[i])) { gtk_text_buffer_insert(buffer, &iter, "☑ ", -1); }else { gtk_text_buffer_insert(buffer, &iter, "☐ ", -1); } gtk_text_buffer_insert_with_tags(buffer, &iter, name, -1, bold_tag, NULL); temp = g_strdup_printf("\t%i.%i.%i\n", version[0], version[1], version[2]); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); } } } if (mpd_check_connected(connection)) { gchar **handlers; /** Plugins */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nMusic Player Daemon:\n", -1, bold_tag, larger_tag, NULL); /* Version */ gtk_text_buffer_insert_with_tags(buffer, &iter, "Version:\t", -1, bold_tag, NULL); temp = mpd_server_get_version(connection); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* total songs */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nSongs:\t", -1, bold_tag, NULL); temp = g_strdup_printf("%i", mpd_stats_get_total_songs(connection)); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); /* hostname */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nHostname:\t", -1, bold_tag, NULL); temp = connection_get_hostname(); gtk_text_buffer_insert(buffer, &iter, temp, -1); /* handlers */ gtk_text_buffer_insert_with_tags(buffer, &iter, "\nUrl handlers:\t", -1, bold_tag, NULL); handlers = mpd_server_get_url_handlers(connection); if (handlers) { temp = g_strjoinv(",", handlers); g_strfreev(handlers); handlers = NULL; } else temp = g_strdup("N/A"); gtk_text_buffer_insert(buffer, &iter, temp, -1); g_free(temp); } }
int main (int argc, char *argv[]) { int ret; sqlite3 *handle; sqlite3_stmt *stmt; gaiaGeomCollPtr geom; char sql[256]; int i; int ic; char **results; int n_rows; int n_columns; char *err_msg = NULL; int len; char *table_name; char **p_geotables = NULL; int n_geotables = 0; int row_no; const void *blob; int blob_size; int geom_type; double measure; void *cache; if (argc != 2) { fprintf (stderr, "usage: %s test_db_path\n", argv[0]); return -1; } /* trying to connect the test DB: - this demo was designed in order to connect the standard TEST-2.3.SQLITE sample DB - but you can try to use any SQLite/SpatiaLite DB at your will Please notice: we'll establish a READ ONLY connection */ ret = sqlite3_open_v2 (argv[1], &handle, SQLITE_OPEN_READONLY, NULL); if (ret != SQLITE_OK) { printf ("cannot open '%s': %s\n", argv[1], sqlite3_errmsg (handle)); sqlite3_close (handle); return -1; } /* VERY IMPORTANT: you must initialize the SpatiaLite extension [and related] BEFORE attempting to perform any other SQLite call ========================================================== Please note: starting since 4.1.0 this is completely canged: - a separate memory block (internal cache) is required by each single connection - allocating/freeing this block falls under the responsibility of the program handling the connection - in multithreaded programs a connection can never be share by different threads; the internal-cache block must be allocated by the same thread holding the connection */ cache = spatialite_alloc_connection (); spatialite_init_ex (handle, cache, 0); /* showing the SQLite version */ printf ("SQLite version: %s\n", sqlite3_libversion ()); /* showing the SpatiaLite version */ printf ("SpatiaLite version: %s\n", spatialite_version ()); printf ("\n\n"); /* SQL query #1 we'll retrieve GEOMETRY tables from Spatial Metadata we are assuming this query will return only few rows, so this time we'll use the sqlite3_get_table() interface this interface is very simple to use the result set is returned as a rectangular array [rows/columns] allocated in a temporary memory storage so, this interface is well suited for small sized result sets, but performs badly when accessing a large sized resul set as a side effect, each column value is returned as text, and isn't possible at all to retrieve true column types (INTEGER, FLOAT ...) */ strcpy (sql, "SELECT DISTINCT f_table_name FROM geometry_columns ORDER BY 1"); ret = sqlite3_get_table (handle, sql, &results, &n_rows, &n_columns, &err_msg); if (ret != SQLITE_OK) { /* some error occurred */ printf ("query#1 SQL error: %s\n", err_msg); sqlite3_free (err_msg); goto abort; } if (n_rows > 1) { /* first row always contains column names and is meaningless in this context */ n_geotables = n_rows; /* allocating a dynamic pointer array to store geotable names */ p_geotables = malloc (sizeof (char *) * n_geotables); for (i = 1; i <= n_rows; i++) { /* now we'll fetch one row at each time [and we have only one column to fetch] this one is is a simplified demo; but when writing a real application you always must check for NULL values !!!! */ table_name = results[(i * n_columns) + 0]; /* and we'll store each geotable name into the dynamic pointer array */ len = strlen (table_name); p_geotables[i - 1] = malloc (len + 1); strcpy (p_geotables[i - 1], table_name); } /* we can now free the table results */ sqlite3_free_table (results); } for (i = 0; i < n_geotables; i++) { /* now we'll scan each geotable we've found in Spatial Metadata */ printf ("========= table '%s' ========================\n", p_geotables[i]); /* SQL query #2 we'll retrieve any column from the current geotable we are assuming this query will return lots of rows, so we have to use sqlite3_prepare_v2() interface this interface is a more complex one, but is well suited in order to access huge sized result sets and true value type control is supported */ sprintf (sql, "SELECT * FROM %s", p_geotables[i]); ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); if (ret != SQLITE_OK) { /* some error occurred */ printf ("query#2 SQL error: %s\n", sqlite3_errmsg (handle)); goto abort; } /* the sqlite3_prepare_v2() call simply parses the SQL statement, checking for syntax validity, allocating internal structs etc but no result set row is really yet available */ /* we'll now save the #columns within the result set */ n_columns = sqlite3_column_count (stmt); row_no = 0; while (1) { /* this is an infinite loop, intended to fetch any row */ /* we are now trying to fetch the next available row */ ret = sqlite3_step (stmt); if (ret == SQLITE_DONE) { /* there are no more rows to fetch - we can stop looping */ break; } if (ret == SQLITE_ROW) { /* ok, we've just fetched a valid row to process */ row_no++; printf ("row #%d\n", row_no); for (ic = 0; ic < n_columns; ic++) { /* and now we'll fetch column values for each column we'll then get: - the column name - a column value, that can be of type: SQLITE_NULL, SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT or SQLITE_BLOB, according to internal DB storage type */ printf ("\t%-10s = ", sqlite3_column_name (stmt, ic)); switch (sqlite3_column_type (stmt, ic)) { case SQLITE_NULL: printf ("NULL"); break; case SQLITE_INTEGER: printf ("%d", sqlite3_column_int (stmt, ic)); break; case SQLITE_FLOAT: printf ("%1.4f", sqlite3_column_double (stmt, ic)); break; case SQLITE_TEXT: printf ("'%s'", sqlite3_column_text (stmt, ic)); break; case SQLITE_BLOB: blob = sqlite3_column_blob (stmt, ic); blob_size = sqlite3_column_bytes (stmt, ic); /* checking if this BLOB actually is a GEOMETRY */ geom = gaiaFromSpatiaLiteBlobWkb (blob, blob_size); if (!geom) { /* for sure this one is not a GEOMETRY */ printf ("BLOB [%d bytes]", blob_size); } else { geom_type = gaiaGeometryType (geom); if (geom_type == GAIA_UNKNOWN) printf ("EMPTY or NULL GEOMETRY"); else { char *geom_name; if (geom_type == GAIA_POINT) geom_name = "POINT"; if (geom_type == GAIA_LINESTRING) geom_name = "LINESTRING"; if (geom_type == GAIA_POLYGON) geom_name = "POLYGON"; if (geom_type == GAIA_MULTIPOINT) geom_name = "MULTIPOINT"; if (geom_type == GAIA_MULTILINESTRING) geom_name = "MULTILINESTRING"; if (geom_type == GAIA_MULTIPOLYGON) geom_name = "MULTIPOLYGON"; if (geom_type == GAIA_GEOMETRYCOLLECTION) geom_name = "GEOMETRYCOLLECTION"; printf ("%s SRID=%d", geom_name, geom->Srid); if (geom_type == GAIA_LINESTRING || geom_type == GAIA_MULTILINESTRING) { #ifndef OMIT_GEOS /* GEOS is required */ gaiaGeomCollLength (geom, &measure); printf (" length=%1.2f", measure); #else printf (" length=?? [no GEOS support available]"); #endif /* GEOS enabled/disabled */ } if (geom_type == GAIA_POLYGON || geom_type == GAIA_MULTIPOLYGON) { #ifndef OMIT_GEOS /* GEOS is required */ gaiaGeomCollArea (geom, &measure); printf (" area=%1.2f", measure); #else printf ("area=?? [no GEOS support available]"); #endif /* GEOS enabled/disabled */ } } /* we have now to free the GEOMETRY */ gaiaFreeGeomColl (geom); } break; }; printf ("\n"); } if (row_no >= 5) { /* we'll exit the loop after the first 5 rows - this is only a demo :-) */ break; } } else { /* some unexpected error occurred */ printf ("sqlite3_step() error: %s\n", sqlite3_errmsg (handle)); sqlite3_finalize (stmt); goto abort; } } /* we have now to finalize the query [memory cleanup] */ sqlite3_finalize (stmt); printf ("\n\n"); } /* disconnecting the test DB */ ret = sqlite3_close (handle); if (ret != SQLITE_OK) { printf ("close() error: %s\n", sqlite3_errmsg (handle)); return -1; } /* freeing the internal-cache memory block */ spatialite_cleanup_ex (cache); printf ("\n\nsample successfully terminated\n"); /* we have to free the dynamic pointer array used to store geotable names */ for (i = 0; i < n_geotables; i++) { /* freeing each tablename */ free (p_geotables[i]); } free (p_geotables); spatialite_shutdown(); return 0; abort: sqlite3_close (handle); /* freeing the internal-cache memory block */ spatialite_cleanup_ex (cache); if (p_geotables) { /* we have to free the dynamic pointer array used to store geotable names */ for (i = 0; i < n_geotables; i++) { /* freeing each tablename */ free (p_geotables[i]); } free (p_geotables); } spatialite_shutdown(); return -1; }