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.

archives.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef SRC_LIBMIME_ARCHIVES_H_
  17. #define SRC_LIBMIME_ARCHIVES_H_
  18. #include "config.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. enum rspamd_archive_type {
  23. RSPAMD_ARCHIVE_ZIP,
  24. RSPAMD_ARCHIVE_RAR,
  25. RSPAMD_ARCHIVE_7ZIP,
  26. RSPAMD_ARCHIVE_GZIP,
  27. };
  28. enum rspamd_archive_flags {
  29. RSPAMD_ARCHIVE_ENCRYPTED = (1u << 0u),
  30. RSPAMD_ARCHIVE_CANNOT_READ = (1u << 1u),
  31. RSPAMD_ARCHIVE_HAS_OBFUSCATED_FILES = (1u << 2u),
  32. };
  33. enum rspamd_archive_file_flags {
  34. RSPAMD_ARCHIVE_FILE_ENCRYPTED = (1u << 0u),
  35. RSPAMD_ARCHIVE_FILE_OBFUSCATED = (1u << 1u),
  36. };
  37. struct rspamd_archive_file {
  38. GString *fname;
  39. gsize compressed_size;
  40. gsize uncompressed_size;
  41. enum rspamd_archive_file_flags flags;
  42. };
  43. struct rspamd_archive {
  44. enum rspamd_archive_type type;
  45. const rspamd_ftok_t *archive_name;
  46. gsize size;
  47. enum rspamd_archive_flags flags;
  48. GPtrArray *files; /* Array of struct rspamd_archive_file */
  49. };
  50. /**
  51. * Process archives from a worker task
  52. */
  53. void rspamd_archives_process(struct rspamd_task *task);
  54. /**
  55. * Get textual representation of an archive's type
  56. */
  57. const char *rspamd_archive_type_str(enum rspamd_archive_type type);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif /* SRC_LIBMIME_ARCHIVES_H_ */