aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: c78b558e75fe57d5db0cb564b89d0c6d32e48ad9 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <assert.h>
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DATABASE_PATH "ftag.db"

static sqlite3 *db;

static void __sqlite3_check(int rc, sqlite3 *db, const char *file, int line)
{
	if (rc == SQLITE_OK)
		return;

	fprintf(stderr, "%s:%d: %s\n", file, line, sqlite3_errmsg(db));
	assert(0);
}

#define sqlite3_check(RC, DB) __sqlite3_check(RC, DB, __FILE__, __LINE__)

static void ftag_init(void)
{
	sqlite3_exec("")
}

static void usage(void)
{
	printf("usage: ftag COMMAND [COMMAND-ARG]...\n");
	printf("Available values for COMMAND:\n");
	printf("  init\n");
}

int main(int argc, char *argv[])
{
	char *err_msg;
	int rc;

	if (argc == 1) {
		usage();
		exit(1);
	}

	rc = sqlite3_open(DATABASE_PATH, &db);
	sqlite3_check(rc, db);

	if (strcmp(argv[1], "init") == 0)
		ftag_init();
	else
		assert(0);

	sqlite3_free(err_msg);
	sqlite3_close(db);
	return 0;
}

/* Local Variables: */
/* compile-command: "gcc -std=c99 -Wall -O0 -g3 $(pkg-config --libs sqlite3) -o sqlite-first main.c" */
/* End: */