cli: run uncrustify

This is the result of running

     $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h

in the top level source directory
This commit is contained in:
uncrustify 2019-06-13 07:31:01 -03:00 committed by David Bremner
parent be8f0ba92a
commit 33382c2b5b
24 changed files with 609 additions and 609 deletions

View file

@ -5,16 +5,16 @@
#include "command-line-arguments.h" #include "command-line-arguments.h"
typedef enum { typedef enum {
OPT_FAILED, /* false */ OPT_FAILED, /* false */
OPT_OK, /* good */ OPT_OK, /* good */
OPT_GIVEBACK, /* pop one of the arguments you thought you were getting off the stack */ OPT_GIVEBACK, /* pop one of the arguments you thought you were getting off the stack */
} opt_handled; } opt_handled;
/* /*
Search the array of keywords for a given argument, assigning the * Search the array of keywords for a given argument, assigning the
output variable to the corresponding value. Return false if nothing * output variable to the corresponding value. Return false if nothing
matches. * matches.
*/ */
static opt_handled static opt_handled
_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next,
@ -84,9 +84,11 @@ _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next,
} }
static opt_handled static opt_handled
_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
{
char *endptr; char *endptr;
if (next == '\0' || arg_str[0] == '\0') { if (next == '\0' || arg_str[0] == '\0') {
fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name); fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
return OPT_FAILED; return OPT_FAILED;
@ -102,7 +104,8 @@ _process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg
} }
static opt_handled static opt_handled
_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str)
{
if (next == '\0') { if (next == '\0') {
fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name); fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name);
@ -117,7 +120,8 @@ _process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *
} }
/* Return number of non-NULL opt_* fields in opt_desc. */ /* Return number of non-NULL opt_* fields in opt_desc. */
static int _opt_set_count (const notmuch_opt_desc_t *opt_desc) static int
_opt_set_count (const notmuch_opt_desc_t *opt_desc)
{ {
return return
(bool) opt_desc->opt_inherit + (bool) opt_desc->opt_inherit +
@ -130,7 +134,8 @@ static int _opt_set_count (const notmuch_opt_desc_t *opt_desc)
} }
/* Return true if opt_desc is valid. */ /* Return true if opt_desc is valid. */
static bool _opt_valid (const notmuch_opt_desc_t *opt_desc) static bool
_opt_valid (const notmuch_opt_desc_t *opt_desc)
{ {
int n = _opt_set_count (opt_desc); int n = _opt_set_count (opt_desc);
@ -142,15 +147,17 @@ static bool _opt_valid (const notmuch_opt_desc_t *opt_desc)
} }
/* /*
Search for the {pos_arg_index}th position argument, return false if * Search for the {pos_arg_index}th position argument, return false if
that does not exist. * that does not exist.
*/ */
bool bool
parse_position_arg (const char *arg_str, int pos_arg_index, parse_position_arg (const char *arg_str, int pos_arg_index,
const notmuch_opt_desc_t *arg_desc) { const notmuch_opt_desc_t *arg_desc)
{
int pos_arg_counter = 0; int pos_arg_counter = 0;
while (_opt_valid (arg_desc)) { while (_opt_valid (arg_desc)) {
if (arg_desc->opt_position) { if (arg_desc->opt_position) {
if (pos_arg_counter == pos_arg_index) { if (pos_arg_counter == pos_arg_index) {
@ -176,12 +183,12 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
int int
parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index) parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index)
{ {
assert(argv); assert (argv);
const char *_arg = argv[opt_index]; const char *_arg = argv[opt_index];
assert(_arg); assert (_arg);
assert(options); assert (options);
const char *arg = _arg + 2; /* _arg starts with -- */ const char *arg = _arg + 2; /* _arg starts with -- */
const char *negative_arg = NULL; const char *negative_arg = NULL;
@ -239,7 +246,7 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
if (lookahead) { if (lookahead) {
next = ' '; next = ' ';
value = next_arg; value = next_arg;
opt_index ++; opt_index++;
} }
opt_handled opt_status = OPT_FAILED; opt_handled opt_status = OPT_FAILED;
@ -258,12 +265,12 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
return -1; return -1;
if (lookahead && opt_status == OPT_GIVEBACK) if (lookahead && opt_status == OPT_GIVEBACK)
opt_index --; opt_index--;
if (try->present) if (try->present)
*try->present = true; *try->present = true;
return opt_index+1; return opt_index + 1;
} }
return -1; return -1;
} }
@ -271,13 +278,14 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_
/* See command-line-arguments.h for description */ /* See command-line-arguments.h for description */
int int
parse_arguments (int argc, char **argv, parse_arguments (int argc, char **argv,
const notmuch_opt_desc_t *options, int opt_index) { const notmuch_opt_desc_t *options, int opt_index)
{
int pos_arg_index = 0; int pos_arg_index = 0;
bool more_args = true; bool more_args = true;
while (more_args && opt_index < argc) { while (more_args && opt_index < argc) {
if (strncmp (argv[opt_index],"--",2) != 0) { if (strncmp (argv[opt_index], "--", 2) != 0) {
more_args = parse_position_arg (argv[opt_index], pos_arg_index, options); more_args = parse_position_arg (argv[opt_index], pos_arg_index, options);
@ -290,7 +298,7 @@ parse_arguments (int argc, char **argv,
int prev_opt_index = opt_index; int prev_opt_index = opt_index;
if (strlen (argv[opt_index]) == 2) if (strlen (argv[opt_index]) == 2)
return opt_index+1; return opt_index + 1;
opt_index = parse_option (argc, argv, options, opt_index); opt_index = parse_option (argc, argv, options, opt_index);
if (opt_index < 0) { if (opt_index < 0) {

View file

@ -45,20 +45,20 @@ typedef struct notmuch_opt_desc {
/* /*
This is the main entry point for command line argument parsing. * This is the main entry point for command line argument parsing.
*
Parse command line arguments according to structure options, * Parse command line arguments according to structure options,
starting at position opt_index. * starting at position opt_index.
*
All output of parsed values is via pointers in options. * All output of parsed values is via pointers in options.
*
Parsing stops at -- (consumed) or at the (k+1)st argument * Parsing stops at -- (consumed) or at the (k+1)st argument
not starting with -- (a "positional argument") if options contains * not starting with -- (a "positional argument") if options contains
k positional argument descriptors. * k positional argument descriptors.
*
Returns the index of first non-parsed argument, or -1 in case of error. * Returns the index of first non-parsed argument, or -1 in case of error.
*
*/ */
int int
parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index); parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);
@ -71,12 +71,12 @@ parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int o
*/ */
int int
parse_option (int argc, char **argv, const notmuch_opt_desc_t* options, int opt_index); parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);
bool bool
parse_position_arg (const char *arg, parse_position_arg (const char *arg,
int position_arg_index, int position_arg_index,
const notmuch_opt_desc_t* options); const notmuch_opt_desc_t *options);
#endif #endif

View file

@ -39,8 +39,7 @@ debugger_is_active (void)
sprintf (buf, "/proc/%d/exe", getppid ()); sprintf (buf, "/proc/%d/exe", getppid ());
if (readlink (buf, buf2, sizeof (buf2)) != -1 && if (readlink (buf, buf2, sizeof (buf2)) != -1 &&
strncmp (basename (buf2), "gdb", 3) == 0) strncmp (basename (buf2), "gdb", 3) == 0) {
{
return true; return true;
} }

View file

@ -47,143 +47,143 @@ static GMimeFilterClass *parent_class = NULL;
GType GType
g_mime_filter_reply_get_type (void) g_mime_filter_reply_get_type (void)
{ {
static GType type = 0; static GType type = 0;
if (!type) { if (! type) {
static const GTypeInfo info = { static const GTypeInfo info = {
.class_size = sizeof (GMimeFilterReplyClass), .class_size = sizeof (GMimeFilterReplyClass),
.base_init = NULL, .base_init = NULL,
.base_finalize = NULL, .base_finalize = NULL,
.class_init = (GClassInitFunc) g_mime_filter_reply_class_init, .class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
.class_finalize = NULL, .class_finalize = NULL,
.class_data = NULL, .class_data = NULL,
.instance_size = sizeof (GMimeFilterReply), .instance_size = sizeof (GMimeFilterReply),
.n_preallocs = 0, .n_preallocs = 0,
.instance_init = (GInstanceInitFunc) g_mime_filter_reply_init, .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
.value_table = NULL, .value_table = NULL,
}; };
type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
} }
return type; return type;
} }
static void static void
g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *class_data)) g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *class_data))
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
object_class->finalize = g_mime_filter_reply_finalize; object_class->finalize = g_mime_filter_reply_finalize;
filter_class->copy = filter_copy; filter_class->copy = filter_copy;
filter_class->filter = filter_filter; filter_class->filter = filter_filter;
filter_class->complete = filter_complete; filter_class->complete = filter_complete;
filter_class->reset = filter_reset; filter_class->reset = filter_reset;
} }
static void static void
g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass) g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass)
{ {
(void) klass; (void) klass;
filter->saw_nl = true; filter->saw_nl = true;
filter->saw_angle = false; filter->saw_angle = false;
} }
static void static void
g_mime_filter_reply_finalize (GObject *object) g_mime_filter_reply_finalize (GObject *object)
{ {
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static GMimeFilter * static GMimeFilter *
filter_copy (GMimeFilter *filter) filter_copy (GMimeFilter *filter)
{ {
GMimeFilterReply *reply = (GMimeFilterReply *) filter; GMimeFilterReply *reply = (GMimeFilterReply *) filter;
return g_mime_filter_reply_new (reply->encode); return g_mime_filter_reply_new (reply->encode);
} }
static void static void
filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace, filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
char **outbuf, size_t *outlen, size_t *outprespace) char **outbuf, size_t *outlen, size_t *outprespace)
{ {
GMimeFilterReply *reply = (GMimeFilterReply *) filter; GMimeFilterReply *reply = (GMimeFilterReply *) filter;
const char *inptr = inbuf; const char *inptr = inbuf;
const char *inend = inbuf + inlen; const char *inend = inbuf + inlen;
char *outptr; char *outptr;
(void) prespace; (void) prespace;
if (reply->encode) { if (reply->encode) {
g_mime_filter_set_size (filter, 3 * inlen, false); g_mime_filter_set_size (filter, 3 * inlen, false);
outptr = filter->outbuf; outptr = filter->outbuf;
while (inptr < inend) { while (inptr < inend) {
if (reply->saw_nl) { if (reply->saw_nl) {
*outptr++ = '>'; *outptr++ = '>';
*outptr++ = ' '; *outptr++ = ' ';
reply->saw_nl = false; reply->saw_nl = false;
} }
if (*inptr == '\n') if (*inptr == '\n')
reply->saw_nl = true; reply->saw_nl = true;
else else
reply->saw_nl = false; reply->saw_nl = false;
if (*inptr != '\r') if (*inptr != '\r')
*outptr++ = *inptr; *outptr++ = *inptr;
inptr++; inptr++;
}
} else {
g_mime_filter_set_size (filter, inlen + 1, false);
outptr = filter->outbuf;
while (inptr < inend) {
if (reply->saw_nl) {
if (*inptr == '>')
reply->saw_angle = true;
else
*outptr++ = *inptr;
reply->saw_nl = false;
} else if (reply->saw_angle) {
if (*inptr == ' ')
;
else
*outptr++ = *inptr;
reply->saw_angle = false;
} else if (*inptr != '\r') {
if (*inptr == '\n')
reply->saw_nl = true;
*outptr++ = *inptr;
}
inptr++;
}
} }
} else {
g_mime_filter_set_size (filter, inlen + 1, false);
*outlen = outptr - filter->outbuf; outptr = filter->outbuf;
*outprespace = filter->outpre; while (inptr < inend) {
*outbuf = filter->outbuf; if (reply->saw_nl) {
if (*inptr == '>')
reply->saw_angle = true;
else
*outptr++ = *inptr;
reply->saw_nl = false;
} else if (reply->saw_angle) {
if (*inptr == ' ')
;
else
*outptr++ = *inptr;
reply->saw_angle = false;
} else if (*inptr != '\r') {
if (*inptr == '\n')
reply->saw_nl = true;
*outptr++ = *inptr;
}
inptr++;
}
}
*outlen = outptr - filter->outbuf;
*outprespace = filter->outpre;
*outbuf = filter->outbuf;
} }
static void static void
filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace, filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
char **outbuf, size_t *outlen, size_t *outprespace) char **outbuf, size_t *outlen, size_t *outprespace)
{ {
if (inbuf && inlen) if (inbuf && inlen)
filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace); filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
} }
static void static void
filter_reset (GMimeFilter *filter) filter_reset (GMimeFilter *filter)
{ {
GMimeFilterReply *reply = (GMimeFilterReply *) filter; GMimeFilterReply *reply = (GMimeFilterReply *) filter;
reply->saw_nl = true; reply->saw_nl = true;
reply->saw_angle = false; reply->saw_angle = false;
} }
@ -202,11 +202,11 @@ filter_reset (GMimeFilter *filter)
GMimeFilter * GMimeFilter *
g_mime_filter_reply_new (gboolean encode) g_mime_filter_reply_new (gboolean encode)
{ {
GMimeFilterReply *new_reply; GMimeFilterReply *new_reply;
new_reply = (GMimeFilterReply *) g_object_new (GMIME_TYPE_FILTER_REPLY, NULL); new_reply = (GMimeFilterReply *) g_object_new (GMIME_TYPE_FILTER_REPLY, NULL);
new_reply->encode = encode; new_reply->encode = encode;
return (GMimeFilter *) new_reply; return (GMimeFilter *) new_reply;
} }

View file

@ -43,15 +43,15 @@ typedef struct _GMimeFilterReplyClass GMimeFilterReplyClass;
* A filter to insert/remove reply markers (lines beginning with >) * A filter to insert/remove reply markers (lines beginning with >)
**/ **/
struct _GMimeFilterReply { struct _GMimeFilterReply {
GMimeFilter parent_object; GMimeFilter parent_object;
gboolean encode; gboolean encode;
gboolean saw_nl; gboolean saw_nl;
gboolean saw_angle; gboolean saw_angle;
}; };
struct _GMimeFilterReplyClass { struct _GMimeFilterReplyClass {
GMimeFilterClass parent_class; GMimeFilterClass parent_class;
}; };

View file

