aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-08-09 07:30:59 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-08-09 07:30:59 +0000
commit4fa342bcfdb5ebcbe65cabe1fb9ac3a46ea4ddca (patch)
treee7398fc7b26e9bd225f2c10ed0557baa771fca78 /include
parente2cda84ebbd073ece54692c6a3d785afc6148268 (diff)
checkpoint (it doesn't compile)
Diffstat (limited to 'include')
-rw-r--r--include/common.h2
-rw-r--r--include/lua_state.h22
-rw-r--r--include/pkg.h20
-rw-r--r--include/state.h1
4 files changed, 32 insertions, 13 deletions
diff --git a/include/common.h b/include/common.h
index a77718b..32d8741 100644
--- a/include/common.h
+++ b/include/common.h
@@ -20,7 +20,7 @@
#ifndef PKGIT_COMMON_H
#define PKGIT_COMMON_H
-#define VERSION "1.2.0"
+#define VERSION "2.0.0_INDEV"
#define RED "\x1b[0;31m"
#define GREEN "\x1b[0;32m"
#define YELLOW "\x1b[0;33m"
diff --git a/include/lua_state.h b/include/lua_state.h
index 49f35e4..db689fe 100644
--- a/include/lua_state.h
+++ b/include/lua_state.h
@@ -12,5 +12,27 @@ extern bool L_is_loaded;
bool init_lua_state(void);
bool init_lua_config(void);
void free_lua_state(void);
+void free_lua_config(void);
+
+#define lua_get_field_type(name, type, file, pop_num) \
+ do { \
+ lua_getfield(L, -1, name); \
+ if (!lua_is##type(L, -1)) { \
+ log_error("lua: expected type '" #type "' for %s in %.*s", \
+ name, str_fmt(file)); \
+ lua_pop(L, pop_num); \
+ return false; \
+ } \
+ } while (0)
+
+#define lua_run_function(name, file, params, returns, pop_num) \
+ do { \
+ if (lua_pcall(L, params, returns, 0) { \
+ log_error("lua: '%s' function borked in %.*s: %s", \
+ name, str_fmt(file)), lua_tostring(L, -1); \
+ lua_pop(L, pop_num); \
+ return false; \
+ } \
+ } while (0)
#endif
diff --git a/include/pkg.h b/include/pkg.h
index 2410710..15990ab 100644
--- a/include/pkg.h
+++ b/include/pkg.h
@@ -3,22 +3,20 @@
#include "str.h"
-struct package_t;
-typedef bool (*package_hook_cb_t)(struct package_t *pkg);
-typedef str (*package_version_cb_t)(struct package_t *pkg);
-
typedef struct package_t {
str name, version, url, src;
unsigned int dep_count;
bool is_local;
- package_hook_cb_t setup, build, install, rm, on_update, fetch_sources;
- package_version_cb_t fetch_latest_version;
} package_t;
-bool setup(package_t *pkg), build(package_t *pkg),
- install(package_t *pkg), rm(package_t *pkg),
- on_update(package_t *pkg),
- fetch_sources(package_t *pkg);
-str fetch_latest_version(package_t *pkg);
+bool pkg_hook_url(package_t *pkg);
+str pkg_get_url(package_t *pkg);
+bool pkg_hook_setup(package_t *pkg);
+bool pkg_hook_build(package_t *pkg);
+bool pkg_hook_install(package_t *pkg);
+bool pkg_hook_remove(package_t *pkg);
+bool pkg_hook_on_update(package_t *pkg);
+bool pkg_hook_fetch_sources(package_t *pkg);
+str pkg_hook_fetch_latest_version(package_t *pkg);
#endif
diff --git a/include/state.h b/include/state.h
index a1c09d7..6793aff 100644
--- a/include/state.h
+++ b/include/state.h
@@ -38,4 +38,3 @@ typedef struct config_t {
extern cli_flags_t flags;
extern user_config_t config;
-extern inst_dirs_t inst_dirs;