DBD-SQLite

 view release on metacpan or  search on metacpan

dbdimp.c  view on Meta::CPAN

#define PERL_NO_GET_CONTEXT

#define NEED_newSVpvn_flags
#define NEED_sv_2pvbyte

#include "SQLiteXS.h"

START_MY_CXT;

DBISTATE_DECLARE;

#define SvPV_nolen_undef_ok(x) (SvOK(x) ? SvPV_nolen(x) : "undef")

/*-----------------------------------------------------*
 * Debug Macros
 *-----------------------------------------------------*/

#undef DBD_SQLITE_CROAK_DEBUG

#ifdef DBD_SQLITE_CROAK_DEBUG
  #define croak_if_db_is_null()   if (!imp_dbh->db)   croak("imp_dbh->db is NULL at line %d in %s", __LINE__, __FILE__)
  #define croak_if_stmt_is_null() if (!imp_sth->stmt) croak("imp_sth->stmt is NULL at line %d in %s", __LINE__, __FILE__)
#else
  #define croak_if_db_is_null()
  #define croak_if_stmt_is_null()
#endif


/*-----------------------------------------------------*
 * Helper Methods
 *-----------------------------------------------------*/

#define sqlite_error(h,rc,what) _sqlite_error(aTHX_ __FILE__, __LINE__, h, rc, what)
#define sqlite_trace(h,xxh,level,what) if ( DBIc_TRACE_LEVEL((imp_xxh_t*)xxh) >= level ) _sqlite_trace(aTHX_ __FILE__, __LINE__, h, (imp_xxh_t*)xxh, what)
#define sqlite_exec(h,sql) _sqlite_exec(aTHX_ h, imp_dbh->db, sql)
#define sqlite_open(dbname,db) _sqlite_open(aTHX_ dbh, dbname, db, 0, 0)
#define sqlite_open2(dbname,db,flags,extended) _sqlite_open(aTHX_ dbh, dbname, db, flags, extended)
#define _isspace(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f')

#define _skip_whitespaces(sql) \
  while ( _isspace(sql[0]) || (sql[0] == '-' && sql[1] == '-')) { \
    if ( _isspace(sql[0]) ) { \
      while ( _isspace(sql[0]) ) sql++; \
      continue; \
    } \
    else if (sql[0] == '-') { \
      while ( sql[0] != 0 && sql[0] != '\n' ) sql++; \
      continue; \
    } \
  }

bool
_starts_with_begin(const char *sql) {
  return (
    ((sql[0] == 'B' || sql[0] == 'b') &&
     (sql[1] == 'E' || sql[1] == 'e') &&
     (sql[2] == 'G' || sql[2] == 'g') &&
     (sql[3] == 'I' || sql[3] == 'i') &&
     (sql[4] == 'N' || sql[4] == 'n')
    ) || (
     (sql[0] == 'S' || sql[0] == 's') &&
     (sql[1] == 'A' || sql[1] == 'a') &&
     (sql[2] == 'V' || sql[2] == 'v') &&
     (sql[3] == 'E' || sql[3] == 'e') &&
     (sql[4] == 'P' || sql[4] == 'p') &&
     (sql[5] == 'O' || sql[5] == 'o') &&
     (sql[6] == 'I' || sql[6] == 'i') &&
     (sql[7] == 'N' || sql[7] == 'n') &&
     (sql[8] == 'T' || sql[8] == 't')
    )
  ) ? TRUE : FALSE;
}

/* adopted from sqlite3.c */



( run in 0.669 second using v1.01-cache-2.11-cpan-39bf76dae61 )