aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-parser.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-08-29 20:04:34 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-08-29 20:04:34 +0800
commit6b132fe48a5fe75643cbff31b26f3d78e66da796 (patch)
tree9bf4acd8ef5b7ce03e601bbc749a8f3ceb23a40d /camel/camel-mime-parser.c
parent54a484f860ece03f6488af5e18be539ca34f4a69 (diff)
downloadgsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar.gz
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar.bz2
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar.lz
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar.xz
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.tar.zst
gsoc2013-evolution-6b132fe48a5fe75643cbff31b26f3d78e66da796.zip
Change the case sensitive search of subject to expect case insensitive
2002-08-29 Not Zed <NotZed@Ximian.com> * tests/folder/test3.c: Change the case sensitive search of subject to expect case insensitive results, as the behaviour has changed. (main): Made the search content before sync nonfatal. its something that needs to be fixed but not practical concern in evolution. * camel-block-file.c (block_file_validate_root): Only spit out the invalid root warnings if the file isn't empty. * camel-text-index.c (text_index_compress_nosync): Swap the path as well when we compress. * camel-mime-parser.c (folder_scan_content): Treat the end of file as a boundary if we're scanning From lines, and drop the last \n. (folder_scan_init_with_fd): Dont pre-read from the fd, and init eof. (folder_scan_init_with_stream): Similar. (folder_read): Handle eof, and set eof on 0 read. (folder_seek): Dont pre-read after a seek, and reset eof flag. (camel_mime_parser_init_with_fd): Fix doco, no pre-read occurs anymore. (camel_mime_parser_init_with_stream): Same. * providers/local/camel-mbox-summary.c (camel_mbox_summary_sync_mbox): Add a \n to end of content of each message, not at start. * providers/local/camel-mbox-folder.c (mbox_append_message): Instead of appending "\nFrom " to a mailbox, start with "From ", and append a \n after the message always. For better mutt/elm compatability. Also, unlock after we've stat'd. (mbox_append_message): Set the message's from_pos exactly as the mbox size. svn path=/trunk/; revision=17921
Diffstat (limited to 'camel/camel-mime-parser.c')
-rw-r--r--camel/camel-mime-parser.c98
1 files changed, 36 insertions, 62 deletions
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 4ecc945542..ed4f50ca46 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -228,6 +228,7 @@ struct _header_scan_state {
unsigned int midline:1; /* are we mid-line interrupted? */
unsigned int scan_from:1; /* do we care about From lines? */
unsigned int scan_pre_from:1; /* do we return pre-from data? */
+ unsigned int eof:1; /* reached eof? */
off_t start_of_from; /* where from started */
off_t start_of_headers; /* where headers started from the last scan */
@@ -572,9 +573,6 @@ camel_mime_parser_from_line(CamelMimeParser *m)
* will be relative to the current file position of the file
* descriptor. As a result, seekable descritors should
* be seeked using the parser seek functions.
- *
- * An initial buffer will be read from the file descriptor
- * immediately, although no parsing will occur.
*
* Return value: Returns -1 on error.
**/
@@ -595,9 +593,6 @@ camel_mime_parser_init_with_fd(CamelMimeParser *m, int fd)
* offsets will be relative to the current file position of
* the stream. As a result, seekable streams should only
* be seeked using the parser seek function.
- *
- * An initial buffer will be read from the stream
- * immediately, although no parsing will occur.
*
* Return value: -1 on error.
**/
@@ -965,7 +960,7 @@ folder_read(struct _header_scan_state *s)
int len;
int inoffset;
- if (s->inptr<s->inend-s->atleast)
+ if (s->inptr<s->inend-s->atleast || s->eof)
return s->inend-s->inptr;
#ifdef PURIFY
purify_watch_remove(inend_id);
@@ -987,6 +982,7 @@ folder_read(struct _header_scan_state *s)
s->seek += s->inptr - s->inbuf;
s->inptr = s->inbuf;
s->inend = s->inbuf+len+inoffset;
+ s->eof = (len == 0);
r(printf("content = %d '%.*s'\n",s->inend - s->inptr, s->inend - s->inptr, s->inptr));
} else {
s->ioerrno = errno?errno:EIO;
@@ -1018,7 +1014,6 @@ static off_t
folder_seek(struct _header_scan_state *s, off_t offset, int whence)
{
off_t newoffset;
- int len;
if (s->stream) {
if (CAMEL_IS_SEEKABLE_STREAM(s->stream)) {
@@ -1040,17 +1035,7 @@ folder_seek(struct _header_scan_state *s, off_t offset, int whence)
s->seek = newoffset;
s->inptr = s->inbuf;
s->inend = s->inbuf;
- if (s->stream)
- len = camel_stream_read(s->stream, s->inbuf, SCAN_BUF);
- else
- len = read(s->fd, s->inbuf, SCAN_BUF);
- if (len>=0) {
- s->inend = s->inbuf+len;
- s->inend[0] = '\n';
- } else {
- newoffset = -1;
- s->ioerrno = errno?errno:EIO;
- }
+ s->eof = FALSE;
} else {
s->ioerrno = errno?errno:EIO;
}
@@ -1388,7 +1373,7 @@ folder_scan_content(struct _header_scan_state *s, int *lastone, char **data, int
newatleast = 1;
*lastone = FALSE;
- c(printf("atleast = %d\n", s->atleast));
+ c(printf("atleast = %d\n", newatleast));
do {
s->atleast = newatleast;
@@ -1428,7 +1413,7 @@ folder_scan_content(struct _header_scan_state *s, int *lastone, char **data, int
}
c(printf("ran out of input, dumping what i have (%d) bytes midline = %s\n",
- inptr-start, s->midline?"TRUE":"FALSE"));
+ inptr-start, s->midline?"TRUE":"FALSE"));
goto content;
}
newatleast = 1;
@@ -1447,6 +1432,9 @@ folder_scan_content(struct _header_scan_state *s, int *lastone, char **data, int
return NULL;
content:
+ /* treat eof as the last boundary in From mode */
+ if (s->scan_from && s->eof)
+ onboundary = TRUE;
part = s->parts;
normal_exit:
s->atleast = atleast;
@@ -1513,6 +1501,7 @@ folder_scan_init(void)
s->midline = FALSE;
s->scan_from = FALSE;
s->scan_pre_from = FALSE;
+ s->eof = FALSE;
s->filters = NULL;
s->filterid = 1;
@@ -1533,57 +1522,42 @@ drop_states(struct _header_scan_state *s)
s->state = HSCAN_INITIAL;
}
+static void
+folder_scan_reset(struct _header_scan_state *s)
+{
+ drop_states(s);
+ s->inend = s->inbuf;
+ s->inptr = s->inbuf;
+ s->inend[0] = '\n';
+ if (s->fd != -1) {
+ close(s->fd);
+ s->fd = -1;
+ }
+ if (s->stream) {
+ camel_object_unref((CamelObject *)s->stream);
+ s->stream = NULL;
+ }
+ s->ioerrno = 0;
+ s->eof = FALSE;
+}
+
static int
folder_scan_init_with_fd(struct _header_scan_state *s, int fd)
{
- int len;
+ folder_scan_reset(s);
+ s->fd = fd;
- len = read(fd, s->inbuf, SCAN_BUF);
- if (len>=0) {
- drop_states(s);
- s->inend = s->inbuf+len;
- s->inptr = s->inbuf;
- s->inend[0] = '\n';
- if (s->fd != -1)
- close(s->fd);
- s->fd = fd;
- if (s->stream) {
- camel_object_unref((CamelObject *)s->stream);
- s->stream = NULL;
- }
- s->ioerrno = 0;
- return 0;
- } else {
- s->ioerrno = errno?errno:EIO;
- return -1;
- }
+ return 0;
}
static int
folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream)
{
- int len;
+ folder_scan_reset(s);
+ s->stream = stream;
+ camel_object_ref((CamelObject *)stream);
- len = camel_stream_read(stream, s->inbuf, SCAN_BUF);
- if (len >= 0) {
- drop_states(s);
- s->inend = s->inbuf+len;
- s->inptr = s->inbuf;
- s->inend[0] = '\n';
- if (s->stream)
- camel_object_unref((CamelObject *)s->stream);
- s->stream = stream;
- camel_object_ref((CamelObject *)stream);
- if (s->fd != -1) {
- close(s->fd);
- s->fd = -1;
- }
- s->ioerrno = 0;
- return 0;
- } else {
- s->ioerrno = errno?errno:EIO;
- return -1;
- }
+ return 0;
}
#define USE_FROM