@ -53,7 +53,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
/* Flush any buffered output before forking. */ /* Flush any buffered output before forking. */
fflush (stdout); fflush (stdout);
pid = fork(); pid = fork ();
if (pid == -1) { if (pid == -1) {
fprintf (stderr, "Error: %s hook fork failed: %s\n", hook, fprintf (stderr, "Error: %s hook fork failed: %s\n", hook,
strerror (errno)); strerror (errno));
@ -78,7 +78,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
goto DONE; goto DONE;
} }
if (!WIFEXITED (status) || WEXITSTATUS (status)) { if (! WIFEXITED (status) || WEXITSTATUS (status)) {
if (WIFEXITED (status)) { if (WIFEXITED (status)) {
fprintf (stderr, "Error: %s hook failed with status %d\n", fprintf (stderr, "Error: %s hook failed with status %d\n",
hook, WEXITSTATUS (status)); hook, WEXITSTATUS (status));

View file

@ -55,7 +55,7 @@ _mime_node_context_free (mime_node_context_t *res)
return 0; return 0;
} }
const _notmuch_message_crypto_t* const _notmuch_message_crypto_t *
mime_node_get_message_crypto_status (mime_node_t *node) mime_node_get_message_crypto_status (mime_node_t *node)
{ {
return node->ctx->msg_crypto; return node->ctx->msg_crypto;
@ -97,8 +97,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
notmuch_filenames_t *filenames; notmuch_filenames_t *filenames;
for (filenames = notmuch_message_get_filenames (message); for (filenames = notmuch_message_get_filenames (message);
notmuch_filenames_valid (filenames); notmuch_filenames_valid (filenames);
notmuch_filenames_move_to_next (filenames)) notmuch_filenames_move_to_next (filenames)) {
{
filename = notmuch_filenames_get (filenames); filename = notmuch_filenames_get (filenames);
fd = open (filename, O_RDONLY); fd = open (filename, O_RDONLY);
if (fd != -1) if (fd != -1)
@ -109,27 +108,27 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
if (fd == -1) { if (fd == -1) {
/* Give up */ /* Give up */
fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno)); fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));
status = NOTMUCH_STATUS_FILE_ERROR; status = NOTMUCH_STATUS_FILE_ERROR;
goto DONE; goto DONE;
}
} }
}
mctx->stream = g_mime_stream_gzfile_new (fd); mctx->stream = g_mime_stream_gzfile_new (fd);
if (!mctx->stream) { if (! mctx->stream) {
fprintf (stderr, "Out of memory.\n"); fprintf (stderr, "Out of memory.\n");
status = NOTMUCH_STATUS_OUT_OF_MEMORY; status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE; goto DONE;
} }
mctx->parser = g_mime_parser_new_with_stream (mctx->stream); mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
if (!mctx->parser) { if (! mctx->parser) {
fprintf (stderr, "Out of memory.\n"); fprintf (stderr, "Out of memory.\n");
status = NOTMUCH_STATUS_OUT_OF_MEMORY; status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE; goto DONE;
} }
mctx->mime_message = g_mime_parser_construct_message (mctx->parser, NULL); mctx->mime_message = g_mime_parser_construct_message (mctx->parser, NULL);
if (!mctx->mime_message) { if (! mctx->mime_message) {
fprintf (stderr, "Failed to parse %s\n", filename); fprintf (stderr, "Failed to parse %s\n", filename);
status = NOTMUCH_STATUS_FILE_ERROR; status = NOTMUCH_STATUS_FILE_ERROR;
goto DONE; goto DONE;
@ -153,7 +152,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
*root_out = root; *root_out = root;
return NOTMUCH_STATUS_SUCCESS; return NOTMUCH_STATUS_SUCCESS;
DONE: DONE:
talloc_free (root); talloc_free (root);
return status; return status;
} }
@ -171,6 +170,7 @@ static void
set_signature_list_destructor (mime_node_t *node) set_signature_list_destructor (mime_node_t *node)
{ {
GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *); GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *);
if (proxy) { if (proxy) {
*proxy = node->sig_list; *proxy = node->sig_list;
talloc_set_destructor (proxy, _signature_list_free); talloc_set_destructor (proxy, _signature_list_free);
@ -259,7 +259,7 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part)
g_object_unref (decrypt_result); g_object_unref (decrypt_result);
} }
DONE: DONE:
if (err) if (err)
g_error_free (err); g_error_free (err);
} }
@ -273,7 +273,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part, int numchild)
/* Set basic node properties */ /* Set basic node properties */
node->part = part; node->part = part;
node->ctx = parent->ctx; node->ctx = parent->ctx;
if (!talloc_reference (node, node->ctx)) { if (! talloc_reference (node, node->ctx)) {
fprintf (stderr, "Out of memory.\n"); fprintf (stderr, "Out of memory.\n");
talloc_free (node); talloc_free (node);
return NULL; return NULL;
@ -335,7 +335,7 @@ mime_node_child (mime_node_t *parent, int child)
GMimeObject *sub; GMimeObject *sub;
mime_node_t *node; mime_node_t *node;
if (!parent || !parent->part || child < 0 || child >= parent->nchildren) if (! parent || ! parent->part || child < 0 || child >= parent->nchildren)
return NULL; return NULL;
if (GMIME_IS_MULTIPART (parent->part)) { if (GMIME_IS_MULTIPART (parent->part)) {

View file

@ -55,7 +55,7 @@
#define unused(x) x ## _unused __attribute__ ((unused)) #define unused(x) x ## _unused __attribute__ ((unused))
#define STRINGIFY(s) STRINGIFY_(s) #define STRINGIFY(s) STRINGIFY_ (s)
#define STRINGIFY_(s) #s #define STRINGIFY_(s) #s
typedef struct mime_node mime_node_t; typedef struct mime_node mime_node_t;
@ -63,10 +63,10 @@ struct sprinter;
struct notmuch_show_params; struct notmuch_show_params;
typedef struct notmuch_show_format { typedef struct notmuch_show_format {
struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream); struct sprinter *(*new_sprinter)(const void *ctx, FILE *stream);
notmuch_status_t (*part) (const void *ctx, struct sprinter *sprinter, notmuch_status_t (*part)(const void *ctx, struct sprinter *sprinter,
struct mime_node *node, int indent, struct mime_node *node, int indent,
const struct notmuch_show_params *params); const struct notmuch_show_params *params);
} notmuch_show_format_t; } notmuch_show_format_t;
typedef struct notmuch_show_params { typedef struct notmuch_show_params {
@ -85,12 +85,12 @@ typedef struct notmuch_show_params {
* *
* Note that __location__ comes from talloc.h. * Note that __location__ comes from talloc.h.
*/ */
#define INTERNAL_ERROR(format, ...) \ #define INTERNAL_ERROR(format, ...) \
do { \ do { \
fprintf(stderr, \ fprintf (stderr, \
"Internal error: " format " (%s)\n", \ "Internal error: " format " (%s)\n", \
##__VA_ARGS__, __location__); \ ##__VA_ARGS__, __location__); \
exit (1); \ exit (1); \
} while (0) } while (0)
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@ -101,8 +101,8 @@ typedef struct notmuch_show_params {
static inline void static inline void
chomp_newline (char *str) chomp_newline (char *str)
{ {
if (str && str[strlen(str)-1] == '\n') if (str && str[strlen (str) - 1] == '\n')
str[strlen(str)-1] = '\0'; str[strlen (str) - 1] = '\0';
} }
/* Exit status code indicating temporary failure; user is invited to /* Exit status code indicating temporary failure; user is invited to
@ -251,8 +251,8 @@ json_quote_str (const void *ctx, const char *str);
/* notmuch-config.c */ /* notmuch-config.c */
typedef enum { typedef enum {
NOTMUCH_CONFIG_OPEN = 1 << 0, NOTMUCH_CONFIG_OPEN = 1 << 0,
NOTMUCH_CONFIG_CREATE = 1 << 1, NOTMUCH_CONFIG_CREATE = 1 << 1,
} notmuch_config_mode_t; } notmuch_config_mode_t;
notmuch_config_t * notmuch_config_t *
@ -328,8 +328,8 @@ notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length
void void
notmuch_config_set_search_exclude_tags (notmuch_config_t *config, notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
const char *list[], const char *list[],
size_t length); size_t length);
int int
notmuch_run_hook (const char *db_path, const char *hook); notmuch_run_hook (const char *db_path, const char *hook);
@ -388,7 +388,7 @@ struct mime_node {
/* The list of signatures for signed or encrypted containers. If /* The list of signatures for signed or encrypted containers. If
* there are no signatures, this will be NULL. */ * there are no signatures, this will be NULL. */
GMimeSignatureList* sig_list; GMimeSignatureList *sig_list;
/* Internal: Context inherited from the root iterator. */ /* Internal: Context inherited from the root iterator. */
struct mime_node_context *ctx; struct mime_node_context *ctx;
@ -435,11 +435,11 @@ mime_node_t *
mime_node_child (mime_node_t *parent, int child); mime_node_child (mime_node_t *parent, int child);
/* Return the nth child of node in a depth-first traversal. If n is /* Return the nth child of node in a depth-first traversal. If n is
* 0, returns node itself. Returns NULL if there is no such part. */ * 0, returns node itself. Returns NULL if there is no such part. */
mime_node_t * mime_node_t *
mime_node_seek_dfs (mime_node_t *node, int n); mime_node_seek_dfs (mime_node_t *node, int n);
const _notmuch_message_crypto_t* const _notmuch_message_crypto_t *
mime_node_get_message_crypto_status (mime_node_t *node); mime_node_get_message_crypto_status (mime_node_t *node);
typedef enum dump_formats { typedef enum dump_formats {
@ -449,9 +449,9 @@ typedef enum dump_formats {
} dump_format_t; } dump_format_t;
typedef enum dump_includes { typedef enum dump_includes {
DUMP_INCLUDE_TAGS = 1, DUMP_INCLUDE_TAGS = 1,
DUMP_INCLUDE_CONFIG = 2, DUMP_INCLUDE_CONFIG = 2,
DUMP_INCLUDE_PROPERTIES = 4 DUMP_INCLUDE_PROPERTIES = 4
} dump_include_t; } dump_include_t;
#define DUMP_INCLUDE_DEFAULT (DUMP_INCLUDE_TAGS | DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_PROPERTIES) #define DUMP_INCLUDE_DEFAULT (DUMP_INCLUDE_TAGS | DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_PROPERTIES)
@ -467,8 +467,8 @@ notmuch_database_dump (notmuch_database_t *notmuch,
bool gzip_output); bool gzip_output);
/* If status is non-zero (i.e. error) print appropriate /* If status is non-zero (i.e. error) print appropriate
messages to stderr. * messages to stderr.
*/ */
notmuch_status_t notmuch_status_t
print_status_query (const char *loc, print_status_query (const char *loc,
@ -491,11 +491,11 @@ status_to_exit (notmuch_status_t status);
#include "command-line-arguments.h" #include "command-line-arguments.h"
extern const char *notmuch_requested_db_uuid; extern const char *notmuch_requested_db_uuid;
extern const notmuch_opt_desc_t notmuch_shared_options []; extern const notmuch_opt_desc_t notmuch_shared_options [];
void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch); void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
void notmuch_process_shared_options (const char* subcommand_name); void notmuch_process_shared_options (const char *subcommand_name);
int notmuch_minimal_options (const char* subcommand_name, int notmuch_minimal_options (const char *subcommand_name,
int argc, char **argv); int argc, char **argv);
@ -504,10 +504,10 @@ int notmuch_minimal_options (const char* subcommand_name,
struct _notmuch_client_indexing_cli_choices { struct _notmuch_client_indexing_cli_choices {
int decrypt_policy; int decrypt_policy;
bool decrypt_policy_set; bool decrypt_policy_set;
notmuch_indexopts_t * opts; notmuch_indexopts_t *opts;
}; };
extern struct _notmuch_client_indexing_cli_choices indexing_cli_choices; extern struct _notmuch_client_indexing_cli_choices indexing_cli_choices;
extern const notmuch_opt_desc_t notmuch_shared_indexing_options []; extern const notmuch_opt_desc_t notmuch_shared_indexing_options [];
notmuch_status_t notmuch_status_t
notmuch_process_shared_indexing_options (notmuch_database_t *notmuch); notmuch_process_shared_indexing_options (notmuch_database_t *notmuch);

View file

@ -151,14 +151,14 @@ get_name_from_passwd_file (void *ctx)
char *name; char *name;
int e; int e;
pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); pw_buf_size = sysconf (_SC_GETPW_R_SIZE_MAX);
if (pw_buf_size == -1) pw_buf_size = 64; if (pw_buf_size == -1) pw_buf_size = 64;
pw_buf = talloc_size (ctx, pw_buf_size); pw_buf = talloc_size (ctx, pw_buf_size);
while ((e = getpwuid_r (getuid (), &passwd, pw_buf, while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
pw_buf_size, &ignored)) == ERANGE) { pw_buf_size, &ignored)) == ERANGE) {
pw_buf_size = pw_buf_size * 2; pw_buf_size = pw_buf_size * 2;
pw_buf = talloc_zero_size(ctx, pw_buf_size); pw_buf = talloc_zero_size (ctx, pw_buf_size);
} }
if (e == 0) { if (e == 0) {
@ -186,14 +186,14 @@ get_username_from_passwd_file (void *ctx)
char *name; char *name;
int e; int e;
pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); pw_buf_size = sysconf (_SC_GETPW_R_SIZE_MAX);
if (pw_buf_size == -1) pw_buf_size = 64; if (pw_buf_size == -1) pw_buf_size = 64;
pw_buf = talloc_zero_size (ctx, pw_buf_size); pw_buf = talloc_zero_size (ctx, pw_buf_size);
while ((e = getpwuid_r (getuid (), &passwd, pw_buf, while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
pw_buf_size, &ignored)) == ERANGE) { pw_buf_size, &ignored)) == ERANGE) {
pw_buf_size = pw_buf_size * 2; pw_buf_size = pw_buf_size * 2;
pw_buf = talloc_zero_size(ctx, pw_buf_size); pw_buf = talloc_zero_size (ctx, pw_buf_size);
} }
if (e == 0) if (e == 0)
@ -217,7 +217,7 @@ get_config_from_file (notmuch_config_t *config, bool create_new)
GError *error = NULL; GError *error = NULL;
bool ret = false; bool ret = false;
FILE *fp = fopen(config->filename, "r"); FILE *fp = fopen (config->filename, "r");
if (fp == NULL) { if (fp == NULL) {
if (errno == ENOENT) { if (errno == ENOENT) {
/* If create_new is true, then the caller is prepared for a /* If create_new is true, then the caller is prepared for a
@ -233,7 +233,7 @@ get_config_from_file (notmuch_config_t *config, bool create_new)
} }
} else { } else {
fprintf (stderr, "Error opening config file '%s': %s\n", fprintf (stderr, "Error opening config file '%s': %s\n",
config->filename, strerror(errno)); config->filename, strerror (errno));
} }
goto out; goto out;
} }
@ -274,12 +274,12 @@ get_config_from_file (notmuch_config_t *config, bool create_new)
g_error_free (error); g_error_free (error);
out: out:
if (fp) if (fp)
fclose(fp); fclose (fp);
if (config_str) if (config_str)
talloc_free(config_str); talloc_free (config_str);
return ret; return ret;
} }
@ -300,7 +300,7 @@ out:
* *
* If is_new_ret is NULL, then a "file not found" message will be * If is_new_ret is NULL, then a "file not found" message will be
* printed to stderr and NULL will be returned. * printed to stderr and NULL will be returned.
*
* If is_new_ret is non-NULL then a default configuration will be * If is_new_ret is non-NULL then a default configuration will be
* returned and *is_new_ret will be set to 1 on return so that * returned and *is_new_ret will be set to 1 on return so that
* the caller can recognize this case. * the caller can recognize this case.
@ -338,6 +338,7 @@ notmuch_config_open (void *ctx,
int file_had_crypto_group; int file_had_crypto_group;
notmuch_config_t *config = talloc_zero (ctx, notmuch_config_t); notmuch_config_t *config = talloc_zero (ctx, notmuch_config_t);
if (config == NULL) { if (config == NULL) {
fprintf (stderr, "Out of memory.\n"); fprintf (stderr, "Out of memory.\n");
return NULL; return NULL;
@ -438,7 +439,7 @@ notmuch_config_open (void *ctx,
} }
if (notmuch_config_get_new_tags (config, &tmp) == NULL) { if (notmuch_config_get_new_tags (config, &tmp) == NULL) {
const char *tags[] = { "unread", "inbox" }; const char *tags[] = { "unread", "inbox" };
notmuch_config_set_new_tags (config, tags, 2); notmuch_config_set_new_tags (config, tags, 2);
} }
@ -503,7 +504,7 @@ notmuch_config_open (void *ctx,
* Note: Any changes made to the configuration are *not* saved by this * Note: Any changes made to the configuration are *not* saved by this
* function. To save changes, call notmuch_config_save before * function. To save changes, call notmuch_config_save before
* notmuch_config_close. * notmuch_config_close.
*/ */
void void
notmuch_config_close (notmuch_config_t *config) notmuch_config_close (notmuch_config_t *config)
{ {
@ -605,13 +606,13 @@ _config_get_list (notmuch_config_t *config,
const char *section, const char *key, const char *section, const char *key,
const char ***outlist, size_t *list_length, size_t *ret_length) const char ***outlist, size_t *list_length, size_t *ret_length)
{ {
assert(outlist); assert (outlist);
/* read from config file and cache value, if not cached already */ /* read from config file and cache value, if not cached already */
if (*outlist == NULL) { if (*outlist == NULL) {
char **inlist = g_key_file_get_string_list (config->key_file, char **inlist = g_key_file_get_string_list (config->key_file,
section, key, list_length, NULL); section, key, list_length, NULL);
if (inlist) { if (inlist) {
unsigned int i; unsigned int i;
@ -648,7 +649,7 @@ _config_set_list (notmuch_config_t *config,
const char * const char *
notmuch_config_get_database_path (notmuch_config_t *config) notmuch_config_get_database_path (notmuch_config_t *config)
{ {
char *db_path = (char *)_config_get (config, &config->database_path, "database", "path"); char *db_path = (char *) _config_get (config, &config->database_path, "database", "path");
if (db_path && *db_path != '/') { if (db_path && *db_path != '/') {
/* If the path in the configuration file begins with any /* If the path in the configuration file begins with any
@ -726,16 +727,16 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,
size_t length) size_t length)
{ {
_config_set_list (config, "user", "other_email", list, length, _config_set_list (config, "user", "other_email", list, length,
&(config->user_other_email)); &(config->user_other_email));
} }
void void
notmuch_config_set_new_tags (notmuch_config_t *config, notmuch_config_set_new_tags (notmuch_config_t *config,
const char *list[], const char *list[],
size_t length) size_t length)
{ {
_config_set_list (config, "new", "tags", list, length, _config_set_list (config, "new", "tags", list, length,
&(config->new_tags)); &(config->new_tags));
} }
void void
@ -744,7 +745,7 @@ notmuch_config_set_new_ignore (notmuch_config_t *config,
size_t length) size_t length)
{ {
_config_set_list (config, "new", "ignore", list, length, _config_set_list (config, "new", "ignore", list, length,
&(config->new_ignore)); &(config->new_ignore));
} }
const char ** const char **
@ -757,8 +758,8 @@ notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length
void void
notmuch_config_set_search_exclude_tags (notmuch_config_t *config, notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
const char *list[], const char *list[],
size_t length) size_t length)
{ {
_config_set_list (config, "search", "exclude_tags", list, length, _config_set_list (config, "search", "exclude_tags", list, length,
&(config->search_exclude_tags)); &(config->search_exclude_tags));
@ -779,7 +780,7 @@ _item_split (char *item, char **group, char **key)
*group = item; *group = item;
period = strchr (item, '.'); period = strchr (item, '.');
if (period == NULL || *(period+1) == '\0') { if (period == NULL || *(period + 1) == '\0') {
fprintf (stderr, fprintf (stderr,
"Invalid configuration name: %s\n" "Invalid configuration name: %s\n"
"(Should be of the form <section>.<item>)\n", item); "(Should be of the form <section>.<item>)\n", item);
@ -793,7 +794,7 @@ _item_split (char *item, char **group, char **key)
} }
/* These are more properly called Xapian fields, but the user facing /* These are more properly called Xapian fields, but the user facing
docs call them prefixes, so make the error message match */ * docs call them prefixes, so make the error message match */
static bool static bool
validate_field_name (const char *str) validate_field_name (const char *str)
{ {
@ -839,10 +840,10 @@ typedef struct config_key {
} config_key_info_t; } config_key_info_t;
static struct config_key static struct config_key
config_key_table[] = { config_key_table[] = {
{"index.decrypt", true, false, NULL}, { "index.decrypt", true, false, NULL },
{"index.header.", true, true, validate_field_name}, { "index.header.", true, true, validate_field_name },
{"query.", true, true, NULL}, { "query.", true, true, NULL },
}; };
static config_key_info_t * static config_key_info_t *
@ -851,10 +852,10 @@ _config_key_info (const char *item)
for (size_t i = 0; i < ARRAY_SIZE (config_key_table); i++) { for (size_t i = 0; i < ARRAY_SIZE (config_key_table); i++) {
if (config_key_table[i].prefix && if (config_key_table[i].prefix &&
strncmp (item, config_key_table[i].name, strncmp (item, config_key_table[i].name,
strlen(config_key_table[i].name)) == 0) strlen (config_key_table[i].name)) == 0)
return config_key_table+i; return config_key_table + i;
if (strcmp (item, config_key_table[i].name) == 0) if (strcmp (item, config_key_table[i].name) == 0)
return config_key_table+i; return config_key_table + i;
} }
return NULL; return NULL;
} }
@ -863,13 +864,14 @@ static bool
_stored_in_db (const char *item) _stored_in_db (const char *item)
{ {
config_key_info_t *info; config_key_info_t *info;
info = _config_key_info (item); info = _config_key_info (item);
return (info && info->in_db); return (info && info->in_db);
} }
static int static int
_print_db_config(notmuch_config_t *config, const char *name) _print_db_config (notmuch_config_t *config, const char *name)
{ {
notmuch_database_t *notmuch; notmuch_database_t *notmuch;
char *val; char *val;
@ -884,7 +886,7 @@ _print_db_config(notmuch_config_t *config, const char *name)
notmuch_database_get_config (notmuch, name, &val))) notmuch_database_get_config (notmuch, name, &val)))
return EXIT_FAILURE; return EXIT_FAILURE;
puts (val); puts (val);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -892,20 +894,20 @@ _print_db_config(notmuch_config_t *config, const char *name)
static int static int
notmuch_config_command_get (notmuch_config_t *config, char *item) notmuch_config_command_get (notmuch_config_t *config, char *item)
{ {
if (strcmp(item, "database.path") == 0) { if (strcmp (item, "database.path") == 0) {
printf ("%s\n", notmuch_config_get_database_path (config)); printf ("%s\n", notmuch_config_get_database_path (config));
} else if (strcmp(item, "user.name") == 0) { } else if (strcmp (item, "user.name") == 0) {
printf ("%s\n", notmuch_config_get_user_name (config)); printf ("%s\n", notmuch_config_get_user_name (config));
} else if (strcmp(item, "user.primary_email") == 0) { } else if (strcmp (item, "user.primary_email") == 0) {
printf ("%s\n", notmuch_config_get_user_primary_email (config)); printf ("%s\n", notmuch_config_get_user_primary_email (config));
} else if (strcmp(item, "user.other_email") == 0) { } else if (strcmp (item, "user.other_email") == 0) {
const char **other_email; const char **other_email;
size_t i, length; size_t i, length;
other_email = notmuch_config_get_user_other_email (config, &length); other_email = notmuch_config_get_user_other_email (config, &length);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
printf ("%s\n", other_email[i]); printf ("%s\n", other_email[i]);
} else if (strcmp(item, "new.tags") == 0) { } else if (strcmp (item, "new.tags") == 0) {
const char **tags; const char **tags;
size_t i, length; size_t i, length;
@ -944,7 +946,7 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
} }
static int static int
_set_db_config(notmuch_config_t *config, const char *key, int argc, char **argv) _set_db_config (notmuch_config_t *config, const char *key, int argc, char **argv)
{ {
notmuch_database_t *notmuch; notmuch_database_t *notmuch;
const char *val = ""; const char *val = "";
@ -1025,15 +1027,15 @@ static
void void
_notmuch_config_list_built_with () _notmuch_config_list_built_with ()
{ {
printf("%scompact=%s\n", printf ("%scompact=%s\n",
BUILT_WITH_PREFIX, BUILT_WITH_PREFIX,
notmuch_built_with ("compact") ? "true" : "false"); notmuch_built_with ("compact") ? "true" : "false");
printf("%sfield_processor=%s\n", printf ("%sfield_processor=%s\n",
BUILT_WITH_PREFIX, BUILT_WITH_PREFIX,
notmuch_built_with ("field_processor") ? "true" : "false"); notmuch_built_with ("field_processor") ? "true" : "false");
printf("%sretry_lock=%s\n", printf ("%sretry_lock=%s\n",
BUILT_WITH_PREFIX, BUILT_WITH_PREFIX,
notmuch_built_with ("retry_lock") ? "true" : "false"); notmuch_built_with ("retry_lock") ? "true" : "false");
} }
static int static int
@ -1054,11 +1056,11 @@ _list_db_config (notmuch_config_t *config)
return EXIT_FAILURE; return EXIT_FAILURE;
for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
printf("%s=%s\n", notmuch_config_list_key (list), notmuch_config_list_value(list)); printf ("%s=%s\n", notmuch_config_list_key (list), notmuch_config_list_value (list));
} }
notmuch_config_list_destroy (list); notmuch_config_list_destroy (list);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
static int static int
@ -1115,8 +1117,8 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_requested_db_uuid); notmuch_requested_db_uuid);
/* skip at least subcommand argument */ /* skip at least subcommand argument */
argc-= opt_index; argc -= opt_index;
argv+= opt_index; argv += opt_index;
if (argc < 1) { if (argc < 1) {
fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); fprintf (stderr, "Error: notmuch config requires at least one argument.\n");

View file

@ -165,10 +165,10 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &output, .name = "output", .keywords = { .opt_keyword = &output, .name = "output", .keywords =
(notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
{ "messages", OUTPUT_MESSAGES }, { "messages", OUTPUT_MESSAGES },
{ "files", OUTPUT_FILES }, { "files", OUTPUT_FILES },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_bool = &exclude, .name = "exclude" }, { .opt_bool = &exclude, .name = "exclude" },
{ .opt_bool = &print_lastmod, .name = "lastmod" }, { .opt_bool = &print_lastmod, .name = "lastmod" },
{ .opt_bool = &batch, .name = "batch" }, { .opt_bool = &batch, .name = "batch" },
@ -214,7 +214,7 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
if (exclude) { if (exclude) {
search_exclude_tags = notmuch_config_get_search_exclude_tags search_exclude_tags = notmuch_config_get_search_exclude_tags
(config, &search_exclude_tags_length); (config, &search_exclude_tags_length);
} }
if (batch) if (batch)

View file

@ -56,7 +56,7 @@ database_dump_config (notmuch_database_t *notmuch, gzFile output)
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
DONE: DONE:
if (list) if (list)
notmuch_config_list_destroy (list); notmuch_config_list_destroy (list);
@ -220,7 +220,7 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,
if (include & DUMP_INCLUDE_CONFIG) { if (include & DUMP_INCLUDE_CONFIG) {
if (print_status_database ("notmuch dump", notmuch, if (print_status_database ("notmuch dump", notmuch,
database_dump_config(notmuch,output))) database_dump_config (notmuch, output)))
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -307,7 +307,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
name_for_error, strerror (errno)); name_for_error, strerror (errno));
if (close (outfd)) if (close (outfd))
fprintf (stderr, "Error closing %s during shutdown: %s\n", fprintf (stderr, "Error closing %s during shutdown: %s\n",
name_for_error, strerror (errno)); name_for_error, strerror (errno));
goto DONE; goto DONE;
} }
@ -346,7 +346,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
} }
} }
DONE: DONE:
if (ret != EXIT_SUCCESS && output) if (ret != EXIT_SUCCESS && output)
(void) gzclose_w (output); (void) gzclose_w (output);
@ -378,13 +378,13 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &output_format, .name = "format", .keywords = { .opt_keyword = &output_format, .name = "format", .keywords =
(notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP }, (notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP },
{ "batch-tag", DUMP_FORMAT_BATCH_TAG }, { "batch-tag", DUMP_FORMAT_BATCH_TAG },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_flags = &include, .name = "include", .keywords = { .opt_flags = &include, .name = "include", .keywords =
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG }, (notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
{ "properties", DUMP_INCLUDE_PROPERTIES }, { "properties", DUMP_INCLUDE_PROPERTIES },
{ "tags", DUMP_INCLUDE_TAGS} } }, { "tags", DUMP_INCLUDE_TAGS } } },
{ .opt_string = &output_file_name, .name = "output" }, { .opt_string = &output_file_name, .name = "output" },
{ .opt_bool = &gzip_output, .name = "gzip" }, { .opt_bool = &gzip_output, .name = "gzip" },
{ .opt_inherit = notmuch_shared_options }, { .opt_inherit = notmuch_shared_options },

View file

@ -99,7 +99,7 @@ is_valid_folder_name (const char *folder)
if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/')) if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))
return false; return false;
p = strchr (p, '/'); p = strchr (p, '/');
if (!p) if (! p)
return true; return true;
p++; p++;
} }
@ -120,7 +120,7 @@ mkdir_recursive (const void *ctx, const char *path, int mode)
/* First check the common case: directory already exists. */ /* First check the common case: directory already exists. */
r = stat (path, &st); r = stat (path, &st);
if (r == 0) { if (r == 0) {
if (! S_ISDIR (st.st_mode)) { if (! S_ISDIR (st.st_mode)) {
fprintf (stderr, "Error: '%s' is not a directory: %s\n", fprintf (stderr, "Error: '%s' is not a directory: %s\n",
path, strerror (EEXIST)); path, strerror (EEXIST));
return false; return false;
@ -282,7 +282,7 @@ copy_fd (int fdout, int fdin)
} while (remain > 0); } while (remain > 0);
} }
return (!interrupted && !empty); return (! interrupted && ! empty);
} }
/* /*
@ -311,7 +311,7 @@ maildir_write_tmp (const void *ctx, int fdin, const char *maildir, bool world_re
return path; return path;
FAIL: FAIL:
close (fdout); close (fdout);
unlink (path); unlink (path);
@ -360,7 +360,7 @@ maildir_write_new (const void *ctx, int fdin, const char *maildir, bool world_re
return newpath; return newpath;
FAIL: FAIL:
unlink (cleanpath); unlink (cleanpath);
return NULL; return NULL;

View file

@ -87,7 +87,7 @@ handle_sigint (unused (int sig))
* result. It is not required for correctness, and if it does * result. It is not required for correctness, and if it does
* fail or produce a short write, we want to get out of the signal * fail or produce a short write, we want to get out of the signal
* handler as quickly as possible, not retry it. */ * handler as quickly as possible, not retry it. */
IGNORE_RESULT (write (2, msg, sizeof(msg)-1)); IGNORE_RESULT (write (2, msg, sizeof (msg) - 1));
interrupted = 1; interrupted = 1;
} }
@ -184,23 +184,23 @@ dirent_type (const char *path, const struct dirent *entry)
/* Mapping from d_type to stat mode_t. We omit DT_LNK so that /* Mapping from d_type to stat mode_t. We omit DT_LNK so that
* we'll fall through to stat and get the real file type. */ * we'll fall through to stat and get the real file type. */
static const mode_t modes[] = { static const mode_t modes[] = {
[DT_BLK] = S_IFBLK, [DT_BLK] = S_IFBLK,
[DT_CHR] = S_IFCHR, [DT_CHR] = S_IFCHR,
[DT_DIR] = S_IFDIR, [DT_DIR] = S_IFDIR,
[DT_FIFO] = S_IFIFO, [DT_FIFO] = S_IFIFO,
[DT_REG] = S_IFREG, [DT_REG] = S_IFREG,
[DT_SOCK] = S_IFSOCK [DT_SOCK] = S_IFSOCK
}; };
if (entry->d_type < ARRAY_SIZE(modes) && modes[entry->d_type]) if (entry->d_type < ARRAY_SIZE (modes) && modes[entry->d_type])
return modes[entry->d_type]; return modes[entry->d_type];
#endif #endif
abspath = talloc_asprintf (NULL, "%s/%s", path, entry->d_name); abspath = talloc_asprintf (NULL, "%s/%s", path, entry->d_name);
if (!abspath) { if (! abspath) {
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
err = stat(abspath, &statbuf); err = stat (abspath, &statbuf);
saved_errno = errno; saved_errno = errno;
talloc_free (abspath); talloc_free (abspath);
if (err < 0) { if (err < 0) {
@ -226,10 +226,9 @@ _entries_resemble_maildir (const char *path, struct dirent **entries, int count)
if (dirent_type (path, entries[i]) != S_IFDIR) if (dirent_type (path, entries[i]) != S_IFDIR)
continue; continue;
if (strcmp(entries[i]->d_name, "new") == 0 || if (strcmp (entries[i]->d_name, "new") == 0 ||
strcmp(entries[i]->d_name, "cur") == 0 || strcmp (entries[i]->d_name, "cur") == 0 ||
strcmp(entries[i]->d_name, "tmp") == 0) strcmp (entries[i]->d_name, "tmp") == 0) {
{
found++; found++;
if (found == 3) if (found == 3)
return 1; return 1;
@ -389,8 +388,8 @@ add_file (notmuch_database_t *notmuch, const char *filename,
notmuch_message_maildir_flags_to_tags (message); notmuch_message_maildir_flags_to_tags (message);
for (tag = state->new_tags; *tag != NULL; tag++) { for (tag = state->new_tags; *tag != NULL; tag++) {
if (strcmp ("unread", *tag) !=0 || if (strcmp ("unread", *tag) != 0 ||
!notmuch_message_has_maildir_flag (message, 'S')) { ! notmuch_message_has_maildir_flag (message, 'S')) {
notmuch_message_add_tag (message, *tag); notmuch_message_add_tag (message, *tag);
} }
} }
@ -415,7 +414,7 @@ add_file (notmuch_database_t *notmuch, const char *filename,
case NOTMUCH_STATUS_READ_ONLY_DATABASE: case NOTMUCH_STATUS_READ_ONLY_DATABASE:
case NOTMUCH_STATUS_XAPIAN_EXCEPTION: case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
case NOTMUCH_STATUS_OUT_OF_MEMORY: case NOTMUCH_STATUS_OUT_OF_MEMORY:
(void) print_status_database("add_file", notmuch, status); (void) print_status_database ("add_file", notmuch, status);
goto DONE; goto DONE;
default: default:
INTERNAL_ERROR ("add_message returned unexpected value: %d", status); INTERNAL_ERROR ("add_message returned unexpected value: %d", status);
@ -534,7 +533,7 @@ add_files (notmuch_database_t *notmuch,
* file system link count. So, only bail early if the * file system link count. So, only bail early if the
* database agrees that there are no sub-directories. */ * database agrees that there are no sub-directories. */
db_subdirs = notmuch_directory_get_child_directories (directory); db_subdirs = notmuch_directory_get_child_directories (directory);
if (!notmuch_filenames_valid (db_subdirs)) if (! notmuch_filenames_valid (db_subdirs))
goto DONE; goto DONE;
notmuch_filenames_destroy (db_subdirs); notmuch_filenames_destroy (db_subdirs);
db_subdirs = NULL; db_subdirs = NULL;
@ -631,7 +630,7 @@ add_files (notmuch_database_t *notmuch,
/* Pass 2: Scan for new files, removed files, and removed directories. */ /* Pass 2: Scan for new files, removed files, and removed directories. */
for (i = 0; i < num_fs_entries && ! interrupted; i++) { for (i = 0; i < num_fs_entries && ! interrupted; i++) {
entry = fs_entries[i]; entry = fs_entries[i];
/* Ignore special directories early. */ /* Ignore special directories early. */
if (_special_directory (entry->d_name)) if (_special_directory (entry->d_name))
@ -648,8 +647,7 @@ add_files (notmuch_database_t *notmuch,
/* Check if we've walked past any names in db_files or /* Check if we've walked past any names in db_files or
* db_subdirs. If so, these have been deleted. */ * db_subdirs. If so, these have been deleted. */
while (notmuch_filenames_valid (db_files) && while (notmuch_filenames_valid (db_files) &&
strcmp (notmuch_filenames_get (db_files), entry->d_name) < 0) strcmp (notmuch_filenames_get (db_files), entry->d_name) < 0) {
{
char *absolute = talloc_asprintf (state->removed_files, char *absolute = talloc_asprintf (state->removed_files,
"%s/%s", path, "%s/%s", path,
notmuch_filenames_get (db_files)); notmuch_filenames_get (db_files));
@ -664,17 +662,15 @@ add_files (notmuch_database_t *notmuch,
} }
while (notmuch_filenames_valid (db_subdirs) && while (notmuch_filenames_valid (db_subdirs) &&
strcmp (notmuch_filenames_get (db_subdirs), entry->d_name) <= 0) strcmp (notmuch_filenames_get (db_subdirs), entry->d_name) <= 0) {
{
const char *filename = notmuch_filenames_get (db_subdirs); const char *filename = notmuch_filenames_get (db_subdirs);
if (strcmp (filename, entry->d_name) < 0) if (strcmp (filename, entry->d_name) < 0) {
{
char *absolute = talloc_asprintf (state->removed_directories, char *absolute = talloc_asprintf (state->removed_directories,
"%s/%s", path, filename); "%s/%s", path, filename);
if (state->debug) if (state->debug)
printf ("(D) add_files, pass 2: queuing passed directory %s for deletion from database\n", printf ("(D) add_files, pass 2: queuing passed directory %s for deletion from database\n",
absolute); absolute);
_filename_list_add (state->removed_directories, absolute); _filename_list_add (state->removed_directories, absolute);
} }
@ -694,8 +690,7 @@ add_files (notmuch_database_t *notmuch,
/* Don't add a file that we've added before. */ /* Don't add a file that we've added before. */
if (notmuch_filenames_valid (db_files) && if (notmuch_filenames_valid (db_files) &&
strcmp (notmuch_filenames_get (db_files), entry->d_name) == 0) strcmp (notmuch_filenames_get (db_files), entry->d_name) == 0) {
{
notmuch_filenames_move_to_next (db_files); notmuch_filenames_move_to_next (db_files);
continue; continue;
} }
@ -708,12 +703,12 @@ add_files (notmuch_database_t *notmuch,
if (state->verbosity >= VERBOSITY_VERBOSE) { if (state->verbosity >= VERBOSITY_VERBOSE) {
if (state->output_is_a_tty) if (state->output_is_a_tty)
printf("\r\033[K"); printf ("\r\033[K");
printf ("%i/%i: %s", state->processed_files, state->total_files, printf ("%i/%i: %s", state->processed_files, state->total_files,
next); next);
putchar((state->output_is_a_tty) ? '\r' : '\n'); putchar ((state->output_is_a_tty) ? '\r' : '\n');
fflush (stdout); fflush (stdout);
} }
@ -738,8 +733,7 @@ add_files (notmuch_database_t *notmuch,
/* Now that we've walked the whole filesystem list, anything left /* Now that we've walked the whole filesystem list, anything left
* over in the database lists has been deleted. */ * over in the database lists has been deleted. */
while (notmuch_filenames_valid (db_files)) while (notmuch_filenames_valid (db_files)) {
{
char *absolute = talloc_asprintf (state->removed_files, char *absolute = talloc_asprintf (state->removed_files,
"%s/%s", path, "%s/%s", path,
notmuch_filenames_get (db_files)); notmuch_filenames_get (db_files));
@ -752,8 +746,7 @@ add_files (notmuch_database_t *notmuch,
notmuch_filenames_move_to_next (db_files); notmuch_filenames_move_to_next (db_files);
} }
while (notmuch_filenames_valid (db_subdirs)) while (notmuch_filenames_valid (db_subdirs)) {
{
char *absolute = talloc_asprintf (state->removed_directories, char *absolute = talloc_asprintf (state->removed_directories,
"%s/%s", path, "%s/%s", path,
notmuch_filenames_get (db_subdirs)); notmuch_filenames_get (db_subdirs));
@ -856,7 +849,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
} }
for (i = 0; i < num_fs_entries && ! interrupted; i++) { for (i = 0; i < num_fs_entries && ! interrupted; i++) {
entry = fs_entries[i]; entry = fs_entries[i];
/* Ignore special directories to avoid infinite recursion. /* Ignore special directories to avoid infinite recursion.
* Also ignore the .notmuch directory. * Also ignore the .notmuch directory.
@ -901,7 +894,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
for (i = 0; i < num_fs_entries; i++) for (i = 0; i < num_fs_entries; i++)
free (fs_entries[i]); free (fs_entries[i]);
free (fs_entries); free (fs_entries);
} }
} }
@ -939,6 +932,7 @@ remove_filename (notmuch_database_t *notmuch,
{ {
notmuch_status_t status; notmuch_status_t status;
notmuch_message_t *message; notmuch_message_t *message;
status = notmuch_database_begin_atomic (notmuch); status = notmuch_database_begin_atomic (notmuch);
if (status) if (status)
return status; return status;
@ -976,13 +970,12 @@ _remove_directory (void *ctx,
char *absolute; char *absolute;
status = notmuch_database_get_directory (notmuch, path, &directory); status = notmuch_database_get_directory (notmuch, path, &directory);
if (status || !directory) if (status || ! directory)
return status; return status;
for (files = notmuch_directory_get_child_files (directory); for (files = notmuch_directory_get_child_files (directory);
notmuch_filenames_valid (files); notmuch_filenames_valid (files);
notmuch_filenames_move_to_next (files)) notmuch_filenames_move_to_next (files)) {
{
absolute = talloc_asprintf (ctx, "%s/%s", path, absolute = talloc_asprintf (ctx, "%s/%s", path,
notmuch_filenames_get (files)); notmuch_filenames_get (files));
status = remove_filename (notmuch, absolute, add_files_state); status = remove_filename (notmuch, absolute, add_files_state);
@ -993,8 +986,7 @@ _remove_directory (void *ctx,
for (subdirs = notmuch_directory_get_child_directories (directory); for (subdirs = notmuch_directory_get_child_directories (directory);
notmuch_filenames_valid (subdirs); notmuch_filenames_valid (subdirs);
notmuch_filenames_move_to_next (subdirs)) notmuch_filenames_move_to_next (subdirs)) {
{
absolute = talloc_asprintf (ctx, "%s/%s", path, absolute = talloc_asprintf (ctx, "%s/%s", path,
notmuch_filenames_get (subdirs)); notmuch_filenames_get (subdirs));
status = _remove_directory (ctx, notmuch, absolute, add_files_state); status = _remove_directory (ctx, notmuch, absolute, add_files_state);
@ -1234,32 +1226,32 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
goto DONE; goto DONE;
gettimeofday (&tv_start, NULL); gettimeofday (&tv_start, NULL);
for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) { for (f = add_files_state.removed_files->head; f && ! interrupted; f = f->next) {
ret = remove_filename (notmuch, f->filename, &add_files_state); ret = remove_filename (notmuch, f->filename, &add_files_state);
if (ret) if (ret)
goto DONE; goto DONE;
if (do_print_progress) { if (do_print_progress) {
do_print_progress = 0; do_print_progress = 0;
generic_print_progress ("Cleaned up", "messages", generic_print_progress ("Cleaned up", "messages",
tv_start, add_files_state.removed_messages + add_files_state.renamed_messages, tv_start, add_files_state.removed_messages + add_files_state.renamed_messages,
add_files_state.removed_files->count); add_files_state.removed_files->count);
} }
} }
gettimeofday (&tv_start, NULL); gettimeofday (&tv_start, NULL);
for (f = add_files_state.removed_directories->head, i = 0; f && !interrupted; f = f->next, i++) { for (f = add_files_state.removed_directories->head, i = 0; f && ! interrupted; f = f->next, i++) {
ret = _remove_directory (config, notmuch, f->filename, &add_files_state); ret = _remove_directory (config, notmuch, f->filename, &add_files_state);
if (ret) if (ret)
goto DONE; goto DONE;
if (do_print_progress) { if (do_print_progress) {
do_print_progress = 0; do_print_progress = 0;
generic_print_progress ("Cleaned up", "directories", generic_print_progress ("Cleaned up", "directories",
tv_start, i, tv_start, i,
add_files_state.removed_directories->count); add_files_state.removed_directories->count);
} }
} }
for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) { for (f = add_files_state.directory_mtimes->head; f && ! interrupted; f = f->next) {
notmuch_directory_t *directory; notmuch_directory_t *directory;
status = notmuch_database_get_directory (notmuch, f->filename, &directory); status = notmuch_database_get_directory (notmuch, f->filename, &directory);
if (status == NOTMUCH_STATUS_SUCCESS && directory) { if (status == NOTMUCH_STATUS_SUCCESS && directory) {
@ -1285,7 +1277,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_database_destroy (notmuch); notmuch_database_destroy (notmuch);
if (hooks && !ret && !interrupted) if (hooks && ! ret && ! interrupted)
ret = notmuch_run_hook (db_path, "post-new"); ret = notmuch_run_hook (db_path, "post-new");
if (ret || interrupted) if (ret || interrupted)

View file

@ -68,13 +68,13 @@ reindex_query (notmuch_database_t *notmuch, const char *query_string,
notmuch_messages_move_to_next (messages)) { notmuch_messages_move_to_next (messages)) {
message = notmuch_messages_get (messages); message = notmuch_messages_get (messages);
ret = notmuch_message_reindex(message, indexopts); ret = notmuch_message_reindex (message, indexopts);
if (ret != NOTMUCH_STATUS_SUCCESS) if (ret != NOTMUCH_STATUS_SUCCESS)
break; break;
notmuch_message_destroy (message); notmuch_message_destroy (message);
} }
if (!ret) if (! ret)
ret = notmuch_database_end_atomic (notmuch); ret = notmuch_database_end_atomic (notmuch);
notmuch_query_destroy (query); notmuch_query_destroy (query);
@ -124,7 +124,7 @@ notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
query_string = query_string_from_args (config, argc-opt_index, argv+opt_index); query_string = query_string_from_args (config, argc - opt_index, argv + opt_index);
if (query_string == NULL) { if (query_string == NULL) {
fprintf (stderr, "Out of memory\n"); fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE; return EXIT_FAILURE;

View file

@ -28,8 +28,8 @@ static void
show_reply_headers (GMimeStream *stream, GMimeMessage *message) show_reply_headers (GMimeStream *stream, GMimeMessage *message)
{ {
/* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */ /* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */
if (g_mime_object_write_to_stream (GMIME_OBJECT(message), NULL, stream) < 0) { if (g_mime_object_write_to_stream (GMIME_OBJECT (message), NULL, stream) < 0) {
INTERNAL_ERROR("failed to write headers to stdout\n"); INTERNAL_ERROR ("failed to write headers to stdout\n");
} }
} }
@ -68,7 +68,7 @@ format_part_reply (GMimeStream *stream, mime_node_t *node)
g_mime_content_type_is_type (content_type, "application", "pgp-signature")) { g_mime_content_type_is_type (content_type, "application", "pgp-signature")) {
/* Ignore PGP/MIME cruft parts */ /* Ignore PGP/MIME cruft parts */
} else if (g_mime_content_type_is_type (content_type, "text", "*") && } else if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html")) { ! g_mime_content_type_is_type (content_type, "text", "html")) {
show_text_part_content (node->part, stream, NOTMUCH_SHOW_TEXT_PART_REPLY); show_text_part_content (node->part, stream, NOTMUCH_SHOW_TEXT_PART_REPLY);
} else if (disposition && } else if (disposition &&
strcasecmp (g_mime_content_disposition_get_disposition (disposition), strcasecmp (g_mime_content_disposition_get_disposition (disposition),
@ -117,7 +117,7 @@ address_match (const char *str, notmuch_config_t *config, address_match_t mode)
const char **other; const char **other;
size_t i, other_len; size_t i, other_len;
if (!str || *str == '\0') if (! str || *str == '\0')
return NULL; return NULL;
primary = notmuch_config_get_user_primary_email (config); primary = notmuch_config_get_user_primary_email (config);
@ -263,14 +263,15 @@ reply_to_header_is_redundant (GMimeMessage *message,
return ret; return ret;
} }
static InternetAddressList *get_sender(GMimeMessage *message) static InternetAddressList *
get_sender (GMimeMessage *message)
{ {
InternetAddressList *reply_to_list; InternetAddressList *reply_to_list;
reply_to_list = g_mime_message_get_reply_to_list (message); reply_to_list = g_mime_message_get_reply_to_list (message);
if (reply_to_list && if (reply_to_list &&
internet_address_list_length (reply_to_list) > 0) { internet_address_list_length (reply_to_list) > 0) {
/* /*
* Some mailing lists munge the Reply-To header despite it * Some mailing lists munge the Reply-To header despite it
* being A Bad Thing, see * being A Bad Thing, see
* http://marc.merlins.org/netrants/reply-to-harmful.html * http://marc.merlins.org/netrants/reply-to-harmful.html
@ -290,17 +291,20 @@ static InternetAddressList *get_sender(GMimeMessage *message)
return g_mime_message_get_from (message); return g_mime_message_get_from (message);
} }
static InternetAddressList *get_to(GMimeMessage *message) static InternetAddressList *
get_to (GMimeMessage *message)
{ {
return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO); return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO);
} }
static InternetAddressList *get_cc(GMimeMessage *message) static InternetAddressList *
get_cc (GMimeMessage *message)
{ {
return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_CC); return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_CC);
} }
static InternetAddressList *get_bcc(GMimeMessage *message) static InternetAddressList *
get_bcc (GMimeMessage *message)
{ {
return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_BCC); return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_BCC);
} }
@ -327,10 +331,10 @@ add_recipients_from_message (GMimeMessage *reply,
InternetAddressList * (*get_header)(GMimeMessage *message); InternetAddressList * (*get_header)(GMimeMessage *message);
GMimeAddressType recipient_type; GMimeAddressType recipient_type;
} reply_to_map[] = { } reply_to_map[] = {
{ get_sender, GMIME_ADDRESS_TYPE_TO }, { get_sender, GMIME_ADDRESS_TYPE_TO },
{ get_to, GMIME_ADDRESS_TYPE_TO }, { get_to, GMIME_ADDRESS_TYPE_TO },
{ get_cc, GMIME_ADDRESS_TYPE_CC }, { get_cc, GMIME_ADDRESS_TYPE_CC },
{ get_bcc, GMIME_ADDRESS_TYPE_BCC }, { get_bcc, GMIME_ADDRESS_TYPE_BCC },
}; };
const char *from_addr = NULL; const char *from_addr = NULL;
unsigned int i; unsigned int i;
@ -344,7 +348,7 @@ add_recipients_from_message (GMimeMessage *reply,
n += scan_address_list (recipients, config, reply, n += scan_address_list (recipients, config, reply,
reply_to_map[i].recipient_type, &from_addr); reply_to_map[i].recipient_type, &from_addr);
if (!reply_all && n) { if (! reply_all && n) {
/* Stop adding new recipients in reply-to-sender mode if /* Stop adding new recipients in reply-to-sender mode if
* we have added some recipient(s) above. * we have added some recipient(s) above.
* *
@ -414,7 +418,7 @@ guess_from_in_received_by (notmuch_config_t *config, const char *received)
if (*by == '\0') if (*by == '\0')
break; break;
mta = xstrdup (by); mta = xstrdup (by);
token = strtok(mta," \t"); token = strtok (mta, " \t");
if (token == NULL) { if (token == NULL) {
free (mta); free (mta);
break; break;
@ -518,12 +522,12 @@ get_from_in_to_headers (notmuch_config_t *config, notmuch_message_t *message)
} }
static GMimeMessage * static GMimeMessage *
create_reply_message(void *ctx, create_reply_message (void *ctx,
notmuch_config_t *config, notmuch_config_t *config,
notmuch_message_t *message, notmuch_message_t *message,
GMimeMessage *mime_message, GMimeMessage *mime_message,
bool reply_all, bool reply_all,
bool limited) bool limited)
{ {
const char *subject, *from_addr = NULL; const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references; const char *in_reply_to, *orig_references, *references;
@ -533,6 +537,7 @@ create_reply_message(void *ctx,
* otherwise. * otherwise.
*/ */
GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1); GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);
if (reply == NULL) { if (reply == NULL) {
fprintf (stderr, "Out of memory\n"); fprintf (stderr, "Out of memory\n");
return NULL; return NULL;
@ -608,11 +613,12 @@ enum {
FORMAT_HEADERS_ONLY, FORMAT_HEADERS_ONLY,
}; };
static int do_reply(notmuch_config_t *config, static int
notmuch_query_t *query, do_reply (notmuch_config_t *config,
notmuch_show_params_t *params, notmuch_query_t *query,
int format, notmuch_show_params_t *params,
bool reply_all) int format,
bool reply_all)
{ {
GMimeMessage *reply; GMimeMessage *reply;
mime_node_t *node; mime_node_t *node;
@ -645,8 +651,7 @@ static int do_reply(notmuch_config_t *config,
for (; for (;
notmuch_messages_valid (messages); notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) notmuch_messages_move_to_next (messages)) {
{
message = notmuch_messages_get (messages); message = notmuch_messages_get (messages);
if (mime_node_open (config, message, &params->crypto, &node)) if (mime_node_open (config, message, &params->crypto, &node))
@ -655,7 +660,7 @@ static int do_reply(notmuch_config_t *config,
reply = create_reply_message (config, config, message, reply = create_reply_message (config, config, message,
GMIME_MESSAGE (node->part), reply_all, GMIME_MESSAGE (node->part), reply_all,
format == FORMAT_HEADERS_ONLY); format == FORMAT_HEADERS_ONLY);
if (!reply) if (! reply)
return 1; return 1;
if (format == FORMAT_JSON || format == FORMAT_SEXP) { if (format == FORMAT_JSON || format == FORMAT_SEXP) {
@ -681,7 +686,7 @@ static int do_reply(notmuch_config_t *config,
format_part_reply (stream_stdout, node); format_part_reply (stream_stdout, node);
} }
g_mime_stream_flush (stream_stdout); g_mime_stream_flush (stream_stdout);
g_object_unref(stream_stdout); g_object_unref (stream_stdout);
} }
g_object_unref (G_OBJECT (reply)); g_object_unref (G_OBJECT (reply));
@ -709,22 +714,22 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords = { .opt_keyword = &format, .name = "format", .keywords =
(notmuch_keyword_t []){ { "default", FORMAT_DEFAULT }, (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
{ "json", FORMAT_JSON }, { "json", FORMAT_JSON },
{ "sexp", FORMAT_SEXP }, { "sexp", FORMAT_SEXP },
{ "headers-only", FORMAT_HEADERS_ONLY }, { "headers-only", FORMAT_HEADERS_ONLY },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_int = &notmuch_format_version, .name = "format-version" }, { .opt_int = &notmuch_format_version, .name = "format-version" },
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords = { .opt_keyword = &reply_all, .name = "reply-to", .keywords =
(notmuch_keyword_t []){ { "all", true }, (notmuch_keyword_t []){ { "all", true },
{ "sender", false }, { "sender", false },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = (int*)(&params.crypto.decrypt), .name = "decrypt", { .opt_keyword = (int *) (&params.crypto.decrypt), .name = "decrypt",
.keyword_no_arg_value = "true", .keywords = .keyword_no_arg_value = "true", .keywords =
(notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE }, (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
{ "auto", NOTMUCH_DECRYPT_AUTO }, { "auto", NOTMUCH_DECRYPT_AUTO },
{ "true", NOTMUCH_DECRYPT_NOSTASH }, { "true", NOTMUCH_DECRYPT_NOSTASH },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_inherit = notmuch_shared_options }, { .opt_inherit = notmuch_shared_options },
{ } { }
}; };
@ -737,7 +742,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_exit_if_unsupported_format (); notmuch_exit_if_unsupported_format ();
query_string = query_string_from_args (config, argc-opt_index, argv+opt_index); query_string = query_string_from_args (config, argc - opt_index, argv + opt_index);
if (query_string == NULL) { if (query_string == NULL) {
fprintf (stderr, "Out of memory\n"); fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE; return EXIT_FAILURE;

View file

@ -25,18 +25,18 @@
#include "zlib-extra.h" #include "zlib-extra.h"
static int static int
process_config_line (notmuch_database_t *notmuch, const char* line) process_config_line (notmuch_database_t *notmuch, const char *line)
{ {
const char *key_p, *val_p; const char *key_p, *val_p;
char *key, *val; char *key, *val;
size_t key_len,val_len; size_t key_len, val_len;
const char *delim = " \t\n"; const char *delim = " \t\n";
int ret = EXIT_FAILURE; int ret = EXIT_FAILURE;
void *local = talloc_new(NULL); void *local = talloc_new (NULL);
key_p = strtok_len_c (line, delim, &key_len); key_p = strtok_len_c (line, delim, &key_len);
val_p = strtok_len_c (key_p+key_len, delim, &val_len); val_p = strtok_len_c (key_p + key_len, delim, &val_len);
key = talloc_strndup (local, key_p, key_len); key = talloc_strndup (local, key_p, key_len);
val = talloc_strndup (local, val_p, val_len); val = talloc_strndup (local, val_p, val_len);
@ -52,14 +52,13 @@ process_config_line (notmuch_database_t *notmuch, const char* line)
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
DONE: DONE:
talloc_free (local); talloc_free (local);
return ret; return ret;
} }
static int static int
process_properties_line (notmuch_database_t *notmuch, const char* line) process_properties_line (notmuch_database_t *notmuch, const char *line)
{ {
const char *id_p, *tok; const char *id_p, *tok;
size_t id_len = 0, tok_len = 0; size_t id_len = 0, tok_len = 0;
@ -248,14 +247,14 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &input_format, .name = "format", .keywords = { .opt_keyword = &input_format, .name = "format", .keywords =
(notmuch_keyword_t []){ { "auto", DUMP_FORMAT_AUTO }, (notmuch_keyword_t []){ { "auto", DUMP_FORMAT_AUTO },
{ "batch-tag", DUMP_FORMAT_BATCH_TAG }, { "batch-tag", DUMP_FORMAT_BATCH_TAG },
{ "sup", DUMP_FORMAT_SUP }, { "sup", DUMP_FORMAT_SUP },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_flags = &include, .name = "include", .keywords = { .opt_flags = &include, .name = "include", .keywords =
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG }, (notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
{ "properties", DUMP_INCLUDE_PROPERTIES }, { "properties", DUMP_INCLUDE_PROPERTIES },
{ "tags", DUMP_INCLUDE_TAGS} } }, { "tags", DUMP_INCLUDE_TAGS } } },
{ .opt_string = &input_file_name, .name = "input" }, { .opt_string = &input_file_name, .name = "input" },
{ .opt_bool = &accumulate, .name = "accumulate" }, { .opt_bool = &accumulate, .name = "accumulate" },
@ -330,13 +329,13 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
if (status) { if (status) {
fprintf (stderr, "Error reading (gzipped) input: %s\n", fprintf (stderr, "Error reading (gzipped) input: %s\n",
gz_error_string(status, input)); gz_error_string (status, input));
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto DONE; goto DONE;
} }
if ((include & DUMP_INCLUDE_CONFIG) && line_len >= 2 && line[0] == '#' && line[1] == '@') { if ((include & DUMP_INCLUDE_CONFIG) && line_len >= 2 && line[0] == '#' && line[1] == '@') {
ret = process_config_line(notmuch, line+2); ret = process_config_line (notmuch, line + 2);
if (ret) if (ret)
goto DONE; goto DONE;
} }
@ -348,8 +347,8 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
} while ((line_len == 0) || } while ((line_len == 0) ||
(line[0] == '#') || (line[0] == '#') ||
/* the cast is safe because we checked about for line_len < 0 */ /* the cast is safe because we checked about for line_len < 0 */
(strspn (line, " \t\n") == (unsigned)line_len)); (strspn (line, " \t\n") == (unsigned) line_len));
if (! ((include & DUMP_INCLUDE_TAGS) || (include & DUMP_INCLUDE_PROPERTIES))) { if (! ((include & DUMP_INCLUDE_TAGS) || (include & DUMP_INCLUDE_PROPERTIES))) {
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
@ -442,7 +441,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
if (input_format == DUMP_FORMAT_SUP) if (input_format == DUMP_FORMAT_SUP)
regfree (&regex); regfree (&regex);
DONE: DONE:
if (line_ctx != NULL) if (line_ctx != NULL)
talloc_free (line_ctx); talloc_free (line_ctx);

View file

@ -87,8 +87,7 @@ get_thread_query (notmuch_thread_t *thread,
for (messages = notmuch_thread_get_messages (thread); for (messages = notmuch_thread_get_messages (thread);
notmuch_messages_valid (messages); notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) notmuch_messages_move_to_next (messages)) {
{
notmuch_message_t *message = notmuch_messages_get (messages); notmuch_message_t *message = notmuch_messages_get (messages);
const char *mid = notmuch_message_get_message_id (message); const char *mid = notmuch_message_get_message_id (message);
/* Determine which query buffer to extend */ /* Determine which query buffer to extend */
@ -103,7 +102,7 @@ get_thread_query (notmuch_thread_t *thread,
*buf = talloc_asprintf_append_buffer (*buf, " %s", escaped); *buf = talloc_asprintf_append_buffer (*buf, " %s", escaped);
else else
*buf = talloc_strdup (thread, escaped); *buf = talloc_strdup (thread, escaped);
if (!*buf) if (! *buf)
return -1; return -1;
} }
talloc_free (escaped); talloc_free (escaped);
@ -134,15 +133,14 @@ do_search_threads (search_context_t *ctx)
} }
status = notmuch_query_search_threads (ctx->query, &threads); status = notmuch_query_search_threads (ctx->query, &threads);
if (print_status_query("notmuch search", ctx->query, status)) if (print_status_query ("notmuch search", ctx->query, status))
return 1; return 1;
format->begin_list (format); format->begin_list (format);
for (i = 0; for (i = 0;
notmuch_threads_valid (threads) && (ctx->limit < 0 || i < ctx->offset + ctx->limit); notmuch_threads_valid (threads) && (ctx->limit < 0 || i < ctx->offset + ctx->limit);
notmuch_threads_move_to_next (threads), i++) notmuch_threads_move_to_next (threads), i++) {
{
thread = notmuch_threads_get (threads); thread = notmuch_threads_get (threads);
if (i < ctx->offset) { if (i < ctx->offset) {
@ -176,23 +174,23 @@ do_search_threads (search_context_t *ctx)
relative_date = notmuch_time_relative_date (ctx_quote, date); relative_date = notmuch_time_relative_date (ctx_quote, date);
if (format->is_text_printer) { if (format->is_text_printer) {
/* Special case for the text formatter */ /* Special case for the text formatter */
printf ("thread:%s %12s ", printf ("thread:%s %12s ",
thread_id, thread_id,
relative_date); relative_date);
if (total == files) if (total == files)
printf ("[%d/%d] %s; %s (", printf ("[%d/%d] %s; %s (",
matched, matched,
total, total,
sanitize_string (ctx_quote, authors), sanitize_string (ctx_quote, authors),
sanitize_string (ctx_quote, subject)); sanitize_string (ctx_quote, subject));
else else
printf ("[%d/%d(%d)] %s; %s (", printf ("[%d/%d(%d)] %s; %s (",
matched, matched,
total, total,
files, files,
sanitize_string (ctx_quote, authors), sanitize_string (ctx_quote, authors),
sanitize_string (ctx_quote, subject)); sanitize_string (ctx_quote, subject));
} else { /* Structured Output */ } else { /* Structured Output */
format->map_key (format, "thread"); format->map_key (format, "thread");
@ -237,12 +235,11 @@ do_search_threads (search_context_t *ctx)
for (tags = notmuch_thread_get_tags (thread); for (tags = notmuch_thread_get_tags (thread);
notmuch_tags_valid (tags); notmuch_tags_valid (tags);
notmuch_tags_move_to_next (tags)) notmuch_tags_move_to_next (tags)) {
{
const char *tag = notmuch_tags_get (tags); const char *tag = notmuch_tags_get (tags);
if (format->is_text_printer) { if (format->is_text_printer) {
/* Special case for the text formatter */ /* Special case for the text formatter */
if (first_tag) if (first_tag)
first_tag = false; first_tag = false;
else else
@ -269,7 +266,8 @@ do_search_threads (search_context_t *ctx)
return 0; return 0;
} }
static mailbox_t *new_mailbox (void *ctx, const char *name, const char *addr) static mailbox_t *
new_mailbox (void *ctx, const char *name, const char *addr)
{ {
mailbox_t *mailbox; mailbox_t *mailbox;
@ -284,7 +282,8 @@ static mailbox_t *new_mailbox (void *ctx, const char *name, const char *addr)
return mailbox; return mailbox;
} }
static int mailbox_compare (const void *v1, const void *v2) static int
mailbox_compare (const void *v1, const void *v2)
{ {
const mailbox_t *m1 = v1, *m2 = v2; const mailbox_t *m1 = v1, *m2 = v2;
int ret; int ret;
@ -488,7 +487,7 @@ print_popular (const search_context_t *ctx, GList *list)
} }
if (! mailbox) if (! mailbox)
INTERNAL_ERROR("Empty list in address hash table\n"); INTERNAL_ERROR ("Empty list in address hash table\n");
/* The original count is no longer needed, so overwrite. */ /* The original count is no longer needed, so overwrite. */
mailbox->count = total; mailbox->count = total;
@ -522,8 +521,8 @@ _count_filenames (notmuch_message_t *message)
filenames = notmuch_message_get_filenames (message); filenames = notmuch_message_get_filenames (message);
while (notmuch_filenames_valid (filenames)) { while (notmuch_filenames_valid (filenames)) {
notmuch_filenames_move_to_next (filenames); notmuch_filenames_move_to_next (filenames);
i++; i++;
} }
notmuch_filenames_destroy (filenames); notmuch_filenames_destroy (filenames);
@ -561,8 +560,7 @@ do_search_messages (search_context_t *ctx)
for (i = 0; for (i = 0;
notmuch_messages_valid (messages) && (ctx->limit < 0 || i < ctx->offset + ctx->limit); notmuch_messages_valid (messages) && (ctx->limit < 0 || i < ctx->offset + ctx->limit);
notmuch_messages_move_to_next (messages), i++) notmuch_messages_move_to_next (messages), i++) {
{
if (i < ctx->offset) if (i < ctx->offset)
continue; continue;
@ -574,24 +572,23 @@ do_search_messages (search_context_t *ctx)
for (j = 1; for (j = 1;
notmuch_filenames_valid (filenames); notmuch_filenames_valid (filenames);
notmuch_filenames_move_to_next (filenames), j++) notmuch_filenames_move_to_next (filenames), j++) {
{
if (ctx->dupe < 0 || ctx->dupe == j) { if (ctx->dupe < 0 || ctx->dupe == j) {
format->string (format, notmuch_filenames_get (filenames)); format->string (format, notmuch_filenames_get (filenames));
format->separator (format); format->separator (format);
} }
} }
notmuch_filenames_destroy( filenames ); notmuch_filenames_destroy ( filenames );
} else if (ctx->output == OUTPUT_MESSAGES) { } else if (ctx->output == OUTPUT_MESSAGES) {
/* special case 1 for speed */ /* special case 1 for speed */
if (ctx->dupe <= 1 || ctx->dupe <= _count_filenames (message)) { if (ctx->dupe <= 1 || ctx->dupe <= _count_filenames (message)) {
format->set_prefix (format, "id"); format->set_prefix (format, "id");
format->string (format, format->string (format,
notmuch_message_get_message_id (message)); notmuch_message_get_message_id (message));
format->separator (format); format->separator (format);
} }
} else { } else {
if (ctx->output & OUTPUT_SENDER) { if (ctx->output & OUTPUT_SENDER) {
const char *addrs; const char *addrs;
@ -657,8 +654,7 @@ do_search_tags (const search_context_t *ctx)
for (; for (;
notmuch_tags_valid (tags); notmuch_tags_valid (tags);
notmuch_tags_move_to_next (tags)) notmuch_tags_move_to_next (tags)) {
{
tag = notmuch_tags_get (tags); tag = notmuch_tags_get (tags);
format->string (format, tag); format->string (format, tag);
@ -702,7 +698,7 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar
break; break;
default: default:
/* this should never happen */ /* this should never happen */
INTERNAL_ERROR("no output format selected"); INTERNAL_ERROR ("no output format selected");
} }
notmuch_exit_if_unsupported_format (); notmuch_exit_if_unsupported_format ();
@ -791,15 +787,15 @@ static search_context_t search_context = {
static const notmuch_opt_desc_t common_options[] = { static const notmuch_opt_desc_t common_options[] = {
{ .opt_keyword = &search_context.sort, .name = "sort", .keywords = { .opt_keyword = &search_context.sort, .name = "sort", .keywords =
(notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST }, (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
{ "newest-first", NOTMUCH_SORT_NEWEST_FIRST }, { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = &search_context.format_sel, .name = "format", .keywords = { .opt_keyword = &search_context.format_sel, .name = "format", .keywords =
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
{ "sexp", NOTMUCH_FORMAT_SEXP }, { "sexp", NOTMUCH_FORMAT_SEXP },
{ "text", NOTMUCH_FORMAT_TEXT }, { "text", NOTMUCH_FORMAT_TEXT },
{ "text0", NOTMUCH_FORMAT_TEXT0 }, { "text0", NOTMUCH_FORMAT_TEXT0 },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_int = &notmuch_format_version, .name = "format-version" }, { .opt_int = &notmuch_format_version, .name = "format-version" },
{ } { }
}; };
@ -812,18 +808,18 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &ctx->output, .name = "output", .keywords = { .opt_keyword = &ctx->output, .name = "output", .keywords =
(notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY }, (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },
{ "threads", OUTPUT_THREADS }, { "threads", OUTPUT_THREADS },
{ "messages", OUTPUT_MESSAGES }, { "messages", OUTPUT_MESSAGES },
{ "files", OUTPUT_FILES }, { "files", OUTPUT_FILES },
{ "tags", OUTPUT_TAGS }, { "tags", OUTPUT_TAGS },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = &ctx->exclude, .name = "exclude", .keywords = { .opt_keyword = &ctx->exclude, .name = "exclude", .keywords =
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
{ "false", NOTMUCH_EXCLUDE_FALSE }, { "false", NOTMUCH_EXCLUDE_FALSE },
{ "flag", NOTMUCH_EXCLUDE_FLAG }, { "flag", NOTMUCH_EXCLUDE_FLAG },
{ "all", NOTMUCH_EXCLUDE_ALL }, { "all", NOTMUCH_EXCLUDE_ALL },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_int = &ctx->offset, .name = "offset" }, { .opt_int = &ctx->offset, .name = "offset" },
{ .opt_int = &ctx->limit, .name = "limit" }, { .opt_int = &ctx->limit, .name = "limit" },
{ .opt_int = &ctx->dupe, .name = "duplicate" }, { .opt_int = &ctx->dupe, .name = "duplicate" },
@ -841,8 +837,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES &&
ctx->dupe != -1) { ctx->dupe != -1) {
fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (_notmuch_search_prepare (ctx, config, if (_notmuch_search_prepare (ctx, config,
@ -878,20 +874,20 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_flags = &ctx->output, .name = "output", .keywords = { .opt_flags = &ctx->output, .name = "output", .keywords =
(notmuch_keyword_t []){ { "sender", OUTPUT_SENDER }, (notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },
{ "recipients", OUTPUT_RECIPIENTS }, { "recipients", OUTPUT_RECIPIENTS },
{ "count", OUTPUT_COUNT }, { "count", OUTPUT_COUNT },
{ "address", OUTPUT_ADDRESS }, { "address", OUTPUT_ADDRESS },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = &ctx->exclude, .name = "exclude", .keywords = { .opt_keyword = &ctx->exclude, .name = "exclude", .keywords =
(notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
{ "false", NOTMUCH_EXCLUDE_FALSE }, { "false", NOTMUCH_EXCLUDE_FALSE },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = &ctx->dedup, .name = "deduplicate", .keywords = { .opt_keyword = &ctx->dedup, .name = "deduplicate", .keywords =
(notmuch_keyword_t []){ { "no", DEDUP_NONE }, (notmuch_keyword_t []){ { "no", DEDUP_NONE },
{ "mailbox", DEDUP_MAILBOX }, { "mailbox", DEDUP_MAILBOX },
{ "address", DEDUP_ADDRESS }, { "address", DEDUP_ADDRESS },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_inherit = common_options }, { .opt_inherit = common_options },
{ .opt_inherit = notmuch_shared_options }, { .opt_inherit = notmuch_shared_options },
{ } { }

View file

@ -47,50 +47,51 @@ static void
welcome_message_pre_setup (void) welcome_message_pre_setup (void)
{ {
printf ( printf (
"Welcome to notmuch!\n\n" "Welcome to notmuch!\n\n"
"The goal of notmuch is to help you manage and search your collection of\n" "The goal of notmuch is to help you manage and search your collection of\n"
"email, and to efficiently keep up with the flow of email as it comes in.\n\n" "email, and to efficiently keep up with the flow of email as it comes in.\n\n"
"Notmuch needs to know a few things about you such as your name and email\n" "Notmuch needs to know a few things about you such as your name and email\n"
"address, as well as the directory that contains your email. This is where\n" "address, as well as the directory that contains your email. This is where\n"
"you already have mail stored and where messages will be delivered in the\n" "you already have mail stored and where messages will be delivered in the\n"
"future. This directory can contain any number of sub-directories. Regular\n" "future. This directory can contain any number of sub-directories. Regular\n"
"files in these directories should be individual email messages. If there\n" "files in these directories should be individual email messages. If there\n"
"are other, non-email files (such as indexes maintained by other email\n" "are other, non-email files (such as indexes maintained by other email\n"
"programs) then notmuch will do its best to detect those and ignore them.\n\n" "programs) then notmuch will do its best to detect those and ignore them.\n\n"
"If you already have your email being delivered to directories in either\n" "If you already have your email being delivered to directories in either\n"
"maildir or mh format, then that's perfect. Mail storage that uses mbox\n" "maildir or mh format, then that's perfect. Mail storage that uses mbox\n"
"format, (where one mbox file contains many messages), will not work with\n" "format, (where one mbox file contains many messages), will not work with\n"
"notmuch. If that's how your mail is currently stored, we recommend you\n" "notmuch. If that's how your mail is currently stored, we recommend you\n"
"first convert it to maildir format with a utility such as mb2md. You can\n" "first convert it to maildir format with a utility such as mb2md. You can\n"
"continue configuring notmuch now, but be sure to complete the conversion\n" "continue configuring notmuch now, but be sure to complete the conversion\n"
"before you run \"notmuch new\" for the first time.\n\n"); "before you run \"notmuch new\" for the first time.\n\n");
} }
static void static void
welcome_message_post_setup (void) welcome_message_post_setup (void)
{ {
printf ("\n" printf ("\n"
"Notmuch is now configured, and the configuration settings are saved in\n" "Notmuch is now configured, and the configuration settings are saved in\n"
"a file in your home directory named .notmuch-config . If you'd like to\n" "a file in your home directory named .notmuch-config . If you'd like to\n"
"change the configuration in the future, you can either edit that file\n" "change the configuration in the future, you can either edit that file\n"
"directly or run \"notmuch setup\". To choose an alternate configuration\n" "directly or run \"notmuch setup\". To choose an alternate configuration\n"
"location, set ${NOTMUCH_CONFIG}.\n\n" "location, set ${NOTMUCH_CONFIG}.\n\n"
"The next step is to run \"notmuch new\" which will create a database\n" "The next step is to run \"notmuch new\" which will create a database\n"
"that indexes all of your mail. Depending on the amount of mail you have\n" "that indexes all of your mail. Depending on the amount of mail you have\n"
"the initial indexing process can take a long time, so expect that.\n" "the initial indexing process can take a long time, so expect that.\n"
"Also, the resulting database will require roughly the same amount of\n" "Also, the resulting database will require roughly the same amount of\n"
"storage space as your current collection of email. So please ensure you\n" "storage space as your current collection of email. So please ensure you\n"
"have sufficient storage space available now.\n\n"); "have sufficient storage space available now.\n\n");
} }
static void static void
print_tag_list (const char **tags, size_t tags_len) print_tag_list (const char **tags, size_t tags_len)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < tags_len; i++) { for (i = 0; i < tags_len; i++) {
if (i != 0) if (i != 0)
printf (" "); printf (" ");
@ -134,15 +135,15 @@ notmuch_setup_command (notmuch_config_t *config,
const char **search_exclude_tags; const char **search_exclude_tags;
size_t search_exclude_tags_len; size_t search_exclude_tags_len;
#define prompt(format, ...) \ #define prompt(format, ...) \
do { \ do { \
printf (format, ##__VA_ARGS__); \ printf (format, ##__VA_ARGS__); \
fflush (stdout); \ fflush (stdout); \
if (getline (&response, &response_size, stdin) < 0) { \ if (getline (&response, &response_size, stdin) < 0) { \
printf ("Exiting.\n"); \ printf ("Exiting.\n"); \
exit (EXIT_FAILURE); \ exit (EXIT_FAILURE); \
} \ } \
chomp_newline (response); \ chomp_newline (response); \
} while (0) } while (0)
if (notmuch_minimal_options ("setup", argc, argv) < 0) if (notmuch_minimal_options ("setup", argc, argv) < 0)
@ -167,14 +168,14 @@ notmuch_setup_command (notmuch_config_t *config,
other_emails = g_ptr_array_new (); other_emails = g_ptr_array_new ();
old_other_emails = notmuch_config_get_user_other_email (config, old_other_emails = notmuch_config_get_user_other_email (config,
&old_other_emails_len); &old_other_emails_len);
for (i = 0; i < old_other_emails_len; i++) { for (i = 0; i < old_other_emails_len; i++) {
prompt ("Additional email address [%s]: ", old_other_emails[i]); prompt ("Additional email address [%s]: ", old_other_emails[i]);
if (strlen (response)) if (strlen (response))
g_ptr_array_add (other_emails, talloc_strdup (config, response)); g_ptr_array_add (other_emails, talloc_strdup (config, response));
else else
g_ptr_array_add (other_emails, talloc_strdup (config, g_ptr_array_add (other_emails, talloc_strdup (config,
old_other_emails[i])); old_other_emails[i]));
} }
do { do {

View file

@ -37,8 +37,7 @@ _get_tags_as_string (const void *ctx, notmuch_message_t *message)
for (tags = notmuch_message_get_tags (message); for (tags = notmuch_message_get_tags (message);
notmuch_tags_valid (tags); notmuch_tags_valid (tags);
notmuch_tags_move_to_next (tags)) notmuch_tags_move_to_next (tags)) {
{
tag = notmuch_tags_get (tags); tag = notmuch_tags_get (tags);
result = talloc_asprintf_append (result, "%s%s", result = talloc_asprintf_append (result, "%s%s",
@ -69,12 +68,13 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
from, relative_date, tags); from, relative_date, tags);
} }
static const char *_get_disposition(GMimeObject *meta) static const char *
_get_disposition (GMimeObject *meta)
{ {
GMimeContentDisposition *disposition; GMimeContentDisposition *disposition;
disposition = g_mime_object_get_content_disposition (meta); disposition = g_mime_object_get_content_disposition (meta);
if (!disposition) if (! disposition)
return NULL; return NULL;
return g_mime_content_disposition_get_disposition (disposition); return g_mime_content_disposition_get_disposition (disposition);
@ -170,7 +170,7 @@ _extract_email_address (const void *ctx, const char *from)
g_object_unref (addresses); g_object_unref (addresses);
return email; return email;
} }
/* Return 1 if 'line' is an mbox From_ line---that is, a line /* Return 1 if 'line' is an mbox From_ line---that is, a line
* beginning with zero or more '>' characters followed by the * beginning with zero or more '>' characters followed by the
@ -290,7 +290,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
charset = g_mime_object_get_content_type_parameter (part, "charset"); charset = g_mime_object_get_content_type_parameter (part, "charset");
charset = charset ? g_mime_charset_canon_name (charset) : NULL; charset = charset ? g_mime_charset_canon_name (charset) : NULL;
wrapper = g_mime_part_get_content (GMIME_PART (part)); wrapper = g_mime_part_get_content (GMIME_PART (part));
if (wrapper && charset && !g_ascii_strncasecmp (charset, "iso-8859-", 9)) { if (wrapper && charset && ! g_ascii_strncasecmp (charset, "iso-8859-", 9)) {
GMimeStream *null_stream = NULL; GMimeStream *null_stream = NULL;
GMimeStream *null_stream_filter = NULL; GMimeStream *null_stream_filter = NULL;
@ -298,10 +298,10 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
null_stream = g_mime_stream_null_new (); null_stream = g_mime_stream_null_new ();
null_stream_filter = g_mime_stream_filter_new (null_stream); null_stream_filter = g_mime_stream_filter_new (null_stream);
windows_filter = g_mime_filter_windows_new (charset); windows_filter = g_mime_filter_windows_new (charset);
g_mime_stream_filter_add(GMIME_STREAM_FILTER (null_stream_filter), g_mime_stream_filter_add (GMIME_STREAM_FILTER (null_stream_filter),
windows_filter); windows_filter);
g_mime_data_wrapper_write_to_stream (wrapper, null_stream_filter); g_mime_data_wrapper_write_to_stream (wrapper, null_stream_filter);
charset = g_mime_filter_windows_real_charset( charset = g_mime_filter_windows_real_charset (
(GMimeFilterWindows *) windows_filter); (GMimeFilterWindows *) windows_filter);
if (null_stream_filter) if (null_stream_filter)
@ -314,8 +314,8 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
stream_filter = g_mime_stream_filter_new (stream_out); stream_filter = g_mime_stream_filter_new (stream_out);
crlf_filter = g_mime_filter_dos2unix_new (false); crlf_filter = g_mime_filter_dos2unix_new (false);
g_mime_stream_filter_add(GMIME_STREAM_FILTER (stream_filter), g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),
crlf_filter); crlf_filter);
g_object_unref (crlf_filter); g_object_unref (crlf_filter);
if (charset) { if (charset) {
@ -345,12 +345,12 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
if (wrapper && stream_filter) if (wrapper && stream_filter)
g_mime_data_wrapper_write_to_stream (wrapper, stream_filter); g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
if (stream_filter) if (stream_filter)
g_object_unref(stream_filter); g_object_unref (stream_filter);
if (windows_filter) if (windows_filter)
g_object_unref (windows_filter); g_object_unref (windows_filter);
} }
static const char* static const char *
signature_status_to_string (GMimeSignatureStatus status) signature_status_to_string (GMimeSignatureStatus status)
{ {
if (g_mime_signature_status_bad (status)) if (g_mime_signature_status_bad (status))
@ -368,12 +368,13 @@ signature_status_to_string (GMimeSignatureStatus status)
/* Print signature flags */ /* Print signature flags */
struct key_map_struct { struct key_map_struct {
GMimeSignatureStatus bit; GMimeSignatureStatus bit;
const char * string; const char *string;
}; };
static void static void
do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map, do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map,
unsigned int array_map_len, GMimeSignatureStatus errors) { unsigned int array_map_len, GMimeSignatureStatus errors)
{
sp->map_key (sp, "errors"); sp->map_key (sp, "errors");
sp->begin_map (sp); sp->begin_map (sp);
@ -392,22 +393,22 @@ format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
{ {
GMimeSignatureStatus errors = g_mime_signature_get_status (signature); GMimeSignatureStatus errors = g_mime_signature_get_status (signature);
if (!(errors & GMIME_SIGNATURE_STATUS_ERROR_MASK)) if (! (errors & GMIME_SIGNATURE_STATUS_ERROR_MASK))
return; return;
struct key_map_struct key_map[] = { struct key_map_struct key_map[] = {
{ GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked"}, { GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked" },
{ GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired"}, { GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired" },
{ GMIME_SIGNATURE_STATUS_SIG_EXPIRED, "sig-expired" }, { GMIME_SIGNATURE_STATUS_SIG_EXPIRED, "sig-expired" },
{ GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing"}, { GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing" },
{ GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing"}, { GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing" },
{ GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old"}, { GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old" },
{ GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy"}, { GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy" },
{ GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error"}, { GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error" },
{ GMIME_SIGNATURE_STATUS_TOFU_CONFLICT, "tofu-conflict"}, { GMIME_SIGNATURE_STATUS_TOFU_CONFLICT, "tofu-conflict" },
}; };
do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors); do_format_signature_errors (sp, key_map, ARRAY_SIZE (key_map), errors);
} }
/* Signature status sprinter */ /* Signature status sprinter */
@ -419,7 +420,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, GMimeSignatureList *siglist)
sp->begin_list (sp); sp->begin_list (sp);
if (!siglist) { if (! siglist) {
sp->end (sp); sp->end (sp);
return; return;
} }
@ -479,7 +480,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, GMimeSignatureList *siglist)
} }
sp->end (sp); sp->end (sp);
} }
sp->end (sp); sp->end (sp);
} }
@ -555,8 +556,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
g_mime_stream_printf (stream, "Date: %s\n", date_string); g_mime_stream_printf (stream, "Date: %s\n", date_string);
g_mime_stream_printf (stream, "\fheader}\n"); g_mime_stream_printf (stream, "\fheader}\n");
if (!params->output_body) if (! params->output_body) {
{
g_mime_stream_printf (stream, "\f%s}\n", part_type); g_mime_stream_printf (stream, "\f%s}\n", part_type);
return NOTMUCH_STATUS_SUCCESS; return NOTMUCH_STATUS_SUCCESS;
} }
@ -566,8 +566,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
if (leaf) { if (leaf) {
if (g_mime_content_type_is_type (content_type, "text", "*") && if (g_mime_content_type_is_type (content_type, "text", "*") &&
(params->include_html || (params->include_html ||
! g_mime_content_type_is_type (content_type, "text", "html"))) ! g_mime_content_type_is_type (content_type, "text", "html"))) {
{
show_text_part_content (node->part, stream, 0); show_text_part_content (node->part, stream, 0);
} else { } else {
char *content_string = g_mime_content_type_get_mime_type (content_type); char *content_string = g_mime_content_type_get_mime_type (content_type);
@ -751,8 +750,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
*/ */
if (g_mime_content_type_is_type (content_type, "text", "*") && if (g_mime_content_type_is_type (content_type, "text", "*") &&
(include_html || (include_html ||
! g_mime_content_type_is_type (content_type, "text", "html"))) ! g_mime_content_type_is_type (content_type, "text", "html"))) {
{
GMimeStream *stream_memory = g_mime_stream_mem_new (); GMimeStream *stream_memory = g_mime_stream_mem_new ();
GByteArray *part_content; GByteArray *part_content;
show_text_part_content (node->part, stream_memory, 0); show_text_part_content (node->part, stream_memory, 0);
@ -824,7 +822,7 @@ format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
ssize_t line_size; ssize_t line_size;
ssize_t line_len; ssize_t line_len;
if (!message) if (! message)
INTERNAL_ERROR ("format_part_mbox requires a root part"); INTERNAL_ERROR ("format_part_mbox requires a root part");
filename = notmuch_message_get_filename (message); filename = notmuch_message_get_filename (message);
@ -883,7 +881,7 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
} }
while (! g_mime_stream_eos (stream)) { while (! g_mime_stream_eos (stream)) {
ssize = g_mime_stream_read (stream, buf, sizeof(buf)); ssize = g_mime_stream_read (stream, buf, sizeof (buf));
if (ssize < 0) { if (ssize < 0) {
fprintf (stderr, "Error: Read failed from %s\n", filename); fprintf (stderr, "Error: Read failed from %s\n", filename);
goto DONE; goto DONE;
@ -898,7 +896,7 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
ret = NOTMUCH_STATUS_SUCCESS; ret = NOTMUCH_STATUS_SUCCESS;
/* XXX This DONE is just for the special case of a node in a single file */ /* XXX This DONE is just for the special case of a node in a single file */
DONE: DONE:
if (stream) if (stream)
g_object_unref (stream); g_object_unref (stream);
@ -967,7 +965,7 @@ show_message (void *ctx,
} }
} }
} }
DONE: DONE :
talloc_free (local); talloc_free (local);
return status; return status;
} }
@ -990,8 +988,7 @@ show_messages (void *ctx,
for (; for (;
notmuch_messages_valid (messages); notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) notmuch_messages_move_to_next (messages)) {
{
sp->begin_list (sp); sp->begin_list (sp);
message = notmuch_messages_get (messages); message = notmuch_messages_get (messages);
@ -1001,9 +998,9 @@ show_messages (void *ctx,
next_indent = indent; next_indent = indent;
if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) { if ((match && (! excluded || ! params->omit_excluded)) || params->entire_thread) {
status = show_message (ctx, format, sp, message, indent, params); status = show_message (ctx, format, sp, message, indent, params);
if (status && !res) if (status && ! res)
res = status; res = status;
next_indent = indent + 1; next_indent = indent + 1;
} else { } else {
@ -1015,7 +1012,7 @@ show_messages (void *ctx,
notmuch_message_get_replies (message), notmuch_message_get_replies (message),
next_indent, next_indent,
params); params);
if (status && !res) if (status && ! res)
res = status; res = status;
notmuch_message_destroy (message); notmuch_message_destroy (message);
@ -1064,7 +1061,7 @@ do_show_single (void *ctx,
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1); notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);
return show_message (ctx, format, sp, message, 0, params) return show_message (ctx, format, sp, message, 0, params)
!= NOTMUCH_STATUS_SUCCESS; != NOTMUCH_STATUS_SUCCESS;
} }
/* Formatted output of threads */ /* Formatted output of threads */
@ -1080,16 +1077,15 @@ do_show (void *ctx,
notmuch_messages_t *messages; notmuch_messages_t *messages;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
status= notmuch_query_search_threads (query, &threads); status = notmuch_query_search_threads (query, &threads);
if (print_status_query ("notmuch show", query, status)) if (print_status_query ("notmuch show", query, status))
return 1; return 1;
sp->begin_list (sp); sp->begin_list (sp);
for ( ; for (;
notmuch_threads_valid (threads); notmuch_threads_valid (threads);
notmuch_threads_move_to_next (threads)) notmuch_threads_move_to_next (threads)) {
{
thread = notmuch_threads_get (threads); thread = notmuch_threads_get (threads);
messages = notmuch_thread_get_toplevel_messages (thread); messages = notmuch_thread_get_toplevel_messages (thread);
@ -1099,7 +1095,7 @@ do_show (void *ctx,
notmuch_thread_get_thread_id (thread)); notmuch_thread_get_thread_id (thread));
status = show_messages (ctx, format, sp, messages, 0, params); status = show_messages (ctx, format, sp, messages, 0, params);
if (status && !res) if (status && ! res)
res = status; res = status;
notmuch_thread_destroy (thread); notmuch_thread_destroy (thread);
@ -1175,24 +1171,24 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords = { .opt_keyword = &format, .name = "format", .keywords =
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
{ "text", NOTMUCH_FORMAT_TEXT }, { "text", NOTMUCH_FORMAT_TEXT },
{ "sexp", NOTMUCH_FORMAT_SEXP }, { "sexp", NOTMUCH_FORMAT_SEXP },
{ "mbox", NOTMUCH_FORMAT_MBOX }, { "mbox", NOTMUCH_FORMAT_MBOX },
{ "raw", NOTMUCH_FORMAT_RAW }, { "raw", NOTMUCH_FORMAT_RAW },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_int = &notmuch_format_version, .name = "format-version" }, { .opt_int = &notmuch_format_version, .name = "format-version" },
{ .opt_bool = &exclude, .name = "exclude" }, { .opt_bool = &exclude, .name = "exclude" },
{ .opt_bool = &params.entire_thread, .name = "entire-thread", { .opt_bool = &params.entire_thread, .name = "entire-thread",
.present = &entire_thread_set }, .present = &entire_thread_set },
{ .opt_int = &params.part, .name = "part" }, { .opt_int = &params.part, .name = "part" },
{ .opt_keyword = (int*)(&params.crypto.decrypt), .name = "decrypt", { .opt_keyword = (int *) (&params.crypto.decrypt), .name = "decrypt",
.keyword_no_arg_value = "true", .keywords = .keyword_no_arg_value = "true", .keywords =
(notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE }, (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
{ "auto", NOTMUCH_DECRYPT_AUTO }, { "auto", NOTMUCH_DECRYPT_AUTO },
{ "true", NOTMUCH_DECRYPT_NOSTASH }, { "true", NOTMUCH_DECRYPT_NOSTASH },
{ "stash", NOTMUCH_DECRYPT_TRUE }, { "stash", NOTMUCH_DECRYPT_TRUE },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_bool = &params.crypto.verify, .name = "verify" }, { .opt_bool = &params.crypto.verify, .name = "verify" },
{ .opt_bool = &params.output_body, .name = "body" }, { .opt_bool = &params.output_body, .name = "body" },
{ .opt_bool = &params.include_html, .name = "include-html" }, { .opt_bool = &params.include_html, .name = "include-html" },
@ -1240,7 +1236,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
(format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP)) (format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP))
params.entire_thread = true; params.entire_thread = true;
if (!params.output_body) { if (! params.output_body) {
if (params.part > 0) { if (params.part > 0) {
fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n"); fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
params.output_body = true; params.output_body = true;
@ -1254,13 +1250,13 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
} }
if (params.include_html && if (params.include_html &&
(format != NOTMUCH_FORMAT_TEXT && (format != NOTMUCH_FORMAT_TEXT &&
format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_JSON &&
format != NOTMUCH_FORMAT_SEXP)) { format != NOTMUCH_FORMAT_SEXP)) {
fprintf (stderr, "Warning: --include-html only implemented for format=text, format=json and format=sexp\n"); fprintf (stderr, "Warning: --include-html only implemented for format=text, format=json and format=sexp\n");
} }
query_string = query_string_from_args (config, argc-opt_index, argv+opt_index); query_string = query_string_from_args (config, argc - opt_index, argv + opt_index);
if (query_string == NULL) { if (query_string == NULL) {
fprintf (stderr, "Out of memory\n"); fprintf (stderr, "Out of memory\n");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -1288,7 +1284,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
/* Create structure printer. */ /* Create structure printer. */
formatter = formatters[format]; formatter = formatters[format];
sprinter = formatter->new_sprinter(config, stdout); sprinter = formatter->new_sprinter (config, stdout);
params.out_stream = g_mime_stream_stdout_new (); params.out_stream = g_mime_stream_stdout_new ();
@ -1305,7 +1301,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_status_t status; notmuch_status_t status;
search_exclude_tags = notmuch_config_get_search_exclude_tags search_exclude_tags = notmuch_config_get_search_exclude_tags
(config, &search_exclude_tags_length); (config, &search_exclude_tags_length);
for (i = 0; i < search_exclude_tags_length; i++) { for (i = 0; i < search_exclude_tags_length; i++) {
status = notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); status = notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
@ -1324,7 +1320,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
ret = do_show (config, query, formatter, sprinter, &params); ret = do_show (config, query, formatter, sprinter, &params);
} }
DONE: DONE :
g_mime_stream_flush (params.out_stream); g_mime_stream_flush (params.out_stream);
g_object_unref (params.out_stream); g_object_unref (params.out_stream);

View file

@ -39,14 +39,14 @@
* *
*/ */
#define MINUTE (60) #define MINUTE (60)
#define HOUR (60 * MINUTE) #define HOUR (60 *MINUTE)
#define DAY (24 * HOUR) #define DAY (24 *HOUR)
#define RELATIVE_DATE_MAX 20 #define RELATIVE_DATE_MAX 20
const char * const char *
notmuch_time_relative_date (const void *ctx, time_t then) notmuch_time_relative_date (const void *ctx, time_t then)
{ {
struct tm tm_now, tm_then; struct tm tm_now, tm_then;
time_t now = time(NULL); time_t now = time (NULL);
time_t delta; time_t delta;
char *result; char *result;
@ -76,26 +76,25 @@ notmuch_time_relative_date (const void *ctx, time_t then)
if (delta <= 7 * DAY) { if (delta <= 7 * DAY) {
if (tm_then.tm_wday == tm_now.tm_wday && if (tm_then.tm_wday == tm_now.tm_wday &&
delta < DAY) delta < DAY) {
{
strftime (result, RELATIVE_DATE_MAX, strftime (result, RELATIVE_DATE_MAX,
"Today %R", &tm_then); /* Today 12:30 */ "Today %R", &tm_then); /* Today 12:30 */
return result; return result;
} else if ((tm_now.tm_wday + 7 - tm_then.tm_wday) % 7 == 1) { } else if ((tm_now.tm_wday + 7 - tm_then.tm_wday) % 7 == 1) {
strftime (result, RELATIVE_DATE_MAX, strftime (result, RELATIVE_DATE_MAX,
"Yest. %R", &tm_then); /* Yest. 12:30 */ "Yest. %R", &tm_then); /* Yest. 12:30 */
return result; return result;
} else { } else {
if (tm_then.tm_wday != tm_now.tm_wday) { if (tm_then.tm_wday != tm_now.tm_wday) {
strftime (result, RELATIVE_DATE_MAX, strftime (result, RELATIVE_DATE_MAX,
"%a. %R", &tm_then); /* Mon. 12:30 */ "%a. %R", &tm_then); /* Mon. 12:30 */
return result; return result;
} }
} }
} }
strftime (result, RELATIVE_DATE_MAX, strftime (result, RELATIVE_DATE_MAX,
"%B %d", &tm_then); /* October 12 */ "%B %d", &tm_then); /* October 12 */
return result; return result;
} }
#undef MINUTE #undef MINUTE

View file

@ -61,9 +61,10 @@ const notmuch_opt_desc_t notmuch_shared_options [] = {
* notmuch_process_shared_options (subcommand_name); * notmuch_process_shared_options (subcommand_name);
*/ */
void void
notmuch_process_shared_options (const char *subcommand_name) { notmuch_process_shared_options (const char *subcommand_name)
{
if (print_version) { if (print_version) {
printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); printf ("notmuch " STRINGIFY (NOTMUCH_VERSION) "\n");
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }
@ -76,8 +77,9 @@ notmuch_process_shared_options (const char *subcommand_name) {
/* This is suitable for subcommands that do not actually open the /* This is suitable for subcommands that do not actually open the
* database. * database.
*/ */
int notmuch_minimal_options (const char *subcommand_name, int
int argc, char **argv) notmuch_minimal_options (const char *subcommand_name,
int argc, char **argv)
{ {
int opt_index; int opt_index;
@ -98,14 +100,14 @@ int notmuch_minimal_options (const char *subcommand_name,
struct _notmuch_client_indexing_cli_choices indexing_cli_choices = { }; struct _notmuch_client_indexing_cli_choices indexing_cli_choices = { };
const notmuch_opt_desc_t notmuch_shared_indexing_options [] = { const notmuch_opt_desc_t notmuch_shared_indexing_options [] = {
{ .opt_keyword = &indexing_cli_choices.decrypt_policy, { .opt_keyword = &indexing_cli_choices.decrypt_policy,
.present = &indexing_cli_choices.decrypt_policy_set, .keywords = .present = &indexing_cli_choices.decrypt_policy_set, .keywords =
(notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE }, (notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
{ "true", NOTMUCH_DECRYPT_TRUE }, { "true", NOTMUCH_DECRYPT_TRUE },
{ "auto", NOTMUCH_DECRYPT_AUTO }, { "auto", NOTMUCH_DECRYPT_AUTO },
{ "nostash", NOTMUCH_DECRYPT_NOSTASH }, { "nostash", NOTMUCH_DECRYPT_NOSTASH },
{ 0, 0 } }, { 0, 0 } },
.name = "decrypt" }, .name = "decrypt" },
{ } { }
}; };
@ -192,7 +194,7 @@ find_command (const char *name)
size_t i; size_t i;
for (i = 0; i < ARRAY_SIZE (commands); i++) for (i = 0; i < ARRAY_SIZE (commands); i++)
if ((!name && !commands[i].name) || if ((! name && ! commands[i].name) ||
(name && commands[i].name && strcmp (name, commands[i].name) == 0)) (name && commands[i].name && strcmp (name, commands[i].name) == 0))
return &commands[i]; return &commands[i];
@ -270,11 +272,11 @@ notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch)
{ {
const char *uuid = NULL; const char *uuid = NULL;
if (!notmuch_requested_db_uuid) if (! notmuch_requested_db_uuid)
return; return;
IGNORE_RESULT (notmuch_database_get_revision (notmuch, &uuid)); IGNORE_RESULT (notmuch_database_get_revision (notmuch, &uuid));
if (strcmp (notmuch_requested_db_uuid, uuid) != 0){ if (strcmp (notmuch_requested_db_uuid, uuid) != 0) {
fprintf (stderr, "Error: requested database revision %s does not match %s\n", fprintf (stderr, "Error: requested database revision %s does not match %s\n",
notmuch_requested_db_uuid, uuid); notmuch_requested_db_uuid, uuid);
exit (1); exit (1);
@ -297,7 +299,7 @@ _help_for (const char *topic_name)
help_topic_t *topic; help_topic_t *topic;
unsigned int i; unsigned int i;
if (!topic_name) { if (! topic_name) {
printf ("The notmuch mail system.\n\n"); printf ("The notmuch mail system.\n\n");
usage (stdout); usage (stdout);
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -333,7 +335,7 @@ _help_for (const char *topic_name)
} }
static int static int
notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]) notmuch_help_command (unused (notmuch_config_t *config), int argc, char *argv[])
{ {
int opt_index; int opt_index;
@ -342,8 +344,8 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
return EXIT_FAILURE; return EXIT_FAILURE;
/* skip at least subcommand argument */ /* skip at least subcommand argument */
argc-= opt_index; argc -= opt_index;
argv+= opt_index; argv += opt_index;
if (argc == 0) { if (argc == 0) {
return _help_for (NULL); return _help_for (NULL);
@ -417,7 +419,8 @@ notmuch_command (notmuch_config_t *config,
* executed. Return true if external command is not found. Return * executed. Return true if external command is not found. Return
* false on errors. * false on errors.
*/ */
static bool try_external_command(char *argv[]) static bool
try_external_command (char *argv[])
{ {
char *old_argv0 = argv[0]; char *old_argv0 = argv[0];
bool ret = true; bool ret = true;
@ -431,7 +434,7 @@ static bool try_external_command(char *argv[])
execvp (argv[0], argv); execvp (argv[0], argv);
if (errno != ENOENT) { if (errno != ENOENT) {
fprintf (stderr, "Error: Running external command '%s' failed: %s\n", fprintf (stderr, "Error: Running external command '%s' failed: %s\n",
argv[0], strerror(errno)); argv[0], strerror (errno));
ret = false; ret = false;
} }
@ -464,7 +467,7 @@ main (int argc, char *argv[])
local = talloc_new (NULL); local = talloc_new (NULL);
g_mime_init (); g_mime_init ();
#if !GLIB_CHECK_VERSION(2, 35, 1) #if ! GLIB_CHECK_VERSION (2, 35, 1)
g_type_init (); g_type_init ();
#endif #endif
@ -484,9 +487,9 @@ main (int argc, char *argv[])
command = find_command (command_name); command = find_command (command_name);
/* if command->function is NULL, try external command */ /* if command->function is NULL, try external command */
if (!command || !command->function) { if (! command || ! command->function) {
/* This won't return if the external command is found. */ /* This won't return if the external command is found. */
if (try_external_command(argv + opt_index)) if (try_external_command (argv + opt_index))
fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
command_name); command_name);
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
@ -494,7 +497,7 @@ main (int argc, char *argv[])
} }
config = notmuch_config_open (local, config_file_name, command->config_mode); config = notmuch_config_open (local, config_file_name, command->config_mode);
if (!config) { if (! config) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto DONE; goto DONE;
} }

View file

@ -13,15 +13,15 @@ typedef struct sprinter {
* a sequence of alternating calls to map_key and one of the * a sequence of alternating calls to map_key and one of the
* value-printing functions until the map is ended by end. * value-printing functions until the map is ended by end.
*/ */
void (*begin_map) (struct sprinter *); void (*begin_map)(struct sprinter *);
/* Start a new list/array structure. /* Start a new list/array structure.
*/ */
void (*begin_list) (struct sprinter *); void (*begin_list)(struct sprinter *);
/* End the last opened list or map structure. /* End the last opened list or map structure.
*/ */
void (*end) (struct sprinter *); void (*end)(struct sprinter *);
/* Print one string/integer/boolean/null element (possibly inside /* Print one string/integer/boolean/null element (possibly inside
* a list or map, followed or preceded by separators). For string * a list or map, followed or preceded by separators). For string
@ -31,16 +31,16 @@ typedef struct sprinter {
* string (but not string_len) the string pointer passed may be * string (but not string_len) the string pointer passed may be
* NULL. * NULL.
*/ */
void (*string) (struct sprinter *, const char *); void (*string)(struct sprinter *, const char *);
void (*string_len) (struct sprinter *, const char *, size_t); void (*string_len)(struct sprinter *, const char *, size_t);
void (*integer) (struct sprinter *, int); void (*integer)(struct sprinter *, int);
void (*boolean) (struct sprinter *, bool); void (*boolean)(struct sprinter *, bool);
void (*null) (struct sprinter *); void (*null)(struct sprinter *);
/* Print the key of a map's key/value pair. The char * must be UTF-8 /* Print the key of a map's key/value pair. The char * must be UTF-8
* encoded. * encoded.
*/ */
void (*map_key) (struct sprinter *, const char *); void (*map_key)(struct sprinter *, const char *);
/* Insert a separator (usually extra whitespace). For the text /* Insert a separator (usually extra whitespace). For the text
* printers, this is a syntactic separator. For the structured * printers, this is a syntactic separator. For the structured
@ -48,13 +48,13 @@ typedef struct sprinter {
* the abstract syntax of the structure being printed. For JSON, * the abstract syntax of the structure being printed. For JSON,
* this could simply be a line break. * this could simply be a line break.
*/ */
void (*separator) (struct sprinter *); void (*separator)(struct sprinter *);
/* Set the current string prefix. This only affects the text /* Set the current string prefix. This only affects the text
* printer, which will print this string, followed by a colon, * printer, which will print this string, followed by a colon,
* before any string. For other printers, this does nothing. * before any string. For other printers, this does nothing.
*/ */
void (*set_prefix) (struct sprinter *, const char *); void (*set_prefix)(struct sprinter *, const char *);
/* True if this is the special-cased plain text printer. /* True if this is the special-cased plain text printer.
*/ */

View file

@ -42,8 +42,8 @@ print_status_message (const char *loc,
notmuch_status_t notmuch_status_t
print_status_database (const char *loc, print_status_database (const char *loc,
const notmuch_database_t *notmuch, const notmuch_database_t *notmuch,
notmuch_status_t status) notmuch_status_t status)
{ {
if (status) { if (status) {
const char *msg; const char *msg;

View file

@ -8,25 +8,25 @@ typedef struct _tag_op_list_t tag_op_list_t;
/* Use powers of 2 */ /* Use powers of 2 */
typedef enum { typedef enum {
TAG_FLAG_NONE = 0, TAG_FLAG_NONE = 0,
/* Operations are synced to maildir, if possible. /* Operations are synced to maildir, if possible.
*/ */
TAG_FLAG_MAILDIR_SYNC = (1 << 0), TAG_FLAG_MAILDIR_SYNC = (1 << 0),
/* Remove all tags from message before applying list. /* Remove all tags from message before applying list.
*/ */
TAG_FLAG_REMOVE_ALL = (1 << 1), TAG_FLAG_REMOVE_ALL = (1 << 1),
/* Don't try to avoid database operations. Useful when we /* Don't try to avoid database operations. Useful when we
* know that message passed needs these operations. * know that message passed needs these operations.
*/ */
TAG_FLAG_PRE_OPTIMIZED = (1 << 2), TAG_FLAG_PRE_OPTIMIZED = (1 << 2),
/* Accept strange tags that might be user error; /* Accept strange tags that might be user error;
* intended for use by notmuch-restore. * intended for use by notmuch-restore.
*/ */
TAG_FLAG_BE_GENEROUS = (1 << 3) TAG_FLAG_BE_GENEROUS = (1 << 3)
} tag_op_flag_t; } tag_op_flag_t;
@ -34,16 +34,16 @@ typedef enum {
* skipped lines are positive. * skipped lines are positive.
*/ */
typedef enum { typedef enum {
TAG_PARSE_OUT_OF_MEMORY = -1, TAG_PARSE_OUT_OF_MEMORY = -1,
/* Line parsed successfully. */ /* Line parsed successfully. */
TAG_PARSE_SUCCESS = 0, TAG_PARSE_SUCCESS = 0,
/* Line has a syntax error */ /* Line has a syntax error */
TAG_PARSE_INVALID = 1, TAG_PARSE_INVALID = 1,
/* Line was blank or a comment */ /* Line was blank or a comment */
TAG_PARSE_SKIPPED = 2 TAG_PARSE_SKIPPED = 2
} tag_parse_status_t; } tag_parse_status_t;