Files
wiktlarp-tf2/make-db/make-db.c
T
2026-07-28 14:44:37 -06:00

46 lines
864 B
C

#include <stdio.h>
#include <string.h>
#include <sqlite3.h>
#include <unistd.h>
const char *word_db_path = "../words.db";
const char *word_plaintext_path = "../words.gz";
char buf[2048] = "";
char *word = buf;
char *read_entry () {
const char *s = fgets (buf, 2048, stdin);
if (s == NULL) {
return NULL;
} else {
char *r = strchr (buf, '\t');
if (r != NULL) {
*r = '\0';
return r + 1;
} else {
return NULL;
}
}
}
int main () {
if (access (word_db_path, F_OK)) {
remove (word_db_path);
}
sqlite3 *db = NULL;
if (! sqlite3_open (word_db_path, &db) == SQLITE_OK) {
fprintf (stderr, "couldn't open sqlite: %s\n", sqlite3_errmsg (db));
} else {
fprintf (stderr, "sqlite open }:3\n");
char *s = read_entry ();
if (s == NULL) {
printf ("%s: %s\n", word, s);
}
}
return 0;
}