4 #include "notmuch-client.h"
6 typedef struct _tag_operation_t tag_operation_t;
7 typedef struct _tag_op_list_t tag_op_list_t;
13 /* Operations are synced to maildir, if possible.
15 TAG_FLAG_MAILDIR_SYNC = (1 << 0),
17 /* Remove all tags from message before applying list.
19 TAG_FLAG_REMOVE_ALL = (1 << 1),
21 /* Don't try to avoid database operations. Useful when we
22 * know that message passed needs these operations.
24 TAG_FLAG_PRE_OPTIMIZED = (1 << 2),
26 /* Accept strange tags that might be user error;
27 * intended for use by notmuch-restore.
29 TAG_FLAG_BE_GENEROUS = (1 << 3)
33 /* These should obey the convention that fatal errors are negative,
34 * skipped lines are positive.
37 TAG_PARSE_OUT_OF_MEMORY = -1,
39 /* Line parsed successfuly. */
40 TAG_PARSE_SUCCESS = 0,
42 /* Line has a syntax error */
43 TAG_PARSE_INVALID = 1,
45 /* Line was blank or a comment */
50 /* Parse a string of the following format:
52 * +<tag>|-<tag> [...] [--] <search-terms>
54 * Each line is interpreted similarly to "notmuch tag" command line
55 * arguments. The delimiter is one or more spaces ' '. Any characters
56 * in <tag> and <search-terms> MAY be hex encoded with %NN where NN is
57 * the hexadecimal value of the character. Any ' ' and '%' characters
58 * in <tag> and <search-terms> MUST be hex encoded (using %20 and %25,
59 * respectively). Any characters that are not part of <tag> or
60 * <search-terms> MUST NOT be hex encoded.
62 * Leading and trailing space ' ' is ignored. Empty lines and lines
63 * beginning with '#' are ignored.
67 * ops contains a list of tag operations
68 * query_str the search terms.
71 parse_tag_line (void *ctx, char *line,
73 char **query_str, tag_op_list_t *ops);
77 /* Parse a command line of the following format:
79 * +<tag>|-<tag> [...] [--] <search-terms>
82 * ops contains a list of tag operations
83 * query_str the search terms.
85 * The ops argument is not cleared.
89 parse_tag_command_line (void *ctx, int argc, char **argv,
90 char **query_str, tag_op_list_t *ops);
93 * Test tags for some forbidden cases.
95 * Relax the checks if 'remove' is true to allow removal of previously
96 * added forbidden tags.
99 * explanatory message otherwise.
102 illegal_tag (const char *tag, notmuch_bool_t remove);
105 * Create an empty list of tag operations
107 * ctx is passed to talloc
111 tag_op_list_create (void *ctx);
114 * Add a tag operation (delete iff remove == TRUE) to a list.
115 * The list is expanded as necessary.
119 tag_op_list_append (tag_op_list_t *list,
121 notmuch_bool_t remove);
124 * Apply a list of tag operations, in order, to a given message.
126 * Flags can be bitwise ORed; see enum above for possibilies.
130 tag_op_list_apply (notmuch_message_t *message,
131 tag_op_list_t *tag_ops,
132 tag_op_flag_t flags);
135 * Return the number of operations in a list
139 tag_op_list_size (const tag_op_list_t *list);
142 * Reset a list to contain no operations
146 tag_op_list_reset (tag_op_list_t *list);
150 * return the i'th tag in the list
154 tag_op_list_tag (const tag_op_list_t *list, size_t i);
157 * Is the i'th tag operation a remove?
161 tag_op_list_isremove (const tag_op_list_t *list, size_t i);