Skip to content

Commit

Permalink
doveadm-server: Skip doveadm_print_init
Browse files Browse the repository at this point in the history
Some commands need to do output that is not doable with
doveadm_print, so we need to have a flag to indicate this.
  • Loading branch information
cmouse authored and sirainen committed Jun 29, 2016
1 parent 20a3cd1 commit d536790
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/doveadm/client-connection-http.c
Expand Up @@ -329,16 +329,18 @@ doveadm_http_server_command_execute(struct client_connection_http *conn)

// create iostream
doveadm_print_ostream = iostream_temp_create("/tmp/doveadm.", 0);
cctx.cmd = conn->cmd;

if ((cctx.cmd->flags & CMD_FLAG_NO_PRINT) == 0)
doveadm_print_init(DOVEADM_PRINT_TYPE_JSON);

doveadm_print_init(DOVEADM_PRINT_TYPE_JSON);
/* then call it */
doveadm_cmd_params_null_terminate_arrays(&conn->pargv);
cctx.argv = array_get(&conn->pargv, (unsigned int*)&cctx.argc);
ioloop = io_loop_create();
lib_signals_reset_ioloop();
doveadm_exit_code = 0;

cctx.cmd = conn->cmd;
cctx.cli = FALSE;
cctx.local_ip = conn->client.local_ip;
cctx.local_port = conn->client.local_port;
Expand All @@ -357,7 +359,8 @@ doveadm_http_server_command_execute(struct client_connection_http *conn)
io_loop_set_current(ioloop);
io_loop_destroy(&ioloop);

doveadm_print_deinit();
if ((cctx.cmd->flags & CMD_FLAG_NO_PRINT) == 0)
doveadm_print_deinit();
if (o_stream_nfinish(doveadm_print_ostream)<0) {
i_info("Error writing output in command %s: %s",
conn->cmd->name,
Expand Down
3 changes: 2 additions & 1 deletion src/doveadm/doveadm-cmd.h
Expand Up @@ -30,7 +30,8 @@ typedef enum {

typedef enum {
CMD_FLAG_NONE = 0x0,
CMD_FLAG_HIDDEN = 0x1
CMD_FLAG_HIDDEN = 0x1,
CMD_FLAG_NO_PRINT = 0x2,
} doveadm_cmd_flag_t;

struct doveadm_cmd_param {
Expand Down

0 comments on commit d536790

Please sign in to comment.