This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Forked from http://pldaniels.com/undark/ | |
// Build: gcc undark.c -o undark.exe -lws2_32 -s | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <ctype.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://habr.com/ru/post/572684/ | |
// template.xslx - https://github.com/little-brother/sqlite-gui/blob/master/resources/template.xlsx | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
const unsigned int crc32_tab[] = { | |
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, | |
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Build | |
gcc.exe -Wall -O2 -c main.c -o obj\main.o | |
gcc.exe -Wall -O2 -c sqlite3.c -o obj\sqlite3.o | |
gcc.exe -o watcher.exe obj\main.o obj\sqlite3.o -s | |
Usage example | |
watcher -d "D:/my.sqlite" -q "select * from t order by 1 desc limit 10" - t 2 | |
*/ | |
#include <stdbool.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared vtab.c -o vtab.dll -s -static | |
// create virtual table t using vtab(4); -- 4 is a column count | |
#include "sqlite3ext.h" | |
SQLITE_EXTENSION_INIT1 | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
typedef struct vtab_vtab vtab_vtab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared vtab.c -o vtab.dll -s -static | |
// select * from vtab('D:/1.txt') | |
// select line from vtab where path = 'D:/1.txt' | |
#include "sqlite3ext.h" | |
SQLITE_EXTENSION_INIT1 | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_LINE_SIZE 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared vtab.c -o vtab.dll -s -static | |
#include "sqlite3ext.h" | |
SQLITE_EXTENSION_INIT1 | |
#include <string.h> | |
typedef struct vtab_vtab vtab_vtab; | |
struct vtab_vtab { | |
sqlite3_vtab base; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared aggavg.c -o aggavg.dll -s -static | |
#include "sqlite3ext.h" | |
SQLITE_EXTENSION_INIT1 | |
typedef struct agg_state { | |
int cnt; | |
double sum; | |
} agg_state; | |
static void avg_step (sqlite3_context *ctx, int argc, sqlite3_value **argv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared aggsum.c -o aggsum.dll -s -static | |
#include "sqlite3ext.h" | |
SQLITE_EXTENSION_INIT1 | |
static void sum_step (sqlite3_context *ctx, int argc, sqlite3_value **argv) { | |
double* total = (double*)sqlite3_aggregate_context(ctx, sizeof(double)); | |
if (total == NULL) | |
return sqlite3_result_error_nomem(ctx); | |
*total += sqlite3_value_double(argv[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc main.c sqlite3.c -o main.exe | |
#include <stdio.h> | |
#include "sqlite3.h" | |
int main() { | |
sqlite3* db; | |
if (SQLITE_OK != sqlite3_open_v2(":memory:", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL)) { | |
printf("Error: can't open a database"); | |
return -1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc main.c sqlite3.c -o main.exe | |
#include <stdio.h> | |
#include "sqlite3.h" | |
static void square (sqlite3_context *ctx, int argc, sqlite3_value **argv) { | |
int type = sqlite3_value_type(argv[0]); | |
double d = sqlite3_value_double(argv[0]); | |
switch (type) { | |
case SQLITE_NULL: |
NewerOlder