mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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:
parent
be8f0ba92a
commit
33382c2b5b
24 changed files with 609 additions and 609 deletions
|
@ -11,10 +11,10 @@ typedef enum {
|
|||
} opt_handled;
|
||||
|
||||
/*
|
||||
Search the array of keywords for a given argument, assigning the
|
||||
output variable to the corresponding value. Return false if nothing
|
||||
matches.
|
||||
*/
|
||||
* Search the array of keywords for a given argument, assigning the
|
||||
* output variable to the corresponding value. Return false if nothing
|
||||
* matches.
|
||||
*/
|
||||
|
||||
static opt_handled
|
||||
_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
|
||||
_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;
|
||||
|
||||
if (next == '\0' || arg_str[0] == '\0') {
|
||||
fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
|
||||
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
|
||||
_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') {
|
||||
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. */
|
||||
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
|
||||
(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. */
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
that does not exist.
|
||||
*/
|
||||
* Search for the {pos_arg_index}th position argument, return false if
|
||||
* that does not exist.
|
||||
*/
|
||||
|
||||
bool
|
||||
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;
|
||||
|
||||
while (_opt_valid (arg_desc)) {
|
||||
if (arg_desc->opt_position) {
|
||||
if (pos_arg_counter == pos_arg_index) {
|
||||
|
@ -176,12 +183,12 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
|
|||
int
|
||||
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];
|
||||
|
||||
assert(_arg);
|
||||
assert(options);
|
||||
assert (_arg);
|
||||
assert (options);
|
||||
|
||||
const char *arg = _arg + 2; /* _arg starts with -- */
|
||||
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) {
|
||||
next = ' ';
|
||||
value = next_arg;
|
||||
opt_index ++;
|
||||
opt_index++;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (lookahead && opt_status == OPT_GIVEBACK)
|
||||
opt_index --;
|
||||
opt_index--;
|
||||
|
||||
if (try->present)
|
||||
*try->present = true;
|
||||
|
||||
return opt_index+1;
|
||||
return opt_index + 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 */
|
||||
int
|
||||
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;
|
||||
bool more_args = true;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -290,7 +298,7 @@ parse_arguments (int argc, char **argv,
|
|||
int prev_opt_index = opt_index;
|
||||
|
||||
if (strlen (argv[opt_index]) == 2)
|
||||
return opt_index+1;
|
||||
return opt_index + 1;
|
||||
|
||||
opt_index = parse_option (argc, argv, options, opt_index);
|
||||
if (opt_index < 0) {
|
||||
|
|
|
@ -45,20 +45,20 @@ typedef struct notmuch_opt_desc {
|
|||
|
||||
|
||||
/*
|
||||
This is the main entry point for command line argument parsing.
|
||||
|
||||
Parse command line arguments according to structure options,
|
||||
starting at position opt_index.
|
||||
|
||||
All output of parsed values is via pointers in options.
|
||||
|
||||
Parsing stops at -- (consumed) or at the (k+1)st argument
|
||||
not starting with -- (a "positional argument") if options contains
|
||||
k positional argument descriptors.
|
||||
|
||||
Returns the index of first non-parsed argument, or -1 in case of error.
|
||||
|
||||
*/
|
||||
* This is the main entry point for command line argument parsing.
|
||||
*
|
||||
* Parse command line arguments according to structure options,
|
||||
* starting at position opt_index.
|
||||
*
|
||||
* All output of parsed values is via pointers in options.
|
||||
*
|
||||
* Parsing stops at -- (consumed) or at the (k+1)st argument
|
||||
* not starting with -- (a "positional argument") if options contains
|
||||
* k positional argument descriptors.
|
||||
*
|
||||
* Returns the index of first non-parsed argument, or -1 in case of error.
|
||||
*
|
||||
*/
|
||||
int
|
||||
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
|
||||
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
|
||||
parse_position_arg (const char *arg,
|
||||
int position_arg_index,
|
||||
const notmuch_opt_desc_t* options);
|
||||
const notmuch_opt_desc_t *options);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,8 +39,7 @@ debugger_is_active (void)
|
|||
|
||||
sprintf (buf, "/proc/%d/exe", getppid ());
|
||||
if (readlink (buf, buf2, sizeof (buf2)) != -1 &&
|
||||
strncmp (basename (buf2), "gdb", 3) == 0)
|
||||
{
|
||||
strncmp (basename (buf2), "gdb", 3) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ g_mime_filter_reply_get_type (void)
|
|||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type) {
|
||||
if (! type) {
|
||||
static const GTypeInfo info = {
|
||||
.class_size = sizeof (GMimeFilterReplyClass),
|
||||
.base_init = NULL,
|
||||
|
|
4
hooks.c
4
hooks.c
|
@ -53,7 +53,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
|
|||
/* Flush any buffered output before forking. */
|
||||
fflush (stdout);
|
||||
|
||||
pid = fork();
|
||||
pid = fork ();
|
||||
if (pid == -1) {
|
||||
fprintf (stderr, "Error: %s hook fork failed: %s\n", hook,
|
||||
strerror (errno));
|
||||
|
@ -78,7 +78,7 @@ notmuch_run_hook (const char *db_path, const char *hook)
|
|||
goto DONE;
|
||||
}
|
||||
|
||||
if (!WIFEXITED (status) || WEXITSTATUS (status)) {
|
||||
if (! WIFEXITED (status) || WEXITSTATUS (status)) {
|
||||
if (WIFEXITED (status)) {
|
||||
fprintf (stderr, "Error: %s hook failed with status %d\n",
|
||||
hook, WEXITSTATUS (status));
|
||||
|
|
18
mime-node.c
18
mime-node.c
|
@ -55,7 +55,7 @@ _mime_node_context_free (mime_node_context_t *res)
|
|||
return 0;
|
||||
}
|
||||
|
||||
const _notmuch_message_crypto_t*
|
||||
const _notmuch_message_crypto_t *
|
||||
mime_node_get_message_crypto_status (mime_node_t *node)
|
||||
{
|
||||
return node->ctx->msg_crypto;
|
||||
|
@ -97,8 +97,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
|
|||
notmuch_filenames_t *filenames;
|
||||
for (filenames = notmuch_message_get_filenames (message);
|
||||
notmuch_filenames_valid (filenames);
|
||||
notmuch_filenames_move_to_next (filenames))
|
||||
{
|
||||
notmuch_filenames_move_to_next (filenames)) {
|
||||
filename = notmuch_filenames_get (filenames);
|
||||
fd = open (filename, O_RDONLY);
|
||||
if (fd != -1)
|
||||
|
@ -115,21 +114,21 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
|
|||
}
|
||||
|
||||
mctx->stream = g_mime_stream_gzfile_new (fd);
|
||||
if (!mctx->stream) {
|
||||
if (! mctx->stream) {
|
||||
fprintf (stderr, "Out of memory.\n");
|
||||
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
|
||||
if (!mctx->parser) {
|
||||
if (! mctx->parser) {
|
||||
fprintf (stderr, "Out of memory.\n");
|
||||
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
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);
|
||||
status = NOTMUCH_STATUS_FILE_ERROR;
|
||||
goto DONE;
|
||||
|
@ -153,7 +152,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
|
|||
*root_out = root;
|
||||
return NOTMUCH_STATUS_SUCCESS;
|
||||
|
||||
DONE:
|
||||
DONE:
|
||||
talloc_free (root);
|
||||
return status;
|
||||
}
|
||||
|
@ -171,6 +170,7 @@ static void
|
|||
set_signature_list_destructor (mime_node_t *node)
|
||||
{
|
||||
GMimeSignatureList **proxy = talloc (node, GMimeSignatureList *);
|
||||
|
||||
if (proxy) {
|
||||
*proxy = node->sig_list;
|
||||
talloc_set_destructor (proxy, _signature_list_free);
|
||||
|
@ -273,7 +273,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part, int numchild)
|
|||
/* Set basic node properties */
|
||||
node->part = part;
|
||||
node->ctx = parent->ctx;
|
||||
if (!talloc_reference (node, node->ctx)) {
|
||||
if (! talloc_reference (node, node->ctx)) {
|
||||
fprintf (stderr, "Out of memory.\n");
|
||||
talloc_free (node);
|
||||
return NULL;
|
||||
|
@ -335,7 +335,7 @@ mime_node_child (mime_node_t *parent, int child)
|
|||
GMimeObject *sub;
|
||||
mime_node_t *node;
|
||||
|
||||
if (!parent || !parent->part || child < 0 || child >= parent->nchildren)
|
||||
if (! parent || ! parent->part || child < 0 || child >= parent->nchildren)
|
||||
return NULL;
|
||||
|
||||
if (GMIME_IS_MULTIPART (parent->part)) {
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
#define unused(x) x ## _unused __attribute__ ((unused))
|
||||
|
||||
#define STRINGIFY(s) STRINGIFY_(s)
|
||||
#define STRINGIFY(s) STRINGIFY_ (s)
|
||||
#define STRINGIFY_(s) #s
|
||||
|
||||
typedef struct mime_node mime_node_t;
|
||||
|
@ -63,8 +63,8 @@ struct sprinter;
|
|||
struct notmuch_show_params;
|
||||
|
||||
typedef struct notmuch_show_format {
|
||||
struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
|
||||
notmuch_status_t (*part) (const void *ctx, struct sprinter *sprinter,
|
||||
struct sprinter *(*new_sprinter)(const void *ctx, FILE *stream);
|
||||
notmuch_status_t (*part)(const void *ctx, struct sprinter *sprinter,
|
||||
struct mime_node *node, int indent,
|
||||
const struct notmuch_show_params *params);
|
||||
} notmuch_show_format_t;
|
||||
|
@ -87,7 +87,7 @@ typedef struct notmuch_show_params {
|
|||
*/
|
||||
#define INTERNAL_ERROR(format, ...) \
|
||||
do { \
|
||||
fprintf(stderr, \
|
||||
fprintf (stderr, \
|
||||
"Internal error: " format " (%s)\n", \
|
||||
##__VA_ARGS__, __location__); \
|
||||
exit (1); \
|
||||
|
@ -101,8 +101,8 @@ typedef struct notmuch_show_params {
|
|||
static inline void
|
||||
chomp_newline (char *str)
|
||||
{
|
||||
if (str && str[strlen(str)-1] == '\n')
|
||||
str[strlen(str)-1] = '\0';
|
||||
if (str && str[strlen (str) - 1] == '\n')
|
||||
str[strlen (str) - 1] = '\0';
|
||||
}
|
||||
|
||||
/* Exit status code indicating temporary failure; user is invited to
|
||||
|
@ -388,7 +388,7 @@ struct mime_node {
|
|||
|
||||
/* The list of signatures for signed or encrypted containers. If
|
||||
* there are no signatures, this will be NULL. */
|
||||
GMimeSignatureList* sig_list;
|
||||
GMimeSignatureList *sig_list;
|
||||
|
||||
/* Internal: Context inherited from the root iterator. */
|
||||
struct mime_node_context *ctx;
|
||||
|
@ -435,11 +435,11 @@ mime_node_t *
|
|||
mime_node_child (mime_node_t *parent, int child);
|
||||
|
||||
/* 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_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);
|
||||
|
||||
typedef enum dump_formats {
|
||||
|
@ -467,8 +467,8 @@ notmuch_database_dump (notmuch_database_t *notmuch,
|
|||
bool gzip_output);
|
||||
|
||||
/* If status is non-zero (i.e. error) print appropriate
|
||||
messages to stderr.
|
||||
*/
|
||||
* messages to stderr.
|
||||
*/
|
||||
|
||||
notmuch_status_t
|
||||
print_status_query (const char *loc,
|
||||
|
@ -494,8 +494,8 @@ extern const char *notmuch_requested_db_uuid;
|
|||
extern const notmuch_opt_desc_t notmuch_shared_options [];
|
||||
void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
|
||||
|
||||
void notmuch_process_shared_options (const char* subcommand_name);
|
||||
int notmuch_minimal_options (const char* subcommand_name,
|
||||
void notmuch_process_shared_options (const char *subcommand_name);
|
||||
int notmuch_minimal_options (const char *subcommand_name,
|
||||
int argc, char **argv);
|
||||
|
||||
|
||||
|
@ -504,7 +504,7 @@ int notmuch_minimal_options (const char* subcommand_name,
|
|||
struct _notmuch_client_indexing_cli_choices {
|
||||
int decrypt_policy;
|
||||
bool decrypt_policy_set;
|
||||
notmuch_indexopts_t * opts;
|
||||
notmuch_indexopts_t *opts;
|
||||
};
|
||||
extern struct _notmuch_client_indexing_cli_choices indexing_cli_choices;
|
||||
extern const notmuch_opt_desc_t notmuch_shared_indexing_options [];
|
||||
|
|
|
@ -151,14 +151,14 @@ get_name_from_passwd_file (void *ctx)
|
|||
char *name;
|
||||
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;
|
||||
pw_buf = talloc_size (ctx, pw_buf_size);
|
||||
|
||||
while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
|
||||
pw_buf_size, &ignored)) == ERANGE) {
|
||||
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) {
|
||||
|
@ -186,14 +186,14 @@ get_username_from_passwd_file (void *ctx)
|
|||
char *name;
|
||||
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;
|
||||
pw_buf = talloc_zero_size (ctx, pw_buf_size);
|
||||
|
||||
while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
|
||||
pw_buf_size, &ignored)) == ERANGE) {
|
||||
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)
|
||||
|
@ -217,7 +217,7 @@ get_config_from_file (notmuch_config_t *config, bool create_new)
|
|||
GError *error = NULL;
|
||||
bool ret = false;
|
||||
|
||||
FILE *fp = fopen(config->filename, "r");
|
||||
FILE *fp = fopen (config->filename, "r");
|
||||
if (fp == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
/* 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 {
|
||||
fprintf (stderr, "Error opening config file '%s': %s\n",
|
||||
config->filename, strerror(errno));
|
||||
config->filename, strerror (errno));
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
@ -274,12 +274,12 @@ get_config_from_file (notmuch_config_t *config, bool create_new)
|
|||
|
||||
g_error_free (error);
|
||||
|
||||
out:
|
||||
out:
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
fclose (fp);
|
||||
|
||||
if (config_str)
|
||||
talloc_free(config_str);
|
||||
talloc_free (config_str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ out:
|
|||
*
|
||||
* If is_new_ret is NULL, then a "file not found" message will be
|
||||
* printed to stderr and NULL will be returned.
|
||||
|
||||
*
|
||||
* 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
|
||||
* the caller can recognize this case.
|
||||
|
@ -338,6 +338,7 @@ notmuch_config_open (void *ctx,
|
|||
int file_had_crypto_group;
|
||||
|
||||
notmuch_config_t *config = talloc_zero (ctx, notmuch_config_t);
|
||||
|
||||
if (config == NULL) {
|
||||
fprintf (stderr, "Out of memory.\n");
|
||||
return NULL;
|
||||
|
@ -503,7 +504,7 @@ notmuch_config_open (void *ctx,
|
|||
* Note: Any changes made to the configuration are *not* saved by this
|
||||
* function. To save changes, call notmuch_config_save before
|
||||
* notmuch_config_close.
|
||||
*/
|
||||
*/
|
||||
void
|
||||
notmuch_config_close (notmuch_config_t *config)
|
||||
{
|
||||
|
@ -605,7 +606,7 @@ _config_get_list (notmuch_config_t *config,
|
|||
const char *section, const char *key,
|
||||
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 */
|
||||
if (*outlist == NULL) {
|
||||
|
@ -648,7 +649,7 @@ _config_set_list (notmuch_config_t *config,
|
|||
const char *
|
||||
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 the path in the configuration file begins with any
|
||||
|
@ -779,7 +780,7 @@ _item_split (char *item, char **group, char **key)
|
|||
*group = item;
|
||||
|
||||
period = strchr (item, '.');
|
||||
if (period == NULL || *(period+1) == '\0') {
|
||||
if (period == NULL || *(period + 1) == '\0') {
|
||||
fprintf (stderr,
|
||||
"Invalid configuration name: %s\n"
|
||||
"(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
|
||||
docs call them prefixes, so make the error message match */
|
||||
* docs call them prefixes, so make the error message match */
|
||||
static bool
|
||||
validate_field_name (const char *str)
|
||||
{
|
||||
|
@ -839,10 +840,10 @@ typedef struct config_key {
|
|||
} config_key_info_t;
|
||||
|
||||
static struct config_key
|
||||
config_key_table[] = {
|
||||
{"index.decrypt", true, false, NULL},
|
||||
{"index.header.", true, true, validate_field_name},
|
||||
{"query.", true, true, NULL},
|
||||
config_key_table[] = {
|
||||
{ "index.decrypt", true, false, NULL },
|
||||
{ "index.header.", true, true, validate_field_name },
|
||||
{ "query.", true, true, NULL },
|
||||
};
|
||||
|
||||
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++) {
|
||||
if (config_key_table[i].prefix &&
|
||||
strncmp (item, config_key_table[i].name,
|
||||
strlen(config_key_table[i].name)) == 0)
|
||||
return config_key_table+i;
|
||||
strlen (config_key_table[i].name)) == 0)
|
||||
return config_key_table + i;
|
||||
if (strcmp (item, config_key_table[i].name) == 0)
|
||||
return config_key_table+i;
|
||||
return config_key_table + i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -863,13 +864,14 @@ static bool
|
|||
_stored_in_db (const char *item)
|
||||
{
|
||||
config_key_info_t *info;
|
||||
|
||||
info = _config_key_info (item);
|
||||
|
||||
return (info && info->in_db);
|
||||
}
|
||||
|
||||
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;
|
||||
char *val;
|
||||
|
@ -892,20 +894,20 @@ _print_db_config(notmuch_config_t *config, const char *name)
|
|||
static int
|
||||
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));
|
||||
} else if (strcmp(item, "user.name") == 0) {
|
||||
} else if (strcmp (item, "user.name") == 0) {
|
||||
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));
|
||||
} else if (strcmp(item, "user.other_email") == 0) {
|
||||
} else if (strcmp (item, "user.other_email") == 0) {
|
||||
const char **other_email;
|
||||
size_t i, length;
|
||||
|
||||
other_email = notmuch_config_get_user_other_email (config, &length);
|
||||
for (i = 0; i < length; i++)
|
||||
printf ("%s\n", other_email[i]);
|
||||
} else if (strcmp(item, "new.tags") == 0) {
|
||||
} else if (strcmp (item, "new.tags") == 0) {
|
||||
const char **tags;
|
||||
size_t i, length;
|
||||
|
||||
|
@ -944,7 +946,7 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
|
|||
}
|
||||
|
||||
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;
|
||||
const char *val = "";
|
||||
|
@ -1025,13 +1027,13 @@ static
|
|||
void
|
||||
_notmuch_config_list_built_with ()
|
||||
{
|
||||
printf("%scompact=%s\n",
|
||||
printf ("%scompact=%s\n",
|
||||
BUILT_WITH_PREFIX,
|
||||
notmuch_built_with ("compact") ? "true" : "false");
|
||||
printf("%sfield_processor=%s\n",
|
||||
printf ("%sfield_processor=%s\n",
|
||||
BUILT_WITH_PREFIX,
|
||||
notmuch_built_with ("field_processor") ? "true" : "false");
|
||||
printf("%sretry_lock=%s\n",
|
||||
printf ("%sretry_lock=%s\n",
|
||||
BUILT_WITH_PREFIX,
|
||||
notmuch_built_with ("retry_lock") ? "true" : "false");
|
||||
}
|
||||
|
@ -1054,7 +1056,7 @@ _list_db_config (notmuch_config_t *config)
|
|||
return EXIT_FAILURE;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1115,8 +1117,8 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
notmuch_requested_db_uuid);
|
||||
|
||||
/* skip at least subcommand argument */
|
||||
argc-= opt_index;
|
||||
argv+= opt_index;
|
||||
argc -= opt_index;
|
||||
argv += opt_index;
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf (stderr, "Error: notmuch config requires at least one argument.\n");
|
||||
|
|
|
@ -220,7 +220,7 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,
|
|||
|
||||
if (include & DUMP_INCLUDE_CONFIG) {
|
||||
if (print_status_database ("notmuch dump", notmuch,
|
||||
database_dump_config(notmuch,output)))
|
||||
database_dump_config (notmuch, output)))
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
{ .opt_flags = &include, .name = "include", .keywords =
|
||||
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
||||
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
||||
{ "tags", DUMP_INCLUDE_TAGS} } },
|
||||
{ "tags", DUMP_INCLUDE_TAGS } } },
|
||||
{ .opt_string = &output_file_name, .name = "output" },
|
||||
{ .opt_bool = &gzip_output, .name = "gzip" },
|
||||
{ .opt_inherit = notmuch_shared_options },
|
||||
|
|
|
@ -99,7 +99,7 @@ is_valid_folder_name (const char *folder)
|
|||
if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))
|
||||
return false;
|
||||
p = strchr (p, '/');
|
||||
if (!p)
|
||||
if (! p)
|
||||
return true;
|
||||
p++;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ copy_fd (int fdout, int fdin)
|
|||
} 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;
|
||||
|
||||
FAIL:
|
||||
FAIL:
|
||||
close (fdout);
|
||||
unlink (path);
|
||||
|
||||
|
@ -360,7 +360,7 @@ maildir_write_new (const void *ctx, int fdin, const char *maildir, bool world_re
|
|||
|
||||
return newpath;
|
||||
|
||||
FAIL:
|
||||
FAIL:
|
||||
unlink (cleanpath);
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -87,7 +87,7 @@ handle_sigint (unused (int sig))
|
|||
* 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
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -191,16 +191,16 @@ dirent_type (const char *path, const struct dirent *entry)
|
|||
[DT_REG] = S_IFREG,
|
||||
[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];
|
||||
#endif
|
||||
|
||||
abspath = talloc_asprintf (NULL, "%s/%s", path, entry->d_name);
|
||||
if (!abspath) {
|
||||
if (! abspath) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
err = stat(abspath, &statbuf);
|
||||
err = stat (abspath, &statbuf);
|
||||
saved_errno = errno;
|
||||
talloc_free (abspath);
|
||||
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)
|
||||
continue;
|
||||
|
||||
if (strcmp(entries[i]->d_name, "new") == 0 ||
|
||||
strcmp(entries[i]->d_name, "cur") == 0 ||
|
||||
strcmp(entries[i]->d_name, "tmp") == 0)
|
||||
{
|
||||
if (strcmp (entries[i]->d_name, "new") == 0 ||
|
||||
strcmp (entries[i]->d_name, "cur") == 0 ||
|
||||
strcmp (entries[i]->d_name, "tmp") == 0) {
|
||||
found++;
|
||||
if (found == 3)
|
||||
return 1;
|
||||
|
@ -389,8 +388,8 @@ add_file (notmuch_database_t *notmuch, const char *filename,
|
|||
notmuch_message_maildir_flags_to_tags (message);
|
||||
|
||||
for (tag = state->new_tags; *tag != NULL; tag++) {
|
||||
if (strcmp ("unread", *tag) !=0 ||
|
||||
!notmuch_message_has_maildir_flag (message, 'S')) {
|
||||
if (strcmp ("unread", *tag) != 0 ||
|
||||
! notmuch_message_has_maildir_flag (message, 'S')) {
|
||||
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_XAPIAN_EXCEPTION:
|
||||
case NOTMUCH_STATUS_OUT_OF_MEMORY:
|
||||
(void) print_status_database("add_file", notmuch, status);
|
||||
(void) print_status_database ("add_file", notmuch, status);
|
||||
goto DONE;
|
||||
default:
|
||||
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
|
||||
* database agrees that there are no sub-directories. */
|
||||
db_subdirs = notmuch_directory_get_child_directories (directory);
|
||||
if (!notmuch_filenames_valid (db_subdirs))
|
||||
if (! notmuch_filenames_valid (db_subdirs))
|
||||
goto DONE;
|
||||
notmuch_filenames_destroy (db_subdirs);
|
||||
db_subdirs = NULL;
|
||||
|
@ -648,8 +647,7 @@ add_files (notmuch_database_t *notmuch,
|
|||
/* Check if we've walked past any names in db_files or
|
||||
* db_subdirs. If so, these have been deleted. */
|
||||
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,
|
||||
"%s/%s", path,
|
||||
notmuch_filenames_get (db_files));
|
||||
|
@ -664,12 +662,10 @@ add_files (notmuch_database_t *notmuch,
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
if (strcmp (filename, entry->d_name) < 0)
|
||||
{
|
||||
if (strcmp (filename, entry->d_name) < 0) {
|
||||
char *absolute = talloc_asprintf (state->removed_directories,
|
||||
"%s/%s", path, filename);
|
||||
if (state->debug)
|
||||
|
@ -694,8 +690,7 @@ add_files (notmuch_database_t *notmuch,
|
|||
|
||||
/* Don't add a file that we've added before. */
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
@ -708,12 +703,12 @@ add_files (notmuch_database_t *notmuch,
|
|||
|
||||
if (state->verbosity >= VERBOSITY_VERBOSE) {
|
||||
if (state->output_is_a_tty)
|
||||
printf("\r\033[K");
|
||||
printf ("\r\033[K");
|
||||
|
||||
printf ("%i/%i: %s", state->processed_files, state->total_files,
|
||||
next);
|
||||
|
||||
putchar((state->output_is_a_tty) ? '\r' : '\n');
|
||||
putchar ((state->output_is_a_tty) ? '\r' : '\n');
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
|
@ -738,8 +733,7 @@ add_files (notmuch_database_t *notmuch,
|
|||
|
||||
/* Now that we've walked the whole filesystem list, anything left
|
||||
* 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,
|
||||
"%s/%s", path,
|
||||
notmuch_filenames_get (db_files));
|
||||
|
@ -752,8 +746,7 @@ add_files (notmuch_database_t *notmuch,
|
|||
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,
|
||||
"%s/%s", path,
|
||||
notmuch_filenames_get (db_subdirs));
|
||||
|
@ -939,6 +932,7 @@ remove_filename (notmuch_database_t *notmuch,
|
|||
{
|
||||
notmuch_status_t status;
|
||||
notmuch_message_t *message;
|
||||
|
||||
status = notmuch_database_begin_atomic (notmuch);
|
||||
if (status)
|
||||
return status;
|
||||
|
@ -976,13 +970,12 @@ _remove_directory (void *ctx,
|
|||
char *absolute;
|
||||
|
||||
status = notmuch_database_get_directory (notmuch, path, &directory);
|
||||
if (status || !directory)
|
||||
if (status || ! directory)
|
||||
return status;
|
||||
|
||||
for (files = notmuch_directory_get_child_files (directory);
|
||||
notmuch_filenames_valid (files);
|
||||
notmuch_filenames_move_to_next (files))
|
||||
{
|
||||
notmuch_filenames_move_to_next (files)) {
|
||||
absolute = talloc_asprintf (ctx, "%s/%s", path,
|
||||
notmuch_filenames_get (files));
|
||||
status = remove_filename (notmuch, absolute, add_files_state);
|
||||
|
@ -993,8 +986,7 @@ _remove_directory (void *ctx,
|
|||
|
||||
for (subdirs = notmuch_directory_get_child_directories (directory);
|
||||
notmuch_filenames_valid (subdirs);
|
||||
notmuch_filenames_move_to_next (subdirs))
|
||||
{
|
||||
notmuch_filenames_move_to_next (subdirs)) {
|
||||
absolute = talloc_asprintf (ctx, "%s/%s", path,
|
||||
notmuch_filenames_get (subdirs));
|
||||
status = _remove_directory (ctx, notmuch, absolute, add_files_state);
|
||||
|
@ -1234,7 +1226,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
goto DONE;
|
||||
|
||||
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);
|
||||
if (ret)
|
||||
goto DONE;
|
||||
|
@ -1247,7 +1239,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
}
|
||||
|
||||
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);
|
||||
if (ret)
|
||||
goto DONE;
|
||||
|
@ -1259,7 +1251,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
status = notmuch_database_get_directory (notmuch, f->filename, &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);
|
||||
|
||||
if (hooks && !ret && !interrupted)
|
||||
if (hooks && ! ret && ! interrupted)
|
||||
ret = notmuch_run_hook (db_path, "post-new");
|
||||
|
||||
if (ret || interrupted)
|
||||
|
|
|
@ -68,13 +68,13 @@ reindex_query (notmuch_database_t *notmuch, const char *query_string,
|
|||
notmuch_messages_move_to_next (messages)) {
|
||||
message = notmuch_messages_get (messages);
|
||||
|
||||
ret = notmuch_message_reindex(message, indexopts);
|
||||
ret = notmuch_message_reindex (message, indexopts);
|
||||
if (ret != NOTMUCH_STATUS_SUCCESS)
|
||||
break;
|
||||
notmuch_message_destroy (message);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
if (! ret)
|
||||
ret = notmuch_database_end_atomic (notmuch);
|
||||
|
||||
notmuch_query_destroy (query);
|
||||
|
@ -124,7 +124,7 @@ notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
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) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -28,8 +28,8 @@ static void
|
|||
show_reply_headers (GMimeStream *stream, GMimeMessage *message)
|
||||
{
|
||||
/* Output RFC 2822 formatted (and RFC 2047 encoded) headers. */
|
||||
if (g_mime_object_write_to_stream (GMIME_OBJECT(message), NULL, stream) < 0) {
|
||||
INTERNAL_ERROR("failed to write headers to stdout\n");
|
||||
if (g_mime_object_write_to_stream (GMIME_OBJECT (message), NULL, stream) < 0) {
|
||||
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")) {
|
||||
/* Ignore PGP/MIME cruft parts */
|
||||
} 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);
|
||||
} else if (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;
|
||||
size_t i, other_len;
|
||||
|
||||
if (!str || *str == '\0')
|
||||
if (! str || *str == '\0')
|
||||
return NULL;
|
||||
|
||||
primary = notmuch_config_get_user_primary_email (config);
|
||||
|
@ -263,7 +263,8 @@ reply_to_header_is_redundant (GMimeMessage *message,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static InternetAddressList *get_sender(GMimeMessage *message)
|
||||
static InternetAddressList *
|
||||
get_sender (GMimeMessage *message)
|
||||
{
|
||||
InternetAddressList *reply_to_list;
|
||||
|
||||
|
@ -290,17 +291,20 @@ static InternetAddressList *get_sender(GMimeMessage *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);
|
||||
}
|
||||
|
||||
static InternetAddressList *get_cc(GMimeMessage *message)
|
||||
static InternetAddressList *
|
||||
get_cc (GMimeMessage *message)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -344,7 +348,7 @@ add_recipients_from_message (GMimeMessage *reply,
|
|||
n += scan_address_list (recipients, config, reply,
|
||||
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
|
||||
* 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')
|
||||
break;
|
||||
mta = xstrdup (by);
|
||||
token = strtok(mta," \t");
|
||||
token = strtok (mta, " \t");
|
||||
if (token == NULL) {
|
||||
free (mta);
|
||||
break;
|
||||
|
@ -518,7 +522,7 @@ get_from_in_to_headers (notmuch_config_t *config, notmuch_message_t *message)
|
|||
}
|
||||
|
||||
static GMimeMessage *
|
||||
create_reply_message(void *ctx,
|
||||
create_reply_message (void *ctx,
|
||||
notmuch_config_t *config,
|
||||
notmuch_message_t *message,
|
||||
GMimeMessage *mime_message,
|
||||
|
@ -533,6 +537,7 @@ create_reply_message(void *ctx,
|
|||
* otherwise.
|
||||
*/
|
||||
GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);
|
||||
|
||||
if (reply == NULL) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return NULL;
|
||||
|
@ -608,7 +613,8 @@ enum {
|
|||
FORMAT_HEADERS_ONLY,
|
||||
};
|
||||
|
||||
static int do_reply(notmuch_config_t *config,
|
||||
static int
|
||||
do_reply (notmuch_config_t *config,
|
||||
notmuch_query_t *query,
|
||||
notmuch_show_params_t *params,
|
||||
int format,
|
||||
|
@ -645,8 +651,7 @@ static int do_reply(notmuch_config_t *config,
|
|||
|
||||
for (;
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages))
|
||||
{
|
||||
notmuch_messages_move_to_next (messages)) {
|
||||
message = notmuch_messages_get (messages);
|
||||
|
||||
if (mime_node_open (config, message, ¶ms->crypto, &node))
|
||||
|
@ -655,7 +660,7 @@ static int do_reply(notmuch_config_t *config,
|
|||
reply = create_reply_message (config, config, message,
|
||||
GMIME_MESSAGE (node->part), reply_all,
|
||||
format == FORMAT_HEADERS_ONLY);
|
||||
if (!reply)
|
||||
if (! reply)
|
||||
return 1;
|
||||
|
||||
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);
|
||||
}
|
||||
g_mime_stream_flush (stream_stdout);
|
||||
g_object_unref(stream_stdout);
|
||||
g_object_unref (stream_stdout);
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (reply));
|
||||
|
@ -719,7 +724,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
(notmuch_keyword_t []){ { "all", true },
|
||||
{ "sender", false },
|
||||
{ 0, 0 } } },
|
||||
{ .opt_keyword = (int*)(¶ms.crypto.decrypt), .name = "decrypt",
|
||||
{ .opt_keyword = (int *) (¶ms.crypto.decrypt), .name = "decrypt",
|
||||
.keyword_no_arg_value = "true", .keywords =
|
||||
(notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
|
||||
{ "auto", NOTMUCH_DECRYPT_AUTO },
|
||||
|
@ -737,7 +742,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
|
||||
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) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -25,18 +25,18 @@
|
|||
#include "zlib-extra.h"
|
||||
|
||||
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;
|
||||
char *key, *val;
|
||||
size_t key_len,val_len;
|
||||
size_t key_len, val_len;
|
||||
const char *delim = " \t\n";
|
||||
int ret = EXIT_FAILURE;
|
||||
|
||||
void *local = talloc_new(NULL);
|
||||
void *local = talloc_new (NULL);
|
||||
|
||||
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);
|
||||
val = talloc_strndup (local, val_p, val_len);
|
||||
|
@ -58,8 +58,7 @@ process_config_line (notmuch_database_t *notmuch, const char* line)
|
|||
}
|
||||
|
||||
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;
|
||||
size_t id_len = 0, tok_len = 0;
|
||||
|
@ -255,7 +254,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
{ .opt_flags = &include, .name = "include", .keywords =
|
||||
(notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG },
|
||||
{ "properties", DUMP_INCLUDE_PROPERTIES },
|
||||
{ "tags", DUMP_INCLUDE_TAGS} } },
|
||||
{ "tags", DUMP_INCLUDE_TAGS } } },
|
||||
|
||||
{ .opt_string = &input_file_name, .name = "input" },
|
||||
{ .opt_bool = &accumulate, .name = "accumulate" },
|
||||
|
@ -330,13 +329,13 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
|
||||
if (status) {
|
||||
fprintf (stderr, "Error reading (gzipped) input: %s\n",
|
||||
gz_error_string(status, input));
|
||||
gz_error_string (status, input));
|
||||
ret = EXIT_FAILURE;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
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)
|
||||
goto DONE;
|
||||
}
|
||||
|
@ -349,7 +348,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
} while ((line_len == 0) ||
|
||||
(line[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))) {
|
||||
ret = EXIT_SUCCESS;
|
||||
|
|
|
@ -87,8 +87,7 @@ get_thread_query (notmuch_thread_t *thread,
|
|||
|
||||
for (messages = notmuch_thread_get_messages (thread);
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages))
|
||||
{
|
||||
notmuch_messages_move_to_next (messages)) {
|
||||
notmuch_message_t *message = notmuch_messages_get (messages);
|
||||
const char *mid = notmuch_message_get_message_id (message);
|
||||
/* 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);
|
||||
else
|
||||
*buf = talloc_strdup (thread, escaped);
|
||||
if (!*buf)
|
||||
if (! *buf)
|
||||
return -1;
|
||||
}
|
||||
talloc_free (escaped);
|
||||
|
@ -134,15 +133,14 @@ do_search_threads (search_context_t *ctx)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
format->begin_list (format);
|
||||
|
||||
for (i = 0;
|
||||
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);
|
||||
|
||||
if (i < ctx->offset) {
|
||||
|
@ -237,8 +235,7 @@ do_search_threads (search_context_t *ctx)
|
|||
|
||||
for (tags = notmuch_thread_get_tags (thread);
|
||||
notmuch_tags_valid (tags);
|
||||
notmuch_tags_move_to_next (tags))
|
||||
{
|
||||
notmuch_tags_move_to_next (tags)) {
|
||||
const char *tag = notmuch_tags_get (tags);
|
||||
|
||||
if (format->is_text_printer) {
|
||||
|
@ -269,7 +266,8 @@ do_search_threads (search_context_t *ctx)
|
|||
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;
|
||||
|
||||
|
@ -284,7 +282,8 @@ static mailbox_t *new_mailbox (void *ctx, const char *name, const char *addr)
|
|||
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;
|
||||
int ret;
|
||||
|
@ -488,7 +487,7 @@ print_popular (const search_context_t *ctx, GList *list)
|
|||
}
|
||||
|
||||
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. */
|
||||
mailbox->count = total;
|
||||
|
@ -561,8 +560,7 @@ do_search_messages (search_context_t *ctx)
|
|||
|
||||
for (i = 0;
|
||||
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)
|
||||
continue;
|
||||
|
||||
|
@ -574,15 +572,14 @@ do_search_messages (search_context_t *ctx)
|
|||
|
||||
for (j = 1;
|
||||
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) {
|
||||
format->string (format, notmuch_filenames_get (filenames));
|
||||
format->separator (format);
|
||||
}
|
||||
}
|
||||
|
||||
notmuch_filenames_destroy( filenames );
|
||||
notmuch_filenames_destroy ( filenames );
|
||||
|
||||
} else if (ctx->output == OUTPUT_MESSAGES) {
|
||||
/* special case 1 for speed */
|
||||
|
@ -657,8 +654,7 @@ do_search_tags (const search_context_t *ctx)
|
|||
|
||||
for (;
|
||||
notmuch_tags_valid (tags);
|
||||
notmuch_tags_move_to_next (tags))
|
||||
{
|
||||
notmuch_tags_move_to_next (tags)) {
|
||||
tag = notmuch_tags_get (tags);
|
||||
|
||||
format->string (format, tag);
|
||||
|
@ -702,7 +698,7 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar
|
|||
break;
|
||||
default:
|
||||
/* this should never happen */
|
||||
INTERNAL_ERROR("no output format selected");
|
||||
INTERNAL_ERROR ("no output format selected");
|
||||
}
|
||||
|
||||
notmuch_exit_if_unsupported_format ();
|
||||
|
|
|
@ -47,50 +47,51 @@ static void
|
|||
welcome_message_pre_setup (void)
|
||||
{
|
||||
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"
|
||||
"email, and to efficiently keep up with the flow of email as it comes in.\n\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"
|
||||
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"programs) then notmuch will do its best to detect those and ignore them.\n\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"
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"continue configuring notmuch now, but be sure to complete the conversion\n"
|
||||
"before you run \"notmuch new\" for the first time.\n\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"
|
||||
"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"
|
||||
"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"
|
||||
"before you run \"notmuch new\" for the first time.\n\n");
|
||||
}
|
||||
|
||||
static void
|
||||
welcome_message_post_setup (void)
|
||||
{
|
||||
printf ("\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"
|
||||
"change the configuration in the future, you can either edit that file\n"
|
||||
"directly or run \"notmuch setup\". To choose an alternate configuration\n"
|
||||
"location, set ${NOTMUCH_CONFIG}.\n\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"
|
||||
"change the configuration in the future, you can either edit that file\n"
|
||||
"directly or run \"notmuch setup\". To choose an alternate configuration\n"
|
||||
"location, set ${NOTMUCH_CONFIG}.\n\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"
|
||||
"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"
|
||||
"storage space as your current collection of email. So please ensure you\n"
|
||||
"have sufficient storage space available now.\n\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"
|
||||
"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"
|
||||
"storage space as your current collection of email. So please ensure you\n"
|
||||
"have sufficient storage space available now.\n\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_tag_list (const char **tags, size_t tags_len)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < tags_len; i++) {
|
||||
if (i != 0)
|
||||
printf (" ");
|
||||
|
|
|
@ -37,8 +37,7 @@ _get_tags_as_string (const void *ctx, notmuch_message_t *message)
|
|||
|
||||
for (tags = notmuch_message_get_tags (message);
|
||||
notmuch_tags_valid (tags);
|
||||
notmuch_tags_move_to_next (tags))
|
||||
{
|
||||
notmuch_tags_move_to_next (tags)) {
|
||||
tag = notmuch_tags_get (tags);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static const char *_get_disposition(GMimeObject *meta)
|
||||
static const char *
|
||||
_get_disposition (GMimeObject *meta)
|
||||
{
|
||||
GMimeContentDisposition *disposition;
|
||||
|
||||
disposition = g_mime_object_get_content_disposition (meta);
|
||||
if (!disposition)
|
||||
if (! disposition)
|
||||
return NULL;
|
||||
|
||||
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);
|
||||
|
||||
return email;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return 1 if 'line' is an mbox From_ line---that is, a line
|
||||
* 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 = charset ? g_mime_charset_canon_name (charset) : NULL;
|
||||
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_filter = NULL;
|
||||
|
||||
|
@ -298,10 +298,10 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
|
|||
null_stream = g_mime_stream_null_new ();
|
||||
null_stream_filter = g_mime_stream_filter_new (null_stream);
|
||||
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);
|
||||
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);
|
||||
|
||||
if (null_stream_filter)
|
||||
|
@ -314,7 +314,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
|
|||
|
||||
stream_filter = g_mime_stream_filter_new (stream_out);
|
||||
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);
|
||||
g_object_unref (crlf_filter);
|
||||
|
||||
|
@ -345,12 +345,12 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
|
|||
if (wrapper && stream_filter)
|
||||
g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
|
||||
if (stream_filter)
|
||||
g_object_unref(stream_filter);
|
||||
g_object_unref (stream_filter);
|
||||
if (windows_filter)
|
||||
g_object_unref (windows_filter);
|
||||
}
|
||||
|
||||
static const char*
|
||||
static const char *
|
||||
signature_status_to_string (GMimeSignatureStatus status)
|
||||
{
|
||||
if (g_mime_signature_status_bad (status))
|
||||
|
@ -368,12 +368,13 @@ signature_status_to_string (GMimeSignatureStatus status)
|
|||
/* Print signature flags */
|
||||
struct key_map_struct {
|
||||
GMimeSignatureStatus bit;
|
||||
const char * string;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
static void
|
||||
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->begin_map (sp);
|
||||
|
||||
|
@ -392,22 +393,22 @@ format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
|
|||
{
|
||||
GMimeSignatureStatus errors = g_mime_signature_get_status (signature);
|
||||
|
||||
if (!(errors & GMIME_SIGNATURE_STATUS_ERROR_MASK))
|
||||
if (! (errors & GMIME_SIGNATURE_STATUS_ERROR_MASK))
|
||||
return;
|
||||
|
||||
struct key_map_struct key_map[] = {
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked"},
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired"},
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked" },
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired" },
|
||||
{ GMIME_SIGNATURE_STATUS_SIG_EXPIRED, "sig-expired" },
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing"},
|
||||
{ GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing"},
|
||||
{ GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old"},
|
||||
{ GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy"},
|
||||
{ GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error"},
|
||||
{ GMIME_SIGNATURE_STATUS_TOFU_CONFLICT, "tofu-conflict"},
|
||||
{ GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing" },
|
||||
{ GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing" },
|
||||
{ GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old" },
|
||||
{ GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy" },
|
||||
{ GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error" },
|
||||
{ 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 */
|
||||
|
@ -419,7 +420,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, GMimeSignatureList *siglist)
|
|||
|
||||
sp->begin_list (sp);
|
||||
|
||||
if (!siglist) {
|
||||
if (! siglist) {
|
||||
sp->end (sp);
|
||||
return;
|
||||
}
|
||||
|
@ -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, "\fheader}\n");
|
||||
|
||||
if (!params->output_body)
|
||||
{
|
||||
if (! params->output_body) {
|
||||
g_mime_stream_printf (stream, "\f%s}\n", part_type);
|
||||
return NOTMUCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -566,8 +566,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
|||
if (leaf) {
|
||||
if (g_mime_content_type_is_type (content_type, "text", "*") &&
|
||||
(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);
|
||||
} else {
|
||||
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", "*") &&
|
||||
(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 ();
|
||||
GByteArray *part_content;
|
||||
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_len;
|
||||
|
||||
if (!message)
|
||||
if (! message)
|
||||
INTERNAL_ERROR ("format_part_mbox requires a root part");
|
||||
|
||||
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)) {
|
||||
ssize = g_mime_stream_read (stream, buf, sizeof(buf));
|
||||
ssize = g_mime_stream_read (stream, buf, sizeof (buf));
|
||||
if (ssize < 0) {
|
||||
fprintf (stderr, "Error: Read failed from %s\n", filename);
|
||||
goto DONE;
|
||||
|
@ -967,7 +965,7 @@ show_message (void *ctx,
|
|||
}
|
||||
}
|
||||
}
|
||||
DONE:
|
||||
DONE :
|
||||
talloc_free (local);
|
||||
return status;
|
||||
}
|
||||
|
@ -990,8 +988,7 @@ show_messages (void *ctx,
|
|||
|
||||
for (;
|
||||
notmuch_messages_valid (messages);
|
||||
notmuch_messages_move_to_next (messages))
|
||||
{
|
||||
notmuch_messages_move_to_next (messages)) {
|
||||
sp->begin_list (sp);
|
||||
|
||||
message = notmuch_messages_get (messages);
|
||||
|
@ -1001,9 +998,9 @@ show_messages (void *ctx,
|
|||
|
||||
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);
|
||||
if (status && !res)
|
||||
if (status && ! res)
|
||||
res = status;
|
||||
next_indent = indent + 1;
|
||||
} else {
|
||||
|
@ -1015,7 +1012,7 @@ show_messages (void *ctx,
|
|||
notmuch_message_get_replies (message),
|
||||
next_indent,
|
||||
params);
|
||||
if (status && !res)
|
||||
if (status && ! res)
|
||||
res = status;
|
||||
|
||||
notmuch_message_destroy (message);
|
||||
|
@ -1080,16 +1077,15 @@ do_show (void *ctx,
|
|||
notmuch_messages_t *messages;
|
||||
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))
|
||||
return 1;
|
||||
|
||||
sp->begin_list (sp);
|
||||
|
||||
for ( ;
|
||||
for (;
|
||||
notmuch_threads_valid (threads);
|
||||
notmuch_threads_move_to_next (threads))
|
||||
{
|
||||
notmuch_threads_move_to_next (threads)) {
|
||||
thread = notmuch_threads_get (threads);
|
||||
|
||||
messages = notmuch_thread_get_toplevel_messages (thread);
|
||||
|
@ -1099,7 +1095,7 @@ do_show (void *ctx,
|
|||
notmuch_thread_get_thread_id (thread));
|
||||
|
||||
status = show_messages (ctx, format, sp, messages, 0, params);
|
||||
if (status && !res)
|
||||
if (status && ! res)
|
||||
res = status;
|
||||
|
||||
notmuch_thread_destroy (thread);
|
||||
|
@ -1186,7 +1182,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
{ .opt_bool = ¶ms.entire_thread, .name = "entire-thread",
|
||||
.present = &entire_thread_set },
|
||||
{ .opt_int = ¶ms.part, .name = "part" },
|
||||
{ .opt_keyword = (int*)(¶ms.crypto.decrypt), .name = "decrypt",
|
||||
{ .opt_keyword = (int *) (¶ms.crypto.decrypt), .name = "decrypt",
|
||||
.keyword_no_arg_value = "true", .keywords =
|
||||
(notmuch_keyword_t []){ { "false", NOTMUCH_DECRYPT_FALSE },
|
||||
{ "auto", NOTMUCH_DECRYPT_AUTO },
|
||||
|
@ -1240,7 +1236,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
(format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP))
|
||||
params.entire_thread = true;
|
||||
|
||||
if (!params.output_body) {
|
||||
if (! params.output_body) {
|
||||
if (params.part > 0) {
|
||||
fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
|
||||
params.output_body = true;
|
||||
|
@ -1260,7 +1256,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
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) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return EXIT_FAILURE;
|
||||
|
@ -1288,7 +1284,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
|
||||
/* Create structure printer. */
|
||||
formatter = formatters[format];
|
||||
sprinter = formatter->new_sprinter(config, stdout);
|
||||
sprinter = formatter->new_sprinter (config, stdout);
|
||||
|
||||
params.out_stream = g_mime_stream_stdout_new ();
|
||||
|
||||
|
@ -1324,7 +1320,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
|
|||
ret = do_show (config, query, formatter, sprinter, ¶ms);
|
||||
}
|
||||
|
||||
DONE:
|
||||
DONE :
|
||||
g_mime_stream_flush (params.out_stream);
|
||||
g_object_unref (params.out_stream);
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
*
|
||||
*/
|
||||
#define MINUTE (60)
|
||||
#define HOUR (60 * MINUTE)
|
||||
#define DAY (24 * HOUR)
|
||||
#define HOUR (60 *MINUTE)
|
||||
#define DAY (24 *HOUR)
|
||||
#define RELATIVE_DATE_MAX 20
|
||||
const char *
|
||||
notmuch_time_relative_date (const void *ctx, time_t then)
|
||||
{
|
||||
struct tm tm_now, tm_then;
|
||||
time_t now = time(NULL);
|
||||
time_t now = time (NULL);
|
||||
time_t delta;
|
||||
char *result;
|
||||
|
||||
|
@ -76,8 +76,7 @@ notmuch_time_relative_date (const void *ctx, time_t then)
|
|||
|
||||
if (delta <= 7 * DAY) {
|
||||
if (tm_then.tm_wday == tm_now.tm_wday &&
|
||||
delta < DAY)
|
||||
{
|
||||
delta < DAY) {
|
||||
strftime (result, RELATIVE_DATE_MAX,
|
||||
"Today %R", &tm_then); /* Today 12:30 */
|
||||
return result;
|
||||
|
|
35
notmuch.c
35
notmuch.c
|
@ -61,9 +61,10 @@ const notmuch_opt_desc_t notmuch_shared_options [] = {
|
|||
* notmuch_process_shared_options (subcommand_name);
|
||||
*/
|
||||
void
|
||||
notmuch_process_shared_options (const char *subcommand_name) {
|
||||
notmuch_process_shared_options (const char *subcommand_name)
|
||||
{
|
||||
if (print_version) {
|
||||
printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n");
|
||||
printf ("notmuch " STRINGIFY (NOTMUCH_VERSION) "\n");
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,8 @@ notmuch_process_shared_options (const char *subcommand_name) {
|
|||
/* This is suitable for subcommands that do not actually open the
|
||||
* database.
|
||||
*/
|
||||
int notmuch_minimal_options (const char *subcommand_name,
|
||||
int
|
||||
notmuch_minimal_options (const char *subcommand_name,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int opt_index;
|
||||
|
@ -192,7 +194,7 @@ find_command (const char *name)
|
|||
size_t 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))
|
||||
return &commands[i];
|
||||
|
||||
|
@ -270,11 +272,11 @@ notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch)
|
|||
{
|
||||
const char *uuid = NULL;
|
||||
|
||||
if (!notmuch_requested_db_uuid)
|
||||
if (! notmuch_requested_db_uuid)
|
||||
return;
|
||||
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",
|
||||
notmuch_requested_db_uuid, uuid);
|
||||
exit (1);
|
||||
|
@ -297,7 +299,7 @@ _help_for (const char *topic_name)
|
|||
help_topic_t *topic;
|
||||
unsigned int i;
|
||||
|
||||
if (!topic_name) {
|
||||
if (! topic_name) {
|
||||
printf ("The notmuch mail system.\n\n");
|
||||
usage (stdout);
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -333,7 +335,7 @@ _help_for (const char *topic_name)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -342,8 +344,8 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
|
|||
return EXIT_FAILURE;
|
||||
|
||||
/* skip at least subcommand argument */
|
||||
argc-= opt_index;
|
||||
argv+= opt_index;
|
||||
argc -= opt_index;
|
||||
argv += opt_index;
|
||||
|
||||
if (argc == 0) {
|
||||
return _help_for (NULL);
|
||||
|
@ -417,7 +419,8 @@ notmuch_command (notmuch_config_t *config,
|
|||
* executed. Return true if external command is not found. Return
|
||||
* false on errors.
|
||||
*/
|
||||
static bool try_external_command(char *argv[])
|
||||
static bool
|
||||
try_external_command (char *argv[])
|
||||
{
|
||||
char *old_argv0 = argv[0];
|
||||
bool ret = true;
|
||||
|
@ -431,7 +434,7 @@ static bool try_external_command(char *argv[])
|
|||
execvp (argv[0], argv);
|
||||
if (errno != ENOENT) {
|
||||
fprintf (stderr, "Error: Running external command '%s' failed: %s\n",
|
||||
argv[0], strerror(errno));
|
||||
argv[0], strerror (errno));
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
@ -464,7 +467,7 @@ main (int argc, char *argv[])
|
|||
local = talloc_new (NULL);
|
||||
|
||||
g_mime_init ();
|
||||
#if !GLIB_CHECK_VERSION(2, 35, 1)
|
||||
#if ! GLIB_CHECK_VERSION (2, 35, 1)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
|
@ -484,9 +487,9 @@ main (int argc, char *argv[])
|
|||
|
||||
command = find_command (command_name);
|
||||
/* 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. */
|
||||
if (try_external_command(argv + opt_index))
|
||||
if (try_external_command (argv + opt_index))
|
||||
fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
|
||||
command_name);
|
||||
ret = EXIT_FAILURE;
|
||||
|
@ -494,7 +497,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
config = notmuch_config_open (local, config_file_name, command->config_mode);
|
||||
if (!config) {
|
||||
if (! config) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto DONE;
|
||||
}
|
||||
|
|
22
sprinter.h
22
sprinter.h
|
@ -13,15 +13,15 @@ typedef struct sprinter {
|
|||
* a sequence of alternating calls to map_key and one of the
|
||||
* 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.
|
||||
*/
|
||||
void (*begin_list) (struct sprinter *);
|
||||
void (*begin_list)(struct sprinter *);
|
||||
|
||||
/* 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
|
||||
* 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
|
||||
* NULL.
|
||||
*/
|
||||
void (*string) (struct sprinter *, const char *);
|
||||
void (*string_len) (struct sprinter *, const char *, size_t);
|
||||
void (*integer) (struct sprinter *, int);
|
||||
void (*boolean) (struct sprinter *, bool);
|
||||
void (*null) (struct sprinter *);
|
||||
void (*string)(struct sprinter *, const char *);
|
||||
void (*string_len)(struct sprinter *, const char *, size_t);
|
||||
void (*integer)(struct sprinter *, int);
|
||||
void (*boolean)(struct sprinter *, bool);
|
||||
void (*null)(struct sprinter *);
|
||||
|
||||
/* Print the key of a map's key/value pair. The char * must be UTF-8
|
||||
* encoded.
|
||||
*/
|
||||
void (*map_key) (struct sprinter *, const char *);
|
||||
void (*map_key)(struct sprinter *, const char *);
|
||||
|
||||
/* Insert a separator (usually extra whitespace). For the text
|
||||
* 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,
|
||||
* 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
|
||||
* printer, which will print this string, followed by a colon,
|
||||
* 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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue