Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9bb7be19
...
9bb7be1916bab7ef490980694e2bfc7a6898c52a
authored
2001-02-07 06:50:17 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Put more headers in the cache, (ugly).
1 parent
419da3f7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
119 additions
and
26 deletions
mailbox/attribute.c
mailbox/body.c
mailbox/header.c
mailbox/mbx_mbox.c
mailbox/mbx_mboxscan.c
mailbox/message.c
mailbox/attribute.c
View file @
9bb7be1
...
...
@@ -67,6 +67,14 @@ attribute_is_modified (attribute_t attr)
}
int
attribute_clear_modified
(
attribute_t
attr
)
{
if
(
attr
)
attr
->
flags
&=
~
MU_ATTRIBUTE_MODIFIED
;
return
0
;
}
int
attribute_get_flags
(
attribute_t
attr
,
int
*
pflags
)
{
if
(
attr
==
NULL
)
...
...
mailbox/body.c
View file @
9bb7be1
...
...
@@ -76,6 +76,22 @@ body_get_owner (body_t body)
return
(
body
)
?
body
->
owner
:
NULL
;
}
/* FIXME: not implemented. */
int
body_is_modified
(
body_t
body
)
{
(
void
)
body
;
return
0
;
}
/* FIXME: not implemented. */
int
body_clear_modified
(
body_t
body
)
{
(
void
)
body
;
return
0
;
}
int
body_get_filename
(
body_t
body
,
char
*
filename
,
size_t
len
,
size_t
*
pn
)
{
...
...
mailbox/header.c
View file @
9bb7be1
...
...
@@ -97,6 +97,14 @@ header_is_modified (header_t header)
return
(
header
)
?
(
header
->
flags
&
HEADER_MODIFIED
)
:
0
;
}
int
header_clear_modified
(
header_t
header
)
{
if
(
header
)
header
->
flags
&=
~
HEADER_MODIFIED
;
return
0
;
}
/* Parsing is done in a rather simple fashion, meaning we just consider an
entry to be a field-name an a field-value. So they maybe duplicate of
field-name like "Received" they are just put in the array, see _get_value()
...
...
mailbox/mbx_mbox.c
View file @
9bb7be1
...
...
@@ -58,28 +58,42 @@ struct _mbox_data;
typedef
struct
_mbox_data
*
mbox_data_t
;
typedef
struct
_mbox_message
*
mbox_message_t
;
/* These represent the header field-name that we are caching for speed. */
#define HDRSIZE 9
/* Below are the headers field-names that we are caching for speed, it is
more or less the list of headers in ENVELOPE command from IMAP. */
#define HDRSIZE 15
const
char
*
fhdr_table
[]
=
{
#define HFROM 0
"From"
,
#define HTO 1
"To"
,
#define HCC 2
#define H_BCC 0
"Bcc"
,
#define H_CC 1
"Cc"
,
#define HSUBJECT 3
"Subject"
,
#define HDATE 4
"Date"
,
#define HX_IMAPBASE 5
"X-IMAPbase"
,
#define HX_UIDL 6
"X-UIDL"
,
#define HX_UID 7
"X-UID"
,
#define HCONTENT_TYPE 8
#define H_CONTENT_LANGUAGE 2
"Content-Language"
,
#define H_CONTENT_TRANSFER_ENCODING 3
"Content-Transfer-Encoding"
,
#define H_CONTENT_TYPE 4
"Content-Type"
,
#define H_DATE 5
"Date"
,
#define H_FROM 6
"From"
,
#define H_IN_REPLY_TO 7
"In-Reply-To"
,
#define H_MESSAGE_ID 8
"Message-ID"
,
#define H_REFERENCE 9
"Reply-To"
,
#define H_REPLY_TO 10
"Reply-To"
,
#define H_SENDER 11
"Sender"
,
#define H_SUBJECT 12
"Subject"
,
#define H_TO 13
"To"
,
#define H_X_UIDL 14
"X-UIDL"
};
/* Keep the positions of where the headers and bodies start and end.
...
...
@@ -146,6 +160,7 @@ struct _mbox_data
static
int
mbox_open
__P
((
mailbox_t
,
int
));
static
int
mbox_close
__P
((
mailbox_t
));
static
int
mbox_get_message
__P
((
mailbox_t
,
size_t
,
message_t
*
));
//static int mbox_get_message_by_uid __P ((mailbox_t, size_t, message_t *));
static
int
mbox_append_message
__P
((
mailbox_t
,
message_t
));
static
int
mbox_messages_count
__P
((
mailbox_t
,
size_t
*
));
static
int
mbox_messages_recent
__P
((
mailbox_t
,
size_t
*
));
...
...
@@ -637,8 +652,23 @@ mbox_expunge (mailbox_t mailbox)
continue
;
}
if
(
mum
->
message
)
/* Do the expensive mbox_append_message0() only if mark dirty. */
if
((
mum
->
attr_flags
&
MU_ATTRIBUTE_MODIFIED
)
||
(
mum
->
message
&&
message_is_modified
(
mum
->
message
)))
{
/* The message was not instanciated, probably the dirty flag was
set by mbox_scan(), create one here. */
if
(
mum
->
message
==
0
)
{
message_t
msg
;
status
=
mbox_get_message
(
mailbox
,
i
,
&
msg
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
}
status
=
mbox_append_message0
(
tmpmailbox
,
mum
->
message
,
&
total
,
1
,
(
i
==
save_imapbase
));
if
(
status
!=
0
)
...
...
@@ -647,6 +677,9 @@ mbox_expunge (mailbox_t mailbox)
strerror
(
status
));
goto
bailout0
;
}
/* Clear the dirty bit. */
mum
->
attr_flags
&=
~
MU_ATTRIBUTE_MODIFIED
;
message_clear_modified
(
mum
->
message
);
}
else
{
...
...
@@ -811,12 +844,24 @@ mbox_expunge (mailbox_t mailbox)
}
else
{
for
(
i
=
0
;
i
<
HDRSIZE
;
i
++
)
if
(
mum
->
fhdr
[
i
])
{
free
(
mum
->
fhdr
[
i
]);
mum
->
fhdr
[
i
]
=
NULL
;
}
memset
(
mum
,
0
,
sizeof
(
*
mum
));
}
}
mum
->
header_from
=
mum
->
header_from_end
=
0
;
mum
->
body
=
mum
->
body_end
=
0
;
mum
->
header_lines
=
mum
->
body_lines
=
0
;
for
(
i
=
0
;
i
<
HDRSIZE
;
i
++
)
if
(
mum
->
fhdr
[
i
])
{
free
(
mum
->
fhdr
[
i
]);
mum
->
fhdr
[
i
]
=
NULL
;
}
}
monitor_unlock
(
mailbox
->
monitor
);
/* This is should reset the messages_count, the last argument 0 means
...
...
@@ -1387,7 +1432,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
*
s
;
size_t
len
=
0
;
envelope_t
envelope
;
envelope_t
envelope
=
NULL
;
message_get_envelope
(
msg
,
&
envelope
);
status
=
envelope_sender
(
envelope
,
mud
->
sender
,
128
,
&
len
);
if
(
status
!=
0
)
...
...
@@ -1414,7 +1459,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
*
s
;
size_t
len
=
0
;
envelope_t
envelope
;
envelope_t
envelope
=
NULL
;
char
buffer
[
1024
];
message_get_envelope
(
msg
,
&
envelope
);
status
=
envelope_date
(
envelope
,
mud
->
date
,
128
,
&
len
);
...
...
@@ -1464,8 +1509,8 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
header_t
header
;
stream_t
is
=
NULL
;
header_t
header
=
NULL
;
message_get_header
(
msg
,
&
header
);
header_get_stream
(
header
,
&
is
);
do
...
...
@@ -1572,8 +1617,8 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
body_t
body
;
stream_t
is
=
NULL
;
body_t
body
=
NULL
;
message_get_body
(
msg
,
&
body
);
body_get_stream
(
body
,
&
is
);
do
...
...
@@ -1616,7 +1661,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
/* Append the Message. */
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
stream_t
is
=
NULL
;
message_get_stream
(
msg
,
&
is
);
do
{
...
...
mailbox/mbx_mboxscan.c
View file @
9bb7be1
This diff is collapsed.
Click to expand it.
mailbox/message.c
View file @
9bb7be1
...
...
@@ -162,10 +162,26 @@ message_is_modified (message_t msg)
int
mod
=
0
;
mod
|=
header_is_modified
(
msg
->
header
);
mod
|=
attribute_is_modified
(
msg
->
attribute
);
mod
|=
body_is_modified
(
msg
->
body
);
return
mod
;
}
int
message_clear_modified
(
message_t
msg
)
{
if
(
msg
)
{
if
(
msg
->
header
)
header_clear_modified
(
msg
->
header
);
if
(
msg
->
attribute
)
attribute_clear_modified
(
msg
->
attribute
);
if
(
msg
->
body
)
body_clear_modified
(
msg
->
body
);
}
return
0
;
}
int
message_set_mailbox
(
message_t
msg
,
mailbox_t
mailbox
)
{
if
(
msg
==
NULL
)
...
...
Please
register
or
sign in
to post a comment