]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm-mail: Rename ctx to mctx to separate from cctx
authorAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 28 Feb 2016 16:33:01 +0000 (18:33 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 28 Feb 2016 16:42:55 +0000 (18:42 +0200)
src/doveadm/client-connection.c
src/doveadm/doveadm-mail.c

index 1bec1717b3c96676adcd70ccf8736112d857a06b..b8bd2040c9904fc5172c1517c16d9ec8d1e39451 100644 (file)
@@ -94,25 +94,25 @@ doveadm_mail_cmd_server_parse(const struct doveadm_mail_cmd *cmd,
                              const struct doveadm_settings *set,
                              int argc, const char **argv,
                              struct doveadm_cmd_context *cctx,
-                             struct doveadm_mail_cmd_context **ctx_r)
+                             struct doveadm_mail_cmd_context **mctx_r)
 {
-       struct doveadm_mail_cmd_context *ctx;
+       struct doveadm_mail_cmd_context *mctx;
        const char *getopt_args;
        bool add_username_header = FALSE;
        int c;
 
-       ctx = doveadm_mail_cmd_init(cmd, set);
-       ctx->full_args = argv+1;
-       ctx->proxying = TRUE;
+       mctx = doveadm_mail_cmd_init(cmd, set);
+       mctx->full_args = argv+1;
+       mctx->proxying = TRUE;
 
-       ctx->service_flags |=
+       mctx->service_flags |=
                MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT |
                MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
        if (doveadm_debug)
-               ctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
+               mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
 
        i_getopt_reset();
-       getopt_args = t_strconcat("AF:S:u:", ctx->getopt_args, NULL);
+       getopt_args = t_strconcat("AF:S:u:", mctx->getopt_args, NULL);
        while ((c = getopt(argc, (char **)argv, getopt_args)) > 0) {
                switch (c) {
                case 'A':
@@ -128,13 +128,13 @@ doveadm_mail_cmd_server_parse(const struct doveadm_mail_cmd *cmd,
                                add_username_header = TRUE;
                        break;
                default:
-                       if ((ctx->v.parse_arg == NULL ||
-                            !ctx->v.parse_arg(ctx, c))) {
+                       if ((mctx->v.parse_arg == NULL ||
+                            !mctx->v.parse_arg(mctx, c))) {
                                i_error("doveadm %s: "
                                        "Client sent unknown parameter: %c",
                                        cmd->name, c);
-                               ctx->v.deinit(ctx);
-                               pool_unref(&ctx->pool);
+                               mctx->v.deinit(mctx);
+                               pool_unref(&mctx->pool);
                                return -1;
                        }
                }
@@ -143,11 +143,11 @@ doveadm_mail_cmd_server_parse(const struct doveadm_mail_cmd *cmd,
        if (argv[optind] != NULL && cmd->usage_args == NULL) {
                i_error("doveadm %s: Client sent unknown parameter: %s",
                        cmd->name, argv[optind]);
-               ctx->v.deinit(ctx);
-               pool_unref(&ctx->pool);
+               mctx->v.deinit(mctx);
+               pool_unref(&mctx->pool);
                return -1;
        }
-       ctx->args = argv+optind;
+       mctx->args = argv+optind;
 
        if (doveadm_print_is_initialized() && add_username_header) {
                doveadm_print_header("username", "Username",
@@ -155,44 +155,44 @@ doveadm_mail_cmd_server_parse(const struct doveadm_mail_cmd *cmd,
                                     DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE);
                doveadm_print_sticky("username", cctx->username);
        }
-       *ctx_r = ctx;
+       *mctx_r = mctx;
        return 0;
 }
 
 static void
 doveadm_mail_cmd_server_run(struct client_connection *conn,
-                           struct doveadm_mail_cmd_context *ctx,
+                           struct doveadm_mail_cmd_context *mctx,
                            struct doveadm_cmd_context *cctx)
 {
        const char *error;
        int ret;
 
-       ctx->conn = conn;
+       mctx->conn = conn;
        o_stream_cork(conn->output);
 
-       if (ctx->v.preinit != NULL)
-               ctx->v.preinit(ctx);
+       if (mctx->v.preinit != NULL)
+               mctx->v.preinit(mctx);
 
-       ret = doveadm_mail_single_user(ctx, cctx, &error);
+       ret = doveadm_mail_single_user(mctx, cctx, &error);
        doveadm_mail_server_flush();
-       ctx->v.deinit(ctx);
+       mctx->v.deinit(mctx);
        doveadm_print_flush();
-       mail_storage_service_deinit(&ctx->storage_service);
+       mail_storage_service_deinit(&mctx->storage_service);
 
        if (ret < 0) {
-               i_error("%s: %s", ctx->cmd->name, error);
+               i_error("%s: %s", mctx->cmd->name, error);
                o_stream_nsend(conn->output, "\n-\n", 3);
        } else if (ret == 0) {
                o_stream_nsend_str(conn->output, "\n-NOUSER\n");
-       } else if (ctx->exit_code != 0) {
+       } else if (mctx->exit_code != 0) {
                /* maybe not an error, but not a full success either */
                o_stream_nsend_str(conn->output,
-                                  t_strdup_printf("\n-%u\n", ctx->exit_code));
+                                  t_strdup_printf("\n-%u\n", mctx->exit_code));
        } else {
                o_stream_nsend(conn->output, "\n+\n", 3);
        }
        o_stream_uncork(conn->output);
-       pool_unref(&ctx->pool);
+       pool_unref(&mctx->pool);
 }
 
 bool doveadm_client_is_allowed_command(const struct doveadm_settings *set,
@@ -224,7 +224,7 @@ static int doveadm_cmd_handle(struct client_connection *conn,
        struct ioloop *ioloop, *prev_ioloop = current_ioloop;
        const struct doveadm_cmd *cmd = NULL;
        const struct doveadm_mail_cmd *mail_cmd;
-       struct doveadm_mail_cmd_context *ctx;
+       struct doveadm_mail_cmd_context *mctx;
        const struct doveadm_cmd_ver2 *cmd_ver2;
 
        if ((cmd_ver2 = doveadm_cmd_find_with_args_ver2(cmd_name, argc, argv)) == NULL) {
@@ -238,7 +238,7 @@ static int doveadm_cmd_handle(struct client_connection *conn,
                } else {
                        if (doveadm_mail_cmd_server_parse(mail_cmd, conn->set,
                                                          argc, argv,
-                                                         cctx, &ctx) < 0)
+                                                         cctx, &mctx) < 0)
                                return -1;
                }
        } else {
@@ -256,7 +256,7 @@ static int doveadm_cmd_handle(struct client_connection *conn,
        else if (cmd != NULL)
                doveadm_cmd_server_run(conn, argc, argv, cmd);
        else
-               doveadm_mail_cmd_server_run(conn, ctx, cctx);
+               doveadm_mail_cmd_server_run(conn, mctx, cctx);
 
        io_loop_set_current(prev_ioloop);
        lib_signals_reset_ioloop();
index d093b886df3d99cd5710ce6ed2686631498e5e9d..25235ad90a4ce9ed9e3e0437a9fa6d9690d99069 100644 (file)
@@ -917,7 +917,7 @@ void doveadm_mail_deinit(void)
 void
 doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
 {
-       struct doveadm_mail_cmd_context *ctx;
+       struct doveadm_mail_cmd_context *mctx;
        const char *wildcard_user;
        const char *fieldstr;
 
@@ -927,11 +927,11 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
                cctx->cmd->mail_cmd, cctx->cmd->name, cctx->cmd->usage
        };
 
-       ctx = doveadm_mail_cmdline_init(&mail_cmd);
+       mctx = doveadm_mail_cmdline_init(&mail_cmd);
 
-       ctx->iterate_all_users = FALSE;
+       mctx->iterate_all_users = FALSE;
        wildcard_user = NULL;
-       p_array_init(&pargv, ctx->pool, 8);
+       p_array_init(&pargv, mctx->pool, 8);
 
        for(i=0;i<cctx->argc;i++) {
                const struct doveadm_cmd_param *arg = &cctx->argv[i];
@@ -940,49 +940,49 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
                        continue;
 
                if (strcmp(arg->name, "all-users") == 0) {
-                       ctx->iterate_all_users = arg->value.v_bool;
+                       mctx->iterate_all_users = arg->value.v_bool;
                } else if (strcmp(arg->name, "socket-path") == 0) {
                        doveadm_settings->doveadm_socket_path = arg->value.v_string;
                        if (doveadm_settings->doveadm_worker_count == 0)
                                doveadm_settings->doveadm_worker_count = 1;
                } else if (strcmp(arg->name, "user") == 0) {
-                       ctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
-                       ctx->cur_username = arg->value.v_string;
-                       if (strchr(ctx->cur_username, '*') != NULL ||
-                           strchr(ctx->cur_username, '?') != NULL) {
-                               wildcard_user = ctx->cur_username;
-                               ctx->cur_username = NULL;
+                       mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
+                       mctx->cur_username = arg->value.v_string;
+                       if (strchr(mctx->cur_username, '*') != NULL ||
+                           strchr(mctx->cur_username, '?') != NULL) {
+                               wildcard_user = mctx->cur_username;
+                               mctx->cur_username = NULL;
                        }
                } else if (strcmp(arg->name, "user-file") == 0) {
-                       ctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
+                       mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
                        wildcard_user = "*";
-                       ctx->users_list_input = arg->value.v_istream;
-                       i_stream_ref(ctx->users_list_input);
+                       mctx->users_list_input = arg->value.v_istream;
+                       i_stream_ref(mctx->users_list_input);
                } else if (strcmp(arg->name, "field") == 0 ||
                           strcmp(arg->name, "flag") == 0) {
                        /* mailbox status, fetch, flags: convert an array into a
                           single space-separated parameter (alternative to
                           fieldstr) */
-                       fieldstr = p_array_const_string_join(ctx->pool,
+                       fieldstr = p_array_const_string_join(mctx->pool,
                                        &arg->value.v_array, " ");
                        array_append(&pargv, &fieldstr, 1);
                } else if (strcmp(arg->name, "file") == 0) {
                        /* input for doveadm_mail_get_input(),
                           used by e.g. save */
-                       if (ctx->cmd_input != NULL) {
+                       if (mctx->cmd_input != NULL) {
                                i_error("Only one file input allowed: %s", arg->name);
-                               doveadm_mail_cmd_free(ctx);
+                               doveadm_mail_cmd_free(mctx);
                                doveadm_exit_code = EX_USAGE;
                                return;
                        }
-                       ctx->cmd_input = arg->value.v_istream;
-                       i_stream_ref(ctx->cmd_input);
+                       mctx->cmd_input = arg->value.v_istream;
+                       i_stream_ref(mctx->cmd_input);
 
                /* Keep all named special parameters above this line */
 
-               } else if (ctx->v.parse_arg != NULL && arg->short_opt != '\0') {
+               } else if (mctx->v.parse_arg != NULL && arg->short_opt != '\0') {
                        optarg = (char*)arg->value.v_string;
-                       ctx->v.parse_arg(ctx, arg->short_opt);
+                       mctx->v.parse_arg(mctx, arg->short_opt);
                } else if ((arg->flags & CMD_PARAM_FLAG_POSITIONAL) != 0) {
                        /* feed this into pargv */
                        if (arg->type == CMD_PARAM_ARRAY)
@@ -992,15 +992,15 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
                } else {
                        doveadm_exit_code = EX_USAGE;
                        i_error("invalid parameter: %s", arg->name);
-                       doveadm_mail_cmd_free(ctx);
+                       doveadm_mail_cmd_free(mctx);
                        return;
                }
        }
 
        array_append_zero(&pargv);
-       ctx->args = array_idx(&pargv, 0);
-       ctx->full_args = ctx->args;
+       mctx->args = array_idx(&pargv, 0);
+       mctx->full_args = mctx->args;
 
-       doveadm_mail_cmd_exec(ctx, wildcard_user);
-       doveadm_mail_cmd_free(ctx);
+       doveadm_mail_cmd_exec(mctx, wildcard_user);
+       doveadm_mail_cmd_free(mctx);
 }