summaryrefslogtreecommitdiff
path: root/src/config.h
blob: 2fa32d2d520e6ee5809b8873c8b0ce1d9efd77c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by Anshul Gupta on 4/6/25.
//

#ifndef CONFIG_H
#define CONFIG_H

#include <stdlib.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;
};

/**
 * 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