sspm.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*======================================================================
  2. FILE: sspm.h Mime Parser
  3. CREATOR: eric 25 June 2000
  4. (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
  5. http://www.softwarestudio.org
  6. The contents of this file are subject to the Mozilla Public License
  7. Version 1.0 (the "License"); you may not use this file except in
  8. compliance with the License. You may obtain a copy of the License at
  9. http://www.mozilla.org/MPL/
  10. Software distributed under the License is distributed on an "AS IS"
  11. basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  12. the License for the specific language governing rights and
  13. limitations under the License.
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of either:
  16. The LGPL as published by the Free Software Foundation, version
  17. 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
  18. Or:
  19. The Mozilla Public License Version 1.0. You may obtain a copy of
  20. the License at http://www.mozilla.org/MPL/
  21. The Initial Developer of the Original Code is Eric Busboom
  22. ======================================================================*/
  23. #ifndef ICAL_SSPM_H
  24. #define ICAL_SSPM_H
  25. #include "libical_ical_export.h"
  26. enum sspm_major_type
  27. {
  28. SSPM_NO_MAJOR_TYPE,
  29. SSPM_TEXT_MAJOR_TYPE,
  30. SSPM_IMAGE_MAJOR_TYPE,
  31. SSPM_AUDIO_MAJOR_TYPE,
  32. SSPM_VIDEO_MAJOR_TYPE,
  33. SSPM_APPLICATION_MAJOR_TYPE,
  34. SSPM_MULTIPART_MAJOR_TYPE,
  35. SSPM_MESSAGE_MAJOR_TYPE,
  36. SSPM_UNKNOWN_MAJOR_TYPE
  37. };
  38. enum sspm_minor_type
  39. {
  40. SSPM_NO_MINOR_TYPE,
  41. SSPM_ANY_MINOR_TYPE,
  42. SSPM_PLAIN_MINOR_TYPE,
  43. SSPM_RFC822_MINOR_TYPE,
  44. SSPM_DIGEST_MINOR_TYPE,
  45. SSPM_CALENDAR_MINOR_TYPE,
  46. SSPM_MIXED_MINOR_TYPE,
  47. SSPM_RELATED_MINOR_TYPE,
  48. SSPM_ALTERNATIVE_MINOR_TYPE,
  49. SSPM_PARALLEL_MINOR_TYPE,
  50. SSPM_UNKNOWN_MINOR_TYPE
  51. };
  52. enum sspm_encoding
  53. {
  54. SSPM_NO_ENCODING,
  55. SSPM_QUOTED_PRINTABLE_ENCODING,
  56. SSPM_8BIT_ENCODING,
  57. SSPM_7BIT_ENCODING,
  58. SSPM_BINARY_ENCODING,
  59. SSPM_BASE64_ENCODING,
  60. SSPM_UNKNOWN_ENCODING
  61. };
  62. enum sspm_error
  63. {
  64. SSPM_NO_ERROR,
  65. SSPM_UNEXPECTED_BOUNDARY_ERROR,
  66. SSPM_WRONG_BOUNDARY_ERROR,
  67. SSPM_NO_BOUNDARY_ERROR,
  68. SSPM_NO_HEADER_ERROR,
  69. SSPM_MALFORMED_HEADER_ERROR
  70. };
  71. struct sspm_header
  72. {
  73. int def;
  74. char *boundary;
  75. enum sspm_major_type major;
  76. enum sspm_minor_type minor;
  77. char *minor_text;
  78. char **content_type_params;
  79. char *charset;
  80. enum sspm_encoding encoding;
  81. char *filename;
  82. char *content_id;
  83. enum sspm_error error;
  84. char *error_text;
  85. };
  86. struct sspm_part
  87. {
  88. struct sspm_header header;
  89. int level;
  90. size_t data_size;
  91. void *data;
  92. };
  93. struct sspm_action_map
  94. {
  95. enum sspm_major_type major;
  96. enum sspm_minor_type minor;
  97. void *(*new_part) (void);
  98. void (*add_line) (void *part, struct sspm_header * header, const char *line, size_t size);
  99. void *(*end_part) (void *part);
  100. void (*free_part) (void *part);
  101. };
  102. LIBICAL_ICAL_EXPORT const char *sspm_major_type_string(enum sspm_major_type type);
  103. LIBICAL_ICAL_EXPORT const char *sspm_minor_type_string(enum sspm_minor_type type);
  104. LIBICAL_ICAL_EXPORT const char *sspm_encoding_string(enum sspm_encoding type);
  105. LIBICAL_ICAL_EXPORT int sspm_parse_mime(struct sspm_part *parts,
  106. size_t max_parts,
  107. const struct sspm_action_map *actions,
  108. char *(*get_string) (char *s, size_t size, void *data),
  109. void *get_string_data, struct sspm_header *first_header);
  110. LIBICAL_ICAL_EXPORT void sspm_free_parts(struct sspm_part *parts, size_t max_parts);
  111. LIBICAL_ICAL_EXPORT char *decode_quoted_printable(char *dest, char *src, size_t *size);
  112. LIBICAL_ICAL_EXPORT char *decode_base64(char *dest, char *src, size_t *size);
  113. LIBICAL_ICAL_EXPORT int sspm_write_mime(struct sspm_part *parts, size_t num_parts,
  114. char **output_string, const char *header);
  115. #endif /* ICAL_SSPM_H */