2009-11-10 21:03:05 +01:00
|
|
|
/* notmuch - Not much of an email program, (just index and search)
|
|
|
|
*
|
|
|
|
* Copyright © 2009 Carl Worth
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-06-02 18:26:14 +02:00
|
|
|
* along with this program. If not, see https://www.gnu.org/licenses/ .
|
2009-11-10 21:03:05 +01:00
|
|
|
*
|
|
|
|
* Author: Carl Worth <cworth@cworth.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NOTMUCH_CLIENT_H
|
|
|
|
#define NOTMUCH_CLIENT_H
|
|
|
|
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE /* for getline */
|
|
|
|
#endif
|
2017-10-07 10:44:04 +02:00
|
|
|
#include <stdbool.h>
|
2009-11-10 21:03:05 +01:00
|
|
|
#include <stdio.h>
|
2016-11-21 21:14:33 +01:00
|
|
|
#include <sysexits.h>
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2009-12-02 00:23:25 +01:00
|
|
|
#include "compat.h"
|
|
|
|
|
2017-05-27 18:51:12 +02:00
|
|
|
#include "gmime-extra.h"
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2015-08-16 19:41:14 +02:00
|
|
|
/* This is automatically included only since gmime 2.6.10 */
|
|
|
|
#include <gmime/gmime-pkcs7-context.h>
|
2012-01-20 10:39:24 +01:00
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
#include "notmuch.h"
|
|
|
|
|
|
|
|
/* This is separate from notmuch-private.h because we're trying to
|
|
|
|
* keep notmuch.c from looking into any internals, (which helps us
|
|
|
|
* develop notmuch.h into a plausible library interface).
|
|
|
|
*/
|
|
|
|
#include "xutil.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
2015-09-25 18:48:20 +02:00
|
|
|
#include <ctype.h>
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2012-12-17 04:12:51 +01:00
|
|
|
#include "talloc-extra.h"
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
#define unused(x) x __attribute__ ((unused))
|
|
|
|
|
2010-04-02 20:55:09 +02:00
|
|
|
#define STRINGIFY(s) STRINGIFY_(s)
|
|
|
|
#define STRINGIFY_(s) #s
|
|
|
|
|
2012-03-18 17:32:36 +01:00
|
|
|
typedef struct mime_node mime_node_t;
|
2012-08-03 03:14:52 +02:00
|
|
|
struct sprinter;
|
2012-01-24 00:33:10 +01:00
|
|
|
struct notmuch_show_params;
|
|
|
|
|
2011-05-20 20:45:33 +02:00
|
|
|
typedef struct notmuch_show_format {
|
2012-08-03 03:14:50 +02:00
|
|
|
struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
|
2012-08-03 03:14:52 +02:00
|
|
|
notmuch_status_t (*part) (const void *ctx, struct sprinter *sprinter,
|
2012-03-06 19:48:39 +01:00
|
|
|
struct mime_node *node, int indent,
|
|
|
|
const struct notmuch_show_params *params);
|
2011-05-20 20:45:33 +02:00
|
|
|
} notmuch_show_format_t;
|
|
|
|
|
2017-10-10 07:49:02 +02:00
|
|
|
typedef struct _notmuch_crypto {
|
2017-10-07 10:44:04 +02:00
|
|
|
bool verify;
|
|
|
|
bool decrypt;
|
2017-07-14 15:12:00 +02:00
|
|
|
#if (GMIME_MAJOR_VERSION < 3)
|
2017-10-10 07:49:03 +02:00
|
|
|
GMimeCryptoContext* gpgctx;
|
|
|
|
GMimeCryptoContext* pkcs7ctx;
|
2014-12-09 21:01:10 +01:00
|
|
|
const char *gpgpath;
|
2017-07-14 15:12:00 +02:00
|
|
|
#endif
|
2017-10-10 07:49:02 +02:00
|
|
|
} _notmuch_crypto_t;
|
2012-05-26 20:45:41 +02:00
|
|
|
|
2011-05-21 00:01:52 +02:00
|
|
|
typedef struct notmuch_show_params {
|
2017-10-07 10:44:04 +02:00
|
|
|
bool entire_thread;
|
|
|
|
bool omit_excluded;
|
|
|
|
bool output_body;
|
2011-05-24 00:31:32 +02:00
|
|
|
int part;
|
2017-10-10 07:49:02 +02:00
|
|
|
_notmuch_crypto_t crypto;
|
2017-10-07 10:44:04 +02:00
|
|
|
bool include_html;
|
2017-05-27 18:51:13 +02:00
|
|
|
GMimeStream *out_stream;
|
2011-05-21 00:01:52 +02:00
|
|
|
} notmuch_show_params_t;
|
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
/* There's no point in continuing when we've detected that we've done
|
|
|
|
* something wrong internally (as opposed to the user passing in a
|
|
|
|
* bogus value).
|
|
|
|
*
|
|
|
|
* Note that __location__ comes from talloc.h.
|
|
|
|
*/
|
|
|
|
#define INTERNAL_ERROR(format, ...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, \
|
|
|
|
"Internal error: " format " (%s)\n", \
|
|
|
|
##__VA_ARGS__, __location__); \
|
|
|
|
exit (1); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
|
|
|
|
|
2009-11-13 05:47:12 +01:00
|
|
|
#define STRNCMP_LITERAL(var, literal) \
|
|
|
|
strncmp ((var), (literal), sizeof (literal) - 1)
|
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
static inline void
|
|
|
|
chomp_newline (char *str)
|
|
|
|
{
|
|
|
|
if (str && str[strlen(str)-1] == '\n')
|
|
|
|
str[strlen(str)-1] = '\0';
|
|
|
|
}
|
|
|
|
|
2016-11-21 21:14:33 +01:00
|
|
|
/* Exit status code indicating temporary failure; user is invited to
|
|
|
|
* retry.
|
|
|
|
*
|
|
|
|
* For example, file(s) in the mail store were removed or renamed
|
|
|
|
* after notmuch new scanned the directories but before indexing the
|
|
|
|
* file(s). If the file was renamed, the indexing might not be
|
|
|
|
* complete, and the user is advised to re-run notmuch new.
|
|
|
|
*/
|
|
|
|
#define NOTMUCH_EXIT_TEMPFAIL EX_TEMPFAIL
|
|
|
|
|
2012-12-16 04:17:23 +01:00
|
|
|
/* Exit status code indicating the requested format version is too old
|
|
|
|
* (support for that version has been dropped). CLI code should use
|
|
|
|
* notmuch_exit_if_unsupported_format rather than directly exiting
|
|
|
|
* with this code.
|
|
|
|
*/
|
|
|
|
#define NOTMUCH_EXIT_FORMAT_TOO_OLD 20
|
|
|
|
/* Exit status code indicating the requested format version is newer
|
|
|
|
* than the version supported by the CLI. CLI code should use
|
|
|
|
* notmuch_exit_if_unsupported_format rather than directly exiting
|
|
|
|
* with this code.
|
|
|
|
*/
|
|
|
|
#define NOTMUCH_EXIT_FORMAT_TOO_NEW 21
|
|
|
|
|
|
|
|
/* The current structured output format version. Requests for format
|
|
|
|
* versions above this will return an error. Backwards-incompatible
|
|
|
|
* changes such as removing map fields, changing the meaning of map
|
|
|
|
* fields, or changing the meanings of list elements should increase
|
|
|
|
* this. New (required) map fields can be added without increasing
|
|
|
|
* this.
|
|
|
|
*/
|
2017-06-03 19:47:34 +02:00
|
|
|
#define NOTMUCH_FORMAT_CUR 4
|
2012-12-16 04:17:23 +01:00
|
|
|
/* The minimum supported structured output format version. Requests
|
|
|
|
* for format versions below this will return an error. */
|
|
|
|
#define NOTMUCH_FORMAT_MIN 1
|
2013-10-24 17:19:02 +02:00
|
|
|
/* The minimum non-deprecated structured output format version.
|
|
|
|
* Requests for format versions below this will print a stern warning.
|
|
|
|
* Must be between NOTMUCH_FORMAT_MIN and NOTMUCH_FORMAT_CUR,
|
|
|
|
* inclusive.
|
|
|
|
*/
|
|
|
|
#define NOTMUCH_FORMAT_MIN_ACTIVE 1
|
2012-12-16 04:17:23 +01:00
|
|
|
|
|
|
|
/* The output format version requested by the caller on the command
|
|
|
|
* line. If no format version is requested, this will be set to
|
|
|
|
* NOTMUCH_FORMAT_CUR. Even though the command-line option is
|
|
|
|
* per-command, this is global because commands can share structured
|
|
|
|
* output code.
|
|
|
|
*/
|
|
|
|
extern int notmuch_format_version;
|
|
|
|
|
2013-03-03 22:55:09 +01:00
|
|
|
typedef struct _notmuch_config notmuch_config_t;
|
|
|
|
|
2012-12-16 04:17:23 +01:00
|
|
|
/* Commands that support structured output should support the
|
|
|
|
* following argument
|
|
|
|
* { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 }
|
|
|
|
* and should invoke notmuch_exit_if_unsupported_format to check the
|
|
|
|
* requested version. If notmuch_format_version is outside the
|
|
|
|
* supported range, this will print a detailed diagnostic message for
|
|
|
|
* the user and exit with NOTMUCH_EXIT_FORMAT_TOO_{OLD,NEW} to inform
|
|
|
|
* the invoking program of the problem.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
notmuch_exit_if_unsupported_format (void);
|
|
|
|
|
2017-07-16 01:01:46 +02:00
|
|
|
#if (GMIME_MAJOR_VERSION <3)
|
2017-10-10 07:49:03 +02:00
|
|
|
GMimeCryptoContext *
|
|
|
|
_notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protocol);
|
2017-07-16 01:01:46 +02:00
|
|
|
#endif
|
2012-05-26 20:45:41 +02:00
|
|
|
|
2017-10-10 07:49:04 +02:00
|
|
|
void
|
2017-10-10 07:49:02 +02:00
|
|
|
_notmuch_crypto_cleanup (_notmuch_crypto_t *crypto);
|
2012-05-26 20:45:41 +02:00
|
|
|
|
2009-11-21 08:15:07 +01:00
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2009-11-06 19:00:38 +01:00
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-06 19:00:38 +01:00
|
|
|
|
2013-06-23 14:20:45 +02:00
|
|
|
int
|
|
|
|
notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]);
|
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
int
|
2017-06-04 14:32:35 +02:00
|
|
|
notmuch_reindex_command (notmuch_config_t *config, int argc, char *argv[]);
|
|
|
|
|
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2014-11-05 01:25:55 +01:00
|
|
|
int
|
|
|
|
notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]);
|
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_setup_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
2009-11-23 01:10:55 +01:00
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]);
|
2009-11-23 01:10:55 +01:00
|
|
|
|
2010-10-22 11:28:03 +02:00
|
|
|
int
|
2013-03-03 22:55:09 +01:00
|
|
|
notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]);
|
2013-10-02 22:30:47 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[]);
|
2010-10-27 22:02:17 +02:00
|
|
|
|
2009-11-10 21:03:05 +01:00
|
|
|
const char *
|
2009-11-18 04:10:37 +01:00
|
|
|
notmuch_time_relative_date (const void *ctx, time_t then);
|
2009-11-10 21:03:05 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_time_print_formatted_seconds (double seconds);
|
|
|
|
|
|
|
|
double
|
|
|
|
notmuch_time_elapsed (struct timeval start, struct timeval end);
|
|
|
|
|
2009-11-06 19:00:38 +01:00
|
|
|
char *
|
|
|
|
query_string_from_args (void *ctx, int argc, char *argv[]);
|
|
|
|
|
2010-03-24 08:21:20 +01:00
|
|
|
notmuch_status_t
|
|
|
|
show_one_part (const char *filename, int part);
|
|
|
|
|
2012-03-18 17:32:36 +01:00
|
|
|
void
|
2012-12-06 22:12:12 +01:00
|
|
|
format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
|
2017-10-07 10:44:04 +02:00
|
|
|
bool output_body,
|
|
|
|
bool include_html);
|
2012-03-18 17:32:36 +01:00
|
|
|
|
|
|
|
void
|
2012-12-06 22:12:12 +01:00
|
|
|
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
|
2017-10-07 10:44:04 +02:00
|
|
|
bool reply);
|
2012-03-18 17:32:36 +01:00
|
|
|
|
2012-03-27 23:59:50 +02:00
|
|
|
typedef enum {
|
|
|
|
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
|
|
|
|
} notmuch_show_text_part_flags;
|
|
|
|
|
|
|
|
void
|
|
|
|
show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
|
|
|
|
notmuch_show_text_part_flags flags);
|
|
|
|
|
2010-04-05 11:33:19 +02:00
|
|
|
char *
|
|
|
|
json_quote_chararray (const void *ctx, const char *str, const size_t len);
|
|
|
|
|
2009-12-31 16:17:40 +01:00
|
|
|
char *
|
|
|
|
json_quote_str (const void *ctx, const char *str);
|
|
|
|
|
2009-11-12 02:01:55 +01:00
|
|
|
/* notmuch-config.c */
|
|
|
|
|
2017-02-26 20:12:38 +01:00
|
|
|
typedef enum {
|
|
|
|
NOTMUCH_CONFIG_OPEN = 1 << 0,
|
|
|
|
NOTMUCH_CONFIG_CREATE = 1 << 1,
|
|
|
|
} notmuch_config_mode_t;
|
|
|
|
|
2009-11-12 02:01:55 +01:00
|
|
|
notmuch_config_t *
|
2009-11-12 02:33:31 +01:00
|
|
|
notmuch_config_open (void *ctx,
|
|
|
|
const char *filename,
|
2017-02-26 20:12:38 +01:00
|
|
|
notmuch_config_mode_t config_mode);
|
2009-11-12 02:01:55 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_close (notmuch_config_t *config);
|
|
|
|
|
|
|
|
int
|
|
|
|
notmuch_config_save (notmuch_config_t *config);
|
|
|
|
|
2017-10-07 10:44:04 +02:00
|
|
|
bool
|
2013-03-03 22:55:07 +01:00
|
|
|
notmuch_config_is_new (notmuch_config_t *config);
|
|
|
|
|
2009-11-12 02:01:55 +01:00
|
|
|
const char *
|
|
|
|
notmuch_config_get_database_path (notmuch_config_t *config);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_database_path (notmuch_config_t *config,
|
|
|
|
const char *database_path);
|
|
|
|
|
2017-07-14 15:12:00 +02:00
|
|
|
#if (GMIME_MAJOR_VERSION < 3)
|
2014-12-09 21:01:11 +01:00
|
|
|
const char *
|
|
|
|
notmuch_config_get_crypto_gpg_path (notmuch_config_t *config);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,
|
|
|
|
const char *gpg_path);
|
2017-07-14 15:12:00 +02:00
|
|
|
#endif
|
2014-12-09 21:01:11 +01:00
|
|
|
|
2009-11-12 02:01:55 +01:00
|
|
|
const char *
|
|
|
|
notmuch_config_get_user_name (notmuch_config_t *config);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_user_name (notmuch_config_t *config,
|
|
|
|
const char *user_name);
|
|
|
|
|
|
|
|
const char *
|
|
|
|
notmuch_config_get_user_primary_email (notmuch_config_t *config);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_user_primary_email (notmuch_config_t *config,
|
|
|
|
const char *primary_email);
|
|
|
|
|
2010-10-27 22:02:17 +02:00
|
|
|
const char **
|
2009-11-12 02:01:55 +01:00
|
|
|
notmuch_config_get_user_other_email (notmuch_config_t *config,
|
|
|
|
size_t *length);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_user_other_email (notmuch_config_t *config,
|
|
|
|
const char *other_email[],
|
|
|
|
size_t length);
|
|
|
|
|
2010-04-23 18:19:52 +02:00
|
|
|
const char **
|
2010-03-12 23:13:26 +01:00
|
|
|
notmuch_config_get_new_tags (notmuch_config_t *config,
|
|
|
|
size_t *length);
|
|
|
|
void
|
|
|
|
notmuch_config_set_new_tags (notmuch_config_t *config,
|
|
|
|
const char *new_tags[],
|
|
|
|
size_t length);
|
|
|
|
|
2012-02-15 10:17:31 +01:00
|
|
|
const char **
|
|
|
|
notmuch_config_get_new_ignore (notmuch_config_t *config,
|
|
|
|
size_t *length);
|
|
|
|
|
|
|
|
void
|
|
|
|
notmuch_config_set_new_ignore (notmuch_config_t *config,
|
|
|
|
const char *new_ignore[],
|
|
|
|
size_t length);
|
|
|
|
|
2017-10-07 10:44:04 +02:00
|
|
|
bool
|
2010-11-11 01:26:14 +01:00
|
|
|
notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
|
2010-10-31 22:29:17 +01:00
|
|
|
|
|
|
|
void
|
2010-11-11 01:26:14 +01:00
|
|
|
notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
|
2017-10-07 10:44:04 +02:00
|
|
|
bool synchronize_flags);
|
2010-10-31 22:29:17 +01:00
|
|
|
|
2012-01-15 01:17:34 +01:00
|
|
|
const char **
|
2012-01-23 05:22:32 +01:00
|
|
|
notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length);
|
2012-01-15 01:17:34 +01:00
|
|
|
|
|
|
|
void
|
2012-01-23 05:22:32 +01:00
|
|
|
notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
|
2012-01-15 01:17:34 +01:00
|
|
|
const char *list[],
|
|
|
|
size_t length);
|
|
|
|
|
2011-12-08 23:48:29 +01:00
|
|
|
int
|
|
|
|
notmuch_run_hook (const char *db_path, const char *hook);
|
|
|
|
|
2017-10-07 10:44:04 +02:00
|
|
|
bool
|
2009-11-22 01:44:31 +01:00
|
|
|
debugger_is_active (void);
|
|
|
|
|
2011-12-24 19:52:44 +01:00
|
|
|
/* mime-node.c */
|
|
|
|
|
|
|
|
/* mime_node_t represents a single node in a MIME tree. A MIME tree
|
|
|
|
* abstracts the different ways of traversing different types of MIME
|
|
|
|
* parts, allowing a MIME message to be viewed as a generic tree of
|
|
|
|
* parts. Message-type parts have one child, multipart-type parts
|
|
|
|
* have multiple children, and leaf parts have zero children.
|
|
|
|
*/
|
2012-03-18 17:32:36 +01:00
|
|
|
struct mime_node {
|
2011-12-24 19:52:44 +01:00
|
|
|
/* The MIME object of this part. This will be a GMimeMessage,
|
|
|
|
* GMimePart, GMimeMultipart, or a subclass of one of these.
|
|
|
|
*
|
|
|
|
* This will never be a GMimeMessagePart because GMimeMessagePart
|
|
|
|
* is structurally redundant with GMimeMessage. If this part is a
|
|
|
|
* message (that is, 'part' is a GMimeMessage), then either
|
|
|
|
* envelope_file will be set to a notmuch_message_t (for top-level
|
|
|
|
* messages) or envelope_part will be set to a GMimeMessagePart
|
|
|
|
* (for embedded message parts).
|
|
|
|
*/
|
|
|
|
GMimeObject *part;
|
|
|
|
|
|
|
|
/* If part is a GMimeMessage, these record the envelope of the
|
|
|
|
* message: either a notmuch_message_t representing a top-level
|
|
|
|
* message, or a GMimeMessagePart representing a MIME part
|
|
|
|
* containing a message.
|
|
|
|
*/
|
|
|
|
notmuch_message_t *envelope_file;
|
|
|
|
GMimeMessagePart *envelope_part;
|
|
|
|
|
|
|
|
/* The number of children of this part. */
|
|
|
|
int nchildren;
|
|
|
|
|
2012-01-24 00:33:09 +01:00
|
|
|
/* The parent of this node or NULL if this is the root node. */
|
|
|
|
struct mime_node *parent;
|
|
|
|
|
|
|
|
/* The depth-first part number of this child if the MIME tree is
|
|
|
|
* being traversed in depth-first order, or -1 otherwise. */
|
|
|
|
int part_num;
|
|
|
|
|
2011-12-24 19:52:44 +01:00
|
|
|
/* True if decryption of this part was attempted. */
|
2017-10-07 10:44:04 +02:00
|
|
|
bool decrypt_attempted;
|
2011-12-24 19:52:44 +01:00
|
|
|
/* 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). */
|
2017-10-07 10:44:04 +02:00
|
|
|
bool decrypt_success;
|
2011-12-24 19:52:44 +01:00
|
|
|
|
|
|
|
/* True if signature verification on this part was attempted. */
|
2017-10-07 10:44:04 +02:00
|
|
|
bool verify_attempted;
|
2015-08-16 17:33:21 +02:00
|
|
|
|
2012-01-20 10:39:24 +01:00
|
|
|
/* The list of signatures for signed or encrypted containers. If
|
|
|
|
* there are no signatures, this will be NULL. */
|
|
|
|
GMimeSignatureList* sig_list;
|
2011-12-24 19:52:44 +01:00
|
|
|
|
|
|
|
/* Internal: Context inherited from the root iterator. */
|
|
|
|
struct mime_node_context *ctx;
|
|
|
|
|
|
|
|
/* Internal: For successfully decrypted multipart parts, the
|
|
|
|
* decrypted part to substitute for the second child. */
|
|
|
|
GMimeObject *decrypted_child;
|
2012-01-24 00:33:09 +01:00
|
|
|
|
|
|
|
/* Internal: The next child for depth-first traversal and the part
|
|
|
|
* number to assign it (or -1 if unknown). */
|
|
|
|
int next_child;
|
|
|
|
int next_part_num;
|
2012-03-18 17:32:36 +01:00
|
|
|
};
|
2011-12-24 19:52:44 +01:00
|
|
|
|
|
|
|
/* Construct a new MIME node pointing to the root message part of
|
2012-05-26 20:45:45 +02:00
|
|
|
* message. If crypto->verify is true, signed child parts will be
|
|
|
|
* verified. If crypto->decrypt is true, encrypted child parts will be
|
2015-08-16 19:41:14 +02:00
|
|
|
* decrypted. If the crypto contexts (crypto->gpgctx or
|
|
|
|
* crypto->pkcs7) are NULL, they will be lazily initialized.
|
2011-12-24 19:52:44 +01:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
*
|
|
|
|
* NOTMUCH_STATUS_SUCCESS: Root node is returned in *node_out.
|
|
|
|
*
|
|
|
|
* NOTMUCH_STATUS_FILE_ERROR: Failed to open message file.
|
|
|
|
*
|
|
|
|
* NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
|
|
|
|
*/
|
|
|
|
notmuch_status_t
|
|
|
|
mime_node_open (const void *ctx, notmuch_message_t *message,
|
2017-10-10 07:49:02 +02:00
|
|
|
_notmuch_crypto_t *crypto, mime_node_t **node_out);
|
2011-12-24 19:52:44 +01:00
|
|
|
|
|
|
|
/* Return a new MIME node for the requested child part of parent.
|
|
|
|
* parent will be used as the talloc context for the returned child
|
|
|
|
* node.
|
|
|
|
*
|
|
|
|
* In case of any failure, this function returns NULL, (after printing
|
|
|
|
* an error message on stderr).
|
|
|
|
*/
|
|
|
|
mime_node_t *
|
2012-01-24 00:33:09 +01:00
|
|
|
mime_node_child (mime_node_t *parent, int child);
|
2011-12-24 19:52:44 +01:00
|
|
|
|
2011-12-24 19:52:45 +01:00
|
|
|
/* 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. */
|
|
|
|
mime_node_t *
|
|
|
|
mime_node_seek_dfs (mime_node_t *node, int n);
|
|
|
|
|
2014-03-25 18:48:57 +01:00
|
|
|
typedef enum dump_formats {
|
|
|
|
DUMP_FORMAT_AUTO,
|
|
|
|
DUMP_FORMAT_BATCH_TAG,
|
|
|
|
DUMP_FORMAT_SUP
|
|
|
|
} dump_format_t;
|
|
|
|
|
2016-03-22 11:54:50 +01:00
|
|
|
typedef enum dump_includes {
|
|
|
|
DUMP_INCLUDE_TAGS = 1,
|
|
|
|
DUMP_INCLUDE_CONFIG = 2,
|
2016-06-13 03:05:54 +02:00
|
|
|
DUMP_INCLUDE_PROPERTIES = 4
|
2016-03-22 11:54:50 +01:00
|
|
|
} dump_include_t;
|
|
|
|
|
2016-06-13 03:05:54 +02:00
|
|
|
#define DUMP_INCLUDE_DEFAULT (DUMP_INCLUDE_TAGS | DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_PROPERTIES)
|
|
|
|
|
2017-03-31 12:55:17 +02:00
|
|
|
#define NOTMUCH_DUMP_VERSION 3
|
2016-03-22 11:54:50 +01:00
|
|
|
|
2014-03-25 18:48:57 +01:00
|
|
|
int
|
|
|
|
notmuch_database_dump (notmuch_database_t *notmuch,
|
|
|
|
const char *output_file_name,
|
2014-03-29 02:14:51 +01:00
|
|
|
const char *query_str,
|
|
|
|
dump_format_t output_format,
|
2016-03-22 11:54:50 +01:00
|
|
|
dump_include_t include,
|
2017-10-07 10:44:04 +02:00
|
|
|
bool gzip_output);
|
2014-03-25 18:48:57 +01:00
|
|
|
|
2015-09-06 15:15:45 +02:00
|
|
|
/* If status is non-zero (i.e. error) print appropriate
|
|
|
|
messages to stderr.
|
|
|
|
*/
|
|
|
|
|
|
|
|
notmuch_status_t
|
|
|
|
print_status_query (const char *loc,
|
|
|
|
const notmuch_query_t *query,
|
|
|
|
notmuch_status_t status);
|
|
|
|
|
2016-01-10 02:34:21 +01:00
|
|
|
notmuch_status_t
|
|
|
|
print_status_database (const char *loc,
|
|
|
|
const notmuch_database_t *database,
|
|
|
|
notmuch_status_t status);
|
|
|
|
|
2016-11-28 04:01:42 +01:00
|
|
|
int
|
|
|
|
status_to_exit (notmuch_status_t status);
|
|
|
|
|
2011-12-01 01:27:26 +01:00
|
|
|
#include "command-line-arguments.h"
|
2015-04-06 00:39:55 +02:00
|
|
|
|
cli: use designated initializers for opt desc
Several changes at once, just to not have to change the same lines
several times over:
- Use designated initializers to initialize opt desc arrays.
- Only initialize the needed fields.
- Remove arg_id (short options) as unused.
- Replace opt_type and output_var with several type safe output
variables, where the output variable being non-NULL determines the
type. Introduce checks to ensure only one is set. The downside is
some waste of const space per argument; this could be saved by
retaining opt_type and using a union, but that's still pretty
verbose.
- Fix some variables due to the type safety. Mostly a good thing, but
leads to some enums being changed to ints. This is pedantically
correct, but somewhat annoying. We could also cast, but that defeats
the purpose a bit.
- Terminate the opt desc arrays using {}.
The output variable type safety and the ability to add new fields for
just some output types or arguments are the big wins. For example, if
we wanted to add a variable to set when the argument is present, we
could do so for just the arguments that need it.
Beauty is in the eye of the beholder, but I think this looks nice when
defining the arguments, and reduces some of the verbosity we have
there.
2017-10-01 22:53:11 +02:00
|
|
|
extern const char *notmuch_requested_db_uuid;
|
2015-04-05 15:13:03 +02:00
|
|
|
extern const notmuch_opt_desc_t notmuch_shared_options [];
|
2015-04-06 00:39:55 +02:00
|
|
|
void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
|
|
|
|
|
2015-04-05 15:13:03 +02:00
|
|
|
void notmuch_process_shared_options (const char* subcommand_name);
|
2015-04-05 22:34:55 +02:00
|
|
|
int notmuch_minimal_options (const char* subcommand_name,
|
|
|
|
int argc, char **argv);
|
2009-11-10 21:03:05 +01:00
|
|
|
#endif
|