Skip to content

Commit

Permalink
#9
Browse files Browse the repository at this point in the history
  • Loading branch information
dedok committed May 4, 2015
1 parent 70c8fa0 commit 7345bd2
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tp_transcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef struct {
tp_transcode_t *tc;
} yajl_ctx_t;

static inline char*
static inline char *
tp_call_wof(struct tp *p)
{
int sz = 5 +
Expand All @@ -123,7 +123,7 @@ tp_call_wof(struct tp *p)
return tp_add(p, sz);
}

static inline char*
static inline char *
tp_call_wof_add_func(struct tp *p, const char *function, int len)
{
int sz = mp_sizeof_uint(TP_FUNCTION) +
Expand All @@ -135,7 +135,7 @@ tp_call_wof_add_func(struct tp *p, const char *function, int len)
return tp_add(p, sz);
}

static inline char*
static inline char *
tp_call_wof_add_params(struct tp *p)
{
int sz = mp_sizeof_uint(TP_TUPLE);
Expand Down Expand Up @@ -696,6 +696,24 @@ typedef struct tp2json {
int state;
} tp2json_t;

static inline int
code_conv(int code)
{
switch (code) {
case 0:
break;
case 32801:
code = -32601;
break;
default:
if (code > 0)
code *= -1;
break;
}

return code;
}

static void*
tp2json_create(tp_transcode_t *tc, char *output, size_t output_size)
{
Expand Down Expand Up @@ -926,7 +944,7 @@ tp_reply2json_transcode(void *ctx_, const char *in, size_t in_size)
"{\"id\":%zu,\"error\":{\"message\":\"%.*s\",\"code\":%d}",
(size_t)tp_getreqid(&ctx->r),
elen, ctx->r.error,
ctx->r.code);
code_conv(ctx->r.code));

} else {

Expand Down

0 comments on commit 7345bd2

Please sign in to comment.