Parse the K/V form in CAP LS

This is a prerequisite for the IRC v3.2 compliance.
This commit is contained in:
LemonBoy 2017-10-21 10:21:03 +02:00
commit 98836f8b7e
4 changed files with 52 additions and 10 deletions

View file

@ -12,7 +12,10 @@ static void perl_irc_connect_fill_hash(HV *hv, IRC_SERVER_CONNECT_REC *conn)
static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server)
{
AV *av;
HV *hv_;
GSList *tmp;
GHashTableIter iter;
gpointer key_, val_;
perl_irc_connect_fill_hash(hv, server->connrec);
perl_server_fill_hash(hv, (SERVER_REC *) server);
@ -34,10 +37,14 @@ static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server)
(void) hv_store(hv, "cap_complete", 12, newSViv(server->cap_complete), 0);
(void) hv_store(hv, "sasl_success", 12, newSViv(server->sasl_success), 0);
av = newAV();
for (tmp = server->cap_supported; tmp != NULL; tmp = tmp->next)
av_push(av, new_pv(tmp->data));
(void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)av), 0);
hv_ = newHV();
g_hash_table_iter_init(&iter, server->cap_supported);
while (g_hash_table_iter_next(&iter, &key_, &val_)) {
char *key = (char *)key_;
char *val = (char *)val_;
hv_store(hv_, key, strlen(key), new_pv(val), 0);
}
(void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)hv_), 0);
av = newAV();
for (tmp = server->cap_active; tmp != NULL; tmp = tmp->next)