MCPcopy Create free account
hub / github.com/MailCore/mailcore2 / get_file_part

Function get_file_part

src/core/rfc822/MCMessageBuilder.cpp:241–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241static struct mailmime * get_file_part(MessageBuilder * builder,
242 const char * filename, const char * mime_type, int is_inline,
243 const char * content_id,
244 const char * content_description,
245 const char * text, size_t length, clist * contentTypeParameters)
246{
247 char * disposition_name;
248 int encoding_type;
249 struct mailmime_disposition * disposition;
250 struct mailmime_mechanism * encoding;
251 struct mailmime_content * content;
252 struct mailmime * mime;
253 struct mailmime_fields * mime_fields;
254 char * dup_content_id;
255 char * dup_content_description;
256
257 disposition_name = NULL;
258 if (filename != NULL) {
259 disposition_name = strdup(filename);
260 }
261 if (is_inline) {
262 disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_INLINE,
263 disposition_name, NULL, NULL, NULL, (size_t) -1);
264 }
265 else {
266 disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_ATTACHMENT,
267 disposition_name, NULL, NULL, NULL, (size_t) -1);
268 }
269 content = mailmime_content_new_with_str(mime_type);
270
271 encoding_type = MAILMIME_MECHANISM_BASE64;
272 encoding = mailmime_mechanism_new(encoding_type, NULL);
273 dup_content_id = NULL;
274 if (content_id != NULL)
275 dup_content_id = strdup(content_id);
276 dup_content_description = NULL;
277 if (content_description != NULL)
278 dup_content_description = strdup(content_description);
279 mime_fields = mailmime_fields_new_with_data(encoding,
280 dup_content_id, dup_content_description, disposition, NULL);
281
282 if (contentTypeParameters != NULL) {
283 clist_concat(content->ct_parameters, contentTypeParameters);
284 }
285
286 mime = part_new_empty(builder, content, mime_fields, NULL, 1);
287 mailmime_set_body_text(mime, (char *) text, length);
288
289 return mime;
290}
291
292#define MIME_ENCODED_STR(str) (str != NULL ? str->encodedMIMEHeaderValue()->bytes() : NULL)
293

Callers 1

mime_from_attachmentFunction · 0.85

Calls 1

part_new_emptyFunction · 0.85

Tested by

no test coverage detected