C99 stdbool turned 18 this year. There really is no reason to use our
own, except in the library interface for backward
compatibility. Convert the cli and test binaries to stdbool.
29 files changed:
/*
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
_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
const notmuch_keyword_t *keywords;
_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
const notmuch_keyword_t *keywords;
else
*arg_desc->opt_keyword = keywords->value;
else
*arg_desc->opt_keyword = keywords->value;
}
if (next != '\0')
fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name);
else
fprintf (stderr, "Option \"%s\" needs a keyword argument.\n", arg_desc->name);
}
if (next != '\0')
fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name);
else
fprintf (stderr, "Option \"%s\" needs a keyword argument.\n", arg_desc->name);
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
if (next == '\0' || strcmp (arg_str, "true") == 0) {
if (next == '\0' || strcmp (arg_str, "true") == 0) {
} else if (strcmp (arg_str, "false") == 0) {
} else if (strcmp (arg_str, "false") == 0) {
} else {
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
} else {
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
}
*arg_desc->opt_bool = value;
}
*arg_desc->opt_bool = value;
_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);
_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);
}
*arg_desc->opt_int = strtol (arg_str, &endptr, 10);
if (*endptr == '\0')
}
*arg_desc->opt_int = strtol (arg_str, &endptr, 10);
if (*endptr == '\0')
fprintf (stderr, "Unable to parse argument \"%s\" for option \"%s\" as an integer.\n",
arg_str, arg_desc->name);
fprintf (stderr, "Unable to parse argument \"%s\" for option \"%s\" as an integer.\n",
arg_str, arg_desc->name);
_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);
_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);
}
if (arg_str[0] == '\0') {
fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);
}
if (arg_str[0] == '\0') {
fprintf (stderr, "String argument for option \"%s\" must be non-empty.\n", arg_desc->name);
}
*arg_desc->opt_string = arg_str;
}
*arg_desc->opt_string = arg_str;
}
/* Return number of non-NULL opt_* fields in opt_desc. */
}
/* Return number of non-NULL opt_* fields in opt_desc. */
!!opt_desc->opt_position;
}
!!opt_desc->opt_position;
}
-/* Return TRUE if opt_desc is valid. */
-static notmuch_bool_t _opt_valid (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)
{
int n = _opt_set_count (opt_desc);
{
int n = _opt_set_count (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
parse_position_arg (const char *arg_str, int pos_arg_index,
const notmuch_opt_desc_t *arg_desc) {
parse_position_arg (const char *arg_str, int pos_arg_index,
const notmuch_opt_desc_t *arg_desc) {
if (pos_arg_counter == pos_arg_index) {
*arg_desc->opt_position = arg_str;
if (arg_desc->present)
if (pos_arg_counter == pos_arg_index) {
*arg_desc->opt_position = arg_str;
if (arg_desc->present)
- *arg_desc->present = TRUE;
- return TRUE;
+ *arg_desc->present = true;
+ return true;
}
pos_arg_counter++;
}
arg_desc++;
}
}
pos_arg_counter++;
}
arg_desc++;
}
- notmuch_bool_t opt_status = FALSE;
+ bool opt_status = false;
if (try->opt_keyword || try->opt_flags)
opt_status = _process_keyword_arg (try, next, value);
else if (try->opt_bool)
if (try->opt_keyword || try->opt_flags)
opt_status = _process_keyword_arg (try, next, value);
else if (try->opt_bool)
return -1;
if (try->present)
return -1;
if (try->present)
const notmuch_opt_desc_t *options, int opt_index) {
int pos_arg_index = 0;
const notmuch_opt_desc_t *options, int opt_index) {
int pos_arg_index = 0;
- notmuch_bool_t more_args = TRUE;
while (more_args && opt_index < argc) {
if (strncmp (argv[opt_index],"--",2) != 0) {
while (more_args && opt_index < argc) {
if (strncmp (argv[opt_index],"--",2) != 0) {
opt_index = parse_option (argc, argv, options, opt_index);
if (opt_index < 0) {
fprintf (stderr, "Unrecognized option: %s\n", argv[prev_opt_index]);
opt_index = parse_option (argc, argv, options, opt_index);
if (opt_index < 0) {
fprintf (stderr, "Unrecognized option: %s\n", argv[prev_opt_index]);
#ifndef NOTMUCH_OPTS_H
#define NOTMUCH_OPTS_H
#ifndef NOTMUCH_OPTS_H
#define NOTMUCH_OPTS_H
typedef struct notmuch_opt_desc {
/* One and only one of opt_* must be set. */
const struct notmuch_opt_desc *opt_inherit;
typedef struct notmuch_opt_desc {
/* One and only one of opt_* must be set. */
const struct notmuch_opt_desc *opt_inherit;
- notmuch_bool_t *opt_bool;
int *opt_int;
int *opt_keyword;
int *opt_flags;
int *opt_int;
int *opt_keyword;
int *opt_flags;
/* Must be set except for opt_inherit and opt_position. */
const char *name;
/* Must be set except for opt_inherit and opt_position. */
const char *name;
- /* Optional, if non-NULL, set to TRUE if the option is present. */
- notmuch_bool_t *present;
+ /* Optional, if non-NULL, set to true if the option is present. */
+ bool *present;
/* Must be set for opt_keyword and opt_flags. */
const struct notmuch_keyword *keywords;
/* Must be set for opt_keyword and opt_flags. */
const struct notmuch_keyword *keywords;
int
parse_option (int argc, char **argv, const notmuch_opt_desc_t* options, int opt_index);
int
parse_option (int argc, char **argv, const notmuch_opt_desc_t* options, int opt_index);
parse_position_arg (const char *arg,
int position_arg_index,
const notmuch_opt_desc_t* options);
parse_position_arg (const char *arg,
int position_arg_index,
const notmuch_opt_desc_t* options);
}
crypto->gpgctx = gpgctx;
}
crypto->gpgctx = gpgctx;
- g_mime_gpg_context_set_use_agent ((GMimeGpgContext *) gpgctx, TRUE);
- g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);
+ g_mime_gpg_context_set_use_agent ((GMimeGpgContext *) gpgctx, true);
+ g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, false);
crypto->pkcs7ctx = pkcs7ctx;
g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context *) pkcs7ctx,
crypto->pkcs7ctx = pkcs7ctx;
g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context *) pkcs7ctx,
#define RUNNING_ON_VALGRIND 0
#endif
#define RUNNING_ON_VALGRIND 0
#endif
debugger_is_active (void)
{
char buf[1024];
if (RUNNING_ON_VALGRIND)
debugger_is_active (void)
{
char buf[1024];
if (RUNNING_ON_VALGRIND)
sprintf (buf, "/proc/%d/exe", getppid ());
if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
{
sprintf (buf, "/proc/%d/exe", getppid ());
if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
{
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "gmime-filter-reply.h"
/**
#include "gmime-filter-reply.h"
/**
g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass)
{
(void) klass;
g_mime_filter_reply_init (GMimeFilterReply *filter, GMimeFilterReplyClass *klass)
{
(void) klass;
- filter->saw_nl = TRUE;
- filter->saw_angle = FALSE;
+ filter->saw_nl = true;
+ filter->saw_angle = false;
(void) prespace;
if (reply->encode) {
(void) prespace;
if (reply->encode) {
- g_mime_filter_set_size (filter, 3 * inlen, FALSE);
+ g_mime_filter_set_size (filter, 3 * inlen, false);
outptr = filter->outbuf;
while (inptr < inend) {
if (reply->saw_nl) {
*outptr++ = '>';
*outptr++ = ' ';
outptr = filter->outbuf;
while (inptr < inend) {
if (reply->saw_nl) {
*outptr++ = '>';
*outptr++ = ' ';
if (*inptr != '\r')
*outptr++ = *inptr;
inptr++;
}
} else {
if (*inptr != '\r')
*outptr++ = *inptr;
inptr++;
}
} else {
- g_mime_filter_set_size (filter, inlen + 1, FALSE);
+ g_mime_filter_set_size (filter, inlen + 1, false);
outptr = filter->outbuf;
while (inptr < inend) {
if (reply->saw_nl) {
if (*inptr == '>')
outptr = filter->outbuf;
while (inptr < inend) {
if (reply->saw_nl) {
if (*inptr == '>')
- reply->saw_angle = TRUE;
+ reply->saw_angle = true;
} else if (reply->saw_angle) {
if (*inptr == ' ')
;
else
*outptr++ = *inptr;
} else if (reply->saw_angle) {
if (*inptr == ' ')
;
else
*outptr++ = *inptr;
- reply->saw_angle = FALSE;
+ reply->saw_angle = false;
} else if (*inptr != '\r') {
if (*inptr == '\n')
} else if (*inptr != '\r') {
if (*inptr == '\n')
{
GMimeFilterReply *reply = (GMimeFilterReply *) filter;
{
GMimeFilterReply *reply = (GMimeFilterReply *) filter;
- reply->saw_nl = TRUE;
- reply->saw_angle = FALSE;
+ reply->saw_nl = true;
+ reply->saw_angle = false;
}
/**
* g_mime_filter_reply_new:
}
/**
* g_mime_filter_reply_new:
- * @encode: %TRUE if the filter should encode or %FALSE otherwise
+ * @encode: %true if the filter should encode or %false otherwise
* @dots: encode/decode dots (as for SMTP)
*
* Creates a new #GMimeFilterReply filter.
*
* @dots: encode/decode dots (as for SMTP)
*
* Creates a new #GMimeFilterReply filter.
*
- * If @encode is %TRUE, then all lines will be prefixed by "> ",
+ * If @encode is %true, then all lines will be prefixed by "> ",
* otherwise any lines starting with "> " will have that removed
*
* Returns: a new #GMimeFilterReply filter.
* otherwise any lines starting with "> " will have that removed
*
* Returns: a new #GMimeFilterReply filter.
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE;
}
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE;
}
- g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), FALSE);
+ g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), false);
mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
if (!mctx->parser) {
mctx->parser = g_mime_parser_new_with_stream (mctx->stream);
if (!mctx->parser) {
- node->verify_attempted = TRUE;
+ node->verify_attempted = true;
node->sig_list = g_mime_multipart_signed_verify
(GMIME_MULTIPART_SIGNED (part), cryptoctx, &err);
node->sig_list = g_mime_multipart_signed_verify
(GMIME_MULTIPART_SIGNED (part), cryptoctx, &err);
GMimeDecryptResult *decrypt_result = NULL;
GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part);
GMimeDecryptResult *decrypt_result = NULL;
GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part);
- node->decrypt_attempted = TRUE;
+ node->decrypt_attempted = true;
node->decrypted_child = g_mime_multipart_encrypted_decrypt
(encrypteddata, cryptoctx, &decrypt_result, &err);
if (! node->decrypted_child) {
node->decrypted_child = g_mime_multipart_encrypted_decrypt
(encrypteddata, cryptoctx, &decrypt_result, &err);
if (! node->decrypted_child) {
- node->decrypt_success = TRUE;
- node->verify_attempted = TRUE;
+ node->decrypt_success = true;
+ node->verify_attempted = true;
/* This may be NULL if the part is not signed. */
node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result);
/* This may be NULL if the part is not signed. */
node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result);
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for getline */
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for getline */
#endif
#include <stdio.h>
#include <sysexits.h>
#include <stdio.h>
#include <sysexits.h>
} notmuch_show_format_t;
typedef struct notmuch_crypto {
} notmuch_show_format_t;
typedef struct notmuch_crypto {
- notmuch_bool_t verify;
- notmuch_bool_t decrypt;
+ bool verify;
+ bool decrypt;
#if (GMIME_MAJOR_VERSION < 3)
notmuch_crypto_context_t* gpgctx;
notmuch_crypto_context_t* pkcs7ctx;
#if (GMIME_MAJOR_VERSION < 3)
notmuch_crypto_context_t* gpgctx;
notmuch_crypto_context_t* pkcs7ctx;
} notmuch_crypto_t;
typedef struct notmuch_show_params {
} notmuch_crypto_t;
typedef struct notmuch_show_params {
- notmuch_bool_t entire_thread;
- notmuch_bool_t omit_excluded;
- notmuch_bool_t output_body;
+ bool entire_thread;
+ bool omit_excluded;
+ bool output_body;
int part;
notmuch_crypto_t crypto;
int part;
notmuch_crypto_t crypto;
- notmuch_bool_t include_html;
GMimeStream *out_stream;
} notmuch_show_params_t;
GMimeStream *out_stream;
} notmuch_show_params_t;
void
format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
void
format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
- notmuch_bool_t output_body,
- notmuch_bool_t include_html);
+ bool output_body,
+ bool include_html);
void
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
void
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
typedef enum {
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
typedef enum {
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
int
notmuch_config_save (notmuch_config_t *config);
int
notmuch_config_save (notmuch_config_t *config);
notmuch_config_is_new (notmuch_config_t *config);
const char *
notmuch_config_is_new (notmuch_config_t *config);
const char *
const char *new_ignore[],
size_t length);
const char *new_ignore[],
size_t length);
notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
void
notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
void
notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
- notmuch_bool_t synchronize_flags);
+ bool synchronize_flags);
const char **
notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length);
const char **
notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length);
int
notmuch_run_hook (const char *db_path, const char *hook);
int
notmuch_run_hook (const char *db_path, const char *hook);
debugger_is_active (void);
/* mime-node.c */
debugger_is_active (void);
/* mime-node.c */
int part_num;
/* True if decryption of this part was attempted. */
int part_num;
/* True if decryption of this part was attempted. */
- notmuch_bool_t decrypt_attempted;
+ bool decrypt_attempted;
/* True if decryption of this part's child succeeded. In this
* case, the decrypted part is substituted for the second child of
* this part (which would usually be the encrypted data). */
/* True if decryption of this part's child succeeded. In this
* case, the decrypted part is substituted for the second child of
* this part (which would usually be the encrypted data). */
- notmuch_bool_t decrypt_success;
/* True if signature verification on this part was attempted. */
/* True if signature verification on this part was attempted. */
- notmuch_bool_t verify_attempted;
/* The list of signatures for signed or encrypted containers. If
* there are no signatures, this will be NULL. */
/* The list of signatures for signed or encrypted containers. If
* there are no signatures, this will be NULL. */
const char *query_str,
dump_format_t output_format,
dump_include_t include,
const char *query_str,
dump_format_t output_format,
dump_include_t include,
- notmuch_bool_t gzip_output);
/* If status is non-zero (i.e. error) print appropriate
messages to stderr.
/* If status is non-zero (i.e. error) print appropriate
messages to stderr.
const char *path = notmuch_config_get_database_path (config);
const char *backup_path = NULL;
notmuch_status_t ret;
const char *path = notmuch_config_get_database_path (config);
const char *backup_path = NULL;
notmuch_status_t ret;
- notmuch_bool_t quiet = FALSE;
int opt_index;
notmuch_opt_desc_t options[] = {
int opt_index;
notmuch_opt_desc_t options[] = {
struct _notmuch_config {
char *filename;
GKeyFile *key_file;
struct _notmuch_config {
char *filename;
GKeyFile *key_file;
char *database_path;
char *crypto_gpg_path;
char *database_path;
char *crypto_gpg_path;
size_t new_tags_length;
const char **new_ignore;
size_t new_ignore_length;
size_t new_tags_length;
const char **new_ignore;
size_t new_ignore_length;
- notmuch_bool_t maildir_synchronize_flags;
+ bool maildir_synchronize_flags;
const char **search_exclude_tags;
size_t search_exclude_tags_length;
};
const char **search_exclude_tags;
size_t search_exclude_tags_length;
};
-static notmuch_bool_t
-get_config_from_file (notmuch_config_t *config, notmuch_bool_t create_new)
+static bool
+get_config_from_file (notmuch_config_t *config, bool create_new)
{
#define BUF_SIZE 4096
char *config_str = NULL;
{
#define BUF_SIZE 4096
char *config_str = NULL;
int config_bufsize = BUF_SIZE;
size_t len;
GError *error = NULL;
int config_bufsize = BUF_SIZE;
size_t len;
GError *error = NULL;
- notmuch_bool_t ret = FALSE;
FILE *fp = fopen(config->filename, "r");
if (fp == NULL) {
FILE *fp = fopen(config->filename, "r");
if (fp == NULL) {
* default configuration file in the case of FILE NOT FOUND.
*/
if (create_new) {
* default configuration file in the case of FILE NOT FOUND.
*/
if (create_new) {
- config->is_new = TRUE;
- ret = TRUE;
+ config->is_new = true;
+ ret = true;
} else {
fprintf (stderr, "Configuration file %s not found.\n"
"Try running 'notmuch setup' to create a configuration.\n",
} else {
fprintf (stderr, "Configuration file %s not found.\n"
"Try running 'notmuch setup' to create a configuration.\n",
if (g_key_file_load_from_data (config->key_file, config_str, config_len,
G_KEY_FILE_KEEP_COMMENTS, &error)) {
if (g_key_file_load_from_data (config->key_file, config_str, config_len,
G_KEY_FILE_KEEP_COMMENTS, &error)) {
talloc_set_destructor (config, notmuch_config_destructor);
/* non-zero defaults */
talloc_set_destructor (config, notmuch_config_destructor);
/* non-zero defaults */
- config->maildir_synchronize_flags = TRUE;
+ config->maildir_synchronize_flags = true;
if (filename) {
config->filename = talloc_strdup (config, filename);
if (filename) {
config->filename = talloc_strdup (config, filename);
config->key_file = g_key_file_new ();
if (config_mode & NOTMUCH_CONFIG_OPEN) {
config->key_file = g_key_file_new ();
if (config_mode & NOTMUCH_CONFIG_OPEN) {
- notmuch_bool_t create_new = (config_mode & NOTMUCH_CONFIG_CREATE) != 0;
+ bool create_new = (config_mode & NOTMUCH_CONFIG_CREATE) != 0;
if (! get_config_from_file (config, create_new)) {
talloc_free (config);
if (! get_config_from_file (config, create_new)) {
talloc_free (config);
g_key_file_get_boolean (config->key_file,
"maildir", "synchronize_flags", &error);
if (error) {
g_key_file_get_boolean (config->key_file,
"maildir", "synchronize_flags", &error);
if (error) {
- notmuch_config_set_maildir_synchronize_flags (config, TRUE);
+ notmuch_config_set_maildir_synchronize_flags (config, true);
notmuch_config_is_new (notmuch_config_t *config)
{
return config->is_new;
notmuch_config_is_new (notmuch_config_t *config)
{
return config->is_new;
notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config)
{
return config->maildir_synchronize_flags;
notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config)
{
return config->maildir_synchronize_flags;
void
notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
void
notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
- notmuch_bool_t synchronize_flags)
+ bool synchronize_flags)
{
g_key_file_set_boolean (config->key_file,
"maildir", "synchronize_flags", synchronize_flags);
{
g_key_file_set_boolean (config->key_file,
"maildir", "synchronize_flags", synchronize_flags);
/* The following is to allow future options to be added more easily */
enum {
/* The following is to allow future options to be added more easily */
enum {
- EXCLUDE_TRUE,
- EXCLUDE_FALSE,
+ EXCLUDE_true,
+ EXCLUDE_false,
};
/* Return the number of files matching the query, or -1 for an error */
};
/* Return the number of files matching the query, or -1 for an error */
char *query_str;
int opt_index;
int output = OUTPUT_MESSAGES;
char *query_str;
int opt_index;
int output = OUTPUT_MESSAGES;
- int exclude = EXCLUDE_TRUE;
+ int exclude = EXCLUDE_true;
const char **search_exclude_tags = NULL;
size_t search_exclude_tags_length = 0;
const char **search_exclude_tags = NULL;
size_t search_exclude_tags_length = 0;
- notmuch_bool_t batch = FALSE;
- notmuch_bool_t print_lastmod = FALSE;
+ bool batch = false;
+ bool print_lastmod = false;
FILE *input = stdin;
const char *input_file_name = NULL;
int ret;
FILE *input = stdin;
const char *input_file_name = NULL;
int ret;
{ "files", OUTPUT_FILES },
{ 0, 0 } } },
{ .opt_keyword = &exclude, .name = "exclude", .keywords =
{ "files", OUTPUT_FILES },
{ 0, 0 } } },
{ .opt_keyword = &exclude, .name = "exclude", .keywords =
- (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
- { "false", EXCLUDE_FALSE },
+ (notmuch_keyword_t []){ { "true", EXCLUDE_true },
+ { "false", EXCLUDE_false },
{ 0, 0 } } },
{ .opt_bool = &print_lastmod, .name = "lastmod" },
{ .opt_bool = &batch, .name = "batch" },
{ 0, 0 } } },
{ .opt_bool = &print_lastmod, .name = "lastmod" },
{ .opt_bool = &batch, .name = "batch" },
notmuch_process_shared_options (argv[0]);
if (input_file_name) {
notmuch_process_shared_options (argv[0]);
if (input_file_name) {
input = fopen (input_file_name, "r");
if (input == NULL) {
fprintf (stderr, "Error opening %s for reading: %s\n",
input = fopen (input_file_name, "r");
if (input == NULL) {
fprintf (stderr, "Error opening %s for reading: %s\n",
- if (exclude == EXCLUDE_TRUE) {
+ if (exclude == EXCLUDE_true) {
search_exclude_tags = notmuch_config_get_search_exclude_tags
(config, &search_exclude_tags_length);
}
search_exclude_tags = notmuch_config_get_search_exclude_tags
(config, &search_exclude_tags_length);
}
{
const char *message_id;
notmuch_message_properties_t *list;
{
const char *message_id;
notmuch_message_properties_t *list;
- notmuch_bool_t first = TRUE;
message_id = notmuch_message_get_message_id (message);
message_id = notmuch_message_get_message_id (message);
- for (list = notmuch_message_get_properties (message, "", FALSE);
+ for (list = notmuch_message_get_properties (message, "", false);
notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
const char *key, *val;
notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
const char *key, *val;
return 1;
}
gzprintf (output, "#= %s", *buffer_p);
return 1;
}
gzprintf (output, "#= %s", *buffer_p);
}
key = notmuch_message_properties_key (list);
}
key = notmuch_message_properties_key (list);
const char *query_str,
dump_format_t output_format,
dump_include_t include,
const char *query_str,
dump_format_t output_format,
dump_include_t include,
- notmuch_bool_t gzip_output)
{
gzFile output = NULL;
const char *mode = gzip_output ? "w9" : "wT";
{
gzFile output = NULL;
const char *mode = gzip_output ? "w9" : "wT";
int output_format = DUMP_FORMAT_BATCH_TAG;
int include = 0;
int output_format = DUMP_FORMAT_BATCH_TAG;
int include = 0;
- notmuch_bool_t gzip_output = 0;
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &output_format, .name = "format", .keywords =
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &output_format, .name = "format", .keywords =
}
/* Call fsync() on a directory path. */
}
/* Call fsync() on a directory path. */
sync_dir (const char *dir)
{
int fd, r;
sync_dir (const char *dir)
{
int fd, r;
fd = open (dir, O_RDONLY);
if (fd == -1) {
fprintf (stderr, "Error: open %s: %s\n", dir, strerror (errno));
fd = open (dir, O_RDONLY);
if (fd == -1) {
fprintf (stderr, "Error: open %s: %s\n", dir, strerror (errno));
/*
* Check the specified folder name does not contain a directory
* component ".." to prevent writes outside of the Maildir
/*
* Check the specified folder name does not contain a directory
* component ".." to prevent writes outside of the Maildir
- * hierarchy. Return TRUE on valid folder name, FALSE otherwise.
+ * hierarchy. Return true on valid folder name, false otherwise.
is_valid_folder_name (const char *folder)
{
const char *p = folder;
for (;;) {
if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))
is_valid_folder_name (const char *folder)
{
const char *p = folder;
for (;;) {
if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))
p = strchr (p, '/');
if (!p)
p = strchr (p, '/');
if (!p)
p++;
}
}
/*
* Make the given directory and its parents as necessary, using the
p++;
}
}
/*
* Make the given directory and its parents as necessary, using the
- * given mode. Return TRUE on success, FALSE otherwise. Partial
+ * given mode. Return true on success, false otherwise. Partial
* results are not cleaned up on errors.
*/
* results are not cleaned up on errors.
*/
mkdir_recursive (const void *ctx, const char *path, int mode)
{
struct stat st;
mkdir_recursive (const void *ctx, const char *path, int mode)
{
struct stat st;
if (! S_ISDIR (st.st_mode)) {
fprintf (stderr, "Error: '%s' is not a directory: %s\n",
path, strerror (EEXIST));
if (! S_ISDIR (st.st_mode)) {
fprintf (stderr, "Error: '%s' is not a directory: %s\n",
path, strerror (EEXIST));
} else if (errno != ENOENT) {
fprintf (stderr, "Error: stat '%s': %s\n", path, strerror (errno));
} else if (errno != ENOENT) {
fprintf (stderr, "Error: stat '%s': %s\n", path, strerror (errno));
}
/* mkdir parents, if any */
}
/* mkdir parents, if any */
parent = talloc_strndup (ctx, path, slash - path);
if (! parent) {
fprintf (stderr, "Error: %s\n", strerror (ENOMEM));
parent = talloc_strndup (ctx, path, slash - path);
if (! parent) {
fprintf (stderr, "Error: %s\n", strerror (ENOMEM));
}
if (! mkdir_recursive (ctx, parent, mode))
}
if (! mkdir_recursive (ctx, parent, mode))
}
if (mkdir (path, mode)) {
fprintf (stderr, "Error: mkdir '%s': %s\n", path, strerror (errno));
}
if (mkdir (path, mode)) {
fprintf (stderr, "Error: mkdir '%s': %s\n", path, strerror (errno));
- return parent ? sync_dir (parent) : TRUE;
+ return parent ? sync_dir (parent) : true;
}
/*
* Create the given maildir folder, i.e. maildir and its
}
/*
* Create the given maildir folder, i.e. maildir and its
- * subdirectories cur/new/tmp. Return TRUE on success, FALSE
+ * subdirectories cur/new/tmp. Return true on success, false
* otherwise. Partial results are not cleaned up on errors.
*/
* otherwise. Partial results are not cleaned up on errors.
*/
maildir_create_folder (const void *ctx, const char *maildir)
{
const char *subdirs[] = { "cur", "new", "tmp" };
maildir_create_folder (const void *ctx, const char *maildir)
{
const char *subdirs[] = { "cur", "new", "tmp" };
subdir = talloc_asprintf (ctx, "%s/%s", maildir, subdirs[i]);
if (! subdir) {
fprintf (stderr, "Error: %s\n", strerror (ENOMEM));
subdir = talloc_asprintf (ctx, "%s/%s", maildir, subdirs[i]);
if (! subdir) {
fprintf (stderr, "Error: %s\n", strerror (ENOMEM));
}
if (! mkdir_recursive (ctx, subdir, mode))
}
if (! mkdir_recursive (ctx, subdir, mode))
- * Copy fdin to fdout, return TRUE on success, and FALSE on errors and
+ * Copy fdin to fdout, return true on success, and false on errors and
copy_fd (int fdout, int fdin)
{
copy_fd (int fdout, int fdin)
{
- notmuch_bool_t empty = TRUE;
while (! interrupted) {
ssize_t remain;
while (! interrupted) {
ssize_t remain;
continue;
fprintf (stderr, "Error: reading from standard input: %s\n",
strerror (errno));
continue;
fprintf (stderr, "Error: reading from standard input: %s\n",
strerror (errno));
if (written <= 0) {
fprintf (stderr, "Error: writing to temporary file: %s",
strerror (errno));
if (written <= 0) {
fprintf (stderr, "Error: writing to temporary file: %s",
strerror (errno));
}
p += written;
remain -= written;
}
p += written;
remain -= written;
/*
* Add the specified message file to the notmuch database, applying
/*
* Add the specified message file to the notmuch database, applying
- * tags in tag_ops. If synchronize_flags is TRUE, the tags are
+ * tags in tag_ops. If synchronize_flags is true, the tags are
* synchronized to maildir flags (which may result in message file
* rename).
*
* Return NOTMUCH_STATUS_SUCCESS on success, errors otherwise. If keep
* synchronized to maildir flags (which may result in message file
* rename).
*
* Return NOTMUCH_STATUS_SUCCESS on success, errors otherwise. If keep
- * is TRUE, errors in tag changes and flag syncing are ignored and
+ * is true, errors in tag changes and flag syncing are ignored and
* success status is returned; otherwise such errors cause the message
* to be removed from the database. Failure to add the message to the
* database results in error status regardless of keep.
*/
static notmuch_status_t
add_file (notmuch_database_t *notmuch, const char *path, tag_op_list_t *tag_ops,
* success status is returned; otherwise such errors cause the message
* to be removed from the database. Failure to add the message to the
* database results in error status regardless of keep.
*/
static notmuch_status_t
add_file (notmuch_database_t *notmuch, const char *path, tag_op_list_t *tag_ops,
- notmuch_bool_t synchronize_flags, notmuch_bool_t keep)
+ bool synchronize_flags, bool keep)
{
notmuch_message_t *message;
notmuch_status_t status;
{
notmuch_message_t *message;
notmuch_status_t status;
tag_op_list_t *tag_ops;
char *query_string = NULL;
const char *folder = "";
tag_op_list_t *tag_ops;
char *query_string = NULL;
const char *folder = "";
- notmuch_bool_t create_folder = FALSE;
- notmuch_bool_t keep = FALSE;
- notmuch_bool_t no_hooks = FALSE;
- notmuch_bool_t synchronize_flags;
+ bool create_folder = false;
+ bool keep = false;
+ bool no_hooks = false;
+ bool synchronize_flags;
char *maildir;
char *newpath;
int opt_index;
char *maildir;
char *newpath;
int opt_index;
for (i = 0; i < new_tags_length; i++) {
const char *error_msg;
for (i = 0; i < new_tags_length; i++) {
const char *error_msg;
- error_msg = illegal_tag (new_tags[i], FALSE);
+ error_msg = illegal_tag (new_tags[i], false);
if (error_msg) {
fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
new_tags[i], error_msg);
return EXIT_FAILURE;
}
if (error_msg) {
fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
new_tags[i], error_msg);
return EXIT_FAILURE;
}
- if (tag_op_list_append (tag_ops, new_tags[i], FALSE))
+ if (tag_op_list_append (tag_ops, new_tags[i], false))
typedef struct {
int output_is_a_tty;
enum verbosity verbosity;
typedef struct {
int output_is_a_tty;
enum verbosity verbosity;
const char **new_tags;
size_t new_tags_length;
const char **new_ignore;
const char **new_tags;
size_t new_tags_length;
const char **new_ignore;
_filename_list_t *removed_directories;
_filename_list_t *directory_mtimes;
_filename_list_t *removed_directories;
_filename_list_t *directory_mtimes;
- notmuch_bool_t synchronize_flags;
+ bool synchronize_flags;
} add_files_state_t;
static volatile sig_atomic_t do_print_progress = 0;
} add_files_state_t;
static volatile sig_atomic_t do_print_progress = 0;
_special_directory (const char *entry)
{
return strcmp (entry, ".") == 0 || strcmp (entry, "..") == 0;
_special_directory (const char *entry)
{
return strcmp (entry, ".") == 0 || strcmp (entry, "..") == 0;
/* Test if the file/directory is to be ignored.
*/
/* Test if the file/directory is to be ignored.
*/
_entry_in_ignore_list (const char *entry, add_files_state_t *state)
{
size_t i;
for (i = 0; i < state->new_ignore_length; i++)
if (strcmp (entry, state->new_ignore[i]) == 0)
_entry_in_ignore_list (const char *entry, add_files_state_t *state)
{
size_t i;
for (i = 0; i < state->new_ignore_length; i++)
if (strcmp (entry, state->new_ignore[i]) == 0)
}
/* Add a single file to the database. */
}
/* Add a single file to the database. */
notmuch_filenames_t *db_subdirs = NULL;
time_t stat_time;
struct stat st;
notmuch_filenames_t *db_subdirs = NULL;
time_t stat_time;
struct stat st;
- notmuch_bool_t is_maildir;
if (stat (path, &st)) {
fprintf (stderr, "Error reading directory %s: %s\n",
if (stat (path, &st)) {
fprintf (stderr, "Error reading directory %s: %s\n",
status = notmuch_database_remove_message (notmuch, path);
if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
add_files_state->renamed_messages++;
status = notmuch_database_remove_message (notmuch, path);
if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
add_files_state->renamed_messages++;
- if (add_files_state->synchronize_flags == TRUE)
+ if (add_files_state->synchronize_flags == true)
notmuch_message_maildir_flags_to_tags (message);
status = NOTMUCH_STATUS_SUCCESS;
} else if (status == NOTMUCH_STATUS_SUCCESS) {
notmuch_message_maildir_flags_to_tags (message);
status = NOTMUCH_STATUS_SUCCESS;
} else if (status == NOTMUCH_STATUS_SUCCESS) {
notmuch_database_t *notmuch;
add_files_state_t add_files_state = {
.verbosity = VERBOSITY_NORMAL,
notmuch_database_t *notmuch;
add_files_state_t add_files_state = {
.verbosity = VERBOSITY_NORMAL,
.output_is_a_tty = isatty (fileno (stdout)),
};
struct timeval tv_start;
.output_is_a_tty = isatty (fileno (stdout)),
};
struct timeval tv_start;
_filename_node_t *f;
int opt_index;
unsigned int i;
_filename_node_t *f;
int opt_index;
unsigned int i;
- notmuch_bool_t timer_is_active = FALSE;
- notmuch_bool_t no_hooks = FALSE;
- notmuch_bool_t quiet = FALSE, verbose = FALSE;
+ bool timer_is_active = false;
+ bool no_hooks = false;
+ bool quiet = false, verbose = false;
notmuch_status_t status;
notmuch_opt_desc_t options[] = {
notmuch_status_t status;
notmuch_opt_desc_t options[] = {
for (i = 0; i < add_files_state.new_tags_length; i++) {
const char *error_msg;
for (i = 0; i < add_files_state.new_tags_length; i++) {
const char *error_msg;
- error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+ error_msg = illegal_tag (add_files_state.new_tags[i], false);
if (error_msg) {
fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
add_files_state.new_tags[i], error_msg);
if (error_msg) {
fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
add_files_state.new_tags[i], error_msg);
}
if (notmuch_database_dump (notmuch, backup_name, "",
}
if (notmuch_database_dump (notmuch, backup_name, "",
- DUMP_FORMAT_BATCH_TAG, DUMP_INCLUDE_DEFAULT, TRUE)) {
+ DUMP_FORMAT_BATCH_TAG, DUMP_INCLUDE_DEFAULT, true)) {
fprintf (stderr, "Backup failed. Aborting upgrade.");
return EXIT_FAILURE;
}
fprintf (stderr, "Backup failed. Aborting upgrade.");
return EXIT_FAILURE;
}
if (add_files_state.verbosity == VERBOSITY_NORMAL &&
add_files_state.output_is_a_tty && ! debugger_is_active ()) {
setup_progress_printing_timer ();
if (add_files_state.verbosity == VERBOSITY_NORMAL &&
add_files_state.output_is_a_tty && ! debugger_is_active ()) {
setup_progress_printing_timer ();
- timer_is_active = TRUE;
+ timer_is_active = true;
}
ret = add_files (notmuch, db_path, &add_files_state);
}
ret = add_files (notmuch, db_path, &add_files_state);
} address_match_t;
/* Match given string against given address according to mode. */
} address_match_t;
/* Match given string against given address according to mode. */
match_address (const char *str, const char *address, address_match_t mode)
{
switch (mode) {
match_address (const char *str, const char *address, address_match_t mode)
{
switch (mode) {
return strcasecmp (address, str) == 0;
}
return strcasecmp (address, str) == 0;
}
}
/* Match given string against user's configured "primary" and "other"
}
/* Match given string against user's configured "primary" and "other"
/* Is the given address configured as one of the user's "primary" or
* "other" addresses. */
/* Is the given address configured as one of the user's "primary" or
* "other" addresses. */
address_is_users (const char *address, notmuch_config_t *config)
{
return address_match (address, config, STRING_IS_USER_ADDRESS) != NULL;
address_is_users (const char *address, notmuch_config_t *config)
{
return address_match (address, config, STRING_IS_USER_ADDRESS) != NULL;
/* Does the address in the Reply-To header of 'message' already appear
* in either the 'To' or 'Cc' header of the message?
*/
/* Does the address in the Reply-To header of 'message' already appear
* in either the 'To' or 'Cc' header of the message?
*/
reply_to_header_is_redundant (GMimeMessage *message,
InternetAddressList *reply_to_list)
{
reply_to_header_is_redundant (GMimeMessage *message,
InternetAddressList *reply_to_list)
{
InternetAddress *address;
InternetAddressMailbox *mailbox;
InternetAddressList *recipients;
InternetAddress *address;
InternetAddressMailbox *mailbox;
InternetAddressList *recipients;
- notmuch_bool_t ret = FALSE;
int i;
if (reply_to_list == NULL ||
int i;
if (reply_to_list == NULL ||
mailbox = INTERNET_ADDRESS_MAILBOX (address);
addr = internet_address_mailbox_get_addr (mailbox);
if (strcmp (addr, reply_to) == 0) {
mailbox = INTERNET_ADDRESS_MAILBOX (address);
addr = internet_address_mailbox_get_addr (mailbox);
if (strcmp (addr, reply_to) == 0) {
add_recipients_from_message (GMimeMessage *reply,
notmuch_config_t *config,
GMimeMessage *message,
add_recipients_from_message (GMimeMessage *reply,
notmuch_config_t *config,
GMimeMessage *message,
- notmuch_bool_t reply_all)
{
/* There is a memory leak here with gmime-2.6 because get_sender
{
/* There is a memory leak here with gmime-2.6 because get_sender
notmuch_config_t *config,
notmuch_message_t *message,
GMimeMessage *mime_message,
notmuch_config_t *config,
notmuch_message_t *message,
GMimeMessage *mime_message,
- notmuch_bool_t reply_all,
- notmuch_bool_t limited)
+ bool reply_all,
+ bool limited)
{
const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references;
{
const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references;
notmuch_query_t *query,
notmuch_show_params_t *params,
int format,
notmuch_query_t *query,
notmuch_show_params_t *params,
int format,
- notmuch_bool_t reply_all)
{
GMimeMessage *reply;
mime_node_t *node;
{
GMimeMessage *reply;
mime_node_t *node;
/* The headers of the reply message we've created */
sp->map_key (sp, "reply-headers");
/* The headers of the reply message we've created */
sp->map_key (sp, "reply-headers");
- format_headers_sprinter (sp, reply, TRUE);
+ format_headers_sprinter (sp, reply, true);
/* Start the original */
sp->map_key (sp, "original");
/* Start the original */
sp->map_key (sp, "original");
- format_part_sprinter (config, sp, node, TRUE, FALSE);
+ format_part_sprinter (config, sp, node, true, false);
.part = -1,
};
int format = FORMAT_DEFAULT;
.part = -1,
};
int format = FORMAT_DEFAULT;
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
{ 0, 0 } } },
{ .opt_int = ¬much_format_version, .name = "format-version" },
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords =
{ 0, 0 } } },
{ .opt_int = ¬much_format_version, .name = "format-version" },
{ .opt_keyword = &reply_all, .name = "reply-to", .keywords =
- (notmuch_keyword_t []){ { "all", TRUE },
- { "sender", FALSE },
+ (notmuch_keyword_t []){ { "all", true },
+ { "sender", false },
{ 0, 0 } } },
{ .opt_bool = ¶ms.crypto.decrypt, .name = "decrypt" },
{ .opt_inherit = notmuch_shared_options },
{ 0, 0 } } },
{ .opt_bool = ¶ms.crypto.decrypt, .name = "decrypt" },
{ .opt_inherit = notmuch_shared_options },
- if (tag_op_list_append (tag_ops, tok, FALSE))
+ if (tag_op_list_append (tag_ops, tok, false))
notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
{
notmuch_database_t *notmuch;
notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
{
notmuch_database_t *notmuch;
- notmuch_bool_t accumulate = FALSE;
+ bool accumulate = false;
tag_op_flag_t flags = 0;
tag_op_list_t *tag_ops;
tag_op_flag_t flags = 0;
tag_op_list_t *tag_ops;
int files = notmuch_thread_get_total_files (thread);
int total = notmuch_thread_get_total_messages (thread);
const char *relative_date = NULL;
int files = notmuch_thread_get_total_files (thread);
int total = notmuch_thread_get_total_messages (thread);
const char *relative_date = NULL;
- notmuch_bool_t first_tag = TRUE;
format->begin_map (format);
format->begin_map (format);
if (format->is_text_printer) {
/* Special case for the text formatter */
if (first_tag)
if (format->is_text_printer) {
/* Special case for the text formatter */
if (first_tag)
else
fputc (' ', stdout);
fputs (tag, stdout);
else
fputc (' ', stdout);
fputs (tag, stdout);
-/* Returns TRUE iff name and addr is duplicate. If not, stores the
+/* Returns true iff name and addr is duplicate. If not, stores the
* name/addr pair in order to detect subsequent duplicates. */
* name/addr pair in order to detect subsequent duplicates. */
is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
{
char *key;
is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
{
char *key;
if (l) {
mailbox = l->data;
mailbox->count++;
if (l) {
mailbox = l->data;
mailbox->count++;
}
mailbox = new_mailbox (ctx->format, name, addr);
if (! mailbox)
}
mailbox = new_mailbox (ctx->format, name, addr);
if (! mailbox)
/*
* XXX: It would be more efficient to prepend to the list, but
/*
* XXX: It would be more efficient to prepend to the list, but
if (list != g_list_append (list, mailbox))
INTERNAL_ERROR ("appending to list changed list head\n");
if (list != g_list_append (list, mailbox))
INTERNAL_ERROR ("appending to list changed list head\n");
}
key = talloc_strdup (ctx->format, addr);
if (! key)
}
key = talloc_strdup (ctx->format, addr);
if (! key)
mailbox = new_mailbox (ctx->format, name, addr);
if (! mailbox)
mailbox = new_mailbox (ctx->format, name, addr);
if (! mailbox)
list = g_list_append (NULL, mailbox);
if (! list)
list = g_list_append (NULL, mailbox);
if (! list)
g_hash_table_insert (ctx->addresses, key, list);
g_hash_table_insert (ctx->addresses, key, list);
/* name_addr has the name part quoted if necessary. Compare
* 'John Doe <john@doe.com>' vs. '"Doe, John" <john@doe.com>' */
/* name_addr has the name part quoted if necessary. Compare
* 'John Doe <john@doe.com>' vs. '"Doe, John" <john@doe.com>' */
- name_addr = internet_address_to_string (ia, FALSE);
+ name_addr = internet_address_to_string (ia, false);
if (format->is_text_printer) {
if (ctx->output & OUTPUT_COUNT) {
if (format->is_text_printer) {
if (ctx->output & OUTPUT_COUNT) {
(const char **)
other_emails->pdata,
other_emails->len);
(const char **)
other_emails->pdata,
other_emails->len);
- g_ptr_array_free (other_emails, TRUE);
+ g_ptr_array_free (other_emails, true);
prompt ("Top-level directory of your email archive [%s]: ",
notmuch_config_get_database_path (config));
prompt ("Top-level directory of your email archive [%s]: ",
notmuch_config_get_database_path (config));
notmuch_config_set_new_tags (config, (const char **) tags->pdata,
tags->len);
notmuch_config_set_new_tags (config, (const char **) tags->pdata,
tags->len);
- g_ptr_array_free (tags, TRUE);
+ g_ptr_array_free (tags, true);
(const char **) tags->pdata,
tags->len);
(const char **) tags->pdata,
tags->len);
- g_ptr_array_free (tags, TRUE);
+ g_ptr_array_free (tags, true);
}
if (notmuch_config_save (config))
}
if (notmuch_config_save (config))
void
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
void
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
{
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
{
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
return;
stream_filter = g_mime_stream_filter_new (stream_out);
return;
stream_filter = g_mime_stream_filter_new (stream_out);
- crlf_filter = g_mime_filter_crlf_new (FALSE, FALSE);
+ crlf_filter = g_mime_filter_crlf_new (false, false);
g_mime_stream_filter_add(GMIME_STREAM_FILTER (stream_filter),
crlf_filter);
g_object_unref (crlf_filter);
g_mime_stream_filter_add(GMIME_STREAM_FILTER (stream_filter),
crlf_filter);
g_object_unref (crlf_filter);
if (flags & NOTMUCH_SHOW_TEXT_PART_REPLY) {
GMimeFilter *reply_filter;
if (flags & NOTMUCH_SHOW_TEXT_PART_REPLY) {
GMimeFilter *reply_filter;
- reply_filter = g_mime_filter_reply_new (TRUE);
+ reply_filter = g_mime_filter_reply_new (true);
if (reply_filter) {
g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),
reply_filter);
if (reply_filter) {
g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),
reply_filter);
for (unsigned int i = 0; i < array_map_len; i++) {
if (errors & key_map[i].bit) {
sp->map_key (sp, key_map[i].string);
for (unsigned int i = 0; i < array_map_len; i++) {
if (errors & key_map[i].bit) {
sp->map_key (sp, key_map[i].string);
- sp->boolean (sp, TRUE);
+ sp->boolean (sp, true);
GMimeObject *meta = node->envelope_part ?
GMIME_OBJECT (node->envelope_part) : node->part;
GMimeContentType *content_type = g_mime_object_get_content_type (meta);
GMimeObject *meta = node->envelope_part ?
GMIME_OBJECT (node->envelope_part) : node->part;
GMimeContentType *content_type = g_mime_object_get_content_type (meta);
- const notmuch_bool_t leaf = GMIME_IS_PART (node->part);
+ const bool leaf = GMIME_IS_PART (node->part);
GMimeStream *stream = params->out_stream;
const char *part_type;
int i;
GMimeStream *stream = params->out_stream;
const char *part_type;
int i;
void
format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
void
format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
- notmuch_bool_t output_body,
- notmuch_bool_t include_html)
+ bool output_body,
+ bool include_html)
{
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
{
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
format_message_sprinter (sp, node->envelope_file);
sp->map_key (sp, "headers");
format_message_sprinter (sp, node->envelope_file);
sp->map_key (sp, "headers");
- format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);
+ format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
if (output_body) {
sp->map_key (sp, "body");
sp->begin_list (sp);
if (output_body) {
sp->map_key (sp, "body");
sp->begin_list (sp);
- format_part_sprinter (ctx, sp, mime_node_child (node, 0), TRUE, include_html);
+ format_part_sprinter (ctx, sp, mime_node_child (node, 0), true, include_html);
sp->end (sp);
}
sp->end (sp);
sp->end (sp);
}
sp->end (sp);
sp->begin_map (sp);
sp->map_key (sp, "headers");
sp->begin_map (sp);
sp->map_key (sp, "headers");
- format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);
+ format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
sp->map_key (sp, "body");
sp->begin_list (sp);
sp->map_key (sp, "body");
sp->begin_list (sp);
}
for (i = 0; i < node->nchildren; i++)
}
for (i = 0; i < node->nchildren; i++)
- format_part_sprinter (ctx, sp, mime_node_child (node, i), TRUE, include_html);
+ format_part_sprinter (ctx, sp, mime_node_child (node, i), true, include_html);
/* Close content structures */
for (i = 0; i < nclose; i++)
/* Close content structures */
for (i = 0; i < nclose; i++)
notmuch_show_params_t *params)
{
notmuch_message_t *message;
notmuch_show_params_t *params)
{
notmuch_message_t *message;
- notmuch_bool_t match;
- notmuch_bool_t excluded;
+ bool match;
+ bool excluded;
int next_indent;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
int next_indent;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
sprinter_t *sprinter;
notmuch_show_params_t params = {
.part = -1,
sprinter_t *sprinter;
notmuch_show_params_t params = {
.part = -1,
- .omit_excluded = TRUE,
- .output_body = TRUE,
+ .omit_excluded = true,
+ .output_body = true,
};
int format = NOTMUCH_FORMAT_NOT_SPECIFIED;
};
int format = NOTMUCH_FORMAT_NOT_SPECIFIED;
- notmuch_bool_t exclude = TRUE;
- notmuch_bool_t entire_thread_set = FALSE;
- notmuch_bool_t single_message;
+ bool exclude = true;
+ bool entire_thread_set = false;
+ bool single_message;
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &format, .name = "format", .keywords =
/* decryption implies verification */
if (params.crypto.decrypt)
/* decryption implies verification */
if (params.crypto.decrypt)
- params.crypto.verify = TRUE;
+ params.crypto.verify = true;
/* specifying a part implies single message display */
single_message = params.part >= 0;
/* specifying a part implies single message display */
single_message = params.part >= 0;
}
} else if (format == NOTMUCH_FORMAT_RAW) {
/* raw format only supports single message display */
}
} else if (format == NOTMUCH_FORMAT_RAW) {
/* raw format only supports single message display */
}
notmuch_exit_if_unsupported_format ();
}
notmuch_exit_if_unsupported_format ();
- /* Default is entire-thread = FALSE except for format=json and
+ /* Default is entire-thread = false except for format=json and
* format=sexp. */
if (! entire_thread_set &&
(format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP))
* format=sexp. */
if (! entire_thread_set &&
(format == NOTMUCH_FORMAT_JSON || format == NOTMUCH_FORMAT_SEXP))
- params.entire_thread = TRUE;
+ params.entire_thread = true;
if (!params.output_body) {
if (params.part > 0) {
fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
if (!params.output_body) {
if (params.part > 0) {
fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
- params.output_body = TRUE;
+ params.output_body = true;
} else {
if (format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP)
fprintf (stderr,
} else {
if (format != NOTMUCH_FORMAT_JSON && format != NOTMUCH_FORMAT_SEXP)
fprintf (stderr,
- if (exclude == FALSE) {
- notmuch_query_set_omit_excluded (query, FALSE);
- params.omit_excluded = FALSE;
+ if (exclude == false) {
+ notmuch_query_set_omit_excluded (query, false);
+ params.omit_excluded = false;
}
ret = do_show (config, query, formatter, sprinter, ¶ms);
}
ret = do_show (config, query, formatter, sprinter, ¶ms);
notmuch_database_t *notmuch;
struct sigaction action;
tag_op_flag_t tag_flags = TAG_FLAG_NONE;
notmuch_database_t *notmuch;
struct sigaction action;
tag_op_flag_t tag_flags = TAG_FLAG_NONE;
- notmuch_bool_t batch = FALSE;
- notmuch_bool_t remove_all = FALSE;
+ bool batch = false;
+ bool remove_all = false;
FILE *input = stdin;
const char *input_file_name = NULL;
int opt_index;
FILE *input = stdin;
const char *input_file_name = NULL;
int opt_index;
notmuch_process_shared_options (argv[0]);
if (input_file_name) {
notmuch_process_shared_options (argv[0]);
if (input_file_name) {
input = fopen (input_file_name, "r");
if (input == NULL) {
fprintf (stderr, "Error opening %s for reading: %s\n",
input = fopen (input_file_name, "r");
if (input == NULL) {
fprintf (stderr, "Error opening %s for reading: %s\n",
static int
_help_for (const char *topic);
static int
_help_for (const char *topic);
-static notmuch_bool_t print_version = FALSE, print_help = FALSE;
+static bool print_version = false, print_help = false;
const char *notmuch_requested_db_uuid = NULL;
const notmuch_opt_desc_t notmuch_shared_options [] = {
const char *notmuch_requested_db_uuid = NULL;
const notmuch_opt_desc_t notmuch_shared_options [] = {
* is).
*
* Does not return if the external command is found and
* is).
*
* Does not return if the external command is found and
- * executed. Return TRUE if external command is not found. Return
- * FALSE on errors.
+ * executed. Return true if external command is not found. Return
+ * false on errors.
-static notmuch_bool_t try_external_command(char *argv[])
+static bool try_external_command(char *argv[])
{
char *old_argv0 = argv[0];
{
char *old_argv0 = argv[0];
- notmuch_bool_t ret = TRUE;
argv[0] = talloc_asprintf (NULL, "notmuch-%s", old_argv0);
argv[0] = talloc_asprintf (NULL, "notmuch-%s", old_argv0);
if (errno != ENOENT) {
fprintf (stderr, "Error: Running external command '%s' failed: %s\n",
argv[0], strerror(errno));
if (errno != ENOENT) {
fprintf (stderr, "Error: Running external command '%s' failed: %s\n",
argv[0], strerror(errno));
/* A flag to signify that a separator should be inserted in the
* output as soon as possible.
*/
/* A flag to signify that a separator should be inserted in the
* output as soon as possible.
*/
- notmuch_bool_t insert_separator;
};
struct json_state {
struct json_state *parent;
/* True if nothing has been printed in this aggregate yet.
* Suppresses the comma before a value. */
};
struct json_state {
struct json_state *parent;
/* True if nothing has been printed in this aggregate yet.
* Suppresses the comma before a value. */
/* The character that closes the current aggregate. */
char close;
};
/* The character that closes the current aggregate. */
char close;
};
fputc (',', spj->stream);
if (spj->insert_separator) {
fputc ('\n', spj->stream);
fputc (',', spj->stream);
if (spj->insert_separator) {
fputc ('\n', spj->stream);
- spj->insert_separator = FALSE;
+ spj->insert_separator = false;
} else {
fputc (' ', spj->stream);
}
} else {
} else {
fputc (' ', spj->stream);
}
} else {
- spj->state->first = FALSE;
+ spj->state->first = false;
fputc (open, spj->stream);
state->parent = spj->state;
fputc (open, spj->stream);
state->parent = spj->state;
state->close = close;
spj->state = state;
}
state->close = close;
spj->state = state;
}
-json_boolean (struct sprinter *sp, notmuch_bool_t val)
+json_boolean (struct sprinter *sp, bool val)
{
struct sprinter_json *spj = json_begin_value (sp);
{
struct sprinter_json *spj = json_begin_value (sp);
json_string (sp, key);
fputs (": ", spj->stream);
json_string (sp, key);
fputs (": ", spj->stream);
- spj->state->first = TRUE;
+ spj->state->first = true;
{
struct sprinter_json *spj = (struct sprinter_json *) sp;
{
struct sprinter_json *spj = (struct sprinter_json *) sp;
- spj->insert_separator = TRUE;
+ spj->insert_separator = true;
.map_key = json_map_key,
.separator = json_separator,
.set_prefix = json_set_prefix,
.map_key = json_map_key,
.separator = json_separator,
.set_prefix = json_set_prefix,
- .is_text_printer = FALSE,
+ .is_text_printer = false,
}
};
struct sprinter_json *res;
}
};
struct sprinter_json *res;
/* A flag to signify that a separator should be inserted in the
* output as soon as possible. */
/* A flag to signify that a separator should be inserted in the
* output as soon as possible. */
- notmuch_bool_t insert_separator;
/* True if nothing has been printed in this aggregate yet.
* Suppresses the space before a value. */
/* True if nothing has been printed in this aggregate yet.
* Suppresses the space before a value. */
};
/* Helper function to set up the stream to print a value. If this
};
/* Helper function to set up the stream to print a value. If this
if (! sps->state->first) {
if (sps->insert_separator) {
fputc ('\n', sps->stream);
if (! sps->state->first) {
if (sps->insert_separator) {
fputc ('\n', sps->stream);
- sps->insert_separator = FALSE;
+ sps->insert_separator = false;
} else {
fputc (' ', sps->stream);
}
} else {
} else {
fputc (' ', sps->stream);
}
} else {
- sps->state->first = FALSE;
+ sps->state->first = false;
fputc ('(', sps->stream);
state->parent = sps->state;
fputc ('(', sps->stream);
state->parent = sps->state;
-sexp_boolean (struct sprinter *sp, notmuch_bool_t val)
+sexp_boolean (struct sprinter *sp, bool val)
{
struct sprinter_sexp *sps = sexp_begin_value (sp);
{
struct sprinter_sexp *sps = sexp_begin_value (sp);
{
struct sprinter_sexp *sps = (struct sprinter_sexp *) sp;
{
struct sprinter_sexp *sps = (struct sprinter_sexp *) sp;
- sps->insert_separator = TRUE;
+ sps->insert_separator = true;
.map_key = sexp_map_key,
.separator = sexp_separator,
.set_prefix = sexp_set_prefix,
.map_key = sexp_map_key,
.separator = sexp_separator,
.set_prefix = sexp_set_prefix,
- .is_text_printer = FALSE,
+ .is_text_printer = false,
}
};
struct sprinter_sexp *res;
}
};
struct sprinter_sexp *res;
/* A flag to indicate if this is the first tag. Used in list of tags
* for summary.
*/
/* A flag to indicate if this is the first tag. Used in list of tags
* for summary.
*/
- notmuch_bool_t first_tag;
-text_boolean (struct sprinter *sp, notmuch_bool_t val)
+text_boolean (struct sprinter *sp, bool val)
{
struct sprinter_text *sptxt = (struct sprinter_text *) sp;
{
struct sprinter_text *sptxt = (struct sprinter_text *) sp;
.map_key = text_map_key,
.separator = text_separator,
.set_prefix = text_set_prefix,
.map_key = text_map_key,
.separator = text_separator,
.set_prefix = text_set_prefix,
- .is_text_printer = TRUE,
+ .is_text_printer = true,
},
};
struct sprinter_text *res;
},
};
struct sprinter_text *res;
#ifndef NOTMUCH_SPRINTER_H
#define NOTMUCH_SPRINTER_H
#ifndef NOTMUCH_SPRINTER_H
#define NOTMUCH_SPRINTER_H
-/* Necessary for notmuch_bool_t */
+/* Necessary for bool */
#include "notmuch-client.h"
/* Structure printer interface. This is used to create output
#include "notmuch-client.h"
/* Structure printer interface. This is used to create output
void (*string) (struct sprinter *, const char *);
void (*string_len) (struct sprinter *, const char *, size_t);
void (*integer) (struct sprinter *, int);
void (*string) (struct sprinter *, const char *);
void (*string_len) (struct sprinter *, const char *, size_t);
void (*integer) (struct sprinter *, int);
- void (*boolean) (struct sprinter *, notmuch_bool_t);
+ 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
void (*null) (struct sprinter *);
/* Print the key of a map's key/value pair. The char * must be UTF-8
/* True if this is the special-cased plain text printer.
*/
/* True if this is the special-cased plain text printer.
*/
- notmuch_bool_t is_text_printer;
struct _tag_operation_t {
const char *tag;
struct _tag_operation_t {
const char *tag;
};
struct _tag_op_list_t {
};
struct _tag_op_list_t {
-illegal_tag (const char *tag, notmuch_bool_t remove)
+illegal_tag (const char *tag, bool remove)
{
if (*tag == '\0' && ! remove)
return "empty tag forbidden";
{
if (*tag == '\0' && ! remove)
return "empty tag forbidden";
/* Parse tags. */
while ((tok = strtok_len (tok + tok_len, " ", &tok_len)) != NULL) {
/* Parse tags. */
while ((tok = strtok_len (tok + tok_len, " ", &tok_len)) != NULL) {
char *tag;
/* Optional explicit end of tags marker. */
char *tag;
/* Optional explicit end of tags marker. */
if (argv[i][0] != '+' && argv[i][0] != '-')
break;
if (argv[i][0] != '+' && argv[i][0] != '-')
break;
- notmuch_bool_t is_remove = argv[i][0] == '-';
+ bool is_remove = argv[i][0] == '-';
const char *msg;
msg = illegal_tag (argv[i] + 1, is_remove);
const char *msg;
msg = illegal_tag (argv[i] + 1, is_remove);
size_t i;
notmuch_tags_t *tags;
size_t i;
notmuch_tags_t *tags;
- notmuch_bool_t changes = FALSE;
/* First, do we delete an existing tag? */
for (tags = notmuch_message_get_tags (message);
/* First, do we delete an existing tag? */
for (tags = notmuch_message_get_tags (message);
notmuch_tags_destroy (tags);
if (changes)
notmuch_tags_destroy (tags);
if (changes)
/* Now check for adding new tags */
for (i = 0; i < list->count; i++) {
/* Now check for adding new tags */
for (i = 0; i < list->count; i++) {
- notmuch_bool_t exists = FALSE;
if (list->ops[i].remove)
continue;
if (list->ops[i].remove)
continue;
notmuch_tags_move_to_next (tags)) {
const char *cur_tag = notmuch_tags_get (tags);
if (strcmp (cur_tag, list->ops[i].tag) == 0) {
notmuch_tags_move_to_next (tags)) {
const char *cur_tag = notmuch_tags_get (tags);
if (strcmp (cur_tag, list->ops[i].tag) == 0) {
* but this is OK from a correctness point of view
*/
if (! exists)
* but this is OK from a correctness point of view
*/
if (! exists)
int
tag_op_list_append (tag_op_list_t *list,
const char *tag,
int
tag_op_list_append (tag_op_list_t *list,
const char *tag,
{
/* Make room if current array is full. This should be a fairly
* rare case, considering the initial array size.
{
/* Make room if current array is full. This should be a fairly
* rare case, considering the initial array size.
* Is the i'th tag operation a remove?
*/
* Is the i'th tag operation a remove?
*/
tag_op_list_isremove (const tag_op_list_t *list, size_t i)
{
assert (i < list->count);
tag_op_list_isremove (const tag_op_list_t *list, size_t i)
{
assert (i < list->count);
* explanatory message otherwise.
*/
const char *
* explanatory message otherwise.
*/
const char *
-illegal_tag (const char *tag, notmuch_bool_t remove);
+illegal_tag (const char *tag, bool remove);
/*
* Create an empty list of tag operations
/*
* Create an empty list of tag operations
tag_op_list_create (void *ctx);
/*
tag_op_list_create (void *ctx);
/*
- * Add a tag operation (delete iff remove == TRUE) to a list.
+ * Add a tag operation (delete iff remove == true) to a list.
* The list is expanded as necessary.
*/
int
tag_op_list_append (tag_op_list_t *list,
const char *tag,
* The list is expanded as necessary.
*/
int
tag_op_list_append (tag_op_list_t *list,
const char *tag,
- notmuch_bool_t remove);
/*
* Apply a list of tag operations, in order, to a given message.
/*
* Apply a list of tag operations, in order, to a given message.
* Is the i'th tag operation a remove?
*/
* Is the i'th tag operation a remove?
*/
tag_op_list_isremove (const tag_op_list_t *list, size_t i);
#endif
tag_op_list_isremove (const tag_op_list_t *list, size_t i);
#endif
const char *pos_arg1=NULL;
const char *pos_arg2=NULL;
const char *string_val=NULL;
const char *pos_arg1=NULL;
const char *pos_arg2=NULL;
const char *string_val=NULL;
- notmuch_bool_t bool_val = FALSE;
- notmuch_bool_t fl_set = FALSE, int_set = FALSE, bool_set = FALSE,
- kw_set = FALSE, string_set = FALSE, pos1_set = FALSE, pos2_set = FALSE;
+ bool bool_val = false;
+ bool fl_set = false, int_set = false, bool_set = false,
+ kw_set = false, string_set = false, pos1_set = false, pos2_set = false;
notmuch_opt_desc_t parent_options[] = {
{ .opt_flags = &fl_val, .name = "flag", .present = &fl_set, .keywords =
notmuch_opt_desc_t parent_options[] = {
{ .opt_flags = &fl_val, .name = "flag", .present = &fl_set, .keywords =
-static int inplace = FALSE;
+static bool inplace = false;
static int
xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
static int
xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
- notmuch_bool_t omit_newline = FALSE;
+ bool omit_newline = false;
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &dir, .name = "direction", .keywords =
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &dir, .name = "direction", .keywords =
char *buffer = NULL;
size_t buf_size = 0;
char *buffer = NULL;
size_t buf_size = 0;
- notmuch_bool_t read_stdin = TRUE;
+ bool read_stdin = true;
for (; opt_index < argc; opt_index++) {
for (; opt_index < argc; opt_index++) {
if (! omit_newline)
putchar ('\n');
if (! omit_newline)
putchar ('\n');
- config = notmuch_config_open (ctx, config_path, FALSE);
+ config = notmuch_config_open (ctx, config_path, false);
if (config == NULL)
return 1;
if (config == NULL)
return 1;