Search results for "380ac94cf78882700d35e00c8906250b" in md5 (2)

/vg/ - /osg/ - oldschool runescape general
Anonymous No.534047573
>Complete royal titans
>Lots of herbs to process to make inventory space
>Now I need to fucking guams for mox paste
/g/ - /dpt/ - Daily Programming Thread
Anonymous No.105557087
I'm using a JSON library in C (yajl) to parse some GLTF (not important), and the library operates by using a callback every time it processes a token.
static int gltf_double(void *userdata, double val)
{
// ...
return 1;
}

static const yajl_callbacks gltf_callbacks = {
.yajl_null = gltf_null,
.yajl_boolean = gltf_boolean,
.yajl_integer = gltf_integer,
.yajl_double = gltf_double,
.yajl_number = NULL,
.yajl_string = gltf_string,
.yajl_start_map = gltf_start_map,
.yajl_map_key = gltf_map_key,
.yajl_end_map = gltf_end_map,
.yajl_start_array = gltf_start_array,
.yajl_end_array = gltf_end_array,
};

yajl_handle yajl = yajl_alloc(&gltf_callbacks, NULL, &state);

I was starting to write a somewhat bloated state machine to handle all of the keys I was expecting, but then it occurred to me, why don't I just fuck with the callback table itself instead?
If I encounter the "scene" key, I change the integer callback to a function that writes the value somewhere (and the others to error out) then restore the table to what it was before.
Is there anything wrong with doing it this way? Is this how people actually use these kinds of libraries?