summaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-09 13:24:53 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-11 00:15:18 -0700
commitf277f41d83d450a1f28d350bb7d6da075d1d2741 (patch)
treee197a7de7e26b47cec57a46acdde4b6c74889ad5 /src/config.h
downloadgithub-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.gz
github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.zst
github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.zip
Initial Commit
Add cmake github workflow Install dependencies in gh action Fix missing directory Fix compiler errors Fix group name to gid conversion Force cjson to statically link Add header guards to query headers Add install and cpack to CMakeLists.txt Add config search and CLI arg parsing Improve docs for git.c Fix program continuing on -h flag
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..0d7d827
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,51 @@
+//
+// Created by Anshul Gupta on 4/6/25.
+//
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include <stdlib.h>
+#include <sys/types.h>
+
+#define GH_DEFAULT_ENDPOINT "https://api.github.com/graphql"
+#define GH_DEFAULT_USER_AGENT "github_mirror/0.1"
+
+extern const char *config_locations[];
+
+struct config {
+ /// The content of the config file
+ char *contents;
+ size_t contents_len;
+
+ const char *endpoint;
+ const char *token;
+ const char *user_agent;
+
+ /// The owner of the repositories
+ const char *owner;
+
+ /// The filepath to the git mirrors
+ /// Default: /srv/git
+ const char *git_base;
+ /// User to give ownership of the git mirrors
+ uid_t git_owner;
+ /// Group to give ownership of the git mirrors
+ gid_t git_group;
+};
+
+/**
+ * Read the INI config file at the given path.
+ * Will print to stderr errors if the file cannot be read.
+ * @param path Path to the config file
+ * @return A pointer to the config struct, or NULL on error
+ */
+struct config *config_read(const char *path);
+
+/**
+ * Free the config struct
+ * @param config The config struct to free
+ */
+void config_free(struct config *config);
+
+#endif // CONFIG_H