From 407d61a90890cb2b70d5a3661367229b7d69502d Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Fri, 18 Oct 2024 17:58:23 -0400 Subject: [PATCH] v4.0.0-rc4 - add config parsing --- etc/example.cfg | 20 ++++++++++++++++++++ include/glacier_config.h | 3 ++- libglacier.c | 18 +++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/etc/example.cfg b/etc/example.cfg index 04f287a..8fe9d3e 100644 --- a/etc/example.cfg +++ b/etc/example.cfg @@ -41,3 +41,23 @@ GLACIER_VERBOSE = false; ### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ### ### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ### ### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ### + +# This system profile is only present for testing purposes. + +# Package repository +# This is the URL which glacier-update-pkgdb will clone +GLACIER_REPO = "https://git.everestlinux.org/EverestLinux/epkgs-x86_64-musl"; + +# System architecture +# The architecture of your system's CPU +GLACIER_ARCH = "x86_64"; + +# Target compilation triplet +# The triplet to be used during compilation +GLACIER_TARGET = "x86_64-linux-musl"; + +# System profile +# This variable tells Glacier about your system and which packages can be installed. +# This setting depends on the three above and should not be changed manually. +# If you wish to migrate system profiles, see https://www.everestlinux.org/docs/musl-or-glibc +GLACIER_SYSTEM_PROFILE = "x86_64-musl"; diff --git a/include/glacier_config.h b/include/glacier_config.h index 2520f34..45ad128 100644 --- a/include/glacier_config.h +++ b/include/glacier_config.h @@ -70,6 +70,7 @@ int load_all_from_config(); /**************************************************************************************************************/ /* + * [[[ DEPRECATED ]]] * load_setting_from_config * DESCRIPTION: Initialize a specified from glacier.cfg. * PARAMETERS: @@ -82,6 +83,6 @@ int load_all_from_config(); * load_setting_from_config(); */ -int load_setting_from_config(char SETTING[]); +/* int load_setting_from_config(char SETTING[]); */ #endif diff --git a/libglacier.c b/libglacier.c index 3abcee6..115c91d 100644 --- a/libglacier.c +++ b/libglacier.c @@ -185,7 +185,7 @@ init_config() { config_init(&cfg); - if (! config_read_file(&cfg, "glacier.cfg")) { + if (! config_read_file(&cfg, runtime_files[0])) { fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); config_destroy(&cfg); @@ -222,6 +222,18 @@ die_config() * */ +int +load_all_from_config() +{ + config_lookup_bool(&cfg, "GLACIER_DO_INT_CHECK", &GLACIER_DO_INT_CHECK); + config_lookup_bool(&cfg, "GLACIER_VERBOSE", &GLACIER_VERBOSE); + + config_lookup_string(&cfg, "GLACIER_REPO", &GLACIER_REPO); + config_lookup_string(&cfg, "GLACIER_ARCH", &GLACIER_ARCH); + config_lookup_string(&cfg, "GLACIER_TARGET", &GLACIER_TARGET); + config_lookup_string(&cfg, "GLACIER_SYSTEM_PROFILE", &GLACIER_SYSTEM_PROFILE); +} + /* issues with this idk int load_all_from_config() @@ -252,9 +264,9 @@ load_all_from_config() * */ -int +/* int load_setting_from_config(char SETTING[]) -{} +{} */ /* * mkworkspace