Skip to content

Commit

Permalink
clt: treat rpc array as a structure, otherwise kamcmd fails
Browse files Browse the repository at this point in the history
- no proper array support for binrpc breaks the ctl-kamcmd. The array
  is displayed as a structure, like it was done in the past
- for proper json output, use kamctl or kamcli
  • Loading branch information
miconda committed Jan 6, 2017
1 parent ec98abd commit 053ddb5
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/modules/ctl/binrpc_run.c
Expand Up @@ -974,18 +974,12 @@ static int rpc_add(struct binrpc_ctx* ctx, char* fmt, ...)
break;
case '{':
case '[':
if(*fmt == '{')
err=binrpc_start_struct(&ctx->out.pkt);
else
err=binrpc_start_array(&ctx->out.pkt);
err=binrpc_start_struct(&ctx->out.pkt);
if (err<0) goto error_add;
rs=new_rpc_struct();
if (rs==0) goto error_mem;
rs->offset=binrpc_pkt_len(&ctx->out.pkt);
if(*fmt == '{')
err=binrpc_end_struct(&ctx->out.pkt);
else
err=binrpc_end_array(&ctx->out.pkt);
err=binrpc_end_struct(&ctx->out.pkt);
if (err<0) goto error_add;
clist_append(&ctx->out.structs, rs, next, prev);
*(va_arg(ap, void**))=rs;
Expand Down Expand Up @@ -1086,10 +1080,7 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...)
break;
case '{':
case '[':
if(*fmt == '{')
avp.type=BINRPC_T_STRUCT;
else
avp.type=BINRPC_T_ARRAY;
avp.type=BINRPC_T_STRUCT;
err=binrpc_addavp(&s->pkt, &avp);
if (err<0){
LM_ERR("failed to add attribute-value (%c)\n", *fmt);
Expand All @@ -1101,10 +1092,7 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...)
goto error_mem;
}
rs->offset=binrpc_pkt_len(&s->pkt);
if(*fmt == '{')
err=binrpc_end_struct(&s->pkt);
else
err=binrpc_end_array(&s->pkt);
err=binrpc_end_struct(&s->pkt);
if (err<0) {
LM_ERR("failed to end struct (%c)\n", *fmt);
goto error_add;
Expand Down Expand Up @@ -1168,18 +1156,12 @@ static int rpc_array_add(struct rpc_struct_l* s, char* fmt, ...)
break;
case '{':
case '[':
if(*fmt == '{')
err=binrpc_start_struct(&s->pkt);
else
err=binrpc_start_array(&s->pkt);
err=binrpc_start_struct(&s->pkt);
if (err<0) goto error_add;
rs=new_rpc_struct();
if (rs==0) goto error_mem;
rs->offset=binrpc_pkt_len(&s->pkt);
if(*fmt == '{')
err=binrpc_end_struct(&s->pkt);
else
err=binrpc_end_array(&s->pkt);
err=binrpc_end_struct(&s->pkt);
if (err<0) goto error_add;
clist_append(&s->substructs, rs, next, prev);
*(va_arg(ap, void**))=rs;
Expand Down

0 comments on commit 053ddb5

Please sign in to comment.