Read a mailbox in MMDF format.
183{
184 if (!m)
186
190
191 char buf[8192] = { 0 };
192 char return_path[1024] = { 0 };
193 int count = 0;
194 int lines;
195 time_t t = 0;
196 LOFF_T loc, tmploc;
197 struct Email *e = NULL;
198 struct stat st = { 0 };
199 struct Progress *progress = NULL;
201
203 {
205 goto fail;
206 }
209 m->
size = st.st_size;
210
211 buf[sizeof(buf) - 1] = '\0';
212
214 {
217 }
218
219 while (true)
220 {
221 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
222 break;
223
225 break;
226
228 {
229 loc = ftello(adata->
fp);
230 if (loc < 0)
231 goto fail;
232
233 count++;
235
241
242 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
243 {
244
246 break;
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
265
266 loc = ftello(adata->
fp);
267 if (loc < 0)
268 goto fail;
269
271 {
273
274 if ((tmploc > 0) && (tmploc < m->size))
275 {
278 {
281 }
282 }
283 else
284 {
286 }
287 }
288 else
289 {
291 }
292
294 {
295 lines = -1;
296 do
297 {
298 loc = ftello(adata->
fp);
299 if (loc < 0)
300 goto fail;
301 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
302 break;
303 lines++;
305
308 }
309
312
315
317 }
318 else
319 {
322 goto fail;
323 }
324 }
325
327 {
330 goto fail;
331 }
332
334fail:
336 return rc;
337}
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.