[PATCH 1/4] show: Pass notmuch_message_t instead of path to show_message_body.

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Fri Dec 9 11:05:23 PST 2011


On Sun,  4 Dec 2011 14:31:37 -0500, Austin Clements <amdragon at MIT.EDU> wrote:
> In addition to simplifying the code, we'll need the notmuch_message_t*
> in show_message_body shortly.
> ---
>  notmuch-client.h |    2 +-
>  notmuch-reply.c  |    3 +--
>  notmuch-show.c   |    3 +--
>  show-message.c   |    3 ++-
>  4 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-client.h b/notmuch-client.h
> index b50cb38..d7fb6ee 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -162,7 +162,7 @@ char *
>  query_string_from_args (void *ctx, int argc, char *argv[]);
>  
>  notmuch_status_t
> -show_message_body (const char *filename,
> +show_message_body (notmuch_message_t *message,
>  		   const notmuch_show_format_t *format,
>  		   notmuch_show_params_t *params);
>  
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 7ac879f..f8d5f64 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -546,8 +546,7 @@ notmuch_reply_format_default(void *ctx,
>  		notmuch_message_get_header (message, "date"),
>  		notmuch_message_get_header (message, "from"));
>  
> -	show_message_body (notmuch_message_get_filename (message),
> -			   format, params);
> +	show_message_body (message, format, params);
>  
>  	notmuch_message_destroy (message);
>      }
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 603992a..1dee3aa 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -753,8 +753,7 @@ show_message (void *ctx,
>      }
>  
>      if (format->part_content)
> -	show_message_body (notmuch_message_get_filename (message),
> -			   format, params);
> +	show_message_body (message, format, params);
>  
>      if (params->part <= 0) {
>  	fputs (format->body_end, stdout);
> diff --git a/show-message.c b/show-message.c
> index d83f04e..09fa607 100644
> --- a/show-message.c
> +++ b/show-message.c
> @@ -175,7 +175,7 @@ show_message_part (GMimeObject *part,
>  }
>  
>  notmuch_status_t
> -show_message_body (const char *filename,
> +show_message_body (notmuch_message_t *message,
>  		   const notmuch_show_format_t *format,
>  		   notmuch_show_params_t *params)

Is show_message_body() (or functions that it calls/would call) supposed
to modify the message structure?  If not, we should make it const.

I would also make all pointers constant (i.e. const notmuch_message_t
*const message), but I can not insist since it is not common in notmuch.

Regards,
  Dmitry

>  {
> @@ -183,6 +183,7 @@ show_message_body (const char *filename,
>      GMimeParser *parser = NULL;
>      GMimeMessage *mime_message = NULL;
>      notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
> +    const char *filename = notmuch_message_get_filename (message);
>      FILE *file = NULL;
>      show_message_state_t state;
>  
> -- 
> 1.7.5.4
> 


More information about the notmuch mailing list