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
200
202 {
204 goto fail;
205 }
208 m->
size = st.st_size;
209
211 {
214 }
215
216
217 while (true)
218 {
219 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
220 break;
221
223 break;
224
226 {
227 loc = ftello(adata->
fp);
228 if (loc < 0)
229 goto fail;
230
231 count++;
233
234
240
241 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
242 {
245 break;
246 }
247
248
249 return_path[0] = '\0';
250
251 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
252 {
254 {
256 goto fail;
257 }
258 }
259 else
260 {
262 }
263
264
266
267 loc = ftello(adata->
fp);
268 if (loc < 0)
269 goto fail;
270
271
272
274 {
276
277 if ((tmploc > 0) && (tmploc < m->size))
278 {
281 {
284 }
285 }
286 else
287 {
289 }
290 }
291 else
292 {
294 }
295
296
298 {
299 lines = -1;
300 do
301 {
302 loc = ftello(adata->
fp);
303 if (loc < 0)
304 goto fail;
305 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
306 break;
307 lines++;
309
312 }
313
314
317
320
322 }
323 else
324 {
327 goto fail;
328 }
329 }
330
332 {
335 goto fail;
336 }
337
339fail:
341 return rc;
342}
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.