ref: 1fc867634ab5ed733786ab86ea0fc47eb9e6d22e
parent: 8fb05d3ff38994f053a47b0977b54702366d1d94
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Nov 14 10:49:00 EST 2020
style: attachments => parts
--- a/mail.h
+++ b/mail.h
@@ -95,8 +95,10 @@
Mesg **child;
int nchild;
int nsub; /* transitive children */
- Mesg **attachments;
- int nattachments;
+
+ Mesg *body; /* best attachment to use, or nil */
+ Mesg **parts;
+ int nparts;
/* info fields */
char *from;
--- a/mesg.c
+++ b/mesg.c
@@ -18,6 +18,10 @@
void
mesgclear(Mesg *m)
{
+ int i;
+
+ for(i = 0; i < m->nparts; i++)
+ mesgclear(m->parts[i]);
free(m->name);
free(m->from);
free(m->to);
@@ -151,7 +155,7 @@
sysfatal("%s read: %r", mbox.path);
best = nil;
- m->attachments = erealloc(m->attachments, (m->nattachments + n)*sizeof(Mesg*));
+ m->parts = erealloc(m->parts, (m->nparts + n)*sizeof(Mesg*));
for(i = 0; i < n; i++){
if(d[i].qid.type != QTDIR)
continue;
@@ -167,7 +171,7 @@
best = sub;
continue;
}
- m->attachments[m->nattachments++] = a;
+ m->parts[m->nparts++] = a;
if(a->filename != nil || a->disposition != nil && strcmp(a->disposition, "inline") != 0)
continue;
if(strcmp(a->type, "text/plain") == 0)
@@ -254,10 +258,10 @@
}
home = getenv("home");
- if(m->nattachments != 0)
+ if(m->nparts != 0)
fprint(wfd, "\n");
- for(i = 0; i < m->nattachments; i++){
- a = m->attachments[i];
+ for(i = 0; i < m->nparts; i++){
+ a = m->parts[i];
if(a == b)
continue;
name = a->name;