//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 10
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 10
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20
-/*
- * For non-multipart messages, we need to generate a quickie partnum of "1"
- * to return to callback functions. Some callbacks demand it.
- */
+// For non-multipart messages, we need to generate a quickie partnum of "1"
+// to return to callback functions. Some callbacks demand it.
char *fixed_partnum(char *supplied_partnum) {
if (supplied_partnum == NULL) return "1";
if (strlen(supplied_partnum)==0) return "1";
char *fixed_partnum(char *supplied_partnum) {
if (supplied_partnum == NULL) return "1";
if (strlen(supplied_partnum)==0) return "1";
-/*
- * Convert "quoted-printable" to binary. Returns number of bytes decoded.
- * according to RFC2045 section 6.7
- */
+
+// Convert "quoted-printable" to binary. Returns number of bytes decoded.
+// according to RFC2045 section 6.7
-/*
- * Given a message or message-part body and a length, handle any necessary
- * decoding and pass the request up the stack.
- */
+// Given a message or message-part body and a length, handle any necessary
+// decoding and pass the request up the stack.
void mime_decode(char *partnum,
char *part_start, size_t length,
char *content_type, char *charset, char *encoding,
void mime_decode(char *partnum,
char *part_start, size_t length,
char *content_type, char *charset, char *encoding,
-/*
- * this is the extract of mime_decode which can be called if 'dont_decode' was set;
- * to save the cpu intense process of decoding to the time when it realy wants the content.
- * returns:
- * - > 0 we decoded something, its on *decoded, you need to free it.
- * - = 0 no need to decode stuff. *decoded will be NULL.
- * - < 0 an error occured, either an unknown encoding, or alloc failed. no need to free.
- */
+// this is the extract of mime_decode which can be called if 'dont_decode' was set;
+// to save the cpu intense process of decoding to the time when it realy wants the content.
+// returns:
+// - > 0 we decoded something, its on *decoded, you need to free it.
+// - = 0 no need to decode stuff. *decoded will be NULL.
+// - < 0 an error occured, either an unknown encoding, or alloc failed. no need to free.
if (!strcasecmp(encoding, "7bit"))
*encoding = '\0';
if (!strcasecmp(encoding, "8bit"))
if (!strcasecmp(encoding, "7bit"))
*encoding = '\0';
if (!strcasecmp(encoding, "8bit"))
if ((strcasecmp(encoding, "base64"))
&& (strcasecmp(encoding, "quoted-printable"))) {
return -1;
}
if ((strcasecmp(encoding, "base64"))
&& (strcasecmp(encoding, "quoted-printable"))) {
return -1;
}
- /*
- * Allocate a buffer for the decoded data. The output buffer is slightly
- * larger than the input buffer; this assumes that the decoded data
- * will never be significantly larger than the encoded data. This is a
- * safe assumption with base64, uuencode, and quoted-printable.
- */
+ // Allocate a buffer for the decoded data. The output buffer is slightly
+ // larger than the input buffer; this assumes that the decoded data
+ // will never be significantly larger than the encoded data. This is a
+ // safe assumption with base64, uuencode, and quoted-printable.
if ((m->b[encoding].len != 0) &&
(strcasecmp(m->b[encoding].Key, "base64") == 0))
if ((m->b[encoding].len != 0) &&
(strcasecmp(m->b[encoding].Key, "base64") == 0))
- /**
- * ok, if we have a content length of the mime part,
- * try skipping the content on the search for the next
- * boundary. since we don't trust the content_length
- * to be all accurate, and suspect it to lose one digit
- * per line with a line length of 80 chars, we need
- * to start searching a little before..
- */
+ // ok, if we have a content length of the mime part,
+ // try skipping the content on the search for the next
+ // boundary. since we don't trust the content_length
+ // to be all accurate, and suspect it to lose one digit
+ // per line with a line length of 80 chars, we need
+ // to start searching a little before..
- /**
- * ok, if we have a content length of the mime part,
- * try skipping the content on the search for the next
- * boundary. since we don't trust the content_length
- * to be all accurate, start searching a little before..
- */
+ // ok, if we have a content length of the mime part,
+ // try skipping the content on the search for the next
+ // boundary. since we don't trust the content_length
+ // to be all accurate, start searching a little before..
srch = next_boundary = NULL;
for (srch = memchr(ptr, '-', content_end - ptr);
(srch != NULL) && (srch < content_end);
srch = memchr(srch, '-', content_end - srch))
{
srch = next_boundary = NULL;
for (srch = memchr(ptr, '-', content_end - ptr);
(srch != NULL) && (srch < content_end);
srch = memchr(srch, '-', content_end - srch))
{
-/*
- * Break out the components of a multipart message
- * (This function expects to be fed HEADERS + CONTENT)
- * Note: NULL can be supplied as content_end; in this case, the message is
- * considered to have ended when the parser encounters a 0x00 byte.
- */
+
+// Break out the components of a multipart message
+// (This function expects to be fed HEADERS + CONTENT)
+// Note: NULL can be supplied as content_end; in this case, the message is
+// considered to have ended when the parser encounters a 0x00 byte.
static void recurseable_mime_parser(char *partnum,
char *content_start, char *content_end,
MimeParserCallBackType CallBack,
static void recurseable_mime_parser(char *partnum,
char *content_start, char *content_end,
MimeParserCallBackType CallBack,
m->b[startary].len = snprintf(m->b[startary].Key, SIZ, "--%s", m->b[boundary].Key);
SubMimeHeaders = InitInterestingMimes ();
m->b[startary].len = snprintf(m->b[startary].Key, SIZ, "--%s", m->b[boundary].Key);
SubMimeHeaders = InitInterestingMimes ();
if ((*(next_boundary + m->b[startary].len) == '-') &&
(*(next_boundary + m->b[startary].len + 1) == '-') ){
ptr = content_end;
}
else {
if ((*(next_boundary + m->b[startary].len) == '-') &&
(*(next_boundary + m->b[startary].len + 1) == '-') ){
ptr = content_end;
}
else {
evaluate_crlf_ptr = part_start;
--evaluate_crlf_ptr;
if ((*evaluate_crlf_ptr == '\r') && (*(evaluate_crlf_ptr + 1) == '\n')) {
evaluate_crlf_ptr = part_start;
--evaluate_crlf_ptr;
if ((*evaluate_crlf_ptr == '\r') && (*(evaluate_crlf_ptr + 1) == '\n')) {
-/*
- * Break out the components of a multipart message
- * (This function expects to be fed HEADERS + CONTENT)
- * Note: NULL can be supplied as content_end; in this case, the message is
- * considered to have ended when the parser encounters a 0x00 byte.
- */
+
+// Break out the components of a multipart message
+// (This function expects to be fed HEADERS + CONTENT)
+// Note: NULL can be supplied as content_end; in this case, the message is
+// considered to have ended when the parser encounters a 0x00 byte.
void the_mime_parser(char *partnum,
char *content_start, char *content_end,
MimeParserCallBackType CallBack,
void the_mime_parser(char *partnum,
char *content_start, char *content_end,
MimeParserCallBackType CallBack,
if (content_end == NULL) {
content_end = &content_start[strlen(content_start)];
}
m = InitInterestingMimes();
if (content_end == NULL) {
content_end = &content_start[strlen(content_start)];
}
m = InitInterestingMimes();
recurseable_mime_parser(partnum,
content_start, content_end,
recurseable_mime_parser(partnum,
content_start, content_end,
-/*
- * Entry point for the MIME parser.
- * (This function expects to be fed HEADERS + CONTENT)
- * Note: NULL can be supplied as content_end; in this case, the message is
- * considered to have ended when the parser encounters a 0x00 byte.
- */
+// Entry point for the MIME parser.
+// (This function expects to be fed HEADERS + CONTENT)
+// Note: NULL can be supplied as content_end; in this case, the message is
+// considered to have ended when the parser encounters a 0x00 byte.
void mime_parser(char *content_start,
char *content_end,
MimeParserCallBackType CallBack,
void mime_parser(char *content_start,
char *content_end,
MimeParserCallBackType CallBack,
the_mime_parser("", content_start, content_end,
CallBack,
PreMultiPartCallBack,
the_mime_parser("", content_start, content_end,
CallBack,
PreMultiPartCallBack,
if ((MyMimes[MimeIndex].PatternLen +
MyMimes[MimeIndex].PatternOffset < dlen) &&
strncmp(MyMimes[MimeIndex].Pattern,
if ((MyMimes[MimeIndex].PatternLen +
MyMimes[MimeIndex].PatternOffset < dlen) &&
strncmp(MyMimes[MimeIndex].Pattern,
-const char* GuessMimeByFilename(const char *what, size_t len)
-{
- /* we know some hardcoded on our own, try them... */
+const char* GuessMimeByFilename(const char *what, size_t len) {
+ // we know some hardcoded on our own, try them...
if ((len > 3) && !strncasecmp(&what[len - 4], ".gif", 4))
return "image/gif";
else if ((len > 2) && !strncasecmp(&what[len - 3], ".js", 3))
if ((len > 3) && !strncasecmp(&what[len - 4], ".gif", 4))
return "image/gif";
else if ((len > 2) && !strncasecmp(&what[len - 3], ".js", 3))
else if ((len > 4) && !strncasecmp(&what[len - 5], ".wbmp", 5))
return "image/vnd.wap.wbmp";
else
else if ((len > 4) && !strncasecmp(&what[len - 5], ".wbmp", 5))
return "image/vnd.wap.wbmp";
else
Icon->FlatName = malloc(d_without_ext + 1);
memcpy(Icon->FlatName, PStart, d_without_ext);
Icon->FlatName[d_without_ext] = '\0';
Icon->FlatName = malloc(d_without_ext + 1);
memcpy(Icon->FlatName, PStart, d_without_ext);
Icon->FlatName[d_without_ext] = '\0';
MinorPtr = strchr(Icon->FlatName, '-');
if (MinorPtr != NULL) {
size_t MinorLen;
MinorLen = 1 + d_without_ext - (MinorPtr - Icon->FlatName + 1);
if ((MinorLen == sizeof(GENSTR)) &&
(strncmp(MinorPtr + 1, GENSTR, sizeof(GENSTR)) == 0)) {
MinorPtr = strchr(Icon->FlatName, '-');
if (MinorPtr != NULL) {
size_t MinorLen;
MinorLen = 1 + d_without_ext - (MinorPtr - Icon->FlatName + 1);
if ((MinorLen == sizeof(GENSTR)) &&
(strncmp(MinorPtr + 1, GENSTR, sizeof(GENSTR)) == 0)) {
Put(IconHash, Icon->FlatName, d_without_ext, Icon, DeleteIcon);
Put(IconHash, Icon->FlatName, d_without_ext, Icon, DeleteIcon);
GetHash(IconHash, MimeType, len, &vIcon), Icon = (IconName*) vIcon;
GetHash(IconHash, MimeType, len, &vIcon), Icon = (IconName*) vIcon;