1 #ifndef MAIL_SEARCH_REGISTER_H 2 #define MAIL_SEARCH_REGISTER_H 3 4 struct mail_search_arg; 5 struct mail_search_build_context; 6 7 struct mail_search_register_arg { 8 const char *key; 9 10 /* returns parsed arg or NULL if error. error message is set to ctx. */ 11 struct mail_search_arg * 12 (*build)(struct mail_search_build_context *ctx); 13 }; 14 15 typedef struct mail_search_arg * 16 mail_search_register_fallback_t(struct mail_search_build_context *ctx, 17 const char *key); 18 19 struct mail_search_register *mail_search_register_init(void); 20 void mail_search_register_deinit(struct mail_search_register **reg); 21 22 void mail_search_register_add(struct mail_search_register *reg, 23 const struct mail_search_register_arg *arg, 24 unsigned int count); 25 /* Register a fallback handler. It's responsible for giving also the 26 "unknown key" error. */ 27 void mail_search_register_fallback(struct mail_search_register *reg, 28 mail_search_register_fallback_t *fallback); 29 30 /* Return all registered args sorted. */ 31 const struct mail_search_register_arg * 32 mail_search_register_get(struct mail_search_register *reg, 33 unsigned int *count_r); 34 35 /* Find key's registered arg, or NULL if not found. */ 36 const struct mail_search_register_arg * 37 mail_search_register_find(struct mail_search_register *reg, const char *key); 38 /* Get registered fallback arg. Returns FALSE if fallback hasn't been 39 registered. */ 40 bool mail_search_register_get_fallback(struct mail_search_register *reg, 41 mail_search_register_fallback_t **fallback_r); 42 43 struct mail_search_register *mail_search_register_get_imap(void); 44 struct mail_search_register *mail_search_register_get_human(void); 45 46 #endif 47