Read a mailbox in MMDF format.
184{
185 if (!m)
187
191
192 char buf[8192] = { 0 };
193 char return_path[1024] = { 0 };
194 int count = 0;
195 int lines;
196 time_t t = 0;
197 LOFF_T loc, tmploc;
198 struct Email *e = NULL;
199 struct stat st = { 0 };
200 struct Progress *progress = NULL;
202
204 {
206 goto fail;
207 }
210 m->
size = st.st_size;
211
212 buf[sizeof(buf) - 1] = '\0';
213
215 {
218 }
219
220 while (true)
221 {
222 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
223 break;
224
226 break;
227
229 {
230 loc = ftello(adata->
fp);
231 if (loc < 0)
232 goto fail;
233
234 count++;
236
242
243 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
244 {
245
247 break;
248 }
249
250 return_path[0] = '\0';
251
252 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
253 {
255 {
257 goto fail;
258 }
259 }
260 else
261 {
263 }
264
266
267 loc = ftello(adata->
fp);
268 if (loc < 0)
269 goto fail;
270
272 {
274
275 if ((tmploc > 0) && (tmploc < m->size))
276 {
279 {
282 }
283 }
284 else
285 {
287 }
288 }
289 else
290 {
292 }
293
295 {
296 lines = -1;
297 do
298 {
299 loc = ftello(adata->
fp);
300 if (loc < 0)
301 goto fail;
302 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
303 break;
304 lines++;
306
309 }
310
313
316
318 }
319 else
320 {
323 goto fail;
324 }
325 }
326
328 {
331 goto fail;
332 }
333
335fail:
337 return rc;
338}
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
struct Email * email_new(void)
Create a new Email.
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
Parses an RFC822 header.
void mutt_file_get_stat_timespec(struct timespec *dest, struct stat *st, enum MuttStatType type)
Read the stat() time into a time value.
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
@ MUTT_STAT_ATIME
File/dir's atime - last accessed time.
@ MUTT_STAT_MTIME
File/dir's mtime - last modified time.
bool is_from(const char *s, char *path, size_t pathlen, time_t *tp)
Is a string a 'From' header line?
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
int mutt_date_local_tz(time_t t)
Calculate the local timezone in seconds east of UTC.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
void mx_alloc_memory(struct Mailbox *m, int req_size)
Create storage for the emails.
MxOpenReturns
Return values for mbox_open()
@ MX_OPEN_ERROR
Open failed with an error.
@ MX_OPEN_ABORT
Open was aborted.
@ MX_OPEN_OK
Open succeeded.
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
void progress_free(struct Progress **ptr)
Free a Progress Bar.
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
#define TAILQ_EMPTY(head)
volatile sig_atomic_t SigInt
true after SIGINT is received
LOFF_T offset
offset where the actual data begins
LOFF_T length
length (in bytes) of attachment
The envelope/body of an email.
struct Envelope * env
Envelope information.
int lines
How many lines in the body of this message?
struct Body * body
List of MIME parts.
LOFF_T offset
Where in the stream does this message begin?
int index
The absolute (unsorted) message number.
time_t received
Time when the message was placed in the mailbox.
struct AddressList return_path
Return path for the Email.
struct AddressList from
Email's 'From' list.
int msg_count
Total number of messages.
struct Email ** emails
Array of Emails.
off_t size
Size of the Mailbox.
bool verbose
Display status messages?
struct timespec atime
File's last-access time.
struct timespec mtime
Time Mailbox was last changed.