null+****@clear*****
null+****@clear*****
2010年 7月 12日 (月) 18:45:09 JST
Daijiro MORI 2010-07-12 09:45:09 +0000 (Mon, 12 Jul 2010) New Revision: 888d84cc38c9e25d4dca4dceb4ffbc9315efac8e Log: call print_return_code() from recvput(). Modified files: lib/ctx.c src/groonga.c Modified: lib/ctx.c (+1 -1) =================================================================== --- lib/ctx.c 2010-07-12 08:28:25 +0000 (8fc7d58) +++ lib/ctx.c 2010-07-12 09:45:09 +0000 (3ebb6e7) @@ -1064,7 +1064,7 @@ grn_ctx_recv(grn_ctx *ctx, char **str, unsigned int *str_len, int *flags) *flags = (header.flags & GRN_CTX_TAIL) ? 0 : GRN_CTX_MORE; } ctx->impl->output_type = header.qtype; - ctx->impl->rc = header.status; + ctx->rc = header.status; } goto exit; } else { Modified: src/groonga.c (+15 -2) =================================================================== --- src/groonga.c 2010-07-12 08:28:25 +0000 (3bca79a) +++ src/groonga.c 2010-07-12 09:45:09 +0000 (5a9dfa9) @@ -401,14 +401,27 @@ recvput(grn_ctx *ctx) unsigned int str_len; do { grn_ctx_recv(ctx, &str, &str_len, &flags); + /* if (ctx->rc) { fprintf(stderr, "grn_ctx_recv failed\n"); return -1; } + */ if (str_len) { - fwrite(str, 1, str_len, stdout); - putchar('\n'); + grn_obj head, body, foot; + GRN_TEXT_INIT(&head, 0); + GRN_TEXT_INIT(&body, GRN_OBJ_DO_SHALLOW_COPY); + GRN_TEXT_INIT(&foot, 0); + GRN_TEXT_SET(ctx, &body, str, str_len); + print_return_code(ctx, ctx->rc, &head, &body, &foot); + fwrite(GRN_TEXT_VALUE(&head), 1, GRN_TEXT_LEN(&head), stdout); + fwrite(GRN_TEXT_VALUE(&body), 1, GRN_TEXT_LEN(&body), stdout); + fwrite(GRN_TEXT_VALUE(&foot), 1, GRN_TEXT_LEN(&foot), stdout); + fputc('\n', stdout); fflush(stdout); + GRN_OBJ_FIN(ctx, &head); + GRN_OBJ_FIN(ctx, &body); + GRN_OBJ_FIN(ctx, &foot); } } while ((flags & GRN_CTX_MORE)); return 0;