Get something working
Some checks failed
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=OFF (push) Failing after 13s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=OFF (push) Failing after 16s
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=ON (push) Failing after 12s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=ON (push) Failing after 14s
CMake / ubuntu-latest - shared=OFF, pthread=ON, posix=ON (push) Failing after 16s
CMake / ubuntu-latest - shared=ON, pthread=ON, posix=ON (push) Failing after 13s

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-08-01 07:38:13 +03:00
parent 80af330d1b
commit 1d40c785f8
5 changed files with 571 additions and 68 deletions

View File

@@ -1,9 +1,11 @@
#include <dcfg.h>
#include <alloca.h>
#include <getopt.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void walk_value(dcfg_Value *value, bool evaluate, int indent, bool first);
#define WALK(v, e, i) walk_value((v), (e), (i), true)
@@ -16,11 +18,25 @@ static void print_indent(int indent)
int main(int argc, char *argv[])
{
if (argc < 2) {
printf("Usage: %s <dcfg file>\n", argv[0]);
bool evaluate = false;
int opt;
while ((opt = getopt(argc, argv, "e")) != -1) {
switch (opt) {
case 'e':
evaluate = true;
break;
default:
fprintf(stderr, "Usage: %s [-e] <dcfg file>\n", argv[0]);
return 1;
}
}
if (optind >= argc) {
fprintf(stderr, "Usage: %s [-e] <dcfg file>\n", argv[0]);
return 1;
}
char const *path = argv[optind];
dcfg_InstanceCreateInfo ci = { 0 };
dcfg_Instance *instance = dcfg_make_instance(&ci);
if (!instance) {
@@ -29,7 +45,7 @@ int main(int argc, char *argv[])
return 1;
}
dcfg_Value *value = dcfg_parse(instance, dcfg_SV(argv[1]));
dcfg_Value *value = dcfg_parse(instance, dcfg_SV(path));
if (!value) {
printf("Failed to parse DCFG file. Error: %s\n",
dcfg_last_error(instance));
@@ -37,7 +53,7 @@ int main(int argc, char *argv[])
return 1;
}
WALK(value, false, 0);
WALK(value, evaluate, 0);
dcfg_destroy(value);
dcfg_destroy_instance(instance);