summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-26 12:59:24 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-04-26 12:59:24 -0700
commita167853da2cfd5d8ac3c4e96f02721f91c48b218 (patch)
treef6b8846b6eed66c0c1460e587abbc52193a37291 /src/config.c
parente479ee2a6e3981d08f83e3364cf7469cf8ecaa66 (diff)
downloadgithub-mirror-a167853da2cfd5d8ac3c4e96f02721f91c48b218.tar.gz
github-mirror-a167853da2cfd5d8ac3c4e96f02721f91c48b218.tar.zst
github-mirror-a167853da2cfd5d8ac3c4e96f02721f91c48b218.zip
Add `skip-private` option to config
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c
index 56aac11..71b735e 100644
--- a/src/config.c
+++ b/src/config.c
@@ -152,6 +152,21 @@ token_check:
return NULL;
}
+static int parse_bool(const char *value, int *out)
+{
+ if (!strcmp(value, "true") || !strcmp(value, "1") ||
+ !strcmp(value, "yes") || !strcmp(value, "on")) {
+ *out = 1;
+ return 0;
+ }
+ if (!strcmp(value, "false") || !strcmp(value, "0") ||
+ !strcmp(value, "no") || !strcmp(value, "off")) {
+ *out = 0;
+ return 0;
+ }
+ return -1;
+}
+
static int parse_line_inner(struct config *cfg, enum config_section section,
char *key, char *value)
{
@@ -171,17 +186,21 @@ static int parse_line_inner(struct config *cfg, enum config_section section,
else if (!strcmp(key, "owner"))
cfg->head->owner = value;
else if (!strcmp(key, "skip-forks")) {
- if (!strcmp(value, "true"))
- cfg->head->skip_forks = 1;
- else if (!strcmp(value, "false"))
- cfg->head->skip_forks = 0;
- else {
+ if (parse_bool(value, &cfg->head->skip_forks) < 0) {
fprintf(stderr,
"Error parsing config file: "
"invalid value for skip-forks: %s\n",
value);
return -1;
}
+ } else if (!strcmp(key, "skip-private")) {
+ if (parse_bool(value, &cfg->head->skip_private) < 0) {
+ fprintf(stderr,
+ "Error parsing config file: "
+ "invalid value for skip-private: %s\n",
+ value);
+ return -1;
+ }
} else {
fprintf(stderr,
"Error parsing config file: unknown key: %s\n",