Commit dd77e5af authored by Shawn Webb's avatar Shawn Webb
Browse files

Track the version of the library



Versioning the objects makes it easy to know ABI compat between old
version of the library and new.
Signed-off-by: Shawn Webb's avatarShawn Webb <shawn.webb@hardenedbsd.org>
parent 384c7855
......@@ -33,6 +33,8 @@
#include <sqlite3.h>
#include <ucl.h>
#define LATTUTIL_VERSION 1
struct _lllog;
struct _sqlite_ctx;
typedef struct _sqlite_ctx sqlite_ctx_t;
......@@ -50,6 +52,7 @@ typedef void (*log_close)(struct _lllog *);
* preferred over directly accessing the ABI.
*/
typedef struct _llconfig {
uint64_t l_version;
struct stat l_sb;
char *l_path;
int l_fd;
......@@ -58,6 +61,7 @@ typedef struct _llconfig {
} lattutil_config_path_t;
typedef struct _lllog {
uint64_t ll_version;
int ll_verbosity;
char *ll_path;
......@@ -70,6 +74,7 @@ typedef struct _lllog {
} lattutil_log_t;
typedef struct _lattutil_sql_ctx {
uint64_t lsq_version;
sqlite3 *lsq_sqlctx;
char *lsq_path;
uint64_t lsq_flags;
......
......@@ -45,6 +45,8 @@ lattutil_find_config(const char **paths, size_t npaths,
return (NULL);
}
res->l_version = LATTUTIL_VERSION;
res->l_fd = -1;
for (i = 0; i < npaths; i++) {
sz = strlen(paths[i]) + strlen(filename) + 3;
......
......@@ -42,6 +42,8 @@ lattutil_log_init(char *path, int verbosity)
return (NULL);
}
res->ll_version = LATTUTIL_VERSION;
res->ll_verbosity = (verbosity == -1) ? LATTUTIL_LOG_VERBOSITY_DEFAULT :
verbosity;
if (path != NULL) {
......
......@@ -53,6 +53,8 @@ lattutil_sqlite_ctx_new(const char *path, lattutil_log_t *logger,
return (NULL);
}
ctx->lsq_version = LATTUTIL_VERSION;
ctx->lsq_path = strdup(path);
if (ctx->lsq_path == NULL) {
free(ctx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment