<commit_before>/*
 * libdbi-drivers - database drivers for libdbi, a database independent
 * abstraction layer for C.
 * Copyright (C) 2002-2007, <NAME>
 * http://libdbi-drivers.sourceforge.net
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * dbd_sqlite3.c: SQLite3 database support (using libsqlite3)
 * Copyright (C) 2005-2007, <NAME> <<EMAIL>>
 * http://libdbi-drivers.sourceforge.net
 * 
 * $Id: dbd_sqlite3.c,v 1.51 2013/10/05 22:40:37 mhoenicka Exp $
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _GNU_SOURCE /* we need asprintf */

/* this is defined by the Makefile and passed via -D */
/* #define DBDIR /usr/local/var/lib/libdbi/sqlite3 */

#ifndef HAVE_ATOLL
long long atoll(const char *str);
#endif

#ifndef HAVE_STRTOLL
long long strtoll(const char *nptr, char **endptr, int base);
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h> /* defines _POSIX_PATH_MAX */
#include <dirent.h> /* directory listings */
#include <unistd.h> /* stat */
#include <sys/stat.h> /* S_ISXX macros */
#include <sys/types.h> /* directory listings */
#include <ctype.h> /* toupper, etc */

#include <dbi/dbi.h>
#include <dbi/dbi-dev.h>
#include <dbi/dbd.h>

#include <sqlite3.h>
#include "dbd_sqlite3.h"

static const dbi_info_t driver_info = {
  "sqlite3",
  "SQLite3 database support (using libsqlite3)",
  "<NAME> <<EMAIL>>",
  "http://libdbi-drivers.sourceforge.net",
  "dbd_sqlite3 v" VERSION,
  __DATE__
};

static const char *custom_functions[] = SQLITE3_CUSTOM_FUNCTIONS;
static const char *reserved_words[] = SQLITE3_RESERVED_WORDS;
static const char default_dbdir[] = DBDIR;

/* the encoding strings */
static const char sqlite3_encoding_UTF8[] = "UTF-8";
static const char sqlite3_encoding_UTF16[] = "UTF-16";

/* pointers to sqlite3 functions - avoids tons of if/elses */
/* int (*my_sqlite3_open)(const char *,sqlite3 **); */<commit_msg>dbd_sqlite3: have compilation succeed on mingw<commit_after>/*
 * libdbi-drivers - database drivers for libdbi, a database independent
 * abstraction layer for C.
 * Copyright (C) 2002-2007, <NAME>
 * http://libdbi-drivers.sourceforge.net
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * dbd_sqlite3.c: SQLite3 database support (using libsqlite3)
 * Copyright (C) 2005-2007, <NAME> <<EMAIL>>
 * http://libdbi-drivers.sourceforge.net
 * 
 * $Id: dbd_sqlite3.c,v 1.51 2013/10/05 22:40:37 mhoenicka Exp $
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _GNU_SOURCE /* we need asprintf */

/* this is defined by the Makefile and passed via -D */
/* #define DBDIR /usr/local/var/lib/libdbi/sqlite3 */

#ifndef HAVE_ATOLL
long long atoll(const char *str);
#endif

#ifndef HAVE_STRTOLL
long long strtoll(const char *nptr, char **endptr, int base);
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h> /* defines _POSIX_PATH_MAX */
#include <dirent.h> /* directory listings */
#include <unistd.h> /* stat */
#include <sys/stat.h> /* S_ISXX macros */
#include <sys/types.h> /* directory listings */
#include <ctype.h> /* toupper, etc */

#include <dbi/dbi.h>
#include <dbi/dbi-dev.h>
#include <dbi/dbd.h>

#include <sqlite3.h>
#include "dbd_sqlite3.h"

#ifdef _WIN32
	/*
	 * Do the same as in libdbi. MSDN says: readdir, strtok have
	 * thread-local storage. Therefore, let's cheat.
	 */
#	define readdir_r(a, b, c) readdir(a)
#	define strtok_r(a, b, c) strtok((a), (b))
#endif

static const dbi_info_t driver_info = {
  "sqlite3",
  "SQLite3 database support (using libsqlite3)",
  "<NAME> <<EMAIL>>",
  "http://libdbi-drivers.sourceforge.net",
  "dbd_sqlite3 v" VERSION,
  __DATE__
};

static const char *custom_functions[] = SQLITE3_CUSTOM_FUNCTIONS;
static const char *reserved_words[] = SQLITE3_RESERVED_WORDS;
static const char default_dbdir[] = DBDIR;

/* the encoding strings */
static const char sqlite3_encoding_UTF8[] = "UTF-8";
static const char sqlite3_encoding_UTF16[] = "UTF-16";

/* pointers to sqlite3 functions - avoids tons of if/elses */
/* int (*my_sqlite3_open)(const char *,sqlite3 **); */
{'fraction_non_alphanumeric': 0.12241914854741458, 'fraction_numerical': 0.027224556915768316, 'mean_word_length': 4.193548387096774, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4413815', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1848, 'n_words': 623}