X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-client.h;h=5f2883681c1ee127332108ba7872146a04eb3e6f;hp=1c336dcb00bdc2776b529b5c91c855c058221a71;hb=25cf5f5dc45cac42f15643f6df09b46d51d7b5ec;hpb=1bf3720b6eaca6698f25781a7d299afcbd7a4be8 diff --git a/notmuch-client.h b/notmuch-client.h index 1c336dcb..5f288368 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -58,7 +58,7 @@ typedef GMimeCipherContext notmuch_crypto_context_t; #include #include -#include +#include "talloc-extra.h" #define unused(x) x __attribute__ ((unused)) @@ -117,6 +117,51 @@ chomp_newline (char *str) str[strlen(str)-1] = '\0'; } +/* 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. + */ +#define NOTMUCH_FORMAT_CUR 1 +/* The minimum supported structured output format version. Requests + * for format versions below this will return an error. */ +#define NOTMUCH_FORMAT_MIN 1 + +/* 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; + +/* 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); + notmuch_crypto_context_t * notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol);