diff lib/db.h @ 19:de4bf839b565

misc: revamp SQL
author David Demelier <markand@malikania.fr>
date Fri, 15 Jul 2022 11:11:48 +0200
parents scid/db.h@600204c31bf0
children f98ea578b1ef
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/db.h	Fri Jul 15 11:11:48 2022 +0200
@@ -0,0 +1,79 @@
+/*
+ * db.h -- scid database access
+ *
+ * Copyright (c) 2021 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef SCI_DB_H
+#define SCI_DB_H
+
+#include <sys/types.h>
+#include <stddef.h>
+
+struct project;
+struct worker;
+struct job;
+struct jobresult;
+
+struct db_ctx {
+	void *handle;
+};
+
+int
+db_open(const char *);
+
+int
+db_job_add(struct job *);
+
+ssize_t
+db_job_todo(struct db_ctx *, struct job *, size_t, int);
+
+int
+db_jobresult_add(struct jobresult *);
+
+int
+db_project_add(struct project *);
+
+int
+db_project_update(const struct project *);
+
+ssize_t
+db_project_list(struct db_ctx *, struct project *, size_t);
+
+int
+db_project_find(struct db_ctx *, struct project *);
+
+int
+db_project_find_id(struct db_ctx *, struct project *);
+
+int
+db_worker_add(struct worker *);
+
+ssize_t
+db_worker_list(struct db_ctx *, struct worker *, size_t);
+
+int
+db_worker_find(struct db_ctx *, struct worker *);
+
+int
+db_worker_find_id(struct db_ctx *, struct worker *);
+
+void
+db_finish(void);
+
+void
+db_ctx_finish(struct db_ctx *);
+
+#endif /* !SCI_DB_H */