Half time

This commit is contained in:
Ano-sys
2025-02-02 18:43:19 +01:00
parent 02c31d009e
commit c370a35d98
29 changed files with 28782 additions and 145 deletions
+11 -2
View File
@@ -104,6 +104,14 @@ void free_key_value_pairs(key_value_pair **head, key_value_pair **tail)
*tail = NULL;
}
int sum_f(const char *str){
if(str == NULL) return 0;
int sum = 0;
for(int i = 0; i < strlen(str); i++){
sum += str[i] - 48;
}
return sum;
}
// adds given key_value_pair to list
int add_key_value_pair(key_value_pair *kv, key_value_pair **head, key_value_pair **tail, bool concat)
@@ -220,15 +228,16 @@ void extract_key_value_pairs(char *red_str, key_value_pair **head, key_value_pai
strncpy(key, word_start, word_length);
key[word_length] = '\0';
char value[16];
if(doReduce)
if(doReduce){
snprintf(value, 16, "%d", (int)value_length);
}
else{
strncpy(value, word_start + word_length, value_length);
value[value_length] = '\0';
}
key_value_pair *kv = init_key_value_pair(key, value);
add_key_value_pair(kv, head, tail, doReduce);
add_key_value_pair(kv, head, tail, false);
// reset
word_length = 0;