Files
helmetc/libxtools/clconfig_test.c
2025-10-18 16:31:44 +02:00

43 lines
901 B
C

/*
*
* Copyright 2023 Oleg Borodin <borodin@unix7.org>
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <clconfig.h>
#include <massert.h>
int main(int argc, char** argv) {
(void)argc;
(void)argv;
char* _argv[] = { argv[0], "--strkey=num5678", "--intkey=12345" };
int _argc = 2;
clconfig_t clconfig;
clconfig_init(&clconfig, _argc, _argv);
int intkey = 0;
char* strkey = NULL;
clconfig_bind(&clconfig, GCONF_INT, "intkey", &intkey);
clconfig_bind(&clconfig, GCONF_STR, "strkey", &strkey);
int res = clconfig_parse(&clconfig);
if (res < 0) {
printf("error: %s\n", clconfig_geterr(&clconfig));
}
MASSERT(res == 0);
clconfig_destroy(&clconfig);
printf("int key = %d\n", intkey);
printf("str key = %s\n", strkey);
return 0;
}