Read a mailbox in MMDF format.
182{
183 if (!m)
185
189
190 char buf[8192] = { 0 };
191 char return_path[1024] = { 0 };
192 int count = 0;
193 int lines;
194 time_t t = 0;
195 LOFF_T loc, tmploc;
196 struct Email *e = NULL;
197 struct stat st = { 0 };
198 struct Progress *progress = NULL;
200
202 {
204 goto fail;
205 }
208 m->
size = st.st_size;
209
210 buf[sizeof(buf) - 1] = '\0';
211
213 {
216 }
217
218 while (true)
219 {
220 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
221 break;
222
224 break;
225
227 {
228 loc = ftello(adata->
fp);
229 if (loc < 0)
230 goto fail;
231
232 count++;
234
240
241 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
242 {
243
245 break;
246 }
247
248 return_path[0] = '\0';
249
250 if (!
is_from(buf, return_path,
sizeof(return_path), &t))
251 {
253 {
255 goto fail;
256 }
257 }
258 else
259 {
261 }
262
264
265 loc = ftello(adata->
fp);
266 if (loc < 0)
267 goto fail;
268
270 {
272
273 if ((tmploc > 0) && (tmploc < m->size))
274 {
277 {
280 }
281 }
282 else
283 {
285 }
286 }
287 else
288 {
290 }
291
293 {
294 lines = -1;
295 do
296 {
297 loc = ftello(adata->
fp);
298 if (loc < 0)
299 goto fail;
300 if (!fgets(buf,
sizeof(buf) - 1, adata->
fp))
301 break;
302 lines++;
304
307 }
308
311
314
316 }
317 else
318 {
321 goto fail;
322 }
323 }
324
326 {
329 goto fail;
330 }
331
333fail:
335 return rc;
336}
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.
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?
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
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)
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.