Skip to content

Commit

Permalink
modules/pua_rpc: return result as struct
Browse files Browse the repository at this point in the history
  • Loading branch information
juha-h committed Dec 12, 2016
1 parent 8aeddc0 commit 07310c6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/modules/pua_rpc/pua_rpc.c
Expand Up @@ -63,6 +63,7 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
{
rpc_delayed_ctx_t* dctx;
void* c;
void* st;
rpc_t* rpc;
struct hdr_field* hdr= NULL;
int statuscode;
Expand Down Expand Up @@ -95,7 +96,13 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
statuscode = reply->first_line.u.reply.statuscode;
reason = reply->first_line.u.reply.reason;
}
rpc->add(c, "dS", statuscode, &reason);
if (rpc->add(c, "{", &st) < 0) {
LM_ERR("rpc->add failed on '{'\n");
rpc->delayed_ctx_close(dctx);
return -1;
}
rpc->struct_add(st, "d", "statusCode", statuscode);
rpc->struct_add(st, "S", "reasonPhrase", &reason);

if (statuscode == 200) {
expires = ((exp_body_t*)reply->expires->parsed)->val;
Expand All @@ -116,7 +123,8 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
}
etag = hdr->body;
LM_DBG("SIP-Etag = %.*s\n", etag.len, etag.s);
rpc->add(c, "Sd", &etag, expires);
rpc->struct_add(st, "S", "SIP-Etag", &etag);
rpc->struct_add(st, "d", "Expires", expires);
}

rpc->delayed_ctx_close(dctx);
Expand Down Expand Up @@ -279,7 +287,7 @@ static void publish(rpc_t* rpc, void* c)


rpc_export_t pua_rpc[] = {
{"pua.publish", publish, publish_doc, 0},
{"pua.publish", publish, publish_doc, 0},
{0, 0, 0, 0}
};

Expand Down

0 comments on commit 07310c6

Please sign in to comment.