Skip to content

Commit

Permalink
More header reorganization: replaced the content type names with an e…
Browse files Browse the repository at this point in the history
…num.
  • Loading branch information
bruceg committed Dec 24, 2004
1 parent bdb1a94 commit 3795f07
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 36 deletions.
6 changes: 3 additions & 3 deletions ezmlm-clean.c
Expand Up @@ -166,9 +166,9 @@ char *d;
} else
if (!stralloc_copys(&charset,TXT_DEF_CHARSET)) die_nomem();
if (!stralloc_0(&charset)) die_nomem();
hdr_mime("multipart/mixed");
hdr_mime(CTYPE_MULTIPART);
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
} else
qmail_puts(&qq,"\n\n");
Expand All @@ -182,7 +182,7 @@ char *d;

if (flagmime) {
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
qmail_puts(&qq,"\n");
}

Expand Down
12 changes: 6 additions & 6 deletions ezmlm-get.c
Expand Up @@ -307,7 +307,7 @@ char format;
qmail_put(&qq,line.s,line.len);
}
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
hdr_adds("Content-Disposition: inline; filename=request.msg");
qmail_puts(&qq,"\n");
}
Expand Down Expand Up @@ -340,14 +340,14 @@ char format; /* output format type (see idx.h) */
case VIRGIN:
case NATIVE:
case MIXED:
hdr_mime((format == MIXED) ? "multipart/mixed" : "multipart/digest");
hdr_mime((format == MIXED) ? CTYPE_MULTIPART : CTYPE_DIGEST);
hdr_add2("Subject: ",subject->s,subject->len);
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc(); /* content-transfer-enc header if needed */
break;
case RFC1153:
hdr_mime("text/plain");
hdr_mime(CTYPE_TEXT);
hdr_add2("Subject: ",subject->s,subject->len);
qmail_puts(&qq,"\n");
flagcd = '\0'; /* We make 8-bit messages, not QP/base64 for rfc1153 */
Expand Down Expand Up @@ -587,7 +587,7 @@ void mime_getbad(msg)
unsigned long msg;
{
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
qmail_puts(&qq,"Content-Disposition: inline; filename=\"");
qmail_put(&qq,listname.s,listname.len);
qmail_puts(&qq,"_");
Expand Down Expand Up @@ -629,7 +629,7 @@ unsigned long msg; char format;
mime_getbad(msg);
} else {
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
qmail_puts(&qq,"Content-Disposition: inline; filename=\"");
qmail_put(&qq,listname.s,listname.len);
qmail_puts(&qq,"_");
Expand Down
4 changes: 2 additions & 2 deletions ezmlm-manage.c
Expand Up @@ -435,7 +435,7 @@ void msg_headers()
if (flaggoodfield)
qmail_put(&qq,line.s,line.len);
}
hdr_mime(flagcd ? "multipart/mixed" : "text/plain");
hdr_mime(flagcd ? CTYPE_MULTIPART : CTYPE_TEXT);
}

