diff options
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/archives.h | 10 | ||||
-rw-r--r-- | src/libmime/content_type.h | 27 | ||||
-rw-r--r-- | src/libmime/email_addr.h | 18 | ||||
-rw-r--r-- | src/libmime/filter.h | 40 | ||||
-rw-r--r-- | src/libmime/filter_private.h | 8 | ||||
-rw-r--r-- | src/libmime/images.h | 14 | ||||
-rw-r--r-- | src/libmime/lang_detection.h | 22 | ||||
-rw-r--r-- | src/libmime/message.h | 29 | ||||
-rw-r--r-- | src/libmime/mime_encoding.c | 1 | ||||
-rw-r--r-- | src/libmime/mime_encoding.h | 23 | ||||
-rw-r--r-- | src/libmime/mime_expressions.h | 16 | ||||
-rw-r--r-- | src/libmime/mime_headers.h | 22 | ||||
-rw-r--r-- | src/libmime/mime_parser.h | 12 | ||||
-rw-r--r-- | src/libmime/smtp_parsers.h | 27 |
14 files changed, 193 insertions, 76 deletions
diff --git a/src/libmime/archives.h b/src/libmime/archives.h index 6abfb857a..bb84d4298 100644 --- a/src/libmime/archives.h +++ b/src/libmime/archives.h @@ -18,6 +18,10 @@ #include "config.h" +#ifdef __cplusplus +extern "C" { +#endif + enum rspamd_archive_type { RSPAMD_ARCHIVE_ZIP, RSPAMD_ARCHIVE_RAR, @@ -57,6 +61,10 @@ void rspamd_archives_process (struct rspamd_task *task); /** * Get textual representation of an archive's type */ -const gchar * rspamd_archive_type_str (enum rspamd_archive_type type); +const gchar *rspamd_archive_type_str (enum rspamd_archive_type type); + +#ifdef __cplusplus +} +#endif #endif /* SRC_LIBMIME_ARCHIVES_H_ */ diff --git a/src/libmime/content_type.h b/src/libmime/content_type.h index 68b1b8107..2e3bf5e40 100644 --- a/src/libmime/content_type.h +++ b/src/libmime/content_type.h @@ -20,6 +20,10 @@ #include "libutil/fstring.h" #include "libutil/mem_pool.h" +#ifdef __cplusplus +extern "C" { +#endif + enum rspamd_content_type_flags { RSPAMD_CONTENT_TYPE_VALID = 0, RSPAMD_CONTENT_TYPE_BROKEN = 1 << 0, @@ -84,8 +88,8 @@ struct rspamd_content_disposition { void rspamd_content_type_add_param (rspamd_mempool_t *pool, struct rspamd_content_type *ct, - gchar *name_start, gchar *name_end, - gchar *value_start, gchar *value_end); + gchar *name_start, gchar *name_end, + gchar *value_start, gchar *value_end); /** * Parse content type from the header (performs copy + lowercase) @@ -94,8 +98,8 @@ rspamd_content_type_add_param (rspamd_mempool_t *pool, * @param pool * @return */ -struct rspamd_content_type * rspamd_content_type_parse (const gchar *in, - gsize len, rspamd_mempool_t *pool); +struct rspamd_content_type *rspamd_content_type_parse (const gchar *in, + gsize len, rspamd_mempool_t *pool); /** * Adds new param for content disposition header @@ -108,9 +112,9 @@ struct rspamd_content_type * rspamd_content_type_parse (const gchar *in, */ void rspamd_content_disposition_add_param (rspamd_mempool_t *pool, - struct rspamd_content_disposition *cd, - const gchar *name_start, const gchar *name_end, - const gchar *value_start, const gchar *value_end); + struct rspamd_content_disposition *cd, + const gchar *name_start, const gchar *name_end, + const gchar *value_start, const gchar *value_end); /** * Parse content-disposition header @@ -119,7 +123,12 @@ rspamd_content_disposition_add_param (rspamd_mempool_t *pool, * @param pool * @return */ -struct rspamd_content_disposition * rspamd_content_disposition_parse (const gchar *in, - gsize len, rspamd_mempool_t *pool); +struct rspamd_content_disposition *rspamd_content_disposition_parse (const gchar *in, + gsize len, + rspamd_mempool_t *pool); + +#ifdef __cplusplus +} +#endif #endif /* SRC_LIBMIME_CONTENT_TYPE_H_ */ diff --git a/src/libmime/email_addr.h b/src/libmime/email_addr.h index 666ded0e9..69aa2aa00 100644 --- a/src/libmime/email_addr.h +++ b/src/libmime/email_addr.h @@ -20,6 +20,11 @@ #include "libutil/mem_pool.h" #include "libutil/ref.h" + +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_mime_header; enum rspamd_email_address_flags { @@ -62,7 +67,7 @@ struct rspamd_task; * @param len length of string * @return */ -struct rspamd_email_address * rspamd_email_address_from_smtp ( +struct rspamd_email_address *rspamd_email_address_from_smtp ( const gchar *str, guint len); /** @@ -75,9 +80,9 @@ struct rspamd_email_address * rspamd_email_address_from_smtp ( * @return */ GPtrArray *rspamd_email_address_from_mime (rspamd_mempool_t *pool, - const gchar *hdr, - guint len, - GPtrArray *src); + const gchar *hdr, + guint len, + GPtrArray *src); /** * Destroys list of email addresses @@ -87,4 +92,9 @@ void rspamd_email_address_list_destroy (gpointer ptr); void rspamd_email_address_free (struct rspamd_email_address *addr); + +#ifdef __cplusplus +} +#endif + #endif /* SRC_LIBMIME_EMAIL_ADDR_H_ */ diff --git a/src/libmime/filter.h b/src/libmime/filter.h index f9218194a..8245f8c53 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -10,6 +10,10 @@ #include "rspamd_symcache.h" #include "task.h" +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; struct rspamd_settings; struct rspamd_classifier_config; @@ -67,14 +71,14 @@ struct kh_rspamd_symbols_group_hash_s; struct rspamd_metric_result { - double score; /**< total score */ - double grow_factor; /**< current grow factor */ + double score; /**< total score */ + double grow_factor; /**< current grow factor */ struct rspamd_passthrough_result *passthrough_result; guint npositive; guint nnegative; double positive_score; double negative_score; - struct kh_rspamd_symbols_hash_s *symbols; /**< symbols of metric */ + struct kh_rspamd_symbols_hash_s *symbols; /**< symbols of metric */ struct kh_rspamd_symbols_group_hash_s *sym_groups; /**< groups of symbols */ struct rspamd_action_result *actions_limits; guint nactions; @@ -85,7 +89,7 @@ struct rspamd_metric_result { * @param task task object * @return metric result or NULL if metric `name` has not been found */ -struct rspamd_metric_result * rspamd_create_metric_result (struct rspamd_task *task); +struct rspamd_metric_result *rspamd_create_metric_result (struct rspamd_task *task); /** * Adds a new passthrough result to a task @@ -118,16 +122,16 @@ enum rspamd_symbol_insert_flags { * @param weight numeric weight for symbol * @param opts list of symbol's options */ -struct rspamd_symbol_result* rspamd_task_insert_result_full (struct rspamd_task *task, - const gchar *symbol, - double weight, - const gchar *opts, - enum rspamd_symbol_insert_flags flags); +struct rspamd_symbol_result *rspamd_task_insert_result_full (struct rspamd_task *task, + const gchar *symbol, + double weight, + const gchar *opts, + enum rspamd_symbol_insert_flags flags); #define rspamd_task_insert_result_single(task, symbol, flag, opts) \ - rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_SINGLE) + rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_SINGLE) #define rspamd_task_insert_result(task, symbol, flag, opts) \ - rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_DEFAULT) + rspamd_task_insert_result_full (task, symbol, flag, opts, RSPAMD_SYMBOL_INSERT_DEFAULT) /** @@ -137,7 +141,7 @@ struct rspamd_symbol_result* rspamd_task_insert_result_full (struct rspamd_task * @param opt */ gboolean rspamd_task_add_result_option (struct rspamd_task *task, - struct rspamd_symbol_result *s, const gchar *opt); + struct rspamd_symbol_result *s, const gchar *opt); /** * Finds symbol result @@ -145,7 +149,7 @@ gboolean rspamd_task_add_result_option (struct rspamd_task *task, * @param sym * @return */ -struct rspamd_symbol_result* rspamd_task_find_symbol_result ( +struct rspamd_symbol_result *rspamd_task_find_symbol_result ( struct rspamd_task *task, const char *sym); /** @@ -166,8 +170,8 @@ void rspamd_task_symbol_result_foreach (struct rspamd_task *task, * @return result metric weight */ double rspamd_factor_consolidation_func (struct rspamd_task *task, - const gchar *metric_name, - const gchar *unused); + const gchar *metric_name, + const gchar *unused); /** @@ -175,6 +179,10 @@ double rspamd_factor_consolidation_func (struct rspamd_task *task, * @param task * @return */ -struct rspamd_action* rspamd_check_action_metric (struct rspamd_task *task); +struct rspamd_action *rspamd_check_action_metric (struct rspamd_task *task); + +#ifdef __cplusplus +} +#endif #endif diff --git a/src/libmime/filter_private.h b/src/libmime/filter_private.h index 82322a6bb..31def75e2 100644 --- a/src/libmime/filter_private.h +++ b/src/libmime/filter_private.h @@ -8,6 +8,10 @@ #include "filter.h" #include "contrib/libucl/khash.h" +#ifdef __cplusplus +extern "C" { +#endif + KHASH_MAP_INIT_STR (rspamd_options_hash, struct rspamd_symbol_option *); /** * Result of metric processing @@ -28,4 +32,8 @@ KHASH_INIT (rspamd_symbols_group_hash, rspamd_ptr_hash_func, rspamd_ptr_equal_func); +#ifdef __cplusplus +} +#endif + #endif //RSPAMD_FILTER_PRIVATE_H diff --git a/src/libmime/images.h b/src/libmime/images.h index 39a7dc8c5..bf1175b2a 100644 --- a/src/libmime/images.h +++ b/src/libmime/images.h @@ -4,6 +4,10 @@ #include "config.h" #include "fstring.h" +#ifdef __cplusplus +extern "C" { +#endif + struct html_image; struct rspamd_task; struct rspamd_mime_part; @@ -41,14 +45,18 @@ void rspamd_images_process (struct rspamd_task *task); * @param data * @return */ -struct rspamd_image* rspamd_maybe_process_image (rspamd_mempool_t *pool, - rspamd_ftok_t *data); +struct rspamd_image *rspamd_maybe_process_image (rspamd_mempool_t *pool, + rspamd_ftok_t *data); /* * Get textual representation of an image's type */ -const gchar * rspamd_image_type_str (enum rspamd_image_type type); +const gchar *rspamd_image_type_str (enum rspamd_image_type type); void rspamd_image_normalize (struct rspamd_task *task, struct rspamd_image *img); +#ifdef __cplusplus +} +#endif + #endif /* IMAGES_H_ */ diff --git a/src/libmime/lang_detection.h b/src/libmime/lang_detection.h index 517ab037e..3eaa4e286 100644 --- a/src/libmime/lang_detection.h +++ b/src/libmime/lang_detection.h @@ -22,6 +22,10 @@ #include "libstat/stat_api.h" #include "libmime/message.h" +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_lang_detector; struct rspamd_language_elt; struct rspamd_task; @@ -57,10 +61,11 @@ struct rspamd_lang_detector_res { * @param cfg * @return */ -struct rspamd_lang_detector* rspamd_language_detector_init (struct rspamd_config *cfg); +struct rspamd_lang_detector *rspamd_language_detector_init (struct rspamd_config *cfg); + +struct rspamd_lang_detector *rspamd_language_detector_ref (struct rspamd_lang_detector *d); -struct rspamd_lang_detector* rspamd_language_detector_ref (struct rspamd_lang_detector* d); -void rspamd_language_detector_unref (struct rspamd_lang_detector* d); +void rspamd_language_detector_unref (struct rspamd_lang_detector *d); /** * Try to detect language of words @@ -70,8 +75,8 @@ void rspamd_language_detector_unref (struct rspamd_lang_detector* d); * @return array of struct rspamd_lang_detector_res sorted by freq descending */ gboolean rspamd_language_detector_detect (struct rspamd_task *task, - struct rspamd_lang_detector *d, - struct rspamd_mime_text_part *part); + struct rspamd_lang_detector *d, + struct rspamd_mime_text_part *part); /** * Returns TRUE if the specified word is known to be a stop word @@ -81,6 +86,11 @@ gboolean rspamd_language_detector_detect (struct rspamd_task *task, * @return */ gboolean rspamd_language_detector_is_stop_word (struct rspamd_lang_detector *d, - const gchar *word, gsize wlen); + const gchar *word, gsize wlen); + + +#ifdef __cplusplus +} +#endif #endif diff --git a/src/libmime/message.h b/src/libmime/message.h index eb260cd77..17c4ec5b9 100644 --- a/src/libmime/message.h +++ b/src/libmime/message.h @@ -16,6 +16,10 @@ #include <unicode/uchar.h> #include <unicode/utext.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; struct controller_session; struct html_content; @@ -106,9 +110,9 @@ struct rspamd_mime_text_part { GArray *utf_words; UText utf_stripped_text; /* Used by libicu to represent the utf8 content */ - GPtrArray *newlines; /**< positions of newlines in text, relative to content*/ + GPtrArray *newlines; /**< positions of newlines in text, relative to content*/ struct html_content *html; - GList *exceptions; /**< list of offsets of urls */ + GList *exceptions; /**< list of offsets of urls */ struct rspamd_mime_part *mime_part; guint flags; @@ -146,8 +150,9 @@ void rspamd_message_process (struct rspamd_task *task); * @return An array of header's values or NULL. It is NOT permitted to free array or values. */ GPtrArray *rspamd_message_get_header_array (struct rspamd_task *task, - const gchar *field, - gboolean strong); + const gchar *field, + gboolean strong); + /** * Get an array of mime parts header's values with specified header's name using raw headers * @param task worker task structure @@ -156,8 +161,8 @@ GPtrArray *rspamd_message_get_header_array (struct rspamd_task *task, * @return An array of header's values or NULL. It is NOT permitted to free array or values. */ GPtrArray *rspamd_message_get_mime_header_array (struct rspamd_task *task, - const gchar *field, - gboolean strong); + const gchar *field, + gboolean strong); /** * Get an array of header's values with specified header's name using raw headers @@ -167,9 +172,9 @@ GPtrArray *rspamd_message_get_mime_header_array (struct rspamd_task *task, * @return An array of header's values or NULL. It is NOT permitted to free array or values. */ GPtrArray *rspamd_message_get_header_from_hash (GHashTable *htb, - rspamd_mempool_t *pool, - const gchar *field, - gboolean strong); + rspamd_mempool_t *pool, + const gchar *field, + gboolean strong); /** @@ -184,6 +189,10 @@ enum rspamd_cte rspamd_cte_from_string (const gchar *str); * @param ct * @return */ -const gchar* rspamd_cte_to_string (enum rspamd_cte ct); +const gchar *rspamd_cte_to_string (enum rspamd_cte ct); + +#ifdef __cplusplus +} +#endif #endif diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index 7b897929e..8dc7da12e 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -18,6 +18,7 @@ #include "libutil/mem_pool.h" #include "libutil/regexp.h" #include "libutil/hash.h" +#include "libserver/cfg_file.h" #include "libserver/task.h" #include "mime_encoding.h" #include "message.h" diff --git a/src/libmime/mime_encoding.h b/src/libmime/mime_encoding.h index 1a61339ca..5224d33fb 100644 --- a/src/libmime/mime_encoding.h +++ b/src/libmime/mime_encoding.h @@ -21,6 +21,10 @@ #include "fstring.h" #include <unicode/uchar.h> +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; struct rspamd_mime_part; struct rspamd_mime_text_part; @@ -32,8 +36,8 @@ struct rspamd_charset_converter; * @param in * @return */ -const gchar * rspamd_mime_detect_charset (const rspamd_ftok_t *in, - rspamd_mempool_t *pool); +const gchar *rspamd_mime_detect_charset (const rspamd_ftok_t *in, + rspamd_mempool_t *pool); /** * Convert text chunk to utf-8. Input encoding is substituted using @@ -48,9 +52,9 @@ const gchar * rspamd_mime_detect_charset (const rspamd_ftok_t *in, * @param err * @return */ -gchar * rspamd_mime_text_to_utf8 (rspamd_mempool_t *pool, - gchar *input, gsize len, const gchar *in_enc, - gsize *olen, GError **err); +gchar *rspamd_mime_text_to_utf8 (rspamd_mempool_t *pool, + gchar *input, gsize len, const gchar *in_enc, + gsize *olen, GError **err); /** * Converts data from `in` to `out`, returns `FALSE` if `enc` is not a valid iconv charset @@ -60,7 +64,7 @@ gchar * rspamd_mime_text_to_utf8 (rspamd_mempool_t *pool, * @return */ gboolean rspamd_mime_to_utf8_byte_array (GByteArray *in, - GByteArray *out, const gchar *enc); + GByteArray *out, const gchar *enc); /** * Maybe convert part to utf-8 @@ -69,7 +73,7 @@ gboolean rspamd_mime_to_utf8_byte_array (GByteArray *in, * @return */ void rspamd_mime_text_part_maybe_convert (struct rspamd_task *task, - struct rspamd_mime_text_part *text_part); + struct rspamd_mime_text_part *text_part); /** * Checks utf8 charset and normalize/validate utf8 string @@ -79,7 +83,7 @@ void rspamd_mime_text_part_maybe_convert (struct rspamd_task *task, * @return */ gboolean rspamd_mime_charset_utf_check (rspamd_ftok_t *charset, - gchar *in, gsize len, gboolean content_check); + gchar *in, gsize len, gboolean content_check); /** * Ensure that all characters in string are valid utf8 chars or replace them @@ -125,5 +129,8 @@ rspamd_converter_to_uchars (struct rspamd_charset_converter *cnv, */ const char *rspamd_mime_charset_find_by_content (const gchar *in, gsize inlen); +#ifdef __cplusplus +} +#endif #endif /* SRC_LIBMIME_MIME_ENCODING_H_ */ diff --git a/src/libmime/mime_expressions.h b/src/libmime/mime_expressions.h index 2677b9968..935027482 100644 --- a/src/libmime/mime_expressions.h +++ b/src/libmime/mime_expressions.h @@ -10,6 +10,10 @@ #include "expression.h" #include "contrib/libucl/ucl.h" +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; struct rspamd_config; @@ -34,8 +38,8 @@ struct expression_argument { }; -typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, - GArray *args, void *user_data); +typedef gboolean (*rspamd_internal_func_t) (struct rspamd_task *, + GArray *args, void *user_data); /** @@ -44,8 +48,8 @@ typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, * @param func pointer to function */ void register_expression_function (const gchar *name, - rspamd_internal_func_t func, - void *user_data); + rspamd_internal_func_t func, + void *user_data); /** * Set global limit of regexp data size to be processed @@ -54,4 +58,8 @@ void register_expression_function (const gchar *name, */ guint rspamd_mime_expression_set_re_limit (guint limit); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/libmime/mime_headers.h b/src/libmime/mime_headers.h index 81fff96a2..5cb300978 100644 --- a/src/libmime/mime_headers.h +++ b/src/libmime/mime_headers.h @@ -20,6 +20,10 @@ #include "libutil/mem_pool.h" #include "libutil/addr.h" +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; enum rspamd_rfc2047_encoding { @@ -97,9 +101,9 @@ struct received_header { * @param check_newlines */ void rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target, - GQueue *order, - const gchar *in, gsize len, - gboolean check_newlines); + GQueue *order, + const gchar *in, gsize len, + gboolean check_newlines); /** * Perform rfc2047 decoding of a header @@ -108,8 +112,8 @@ void rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target, * @param inlen * @return */ -gchar * rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, - gsize inlen, gboolean *invalid_utf); +gchar *rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, + gsize inlen, gboolean *invalid_utf); /** * Encode mime header if needed @@ -117,13 +121,17 @@ gchar * rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in, * @param len * @return newly allocated encoded header */ -gchar * rspamd_mime_header_encode (const gchar *in, gsize len); +gchar *rspamd_mime_header_encode (const gchar *in, gsize len); /** * Generate new unique message id * @param fqdn * @return */ -gchar * rspamd_mime_message_id_generate (const gchar *fqdn); +gchar *rspamd_mime_message_id_generate (const gchar *fqdn); + +#ifdef __cplusplus +} +#endif #endif /* SRC_LIBMIME_MIME_HEADERS_H_ */ diff --git a/src/libmime/mime_parser.h b/src/libmime/mime_parser.h index 987ec1395..ed3fe5f87 100644 --- a/src/libmime/mime_parser.h +++ b/src/libmime/mime_parser.h @@ -18,6 +18,11 @@ #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + struct rspamd_task; struct rspamd_mime_part; @@ -29,8 +34,13 @@ enum rspamd_mime_parse_error { }; enum rspamd_mime_parse_error rspamd_mime_parse_task (struct rspamd_task *task, - GError **err); + GError **err); void rspamd_mime_parser_calc_digest (struct rspamd_mime_part *part); + +#ifdef __cplusplus +} +#endif + #endif /* SRC_LIBMIME_MIME_PARSER_H_ */ diff --git a/src/libmime/smtp_parsers.h b/src/libmime/smtp_parsers.h index 6904bece0..b4fb825b4 100644 --- a/src/libmime/smtp_parsers.h +++ b/src/libmime/smtp_parsers.h @@ -22,21 +22,34 @@ #include "task.h" #include "message.h" + +#ifdef __cplusplus +extern "C" { +#endif + int rspamd_smtp_received_parse (struct rspamd_task *task, - const char *data, size_t len, struct received_header *rh); + const char *data, size_t len, + struct received_header *rh); + int rspamd_smtp_addr_parse (const char *data, size_t len, - struct rspamd_email_address *addr); + struct rspamd_email_address *addr); + gboolean rspamd_content_disposition_parser (const char *data, size_t len, - struct rspamd_content_disposition *cd, rspamd_mempool_t *pool); + struct rspamd_content_disposition *cd, + rspamd_mempool_t *pool); gboolean rspamd_rfc2047_parser (const gchar *in, gsize len, gint *pencoding, - const gchar **charset, gsize *charset_len, - const gchar **encoded, gsize *encoded_len); + const gchar **charset, gsize *charset_len, + const gchar **encoded, gsize *encoded_len); -rspamd_inet_addr_t* rspamd_parse_smtp_ip (const char *data, size_t len, - rspamd_mempool_t *pool); +rspamd_inet_addr_t *rspamd_parse_smtp_ip (const char *data, size_t len, + rspamd_mempool_t *pool); guint64 rspamd_parse_smtp_date (const char *data, size_t len); +#ifdef __cplusplus +} +#endif + #endif /* SRC_LIBMIME_SMTP_PARSERS_H_ */ |