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

Method setBytes

src/core/rfc822/MCMessageParser.cpp:40–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void MessageParser::setBytes(char * dataBytes, unsigned int dataLength)
41{
42 const char * start = NULL;
43 unsigned int length = 0;
44 if (dataLength > 5) {
45 if (strncmp(dataBytes, "From ", 5) == 0) {
46 start = dataBytes;
47 for(unsigned int i = 0 ; i < dataLength ; i ++) {
48 if (start[i] == '\n') {
49 start = start + i + 1;
50 length = dataLength - (i + 1);
51 break;
52 }
53 }
54 }
55 }
56 if (start != NULL) {
57 dataBytes = (char *) start;
58 dataLength = length;
59 }
60
61 mailmessage * msg;
62 struct mailmime * mime;
63
64 msg = data_message_init(dataBytes, dataLength);
65 mailmessage_get_bodystructure(msg, &mime);
66 mMainPart = (AbstractPart *) Attachment::attachmentsWithMIME(msg->msg_mime)->retain();
67 mMainPart->applyUniquePartID();
68
69 size_t cur_token = 0;
70 struct mailimf_fields * fields;
71 int r = mailimf_envelope_and_optional_fields_parse(dataBytes, dataLength, &cur_token, &fields);
72 if (r == MAILIMAP_NO_ERROR) {
73 header()->importIMFFields(fields);
74 mailimf_fields_free(fields);
75 }
76 mailmessage_free(msg);
77
78 setupPartID();
79}
80
81MessageParser::MessageParser()
82{

Callers

nothing calls this directly

Calls 3

retainMethod · 0.80
applyUniquePartIDMethod · 0.80
importIMFFieldsMethod · 0.80

Tested by

no test coverage detected