sqlite3.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <sqlite3_ruby.h>
  2. VALUE mSqlite3;
  3. VALUE cSqlite3Blob;
  4. static VALUE libversion(VALUE UNUSED(klass))
  5. {
  6. return INT2NUM(sqlite3_libversion_number());
  7. }
  8. void Init_sqlite3_native()
  9. {
  10. /*
  11. * SQLite3 is a wrapper around the popular database
  12. * sqlite[http://sqlite.org].
  13. *
  14. * For an example of usage, see SQLite3::Database.
  15. */
  16. mSqlite3 = rb_define_module("SQLite3");
  17. /* A class for differentiating between strings and blobs, when binding them
  18. * into statements.
  19. */
  20. cSqlite3Blob = rb_define_class_under(mSqlite3, "Blob", rb_cString);
  21. /* Initialize the sqlite3 library */
  22. #ifdef HAVE_SQLITE3_INITIALIZE
  23. sqlite3_initialize();
  24. #endif
  25. init_sqlite3_database();
  26. init_sqlite3_statement();
  27. #ifdef HAVE_SQLITE3_BACKUP_INIT
  28. init_sqlite3_backup();
  29. #endif
  30. rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
  31. rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
  32. rb_define_const(mSqlite3, "SQLITE_VERSION_NUMBER", INT2FIX(SQLITE_VERSION_NUMBER));
  33. }