aboutsummaryrefslogtreecommitdiff
path: root/src/vdf/vdf.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-06-29 18:35:24 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-06-29 18:35:24 +0200
commitd89a23076329c7fb8dd259fa4ef4c354d22a457e (patch)
tree52c7f50d2bae2ff487aae3e5f7d8b856aeff9762 /src/vdf/vdf.c
parente8cac02fb846428c86b4fe19038893b4fb040af2 (diff)
downloadOFQT-d89a23076329c7fb8dd259fa4ef4c354d22a457e.tar.gz
OFQT-d89a23076329c7fb8dd259fa4ef4c354d22a457e.zip
remove unimportant vdf data types, make vdf failure more transparent
Diffstat (limited to 'src/vdf/vdf.c')
-rw-r--r--src/vdf/vdf.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/src/vdf/vdf.c b/src/vdf/vdf.c
index 2708a5d..10c3ed1 100644
--- a/src/vdf/vdf.c
+++ b/src/vdf/vdf.c
@@ -18,7 +18,6 @@
#define FMT_UNKNOWN_CHAR "Encountered Unknown Character %c (%li)\n"
-
struct vdf_object* vdf_parse_buffer(const char* buffer, size_t size)
{
if (!buffer)
@@ -69,12 +68,6 @@ struct vdf_object* vdf_parse_buffer(const char* buffer, size_t size)
{
o->type = VDF_TYPE_INT;
}
- else if (len > 6 && len < 9 && (chars+digits) == len-1 && buf[0] == '#')
- {
- // TODO
- //o->type = VDF_TYPE_COLOR;
- o->type = VDF_TYPE_STRING;
- }
else
{
o->type = VDF_TYPE_STRING;
@@ -230,9 +223,8 @@ struct vdf_object* vdf_object_index_array(struct vdf_object* o, size_t index)
struct vdf_object* vdf_object_index_array_str(struct vdf_object* o, char* str)
{
- assert(o);
- assert(str);
- assert(o->type == VDF_TYPE_ARRAY);
+ if (!o || !str || o->type != VDF_TYPE_ARRAY)
+ return NULL;
for (size_t i = 0; i < o->data.data_array.len; ++i)
{
@@ -283,26 +275,18 @@ static void vdf_print_object_indent(struct vdf_object* o, int l)
puts("}");
break;
- default:
- case VDF_TYPE_NONE:
- case VDF_TYPE_FLOAT:
- case VDF_TYPE_PTR: // ?
- case VDF_TYPE_COLOR:
- assert(0);
- break;
-
case VDF_TYPE_INT:
- printf("\t\t\"%i\"\n", o->data.data_int);
+ printf("\t\t\"%lli\"\n", o->data.data_int);
break;
case VDF_TYPE_STRING:
printf("\t\t\"%s\"\n", o->data.data_string.str);
break;
- case VDF_TYPE_WSTRING:
+ default:
+ case VDF_TYPE_NONE:
assert(0);
break;
-
}
}
@@ -326,22 +310,14 @@ void vdf_free_object(struct vdf_object* o)
free(o->data.data_array.data_value);
break;
- default:
- case VDF_TYPE_NONE:
- case VDF_TYPE_INT:
- case VDF_TYPE_FLOAT:
- case VDF_TYPE_PTR: // ?
- case VDF_TYPE_COLOR:
- break;
case VDF_TYPE_STRING:
if (o->data.data_string.str)
free(o->data.data_string.str);
break;
- case VDF_TYPE_WSTRING:
- if (o->data.data_wstring.str)
- free(o->data.data_wstring.str);
+ default:
+ case VDF_TYPE_NONE:
break;
}