aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE7
-rw-r--r--meson.build10
-rw-r--r--src/args.c38
-rw-r--r--src/args.h14
-rw-r--r--src/config.c31
-rw-r--r--src/config.h11
-rw-r--r--src/main.c14
-rw-r--r--src/repo.c0
-rw-r--r--src/repo.h3
9 files changed, 122 insertions, 6 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..af30a89
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright © 2026 foreverk238 <forever2k38@disroot.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/meson.build b/meson.build
index 2b66e53..92c300a 100644
--- a/meson.build
+++ b/meson.build
@@ -1,11 +1,15 @@
-project('xd', 'c')
+project('pow', 'c', default_options: ['c_std=c99'])
deps = [
dependency('luajit')
]
sources = [
- 'src/main.c'
+ 'src/main.c',
+
+ 'src/args.c',
+ 'src/config.c',
+ 'src/repo.c'
]
-executable('xd', sources, dependencies: deps)
+executable('pow', sources, dependencies: deps)
diff --git a/src/args.c b/src/args.c
new file mode 100644
index 0000000..424492c
--- /dev/null
+++ b/src/args.c
@@ -0,0 +1,38 @@
+#include "args.h"
+
+#include "stdbool.h"
+#include "stdio.h"
+#include "string.h"
+
+char *help = "pow! - the pow!erful package manager\n"
+ "Made with love by forever2k38\n"
+ "Source code at: https://codeberg.org/einfach/pow\n"
+ "Use outside of einfach is unsupported.\n"
+ "This software comes with no warranty.\n"
+ "\n"
+ "Usage: pow\n"
+ " --help Prints this help message\n"
+ " -c Specify config file path.\n";
+
+int pow_args_parse(int argc, char **argv, pow_args *args) {
+ int flags = 0;
+
+ for (int i = 0; i < argc; i++) {
+ char *arg = argv[i];
+
+ if (strcmp(arg, "--help") == 0) {
+ flags |= POW_FLAG_HELP;
+
+ continue;
+ }
+
+ if (strcmp(arg, "-c") == 0) {
+ }
+ }
+
+ args->flags = flags;
+
+ return 0;
+}
+
+void pow_args_print_help() { printf("%s", help); };
diff --git a/src/args.h b/src/args.h
new file mode 100644
index 0000000..79ea308
--- /dev/null
+++ b/src/args.h
@@ -0,0 +1,14 @@
+#include "stddef.h"
+
+#define DEFAULT_CONFIG_PATH "/etc/pow/opts.lua"
+
+#define POW_FLAG_HELP 1
+
+typedef struct {
+ int flags;
+
+ char *cfg_path;
+} pow_args;
+
+int pow_args_parse(int argc, char *argv[], pow_args *args);
+void pow_args_print_help();
diff --git a/src/config.c b/src/config.c
new file mode 100644
index 0000000..33d59b8
--- /dev/null
+++ b/src/config.c
@@ -0,0 +1,31 @@
+#include "config.h"
+
+#include "lauxlib.h"
+
+int open_config(pow_config *cfg, char *path) {
+ int err;
+
+ cfg->L = luaL_newstate();
+
+ if (!cfg->L) {
+ return 1;
+ }
+
+ lua_State *L = cfg->L; // just easier to access
+
+ err = luaL_loadfile(L, path);
+
+ if (err) {
+ return 1;
+ }
+
+ err = lua_pcall(L, 0, 0, 0);
+
+ if (err) {
+ printf("%s\n", lua_tostring(L, -1));
+
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..9150a82
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,11 @@
+#include "repo.h"
+
+#include "lua.h"
+
+typedef struct {
+ pow_repo **repos;
+
+ lua_State *L;
+} pow_config;
+
+int open_config(pow_config *cfg, char *path);
diff --git a/src/main.c b/src/main.c
index 9cc3ae6..4de964d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,15 @@
-#include <stdio.h>
+#include "args.h"
-int main() {
- printf("hello world!");
+int main(int argc, char *argv[]) {
+ pow_args args = {0};
+
+ pow_args_parse(argc, argv, &args);
+
+ if (args.flags & POW_FLAG_HELP) {
+ pow_args_print_help();
+
+ return 0;
+ }
return 0;
}
diff --git a/src/repo.c b/src/repo.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/repo.c
diff --git a/src/repo.h b/src/repo.h
new file mode 100644
index 0000000..9787375
--- /dev/null
+++ b/src/repo.h
@@ -0,0 +1,3 @@
+typedef struct {
+ char *path;
+} pow_repo;