// s, len is the raw kv string static void _cookie_kv(VALUE output, const char* s, long len) { // strip for (; len > 0; len--, s++) { if (!isspace(*s)) { break; } } for (; len > 0; len--) { if (!isspace(s[len - 1])) { break; } } if (len > 0) { volatile VALUE key = rb_enc_str_new("", 0, u8_encoding); volatile VALUE value = rb_enc_str_new("", 0, u8_encoding); nyara_decode_uri_kv(key, value, s, len); rb_hash_aset(output, key, value); } }
// s, len is the raw kv string static void _param_kv(VALUE output, const char* s, long len) { // strip for (; len > 0; len--, s++) { if (!isspace(*s)) { break; } } for (; len > 0; len--) { if (!isspace(s[len - 1])) { break; } } if (len <= 0) { return; } volatile VALUE name = rb_enc_str_new("", 0, u8_encoding); volatile VALUE value = rb_enc_str_new("", 0, u8_encoding); nyara_decode_uri_kv(name, value, s, len); _nested_aset(output, _split_name(name), value); }
static VALUE ext_decode_uri_kv(VALUE _, VALUE str) { volatile VALUE k = _new_blank_str(); volatile VALUE v = _new_blank_str(); nyara_decode_uri_kv(k, v, RSTRING_PTR(str), RSTRING_LEN(str)); return rb_ary_new3(2, k, v); }