aboutsummaryrefslogtreecommitdiff
path: root/cd.c
blob: 14a9105f841217d9932871061c21e0d874bc1611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sqlite3.h>
#include "segmenttree.h"

int main(int argc, char* argv[]) {
	char *file = "cards";
	bool verbose = false;

	static struct option long_options[] = {
		{"file",    required_argument, 0, 'f'},
		{"verbose", no_argument,       0, 'v'}
	};
	while (1) {
		int option_index = 0;
		int c = getopt_long(argc, argv, "f:v", long_options, &option_index);
		if (c == -1) break;
		switch (c) {
			case 'f': file = strdup(optarg); break;
			case 'v': verbose = true; break;
			default: abort();
		}
	}

	printf("%s", file);

	sqlite3 *db;
	int rc = sqlite3_open(file, &db);
	if (rc) {
		fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
		abort();
	}
	fprintf(stderr, "Opened database successfully\n");

	//int N = sqlite3_exec(db, "SELECT COUNT(*) FROM cards", callback)

	sqlite3_close(db);
}