char *part_start, size_t length,
char *content_type, char *charset, char *encoding,
char *disposition,
+ char *id,
char *name, char *filename,
void (*CallBack)
(char *cbname,
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PreMultiPartCallBack)
(char *cbname,
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PostMultiPartCallBack)
(char *cbname,
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void *userdata,
int dont_decode
if (CallBack != NULL) {
CallBack(name, filename, fixed_partnum(partnum),
disposition, part_start,
- content_type, charset, length, encoding, userdata);
+ content_type, charset, length, encoding, id, userdata);
}
return;
}
if (bytes_decoded > 0) if (CallBack != NULL) {
CallBack(name, filename, fixed_partnum(partnum),
disposition, decoded,
- content_type, charset, bytes_decoded, "binary", userdata);
+ content_type, charset, bytes_decoded, "binary", id, userdata);
}
free(decoded);
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PreMultiPartCallBack)
(char *cbname,
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PostMultiPartCallBack)
(char *cbname,
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void *userdata,
int dont_decode
size_t content_length;
char *encoding;
char *disposition;
+ char *id;
char *name = NULL;
char *content_type_name;
char *content_disposition_name;
disposition = malloc(SIZ);
memset(disposition, 0, SIZ);
+ id = malloc(SIZ);
+ memset(id, 0, SIZ);
+
/* If the caller didn't supply an endpointer, generate one by measure */
if (content_end == NULL) {
content_end = &content_start[strlen(content_start)];
extract_key(content_disposition_name, disposition, "name");
extract_key(filename, disposition, "filename");
}
+ if (!strncasecmp(header, "Content-ID:", 11)) {
+ strcpy(id, &header[11]);
+ striplt(id);
+ stripallbut(id, '<', '>');
+ }
if (!strncasecmp(header, "Content-length: ", 15)) {
char clbuf[10];
safestrncpy(clbuf, &header[15], sizeof clbuf);
if (PreMultiPartCallBack != NULL) {
PreMultiPartCallBack("", "", partnum, "",
NULL, content_type, charset,
- 0, encoding, userdata);
+ 0, encoding, id, userdata);
}
/* Figure out where the boundaries are */
if (PostMultiPartCallBack != NULL) {
PostMultiPartCallBack("", "", partnum, "", NULL,
- content_type, charset, 0, encoding, userdata);
+ content_type, charset, 0, encoding, id, userdata);
}
goto end_parser;
}
}
part_end = content_end;
- /******
- * I thought there was an off-by-one error here, but there isn't.
- * This probably means that there's an off-by-one error somewhere
- * else ... or maybe only in certain messages?
- --part_end;
- --length;
- ******/
-
- /* Truncate if the header told us to */
- if ( (content_length > 0) && (length > content_length) ) {
- length = content_length;
- }
+
+ /* The following code will truncate the MIME part to the size
+ * specified by the Content-length: header. We have commented it
+ * out because these headers have a tendency to be wrong.
+ *
+ * if ( (content_length > 0) && (length > content_length) ) {
+ * length = content_length;
+ * }
+ */
/* Sometimes the "name" field is tacked on to Content-type,
* and sometimes it's tacked on to Content-disposition. Use
*/
mime_decode(partnum,
part_start, length,
- content_type, charset, encoding, disposition,
+ content_type, charset, encoding, disposition, id,
name, filename,
CallBack, NULL, NULL,
userdata, dont_decode
if (PreMultiPartCallBack != NULL) {
PreMultiPartCallBack("", "", partnum, "",
NULL, content_type, charset,
- 0, encoding, userdata);
+ 0, encoding, id, userdata);
}
if (CallBack != NULL) {
if (strlen(partnum) > 0) {
}
if (PostMultiPartCallBack != NULL) {
PostMultiPartCallBack("", "", partnum, "", NULL,
- content_type, charset, 0, encoding, userdata);
+ content_type, charset, 0, encoding, id, userdata);
}
free(content_disposition_name);
free(filename);
free(disposition);
+ free(id);
}
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PreMultiPartCallBack)
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void (*PostMultiPartCallBack)
char *cbcharset,
size_t cblength,
char *cbencoding,
+ char *cbid,
void *cbuserdata),
void *userdata,
};
-const char *GuessMimeType(char *data, size_t dlen)
+const char *GuessMimeType(const char *data, size_t dlen)
{
int MimeIndex = 0;
IconName *Icon = (IconName*) IconNamePtr;
free(Icon->FlatName);
free(Icon->FileName);
+ free(Icon);
}
+/*
static const char *PrintFlat(void *IconNamePtr)
{
IconName *Icon = (IconName*) IconNamePtr;
IconName *Icon = (IconName*) IconNamePtr;
return Icon->FileName;
}
+*/
+
#define GENSTR "x-generic"
#define IGNORE_PREFIX_1 "gnome-mime"
int LoadIconDir(const char *DirName)
Put(IconHash, Icon->FlatName, d_without_ext, Icon, DeleteIcon);
// PrintHash(IconHash, PrintFlat, PrintFile);
}
+ closedir(filedir);
return 1;
}