This commit is contained in:
Олег Бородин
2023-08-15 14:39:09 +02:00
parent b0058875a1
commit 42ad1c0f93
22 changed files with 1338 additions and 1300 deletions

View File

@@ -6,6 +6,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <logger.h>
#include <clparser.h>
@@ -155,15 +156,21 @@ int clparser_parse(clparser_t * parser, char** argv, int argc) {
for (int i = 0; i < parser->bindsize; i++) {
if (strcmp(parser->bindarr[i].key, key) == 0) {
switch (parser->bindarr[i].type) {
case CLVALTYPE_INT:{
char* eptr = NULL;
*(int *)(parser->bindarr[i].ref) = (int)strtol(val, &eptr, 10);
case CLVALTYPE_STR:{
*(char **)(parser->bindarr[i].ref) = strcopy(val);
free(key);
free(val);
break;
}
case CLVALTYPE_STR:{
*(char **)(parser->bindarr[i].ref) = strcopy(val);
case CLVALTYPE_INT:{
for (size_t i = 0; i < strlen(val); i++) {
if (isdigit(val[i]) == 0 && val[i] != '-' ) {
log_error("wrong integer value: %s = %s", key, val);
//return -1;
}
}
char* eptr = NULL;
*(int *)(parser->bindarr[i].ref) = (int)strtol(val, &eptr, 10);
free(key);
free(val);
break;
@@ -175,7 +182,8 @@ int clparser_parse(clparser_t * parser, char** argv, int argc) {
} else if (strcmp(val, "false") == 0) {
*(bool*)(parser->bindarr[i].ref) = false;
} else {
log_error("wrong boolean key value: %s = %s", key, val);
log_error("wrong boolean value: %s = %s", key, val);
//return -1;
}
free(key);
free(val);