Read a mailbox in MMDF format.
181{
182 if (!m)
184
188
189 char buf[8192] = { 0 };
190 char return_path[1024] = { 0 };
191 int count = 0;
192 int lines;
193 time_t t = 0;
194 LOFF_T loc, tmploc;
195 struct Email *e = NULL;
196 struct stat st = { 0 };
197 struct Progress *progress = NULL;
199
201 {
203 goto fail;
204 }
207 m->
size = st.st_size;
208
210 {
213 }
214
215 while (true)
216 {
217 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
218 break;
219
221 break;
222
224 {
225 loc = ftello(adata->
fp);
226 if (loc < 0)
227 goto fail;
228
229 count++;
231
237
238 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
239 {
242 break;
243 }
244
245 return_path[0] = '\0';
246
247 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
248 {
250 {
252 goto fail;
253 }
254 }
255 else
256 {
258 }
259
261
262 loc = ftello(adata->
fp);
263 if (loc < 0)
264 goto fail;
265
267 {
269
270 if ((tmploc > 0) && (tmploc < m->size))
271 {
274 {
277 }
278 }
279 else
280 {
282 }
283 }
284 else
285 {
287 }
288
290 {
291 lines = -1;
292 do
293 {
294 loc = ftello(adata->
fp);
295 if (loc < 0)
296 goto fail;
297 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
298 break;
299 lines++;
301
304 }
305
308
311
313 }
314 else
315 {
318 goto fail;
319 }
320 }
321
323 {
326 goto fail;
327 }
328
330fail:
332 return rc;
333}
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.
void email_free(struct Email **ptr)
Free an 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.