#!/usr/bin/env php [ "members" => [ "username" => [ "json" => "username", "type" => "string" ], "discriminator" => [ "json" => "discriminator", "type" => "number" ] ] ], "channel" => [ "members" => [ "name" => [ "json" => "name", "type" => "string" ], "type" => [ "json" => "type", "type" => "number" ] ], "parsing" => [ "checks" => [ 'DC_CHANNEL_SUPPORTED(cJSON_GNV(cJSON_GOI(s, "type")))' ], "code" => <<id = strtoull(st, NULL, 10); u = dc_addr_user(p, DC_ISAE(p->users), u, DC_MAY_FREE); dc_add_user(DC_ISAE(ch->users), u, 0); } HEREDOC, ] ] ]; foreach ($s as $name => $fields) { echo <<{$name}s, p->{$name}s_length, i); HEREDOC; if (isset($fields["parsing"]) && sizeof($fields["parsing"]["checks"])) { echo " if ("; $arr = $fields["parsing"]["checks"]; foreach ($arr as $n => $check) { $or = ""; $end = ""; if ($n != array_key_first($arr)) $or = " || "; if ($n != array_key_last($arr)) $end = PHP_EOL; echo "$or!($check)$end"; } echo <<id = i; dc_addr_$name(p, DC_ISAE(p->{$name}s), n, 0); } HEREDOC; if (isset($fields["parsing"])) echo $fields["parsing"]["code"] . PHP_EOL; foreach ($fields["members"] as $member => $meta) { switch ($meta["type"]) { case "string": echo <<$member); n->$member = strdup(c); } HEREDOC; break; case "number": echo <<$member = cJSON_GNV(o); HEREDOC; break; } } echo <<