You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

images.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef IMAGES_H_
  2. #define IMAGES_H_
  3. #include "config.h"
  4. #include "fstring.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. struct html_image;
  9. struct rspamd_task;
  10. struct rspamd_mime_part;
  11. #define RSPAMD_DCT_LEN (64 * 64)
  12. enum rspamd_image_type {
  13. IMAGE_TYPE_PNG = 0,
  14. IMAGE_TYPE_JPG,
  15. IMAGE_TYPE_GIF,
  16. IMAGE_TYPE_BMP,
  17. IMAGE_TYPE_UNKNOWN
  18. };
  19. struct rspamd_image {
  20. struct rspamd_mime_part *parent;
  21. rspamd_ftok_t *data;
  22. rspamd_ftok_t *filename;
  23. struct html_image *html_image;
  24. enum rspamd_image_type type;
  25. uint32_t width;
  26. uint32_t height;
  27. gboolean is_normalized;
  28. unsigned char *dct;
  29. };
  30. /*
  31. * Process images from a worker task
  32. */
  33. void rspamd_images_process(struct rspamd_task *task);
  34. /**
  35. * Process image if possible in a single mime part
  36. * @param task
  37. * @param part
  38. * @return
  39. */
  40. bool rspamd_images_process_mime_part_maybe(struct rspamd_task *task,
  41. struct rspamd_mime_part *part);
  42. /*
  43. * Link embedded images to the HTML parts
  44. */
  45. void rspamd_images_link(struct rspamd_task *task);
  46. /**
  47. * Processes image in raw data
  48. * @param task
  49. * @param data
  50. * @return
  51. */
  52. struct rspamd_image *rspamd_maybe_process_image(rspamd_mempool_t *pool,
  53. rspamd_ftok_t *data);
  54. /*
  55. * Get textual representation of an image's type
  56. */
  57. const char *rspamd_image_type_str(enum rspamd_image_type type);
  58. void rspamd_image_normalize(struct rspamd_task *task, struct rspamd_image *img);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif /* IMAGES_H_ */