view scid/scid.c @ 27:dae2de19ca5d

misc: switch to JSON everywhere
author David Demelier <markand@malikania.fr>
date Wed, 03 Aug 2022 15:18:09 +0200
parents 7e10cace67a3
children 4c16bb25e4f1
line wrap: on
line source

#include <assert.h>
#include <stdio.h>

#include "db.h"
#include "log.h"
#include "scid.h"

struct scid scid = {
	.dbpath = VARDIR "/db/sci/sci.db"
};

void
scid_init(void)
{
	log_open("scid");
	log_info("opening database %s", scid.dbpath);

	if (db_open(scid.dbpath) < 0)
		log_die("abort: unable to open database");
}

const char *
scid_theme_path(const char *filename)
{
	assert(filename);

	/* Build path to the template file. */
	static _Thread_local char path[PATH_MAX];

	snprintf(path, sizeof (path), "%s/%s", scid.themedir, filename);

	return path;
}

void
scid_finish(void)
{
	db_finish();
	log_finish();
}