summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/sieve-validator.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/src/lib-sieve/sieve-validator.h
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pigeonhole/src/lib-sieve/sieve-validator.h')
-rw-r--r--pigeonhole/src/lib-sieve/sieve-validator.h197
1 files changed, 197 insertions, 0 deletions
diff --git a/pigeonhole/src/lib-sieve/sieve-validator.h b/pigeonhole/src/lib-sieve/sieve-validator.h
new file mode 100644
index 0000000..21b41cc
--- /dev/null
+++ b/pigeonhole/src/lib-sieve/sieve-validator.h
@@ -0,0 +1,197 @@
+#ifndef SIEVE_VALIDATOR_H
+#define SIEVE_VALIDATOR_H
+
+#include "lib.h"
+
+#include "sieve-common.h"
+
+/*
+ * Types
+ */
+
+enum sieve_argument_type {
+ SAT_NUMBER,
+ SAT_CONST_STRING,
+ SAT_VAR_STRING,
+ SAT_STRING_LIST,
+
+ SAT_COUNT
+};
+
+struct sieve_command_registration;
+
+/*
+ * Validator
+ */
+
+struct sieve_validator;
+
+struct sieve_validator *
+sieve_validator_create(struct sieve_ast *ast,
+ struct sieve_error_handler *ehandler,
+ enum sieve_compile_flags flags);
+void sieve_validator_free(struct sieve_validator **valdtr);
+pool_t sieve_validator_pool(struct sieve_validator *valdtr);
+
+bool sieve_validator_run(struct sieve_validator *valdtr);
+
+/*
+ * Accessors
+ */
+
+struct sieve_error_handler *
+sieve_validator_error_handler(struct sieve_validator *valdtr);
+struct sieve_ast *sieve_validator_ast(struct sieve_validator *valdtr);
+struct sieve_script *sieve_validator_script(struct sieve_validator *valdtr);
+struct sieve_instance *sieve_validator_svinst(struct sieve_validator *valdtr);
+enum sieve_compile_flags
+sieve_validator_compile_flags(struct sieve_validator *valdtr);
+
+/*
+ * Command/Test registry
+ */
+
+void sieve_validator_register_command(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext,
+ const struct sieve_command_def *command);
+
+/*
+ * Per-command tagged argument registry
+ */
+
+void sieve_validator_register_tag(struct sieve_validator *valdtr,
+ struct sieve_command_registration *cmd_reg,
+ const struct sieve_extension *ext,
+ const struct sieve_argument_def *tag_def,
+ int id_code);
+void sieve_validator_register_external_tag(
+ struct sieve_validator *valdtr, const char *command,
+ const struct sieve_extension *ext,
+ const struct sieve_argument_def *tag_def, int id_code);
+void sieve_validator_register_persistent_tag(
+ struct sieve_validator *valdtr, const char *command,
+ const struct sieve_extension *ext,
+ const struct sieve_argument_def *tag_def);
+
+/*
+ * Overriding the default literal arguments
+ */
+
+void sieve_validator_argument_override(
+ struct sieve_validator *valdtr, enum sieve_argument_type type,
+ const struct sieve_extension *ext,
+ const struct sieve_argument_def *arg_def);
+bool sieve_validator_argument_activate_super(
+ struct sieve_validator *valdtr, struct sieve_command *cmd,
+ struct sieve_ast_argument *arg, bool constant);
+
+/*
+ * Argument validation API
+ */
+
+bool sieve_validate_positional_argument(struct sieve_validator *valdtr,
+ struct sieve_command *cmd,
+ struct sieve_ast_argument *arg,
+ const char *arg_name,
+ unsigned int arg_pos,
+ enum sieve_ast_argument_type req_type);
+bool sieve_validator_argument_activate(struct sieve_validator *valdtr,
+ struct sieve_command *cmd,
+ struct sieve_ast_argument *arg,
+ bool constant);
+
+bool sieve_validate_tag_parameter(struct sieve_validator *valdtr,
+ struct sieve_command *cmd,
+ struct sieve_ast_argument *tag,
+ struct sieve_ast_argument *param,
+ const char *arg_name, unsigned int arg_pos,
+ enum sieve_ast_argument_type req_type,
+ bool constant);
+
+/*
+ * Extension support
+ */
+
+struct sieve_validator_extension {
+ const struct sieve_extension_def *ext;
+
+ bool (*check_conflict)(const struct sieve_extension *ext,
+ struct sieve_validator *valdtr, void *context,
+ struct sieve_ast_argument *require_arg,
+ const struct sieve_extension *ext_other,
+ bool required);
+ bool (*validate)(const struct sieve_extension *ext,
+ struct sieve_validator *valdtr, void *context,
+ struct sieve_ast_argument *require_arg, bool required);
+
+ void (*free)(const struct sieve_extension *ext,
+ struct sieve_validator *valdtr, void *context);
+};
+
+bool sieve_validator_extension_load(struct sieve_validator *valdtr,
+ struct sieve_command *cmd,
+ struct sieve_ast_argument *ext_arg,
+ const struct sieve_extension *ext,
+ bool required) ATTR_NULL(2, 3);
+const struct sieve_extension *
+sieve_validator_extension_load_by_name(struct sieve_validator *valdtr,
+ struct sieve_command *cmd,
+ struct sieve_ast_argument *ext_arg,
+ const char *ext_name);
+const struct sieve_extension *
+sieve_validator_extension_load_implicit(struct sieve_validator *valdtr,
+ const char *ext_name);
+
+void sieve_validator_extension_register(
+ struct sieve_validator *valdtr, const struct sieve_extension *ext,
+ const struct sieve_validator_extension *valext, void *context);
+bool sieve_validator_extension_loaded(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext);
+
+void sieve_validator_extension_set_context(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext,
+ void *context);
+void *sieve_validator_extension_get_context(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext);
+
+/*
+ * Validator object registry
+ */
+
+struct sieve_validator_object_registry;
+
+struct sieve_validator_object_registry *
+sieve_validator_object_registry_get(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext);
+void sieve_validator_object_registry_add(
+ struct sieve_validator_object_registry *regs,
+ const struct sieve_extension *ext,
+ const struct sieve_object_def *obj_def);
+bool sieve_validator_object_registry_find(
+ struct sieve_validator_object_registry *regs, const char *identifier,
+ struct sieve_object *obj);
+struct sieve_validator_object_registry *
+sieve_validator_object_registry_create(struct sieve_validator *valdtr);
+struct sieve_validator_object_registry *
+sieve_validator_object_registry_init(struct sieve_validator *valdtr,
+ const struct sieve_extension *ext);
+
+/*
+ * Error handling
+ */
+
+void sieve_validator_error(struct sieve_validator *valdtr,
+ const char *csrc_filename, unsigned int csrc_linenum,
+ unsigned int source_line, const char *fmt, ...)
+ ATTR_FORMAT(5, 6);
+#define sieve_validator_error(valdtr, ...) \
+ sieve_validator_error(valdtr, __FILE__, __LINE__, __VA_ARGS__)
+void sieve_validator_warning(struct sieve_validator *valdtr,
+ const char *csrc_filename,
+ unsigned int csrc_linenum,
+ unsigned int source_line, const char *fmt, ...)
+ ATTR_FORMAT(5, 6);
+#define sieve_validator_warning(valdtr, ...) \
+ sieve_validator_warning(valdtr, __FILE__, __LINE__, __VA_ARGS__)
+
+#endif