#include <string.h>
#include <sys/stat.h>
#include <errno.h>
+
#include "citadel.h"
#include "server.h"
#include "dynloader.h"
#include "sysdep_decls.h"
-#include "mime_parser.h"
#include "tools.h"
+#include "mime_parser.h"
+
void extract_key(char *target, char *source, char *key)
{
char *decoded;
size_t bytes_decoded = 0;
- lprintf(9, "mime_decode() called\n");
-
/* Some encodings aren't really encodings */
if (!strcasecmp(encoding, "7bit"))
strcpy(encoding, "");
if ((strcasecmp(encoding, "base64"))
&& (strcasecmp(encoding, "quoted-printable"))) {
- lprintf(9, "ERROR: unknown MIME encoding '%s'\n", encoding);
return;
}
/*
* will never be larger than the encoded data. This is a safe
* assumption with base64, uuencode, and quoted-printable.
*/
- lprintf(9, "About to allocate %d bytes for decoded part\n",
- length+2048);
decoded = mallok(length+2048);
if (decoded == NULL) {
- lprintf(9, "ERROR: cannot allocate memory.\n");
return;
}
- lprintf(9, "Got it!\n");
- lprintf(9, "Decoding %s\n", encoding);
if (!strcasecmp(encoding, "base64")) {
bytes_decoded = decode_base64(decoded, part_start, length);
}
bytes_decoded = decode_quoted_printable(decoded,
part_start, length);
}
- lprintf(9, "Bytes decoded: %d\n", bytes_decoded);
if (bytes_decoded > 0) if (CallBack != NULL) {
CallBack(name, filename, fixed_partnum(partnum),
size_t length;
char nested_partnum[SIZ];
- lprintf(9, "the_mime_parser() called\n");
ptr = content_start;
content_length = 0;
*(strchr(content_type, ' ')) = '\0';
if (strchr(content_type, ';'))
*(strchr(content_type, ';')) = '\0';
- lprintf(9, "Extracted content-type <%s>\n",
- content_type);
}
if (!strncasecmp(header, "Content-Disposition: ", 21)) {
strcpy(disposition, &header[21]);
is_multipart = 0;
}
- lprintf(9, "is_multipart=%d, boundary=<%s>\n",
- is_multipart, boundary);
-
/* If this is a multipart message, then recursively process it */
part_start = NULL;
if (is_multipart) {
do {
if ( (!strncasecmp(ptr, startary, strlen(startary)))
|| (!strncasecmp(ptr, endary, strlen(endary))) ) {
- lprintf(9, "hit boundary!\n");
if (part_start != NULL) {
if (strlen(partnum) > 0) {
snprintf(nested_partnum,
/* If it's not a multipart message, then do something with it */
if (!is_multipart) {
- lprintf(9, "doing non-multipart thing\n");
part_start = ptr;
length = 0;
while (ptr < content_end) {
/* Truncate if the header told us to */
if ( (content_length > 0) && (length > content_length) ) {
length = content_length;
- lprintf(9, "truncated to %ld\n", (long)content_length);
}
mime_decode(partnum,
)
{
- lprintf(9, "mime_parser() called\n");
the_mime_parser("", content_start, content_end,
CallBack,
PreMultiPartCallBack,