int geton(action)
Expand Down Expand Up @@ -591,7 +591,7 @@ void copybottom()
qmail_put(&qq,line.s,line.len);
}
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
hdr_adds("Content-Disposition: inline; filename=request.msg");
qmail_puts(&qq,"\n");
}
Expand Down
6 changes: 3 additions & 3 deletions ezmlm-moderate.c
Expand Up @@ -357,9 +357,9 @@ char **argv;
if (!stralloc_copys(&charset,TXT_DEF_CHARSET)) die_nomem();
if (!stralloc_0(&charset)) die_nomem();
qmail_puts(&qq,"\n");
hdr_mime("multipart/mixed");
hdr_mime(CTYPE_MULTIPART);
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
}
copy(&qq,"text/top",flagcd,FATAL);
Expand Down Expand Up @@ -445,7 +445,7 @@ char **argv;
}
if (flagmime) {
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
}
qmail_puts(&qq,"\n");
if (seek_begin(fd) == -1)
Expand Down
4 changes: 2 additions & 2 deletions ezmlm-request.c
Expand Up @@ -675,7 +675,7 @@ char **argv;
qmail_put(&qq,mydtline.s,mydtline.len);
if (!quote2(&line,to.s)) die_nomem();
hdr_add2("To: ",line.s,line.len);
hdr_mime(flagcd ? "multipart/mixed" : "text/plain");
hdr_mime(flagcd ? CTYPE_MULTIPART : CTYPE_TEXT);
qmail_puts(&qq,"Subject: ");
if (!quote2(&line,outlocal.s)) die_nomem();
qmail_put(&qq,line.s,line.len);
Expand Down Expand Up @@ -748,7 +748,7 @@ char **argv;
qmail_put(&qq,line.s,line.len);
}
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
hdr_adds("Content-Disposition: inline; filename=request.msg");
qmail_puts(&qq,"\n");
}
Expand Down
2 changes: 1 addition & 1 deletion ezmlm-send.c
Expand Up @@ -685,7 +685,7 @@ char **argv;
if (flagtrailer) {
qmail_puts(&qq,"\n");
hdr_add(boundary.s,boundary.len);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc(); /* trailer for multipart message */
copy(&qq,"text/trailer",flagcd,FATAL);
if (flagcd == 'B') { /* need to do our own flushing */
Expand Down
6 changes: 3 additions & 3 deletions ezmlm-store.c
Expand Up @@ -373,10 +373,10 @@ char **argv;
} else
if (!stralloc_copys(&charset,TXT_DEF_CHARSET)) die_nomem();
if (!stralloc_0(&charset)) die_nomem();
hdr_mime("multipart/mixed");
hdr_mime(CTYPE_MULTIPART);
qmail_put(&qq,subject.s,subject.len);
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
} else {
qmail_put(&qq,subject.s,subject.len);
Expand All @@ -393,7 +393,7 @@ char **argv;

if (flagmime) {
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
qmail_puts(&qq, "\n");
}

Expand Down
6 changes: 3 additions & 3 deletions ezmlm-warn.c
Expand Up @@ -145,12 +145,12 @@ int flagw;
if (!quote2(&quoted,addr.s)) die_nomem();
hdr_add2("To: ",quoted.s,quoted.len);
/* to accomodate transfer-encoding */
hdr_mime(flagcd ? "multipart/mixed" : "text/plain");
hdr_mime(flagcd ? CTYPE_MULTIPART : CTYPE_TEXT);
hdr_adds(flagw ? "Subject: ezmlm probe" : "Subject: ezmlm warning");

if (flagcd) { /* first part for QP/base64 multipart msg */
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
} else
qmail_puts(&qq,"\n");
Expand Down Expand Up @@ -193,7 +193,7 @@ int flagw;
qmail_put(&qq,line.s,line.len); /* flush */
}
hdr_boundary(0);
hdr_ctype("message/rfc822");
hdr_ctype(CTYPE_MESSAGE);
qmail_puts(&qq,"\n");
}
if (substdio_copy(&ssqq,&ssin) < 0) die_read();
Expand Down
11 changes: 9 additions & 2 deletions hdr.h
Expand Up @@ -3,11 +3,18 @@
#ifndef HDR_H
#define HDR_H

enum ctype {
CTYPE_TEXT,
CTYPE_MULTIPART,
CTYPE_DIGEST,
CTYPE_MESSAGE,
};

extern void hdr_transferenc(void);
extern void hdr_ctboundary(void);
extern void hdr_datemsgid(unsigned long when);
extern void hdr_mime(const char *ctype);
extern void hdr_ctype(const char *ctype);
extern void hdr_mime(enum ctype ctype);
extern void hdr_ctype(enum ctype ctype);
extern void hdr_from(const char *append);
extern void hdr_boundary(int last);

Expand Down
2 changes: 1 addition & 1 deletion hdr_ctboundary.c
Expand Up @@ -9,7 +9,7 @@ void hdr_ctboundary(void)
{
if (flagcd) {
hdr_boundary(0);
hdr_ctype("text/plain");
hdr_ctype(CTYPE_TEXT);
hdr_transferenc();
} else
qmail_puts(&qq,"\n");
Expand Down
28 changes: 18 additions & 10 deletions hdr_mime.c
Expand Up @@ -10,27 +10,35 @@ extern struct qmail qq;
extern char boundary[HASHLEN];
extern stralloc charset;

void hdr_ctype(const char *ctype)
{
static const char *ctype_names[] = {
/* This list must match enum ctype in hdr.h exactly! */
"text/plain",
"multipart/mixed",
"multipart/digest",
"message/rfc822",
};

void hdr_ctype(enum ctype ctype)
{
qmail_puts(&qq,"Content-Type: ");
qmail_puts(&qq,ctype);
if (str_diffn(ctype, "text/", 5) == 0
&& charset.s != 0
&& charset.len > 0) {
/* text/something, needs a charset */
qmail_puts(&qq,ctype_names[ctype]);
switch (ctype) {
case CTYPE_TEXT:
/* text/plain, needs a charset */
qmail_puts(&qq,"; charset=");
qmail_puts(&qq,charset.s);
}
if (str_diffn(ctype, "multipart/", 10) == 0) {
break;
case CTYPE_MULTIPART:
case CTYPE_DIGEST:
/* multipart/something, needs a boundary */
qmail_puts(&qq,"; boundary=");
qmail_put(&qq,boundary,HASHLEN);
break;
}
qmail_puts(&qq,"\n");
}

void hdr_mime(const char *ctype)
void hdr_mime(enum ctype ctype)
{
qmail_puts(&qq, "MIME-Version: 1.0\n");
hdr_ctype(ctype);
Expand Down

0 comments on commit 3795f07

Please sign in to comment.