Read a mailbox in MMDF format.
185{
186 if (!m)
188
192
193 char buf[8192] = { 0 };
194 char return_path[1024] = { 0 };
195 int count = 0;
196 int lines;
197 time_t t = 0;
198 LOFF_T loc, tmploc;
199 struct Email *e = NULL;
200 struct stat st = { 0 };
201 struct Progress *progress = NULL;
203
205 {
207 goto fail;
208 }
211 m->
size = st.st_size;
212
213 buf[sizeof(buf) - 1] = '\0';
214
216 {
219 }
220
221 while (true)
222 {
223 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
224 break;
225
227 break;
228
230 {
231 loc = ftello(adata->
fp);
232 if (loc < 0)
233 goto fail;
234
235 count++;
237
243
244 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
245 {
246
248 break;
249 }
250
251 return_path[0] = '\0';
252
253 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
254 {
256 {
258 goto fail;
259 }
260 }
261 else
262 {
264 }
265
267
268 loc = ftello(adata->
fp);
269 if (loc < 0)
270 goto fail;
271
273 {
275
276 if ((tmploc > 0) && (tmploc < m->size))
277 {
280 {
283 }
284 }
285 else
286 {
288 }
289 }
290 else
291 {
293 }
294
296 {
297 lines = -1;
298 do
299 {
300 loc = ftello(adata->
fp);
301 if (loc < 0)
302 goto fail;
303 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
304 break;
305 lines++;
307
310 }
311
314
317
319 }
320 else
321 {
324 goto fail;
325 }
326 }
327
329 {
332 goto fail;
333 }
334
336fail:
338 return rc;
339}
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.