Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.

This commit is contained in:
rsc 2006-04-01 19:24:03 +00:00
parent 226d80b821
commit cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions

View file

@ -7,7 +7,7 @@
enum
{
MAXTAB = 256,
MAXBEST = 32,
MAXBEST = 32
};
typedef struct Table Table;

View file

@ -667,8 +667,8 @@ main(int argc, char **argv)
if(p == 0){
print("=== %s: bad regexp\n", argv[i]);
}
// print("=== %s\n", argv[i]);
// rdump(p);
/* print("=== %s\n", argv[i]); */
/* rdump(p); */
dp = dregcvt(p);
print("=== dfa\n");
dump(dp);

View file

@ -55,8 +55,8 @@ main(int argc, char **argv)
if(p == 0){
print("=== %s: bad regexp\n", argv[i]);
}
// print("=== %s\n", argv[i]);
// rdump(p);
/* print("=== %s\n", argv[i]); */
/* rdump(p); */
dp = dregcvt(p);
print("=== dfa\n");
dump(dp);

View file

@ -15,7 +15,7 @@ enum
{
MAXBEST = 32,
MAXLEN = 64,
MAXTAB = 256,
MAXTAB = 256
};
typedef struct Ndb Ndb;
@ -163,7 +163,7 @@ main(int argc, char **argv)
w.p[i] = p;
totp += p;
}
//fprint(2, "%s tot %d totp %g\n", s, tot, totp);
/*fprint(2, "%s tot %d totp %g\n", s, tot, totp); */
if(tot < 2)
continue;
w.mp = 0.0;

View file

@ -52,12 +52,12 @@ char *ignore[] =
/* little things */
".",
"\n",
"\n"
};
char *keywords[] =
{
"([a-zA-Z'`$!¡-￿]|[0-9]([.,][0-9])*)+",
"([a-zA-Z'`$!¡-￿]|[0-9]([.,][0-9])*)+"
};
int debug;

View file

@ -1,7 +1,7 @@
#include "common.h"
enum {
Buffersize = 64*1024,
Buffersize = 64*1024
};
typedef struct Inbuf Inbuf;

View file

@ -19,7 +19,7 @@ enum
Errlen= 128,
Pathlen= 256,
RetryCode = 2,
RetryCode = 2
};
/*

View file

@ -805,9 +805,9 @@ remoteaddr(int fd, char *dir)
return raddr;
}
// create a file and
// 1) ensure the modes we asked for
// 2) make gid == uid
/* create a file and */
/* 1) ensure the modes we asked for */
/* 2) make gid == uid */
static int
docreate(char *file, int perm)
{
@ -815,7 +815,7 @@ docreate(char *file, int perm)
Dir ndir;
Dir *d;
// create the mbox
/* create the mbox */
fd = create(file, OREAD, perm);
if(fd < 0){
fprint(2, "couldn't create %s\n", file);
@ -835,7 +835,7 @@ docreate(char *file, int perm)
return 0;
}
// create a mailbox
/* create a mailbox */
int
creatembox(char *user, char *folder)
{
@ -852,14 +852,14 @@ creatembox(char *user, char *folder)
mboxpath(buf, user, mailfile, 0);
}
// don't destroy existing mailbox
/* don't destroy existing mailbox */
if(access(s_to_c(mailfile), 0) == 0){
fprint(2, "mailbox already exists\n");
return -1;
}
fprint(2, "creating new mbox: %s\n", s_to_c(mailfile));
// make sure preceding levels exist
/* make sure preceding levels exist */
for(p = s_to_c(mailfile); p; p++) {
if(*p == '/') /* skip leading or consecutive slashes */
continue;
@ -874,7 +874,7 @@ creatembox(char *user, char *folder)
*p = '/';
}
// create the mbox
/* create the mbox */
if(docreate(s_to_c(mailfile), 0622|DMAPPEND|DMEXCL) < 0)
return -1;

View file

@ -79,7 +79,7 @@ enum
Dfile,
Dignore,
PAD64= '=',
PAD64= '='
};
typedef struct Mailbox Mailbox;
@ -194,7 +194,7 @@ enum
Qmbox,
Qdir,
Qctl,
Qmboxctl,
Qmboxctl
};
#define PATH(id, f) ((((id)&0xfffff)<<10) | (f))

View file

@ -8,7 +8,7 @@
enum
{
OPERM = 0x3, // mask of all permission types in open mode
OPERM = 0x3, /* mask of all permission types in open mode */
};
typedef struct Fid Fid;
@ -22,15 +22,15 @@ struct Fid
Fid *next;
Mailbox *mb;
Message *m;
Message *mtop; // top level message
Message *mtop; /* top level message */
//finger pointers to speed up reads of large directories
long foff; // offset/DIRLEN of finger
Message *fptr; // pointer to message at off
int fvers; // mailbox version when finger was saved
/*finger pointers to speed up reads of large directories */
long foff; /* offset/DIRLEN of finger */
Message *fptr; /* pointer to message at off */
int fvers; /* mailbox version when finger was saved */
};
ulong path; // incremented for each new file
ulong path; /* incremented for each new file */
Fid *fids;
int mfd[2];
char user[Elemlen];
@ -81,7 +81,7 @@ char *(*fcalls[])(Fid*) = {
[Tclunk] rclunk,
[Tremove] rremove,
[Tstat] rstat,
[Twstat] rwstat,
[Twstat] rwstat
};
char Eperm[] = "permission denied";
@ -125,12 +125,12 @@ char *dirtab[] =
[Qunixdate] "unixdate",
[Qunixheader] "unixheader",
[Qctl] "ctl",
[Qmboxctl] "ctl",
[Qmboxctl] "ctl"
};
enum
{
Hsize= 1277,
Hsize= 1277
};
Hash *htab[Hsize];
@ -455,7 +455,7 @@ int infofields[] = {
Qsender,
Qmessageid,
Qlines,
-1,
-1
};
static int
@ -654,7 +654,7 @@ dowalk(Fid *f, char *name)
else
qlock(&mbllock);
// this must catch everything except . and ..
/* this must catch everything except . and .. */
retry:
h = hlook(f->qid.path, name);
if(h != nil){
@ -788,7 +788,7 @@ ropen(Fid *f)
if(file != Qctl && file != Qmboxctl)
return Eperm;
// make sure we've decoded
/* make sure we've decoded */
if(file == Qbody){
if(f->m->decoded == 0)
decode(f->m);
@ -865,7 +865,7 @@ readmboxdir(Fid *f, uchar *buf, long off, int cnt, int blen)
off -= m;
}
// to avoid n**2 reads of the directory, use a saved finger pointer
/* to avoid n**2 reads of the directory, use a saved finger pointer */
if(f->mb->vers == f->fvers && off >= f->foff && f->fptr != nil){
msg = f->fptr;
pos = f->foff;
@ -875,7 +875,7 @@ readmboxdir(Fid *f, uchar *buf, long off, int cnt, int blen)
}
for(; cnt > 0 && msg != nil; msg = msg->next){
// act like deleted files aren't there
/* act like deleted files aren't there */
if(msg->deleted)
continue;
@ -890,7 +890,7 @@ readmboxdir(Fid *f, uchar *buf, long off, int cnt, int blen)
pos += m;
}
// save a finger pointer for next read of the mbox directory
/* save a finger pointer for next read of the mbox directory */
f->foff = pos;
f->fptr = msg;
f->fvers = f->mb->vers;
@ -1370,7 +1370,7 @@ hdrlen(char *p, char *e)
return ep - p;
}
// rfc2047 non-ascii
/* rfc2047 non-ascii */
typedef struct Charset Charset;
struct Charset {
char *name;
@ -1386,7 +1386,7 @@ struct Charset {
{ "big5", 4, 2, "big5", },
{ "iso-2022-jp", 11, 2, "jis", },
{ "windows-1251", 12, 2, "cp1251"},
{ "koi8-r", 6, 2, "koi8"},
{ "koi8-r", 6, 2, "koi8"}
};
int
@ -1403,7 +1403,7 @@ rfc2047convert(String *s, char *token, int len)
e = token+len-2;
token += 2;
// bail if we don't understand the character set
/* bail if we don't understand the character set */
for(i = 0; i < nelem(charsets); i++)
if(cistrncmp(charsets[i].name, token, charsets[i].len) == 0)
if(token[charsets[i].len] == '?'){
@ -1413,11 +1413,11 @@ rfc2047convert(String *s, char *token, int len)
if(i >= nelem(charsets))
return -1;
// bail if it doesn't fit
/* bail if it doesn't fit */
if(e-token > sizeof(decoded)-1)
return -1;
// bail if we don't understand the encoding
/* bail if we don't understand the encoding */
if(cistrncmp(token, "b?", 2) == 0){
token += 2;
len = dec64((uchar*)decoded, sizeof(decoded), token, e-token);
@ -1483,7 +1483,7 @@ rfc2047start(char *start, char *end)
return nil;
}
// convert a header line
/* convert a header line */
String*
stringconvert(String *s, char *uneaten, int len)
{
@ -1521,7 +1521,7 @@ readheader(Message *m, char *buf, int off, int cnt)
e = m->hend;
s = nil;
// copy in good headers
/* copy in good headers */
while(cnt > 0 && p < e){
n = hdrlen(p, e);
if(ignore(p)){
@ -1529,7 +1529,7 @@ readheader(Message *m, char *buf, int off, int cnt)
continue;
}
// rfc2047 processing
/* rfc2047 processing */
s = stringconvert(s, p, n);
ns = s_len(s);
if(off > 0){

View file

@ -15,7 +15,7 @@ int pipeline = 1;
typedef struct Imap Imap;
struct Imap {
char *freep; // free this to free the strings below
char *freep; /* free this to free the strings below */
char *host;
char *user;
@ -38,7 +38,7 @@ struct Imap {
Thumbprint *thumb;
// open network connection
/* open network connection */
Biobuf bin;
Biobuf bout;
int fd;
@ -56,9 +56,9 @@ removecr(char *s)
return s;
}
//
// send imap4 command
//
/* */
/* send imap4 command */
/* */
static void
imap4cmd(Imap *imap, char *fmt, ...)
{
@ -89,7 +89,7 @@ enum {
EXISTS,
STATUS,
FETCH,
UNKNOWN,
UNKNOWN
};
static char *verblist[] = {
@ -99,7 +99,7 @@ static char *verblist[] = {
[BYE] "BYE",
[EXISTS] "EXISTS",
[STATUS] "STATUS",
[FETCH] "FETCH",
[FETCH] "FETCH"
};
static int
@ -141,7 +141,7 @@ imapgrow(Imap *imap, int n)
imap->size = n+1;
}
if(n >= imap->size){
// friggin microsoft - reallocate
/* friggin microsoft - reallocate */
i = imap->data - imap->base;
imap->base = erealloc(imap->base, i+n+1);
imap->data = imap->base + i;
@ -150,10 +150,10 @@ imapgrow(Imap *imap, int n)
}
//
// get imap4 response line. there might be various
// data or other informational lines mixed in.
//
/* */
/* get imap4 response line. there might be various */
/* data or other informational lines mixed in. */
/* */
static char*
imap4resp(Imap *imap)
{
@ -176,7 +176,7 @@ imap4resp(Imap *imap)
fprint(2, "unexpected: %s\n", p);
break;
// ``unsolicited'' information; everything happens here.
/* ``unsolicited'' information; everything happens here. */
case '*':
if(p[1]!=' ')
continue;
@ -196,19 +196,19 @@ imap4resp(Imap *imap)
case OK:
case NO:
case BAD:
// human readable text at p;
/* human readable text at p; */
break;
case BYE:
// early disconnect
// human readable text at p;
/* early disconnect */
/* human readable text at p; */
break;
// * 32 EXISTS
/* * 32 EXISTS */
case EXISTS:
imap->nmsg = n;
break;
// * STATUS Inbox (MESSAGES 2 UIDVALIDITY 960164964)
/* * STATUS Inbox (MESSAGES 2 UIDVALIDITY 960164964) */
case STATUS:
if(q = strstr(p, "MESSAGES"))
imap->nmsg = atoi(q+8);
@ -217,9 +217,9 @@ imap4resp(Imap *imap)
break;
case FETCH:
// * 1 FETCH (uid 8889 RFC822.SIZE 3031 body[] {3031}
// <3031 bytes of data>
// )
/* * 1 FETCH (uid 8889 RFC822.SIZE 3031 body[] {3031} */
/* <3031 bytes of data> */
/* ) */
if(strstr(p, "RFC822.SIZE") && strstr(p, "BODY[]")){
if((q = strchr(p, '{'))
&& (n=strtol(q+1, &en, 0), *en=='}')){
@ -257,16 +257,16 @@ imap4resp(Imap *imap)
break;
}
// * 1 FETCH (UID 1 RFC822.SIZE 511)
/* * 1 FETCH (UID 1 RFC822.SIZE 511) */
if(q=strstr(p, "RFC822.SIZE")){
imap->size = atoi(q+11);
break;
}
// * 1 FETCH (UID 1 RFC822.HEADER {496}
// <496 bytes of data>
// )
// * 1 FETCH (UID 1 RFC822.HEADER "data")
/* * 1 FETCH (UID 1 RFC822.HEADER {496} */
/* <496 bytes of data> */
/* ) */
/* * 1 FETCH (UID 1 RFC822.HEADER "data") */
if(strstr(p, "RFC822.HEADER") || strstr(p, "RFC822.TEXT")){
if((q = strchr(p, '{'))
&& (n=strtol(q+1, &en, 0), *en=='}')){
@ -304,8 +304,8 @@ imap4resp(Imap *imap)
break;
}
// * 1 FETCH (UID 1)
// * 2 FETCH (UID 6)
/* * 1 FETCH (UID 1) */
/* * 2 FETCH (UID 6) */
if(q = strstr(p, "UID")){
if(imap->nuid < imap->muid)
imap->uid[imap->nuid++] = ((vlong)imap->validity<<32)|strtoul(q+3, nil, 10);
@ -317,7 +317,7 @@ imap4resp(Imap *imap)
return line;
break;
case '9': // response to our message
case '9': /* response to our message */
op = p;
if(p[1]=='X' && strtoul(p+2, &p, 10)==imap->tag){
while(*p==' ')
@ -343,9 +343,9 @@ isokay(char *resp)
return strncmp(resp, "OK", 2)==0;
}
//
// log in to IMAP4 server, select mailbox, no SSL at the moment
//
/* */
/* log in to IMAP4 server, select mailbox, no SSL at the moment */
/* */
static char*
imap4login(Imap *imap)
{
@ -377,9 +377,9 @@ imap4login(Imap *imap)
return nil;
}
//
// push tls onto a connection
//
/* */
/* push tls onto a connection */
/* */
int
mypushtls(int fd)
{
@ -409,9 +409,9 @@ mypushtls(int fd)
return p[1];
}
//
// dial and handshake with the imap server
//
/* */
/* dial and handshake with the imap server */
/* */
static char*
imap4dial(Imap *imap)
{
@ -476,9 +476,9 @@ imap4dial(Imap *imap)
return nil;
}
//
// close connection
//
/* */
/* close connection */
/* */
#if 0 /* jpc */
static void
imap4hangup(Imap *imap)
@ -489,9 +489,9 @@ imap4hangup(Imap *imap)
}
#endif
//
// download a single message
//
/* */
/* download a single message */
/* */
static char*
imap4fetch(Mailbox *mb, Message *m)
{
@ -522,7 +522,7 @@ imap4fetch(Mailbox *mb, Message *m)
parse(m, 0, mb, 1);
// digest headers
/* digest headers */
sha1((uchar*)m->start, m->end - m->start, m->digest, nil);
for(i = 0; i < SHA1dlen; i++)
sprint(sdigest+2*i, "%2.2ux", m->digest[i]);
@ -531,10 +531,10 @@ imap4fetch(Mailbox *mb, Message *m)
return nil;
}
//
// check for new messages on imap4 server
// download new messages, mark deleted messages
//
/* */
/* check for new messages on imap4 server */
/* download new messages, mark deleted messages */
/* */
static char*
imap4read(Imap *imap, Mailbox *mb, int doplumb)
{
@ -565,7 +565,7 @@ imap4read(Imap *imap, Mailbox *mb, int doplumb)
l = &(*l)->next;
break;
}else{
// old mail, we don't have it anymore
/* old mail, we don't have it anymore */
if(doplumb)
mailplumb(mb, *l, 1);
(*l)->inmbox = 0;
@ -576,18 +576,18 @@ imap4read(Imap *imap, Mailbox *mb, int doplumb)
if(ignore)
continue;
// new message
/* new message */
m = newmessage(mb->root);
m->mallocd = 1;
m->inmbox = 1;
m->imapuid = imap->uid[i];
// add to chain, will download soon
/* add to chain, will download soon */
*l = m;
l = &m->next;
}
// whatever is left at the end of the chain is gone
/* whatever is left at the end of the chain is gone */
while(*l != nil){
if(doplumb)
mailplumb(mb, *l, 1);
@ -596,7 +596,7 @@ imap4read(Imap *imap, Mailbox *mb, int doplumb)
l = &(*l)->next;
}
// download new messages
/* download new messages */
t = imap->tag;
if(pipeline)
switch(rfork(RFPROC|RFMEM)){
@ -631,7 +631,7 @@ imap4read(Imap *imap, Mailbox *mb, int doplumb)
}
if(s = imap4fetch(mb, m)){
// message disappeared? unchain
/* message disappeared? unchain */
fprint(2, "download %lud: %s\n", (ulong)m->imapuid, s);
delmessage(mb, m);
mb->root->subname--;
@ -652,9 +652,9 @@ imap4read(Imap *imap, Mailbox *mb, int doplumb)
return nil;
}
//
// sync mailbox
//
/* */
/* sync mailbox */
/* */
static void
imap4purge(Imap *imap, Mailbox *mb)
{
@ -682,9 +682,9 @@ imap4purge(Imap *imap, Mailbox *mb)
}
}
//
// connect to imap4 server, sync mailbox
//
/* */
/* connect to imap4 server, sync mailbox */
/* */
static char*
imap4sync(Mailbox *mb, int doplumb)
{
@ -705,7 +705,7 @@ imap4sync(Mailbox *mb, int doplumb)
/*
* don't hang up; leave connection open for next time.
*/
// imap4hangup(imap);
/* imap4hangup(imap); */
mb->waketime = time(0) + imap->refreshtime;
return err;
}
@ -754,9 +754,9 @@ imap4ctl(Mailbox *mb, int argc, char **argv)
return Eimap4ctl;
}
//
// free extra memory associated with mb
//
/* */
/* free extra memory associated with mb */
/* */
static void
imap4close(Mailbox *mb)
{
@ -771,9 +771,9 @@ imap4close(Mailbox *mb)
free(imap);
}
//
// open mailboxes of the form /imap/host/user
//
/* */
/* open mailboxes of the form /imap/host/user */
/* */
char*
imap4mbox(Mailbox *mb, char *path)
{
@ -818,20 +818,20 @@ imap4mbox(Mailbox *mb, char *path)
mb->close = imap4close;
mb->ctl = imap4ctl;
mb->d = emalloc(sizeof(*mb->d));
//mb->fetch = imap4fetch;
/*mb->fetch = imap4fetch; */
return nil;
}
//
// Formatter for %"
// Use double quotes to protect white space, frogs, \ and "
//
/* */
/* Formatter for %" */
/* Use double quotes to protect white space, frogs, \ and " */
/* */
enum
{
Qok = 0,
Qquote,
Qbackslash,
Qbackslash
};
static int

View file

@ -53,7 +53,7 @@ Header head[] =
[Mhead] { "content-type:", ctype, },
{ "content-transfer-encoding:", cencoding, },
{ "content-disposition:", cdisposition, },
{ 0, },
{ 0, }
};
/* static void fatal(char *fmt, ...); jpc */
@ -76,13 +76,13 @@ char *Enotme = "path not served by this file server";
enum
{
Chunksize = 1024,
Chunksize = 1024
};
Mailboxinit *boxinit[] = {
imap4mbox,
pop3mbox,
plan9mbox,
plan9mbox
};
char*
@ -119,7 +119,7 @@ newmbox(char *path, char *name, int std)
}
rv = nil;
// check for a mailbox type
/* check for a mailbox type */
for(i=0; i<nelem(boxinit); i++)
if((rv = (*boxinit[i])(mb, path)) != Enotme)
break;
@ -128,13 +128,13 @@ newmbox(char *path, char *name, int std)
return "bad path";
}
// on error, give up
/* on error, give up */
if(rv){
free(mb);
return rv;
}
// make sure name isn't taken
/* make sure name isn't taken */
qlock(&mbllock);
for(l = &mbl; *l != nil; l = &(*l)->next){
if(strcmp((*l)->name, mb->name) == 0){
@ -150,7 +150,7 @@ newmbox(char *path, char *name, int std)
}
}
// always try locking
/* always try locking */
mb->dolock = 1;
mb->refs = 1;
@ -172,7 +172,7 @@ newmbox(char *path, char *name, int std)
return rv;
}
// close the named mailbox
/* close the named mailbox */
void
freembox(char *name)
{
@ -248,7 +248,7 @@ parseheaders(Message *m, int justmime, Mailbox *mb, int addfrom)
henter(PATH(m->id, Qdir), dirtab[i],
(Qid){PATH(m->id, i), 0, QTFILE}, m, mb);
// parse mime headers
/* parse mime headers */
p = m->header;
hl = s_new();
while(headerline(&p, hl)){
@ -266,7 +266,7 @@ parseheaders(Message *m, int justmime, Mailbox *mb, int addfrom)
}
s_free(hl);
// the blank line isn't really part of the body or header
/* the blank line isn't really part of the body or header */
if(justmime){
m->mhend = p;
m->hend = m->header;
@ -277,27 +277,27 @@ parseheaders(Message *m, int justmime, Mailbox *mb, int addfrom)
p++;
m->rbody = m->body = p;
// if type is text, get any nulls out of the body. This is
// for the two seans and imap clients that get confused.
/* if type is text, get any nulls out of the body. This is */
/* for the two seans and imap clients that get confused. */
if(strncmp(s_to_c(m->type), "text/", 5) == 0)
nullsqueeze(m);
//
// cobble together Unix-style from line
// for local mailbox messages, we end up recreating the
// original header.
// for pop3 messages, the best we can do is
// use the From: information and the RFC822 date.
//
/* */
/* cobble together Unix-style from line */
/* for local mailbox messages, we end up recreating the */
/* original header. */
/* for pop3 messages, the best we can do is */
/* use the From: information and the RFC822 date. */
/* */
if(m->unixdate == nil || strcmp(s_to_c(m->unixdate), "???") == 0
|| strcmp(s_to_c(m->unixdate), "Thu Jan 1 00:00:00 GMT 1970") == 0){
if(m->unixdate){
s_free(m->unixdate);
m->unixdate = nil;
}
// look for the date in the first Received: line.
// it's likely to be the right time zone (it's
// the local system) and in a convenient format.
/* look for the date in the first Received: line. */
/* it's likely to be the right time zone (it's */
/* the local system) and in a convenient format. */
if(cistrncmp(m->header, "received:", 9)==0){
if((q = strchr(m->header, ';')) != nil){
p = q;
@ -314,7 +314,7 @@ parseheaders(Message *m, int justmime, Mailbox *mb, int addfrom)
}
}
// fall back on the rfc822 date
/* fall back on the rfc822 date */
if(m->unixdate==nil && m->date822)
m->unixdate = date822tounix(s_to_c(m->date822));
}
@ -322,10 +322,10 @@ parseheaders(Message *m, int justmime, Mailbox *mb, int addfrom)
if(m->unixheader != nil)
s_free(m->unixheader);
// only fake header for top-level messages for pop3 and imap4
// clients (those protocols don't include the unix header).
// adding the unix header all the time screws up mime-attached
// rfc822 messages.
/* only fake header for top-level messages for pop3 and imap4 */
/* clients (those protocols don't include the unix header). */
/* adding the unix header all the time screws up mime-attached */
/* rfc822 messages. */
if(!addfrom && !m->unixfrom){
m->unixheader = nil;
return;
@ -365,7 +365,7 @@ parsebody(Message *m, Mailbox *mb)
{
Message *nm;
// recurse
/* recurse */
if(strncmp(s_to_c(m->type), "multipart/", 10) == 0){
parseattachments(m, mb);
} else if(strcmp(s_to_c(m->type), "message/rfc822") == 0){
@ -373,7 +373,7 @@ parsebody(Message *m, Mailbox *mb)
parseattachments(m, mb);
nm = m->part;
// promote headers
/* promote headers */
if(m->replyto822 == nil && m->from822 == nil && m->sender822 == nil){
m->from822 = promote(&nm->from822);
m->to822 = promote(&nm->to822);
@ -399,7 +399,7 @@ parseattachments(Message *m, Mailbox *mb)
Message *nm, **l;
char *p, *x;
// if there's a boundary, recurse...
/* if there's a boundary, recurse... */
if(m->boundary != nil){
p = m->body;
nm = nil;
@ -442,7 +442,7 @@ parseattachments(Message *m, Mailbox *mb)
return;
}
// if we've got an rfc822 message, recurse...
/* if we've got an rfc822 message, recurse... */
if(strcmp(s_to_c(m->type), "message/rfc822") == 0){
nm = newmessage(m);
m->part = nm;
@ -496,11 +496,11 @@ addr822(char *p)
for(; *p; p++){
c = *p;
// whitespace is ignored
/* whitespace is ignored */
if(!quoted && isspace(c) || c == '\r')
continue;
// strings are always treated as atoms
/* strings are always treated as atoms */
if(!quoted && c == '"'){
if(!addrdone && !incomment)
s_putc(s, c);
@ -520,7 +520,7 @@ addr822(char *p)
continue;
}
// ignore everything in an expicit comment
/* ignore everything in an expicit comment */
if(!quoted && c == '('){
incomment = 1;
continue;
@ -532,7 +532,7 @@ addr822(char *p)
continue;
}
// anticomments makes everything outside of them comments
/* anticomments makes everything outside of them comments */
if(!quoted && c == '<' && !inanticomment){
inanticomment = 1;
s = s_reset(s);
@ -544,7 +544,7 @@ addr822(char *p)
continue;
}
// commas separate addresses
/* commas separate addresses */
if(!quoted && c == ',' && !inanticomment){
s_terminate(s);
addrdone = 0;
@ -555,10 +555,10 @@ addr822(char *p)
continue;
}
// what's left is part of the address
/* what's left is part of the address */
s_putc(s, c);
// quoted characters are recognized only as characters
/* quoted characters are recognized only as characters */
if(c == '\\')
quoted = 1;
else
@ -801,7 +801,7 @@ newmessage(Message *parent)
return m;
}
// delete a message from a mailbox
/* delete a message from a mailbox */
void
delmessage(Mailbox *mb, Message *m)
{
@ -812,13 +812,13 @@ delmessage(Mailbox *mb, Message *m)
msgfreed++;
if(m->whole != m){
// unchain from parent
/* unchain from parent */
for(l = &m->whole->part; *l && *l != m; l = &(*l)->next)
;
if(*l != nil)
*l = m->next;
// clear out of name lookup hash table
/* clear out of name lookup hash table */
if(m->whole->whole == m->whole)
hfree(PATH(mb->id, Qmbox), m->name);
else
@ -862,7 +862,7 @@ delmessage(Mailbox *mb, Message *m)
free(m);
}
// mark messages (identified by path) for deletion
/* mark messages (identified by path) for deletion */
void
delmessages(int ac, char **av)
{
@ -1019,9 +1019,9 @@ setfilename(Message *m, char *p)
*p = '_';
}
//
// undecode message body
//
/* */
/* undecode message body */
/* */
void
decode(Message *m)
{
@ -1033,7 +1033,7 @@ decode(Message *m)
switch(m->encoding){
case Ebase64:
len = m->bend - m->body;
i = (len*3)/4+1; // room for max chars + null
i = (len*3)/4+1; /* room for max chars + null */
x = emalloc(i);
len = dec64((uchar*)x, i, m->body, len);
if(m->ballocd)
@ -1044,7 +1044,7 @@ decode(Message *m)
break;
case Equoted:
len = m->bend - m->body;
x = emalloc(len+2); // room for null and possible extra nl
x = emalloc(len+2); /* room for null and possible extra nl */
len = decquoted(x, m->body, m->bend);
if(m->ballocd)
free(m->body);
@ -1058,14 +1058,14 @@ decode(Message *m)
m->decoded = 1;
}
// convert latin1 to utf
/* convert latin1 to utf */
void
convert(Message *m)
{
int len;
char *x;
// don't convert if we're not a leaf, not text, or already converted
/* don't convert if we're not a leaf, not text, or already converted */
if(m->converted)
return;
if(m->part != nil)
@ -1161,7 +1161,7 @@ convert(Message *m)
enum
{
Self= 1,
Hex= 2,
Hex= 2
};
uchar tableqp[256];
@ -1243,7 +1243,7 @@ decquoted(char *out, char *in, char *e)
if(in < e)
p = decquotedline(p, in, e-1);
// make sure we end with a new line
/* make sure we end with a new line */
if(*(p-1) != '\n'){
*p++ = '\n';
*p = 0;
@ -1281,7 +1281,7 @@ is8bit(Message *m)
return count;
}
// translate latin1 directly since it fits neatly in utf
/* translate latin1 directly since it fits neatly in utf */
int
latin1toutf(char *out, char *in, char *e)
{
@ -1297,7 +1297,7 @@ latin1toutf(char *out, char *in, char *e)
return p - out;
}
// translate any thing else using the tcs program
/* translate any thing else using the tcs program */
int
xtoutf(char *charset, char **out, char *in, char *e)
{
@ -1334,7 +1334,7 @@ xtoutf(char *charset, char **out, char *in, char *e)
dup(totcs[0], 0);
close(fromtcs[1]); close(totcs[0]);
dup(open("/dev/null", OWRITE), 2);
//jpc exec("/bin/tcs", av);
/*jpc exec("/bin/tcs", av); */
exec(unsharp("#9/bin/tcs"), av);
/* _exits(0); */
threadexits(nil);
@ -1380,7 +1380,7 @@ xtoutf(char *charset, char **out, char *in, char *e)
enum {
Winstart= 0x7f,
Winend= 0x9f,
Winend= 0x9f
};
Rune winchars[] = {
@ -1388,7 +1388,7 @@ Rune winchars[] = {
L'', L'', L'', L'ƒ', L'', L'', L'', L'',
L'ˆ', L'', L'Š', L'', L'Œ', L'', L'', L'',
L'', L'', L'', L'', L'', L'', L'', L'',
L'˜', L'', L'š', L'', L'œ', L'', L'', L'Ÿ',
L'˜', L'', L'š', L'', L'œ', L'', L'', L'Ÿ'
};
int
@ -1518,9 +1518,9 @@ mailplumb(Mailbox *mb, Message *m, int delete)
plumbsend(fd, &p);
}
//
// count the number of lines in the body (for imap4)
//
/* */
/* count the number of lines in the body (for imap4) */
/* */
void
countlines(Message *m)
{
@ -1573,15 +1573,15 @@ nullsqueeze(Message *m)
}
//
// convert an RFC822 date into a Unix style date
// for when the Unix From line isn't there (e.g. POP3).
// enough client programs depend on having a Unix date
// that it's easiest to write this conversion code once, right here.
//
// people don't follow RFC822 particularly closely,
// so we use strtotm, which is a bunch of heuristics.
//
/* */
/* convert an RFC822 date into a Unix style date */
/* for when the Unix From line isn't there (e.g. POP3). */
/* enough client programs depend on having a Unix date */
/* that it's easiest to write this conversion code once, right here. */
/* */
/* people don't follow RFC822 particularly closely, */
/* so we use strtotm, which is a bunch of heuristics. */
/* */
extern int strtotm(char*, Tm*);
String*

View file

@ -5,7 +5,7 @@
#include "dat.h"
enum {
Buffersize = 64*1024,
Buffersize = 64*1024
};
typedef struct Inbuf Inbuf;
@ -23,7 +23,7 @@ addtomessage(Message *m, uchar *p, int n, int done)
{
int i, len;
// add to message (+ 1 in malloc is for a trailing null)
/* add to message (+ 1 in malloc is for a trailing null) */
if(m->lim - m->end < n){
if(m->start != nil){
i = m->end-m->start;
@ -48,9 +48,9 @@ addtomessage(Message *m, uchar *p, int n, int done)
m->end += n;
}
//
// read in a single message
//
/* */
/* read in a single message */
/* */
static int
readmessage(Message *m, Inbuf *inb)
{
@ -83,9 +83,9 @@ readmessage(Message *m, Inbuf *inb)
inb->wptr += i;
}
// look for end of message
/* look for end of message */
for(p = inb->rptr; p < inb->wptr; p = np+1){
// first part of search for '\nFrom '
/* first part of search for '\nFrom ' */
np = memchr(p, '\n', inb->wptr - p);
if(np == nil){
p = inb->wptr;
@ -109,24 +109,24 @@ readmessage(Message *m, Inbuf *inb)
}
}
// add to message (+ 1 in malloc is for a trailing null)
/* add to message (+ 1 in malloc is for a trailing null) */
n = p - inb->rptr;
addtomessage(m, inb->rptr, n, done);
inb->rptr += n;
}
// if it doesn't start with a 'From ', this ain't a mailbox
/* if it doesn't start with a 'From ', this ain't a mailbox */
if(strncmp(m->start, "From ", 5) != 0)
return -1;
// dump trailing newline, make sure there's a trailing null
// (helps in body searches)
/* dump trailing newline, make sure there's a trailing null */
/* (helps in body searches) */
if(*(m->end-1) == '\n')
m->end--;
*m->end = 0;
m->bend = m->rbend = m->end;
// digest message
/* digest message */
sha1((uchar*)m->start, m->end - m->start, m->digest, nil);
for(i = 0; i < SHA1dlen; i++)
sprint(sdigest+2*i, "%2.2ux", m->digest[i]);
@ -136,14 +136,14 @@ readmessage(Message *m, Inbuf *inb)
}
// throw out deleted messages. return number of freshly deleted messages
/* throw out deleted messages. return number of freshly deleted messages */
int
purgedeleted(Mailbox *mb)
{
Message *m, *next;
int newdels;
// forget about what's no longer in the mailbox
/* forget about what's no longer in the mailbox */
newdels = 0;
for(m = mb->root->part; m != nil; m = next){
next = m->next;
@ -156,9 +156,9 @@ purgedeleted(Mailbox *mb)
return newdels;
}
//
// read in the mailbox and parse into messages.
//
/* */
/* read in the mailbox and parse into messages. */
/* */
static char*
_readmbox(Mailbox *mb, int doplumb, Mlock *lk)
{
@ -223,7 +223,7 @@ retry:
inb->rptr = inb->wptr = inb->data;
inb->fd = fd;
// read new messages
/* read new messages */
snprint(err, sizeof err, "reading '%s'", mb->path);
logmsg(err, nil);
for(;;){
@ -238,10 +238,10 @@ retry:
break;
}
// merge mailbox versions
/* merge mailbox versions */
while(*l != nil){
if(memcmp((*l)->digest, m->digest, SHA1dlen) == 0){
// matches mail we already read, discard
/* matches mail we already read, discard */
logmsg("duplicate", *l);
delmessage(mb, m);
mb->root->subname--;
@ -249,7 +249,7 @@ retry:
l = &(*l)->next;
break;
} else {
// old mail no longer in box, mark deleted
/* old mail no longer in box, mark deleted */
logmsg("disappeared", *l);
if(doplumb)
mailplumb(mb, *l, 1);
@ -280,7 +280,7 @@ retry:
}
logmsg("mbox read", nil);
// whatever is left has been removed from the mbox, mark deleted
/* whatever is left has been removed from the mbox, mark deleted */
while(*l != nil){
if(doplumb)
mailplumb(mb, *l, 1);
@ -380,9 +380,9 @@ plan9syncmbox(Mailbox *mb, int doplumb)
return rv;
}
//
// look to see if we can open this mail box
//
/* */
/* look to see if we can open this mail box */
/* */
char*
plan9mbox(Mailbox *mb, char *path)
{

View file

@ -11,7 +11,7 @@
typedef struct Pop Pop;
struct Pop {
char *freep; // free this to free the strings below
char *freep; /* free this to free the strings below */
char *host;
char *user;
@ -26,11 +26,11 @@ struct Pop {
int notls;
int needssl;
// open network connection
/* open network connection */
Biobuf bin;
Biobuf bout;
int fd;
char *lastline; // from Brdstr
char *lastline; /* from Brdstr */
Thumbprint *thumb;
};
@ -45,11 +45,11 @@ geterrstr(void)
return err;
}
//
// get pop3 response line , without worrying
// about multiline responses; the clients
// will deal with that.
//
/* */
/* get pop3 response line , without worrying */
/* about multiline responses; the clients */
/* will deal with that. */
/* */
static int
isokay(char *s)
{
@ -124,7 +124,7 @@ pop3pushtls(Pop *pop)
TLSconn conn;
memset(&conn, 0, sizeof conn);
// conn.trace = pop3log;
/* conn.trace = pop3log; */
fd = tlsClient(pop->fd, &conn);
if(fd < 0)
return "tls error";
@ -149,9 +149,9 @@ pop3pushtls(Pop *pop)
return nil;
}
//
// get capability list, possibly start tls
//
/* */
/* get capability list, possibly start tls */
/* */
static char*
pop3capa(Pop *pop)
{
@ -183,9 +183,9 @@ pop3capa(Pop *pop)
return nil;
}
//
// log in using APOP if possible, password if allowed by user
//
/* */
/* log in using APOP if possible, password if allowed by user */
/* */
static char*
pop3login(Pop *pop)
{
@ -204,7 +204,7 @@ pop3login(Pop *pop)
else
ubuf[0] = '\0';
// look for apop banner
/* look for apop banner */
if(pop->ppop==0 && (p = strchr(s, '<')) && (q = strchr(p+1, '>'))) {
*++q = '\0';
if((n=auth_respond(p, q-p, user, sizeof user, buf, sizeof buf, auth_getkey, "proto=apop role=client server=%q%s",
@ -250,9 +250,9 @@ pop3login(Pop *pop)
}
}
//
// dial and handshake with pop server
//
/* */
/* dial and handshake with pop server */
/* */
static char*
pop3dial(Pop *pop)
{
@ -277,9 +277,9 @@ pop3dial(Pop *pop)
return nil;
}
//
// close connection
//
/* */
/* close connection */
/* */
static void
pop3hangup(Pop *pop)
{
@ -288,9 +288,9 @@ pop3hangup(Pop *pop)
close(pop->fd);
}
//
// download a single message
//
/* */
/* download a single message */
/* */
static char*
pop3download(Pop *pop, Message *m)
{
@ -361,13 +361,13 @@ pop3download(Pop *pop, Message *m)
m->end = wp;
// make sure there's a trailing null
// (helps in body searches)
/* make sure there's a trailing null */
/* (helps in body searches) */
*m->end = 0;
m->bend = m->rbend = m->end;
m->header = m->start;
// digest message
/* digest message */
sha1((uchar*)m->start, m->end - m->start, m->digest, nil);
for(i = 0; i < SHA1dlen; i++)
sprint(sdigest+2*i, "%2.2ux", m->digest[i]);
@ -376,12 +376,12 @@ pop3download(Pop *pop, Message *m)
return nil;
}
//
// check for new messages on pop server
// UIDL is not required by RFC 1939, but
// netscape requires it, so almost every server supports it.
// we'll use it to make our lives easier.
//
/* */
/* check for new messages on pop server */
/* UIDL is not required by RFC 1939, but */
/* netscape requires it, so almost every server supports it. */
/* we'll use it to make our lives easier. */
/* */
static char*
pop3read(Pop *pop, Mailbox *mb, int doplumb)
{
@ -389,12 +389,12 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
int mesgno, ignore, nnew;
Message *m, *next, **l;
// Some POP servers disallow UIDL if the maildrop is empty.
/* Some POP servers disallow UIDL if the maildrop is empty. */
pop3cmd(pop, "STAT");
if(!isokay(s = pop3resp(pop)))
return s;
// fetch message listing; note messages to grab
/* fetch message listing; note messages to grab */
l = &mb->root->part;
if(strncmp(s, "+OK 0 ", 6) != 0) {
pop3cmd(pop, "UIDL");
@ -411,19 +411,19 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
mesgno = atoi(f[0]);
uidl = f[1];
if(strlen(uidl) > 75) // RFC 1939 says 70 characters max
if(strlen(uidl) > 75) /* RFC 1939 says 70 characters max */
continue;
ignore = 0;
while(*l != nil) {
if(strcmp((*l)->uidl, uidl) == 0) {
// matches mail we already have, note mesgno for deletion
/* matches mail we already have, note mesgno for deletion */
(*l)->mesgno = mesgno;
ignore = 1;
l = &(*l)->next;
break;
} else {
// old mail no longer in box mark deleted
/* old mail no longer in box mark deleted */
if(doplumb)
mailplumb(mb, *l, 1);
(*l)->inmbox = 0;
@ -440,13 +440,13 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
m->mesgno = mesgno;
strcpy(m->uidl, uidl);
// chain in; will fill in message later
/* chain in; will fill in message later */
*l = m;
l = &m->next;
}
}
// whatever is left has been removed from the mbox, mark as deleted
/* whatever is left has been removed from the mbox, mark as deleted */
while(*l != nil) {
if(doplumb)
mailplumb(mb, *l, 1);
@ -455,7 +455,7 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
l = &(*l)->next;
}
// download new messages
/* download new messages */
nnew = 0;
if(pop->pipeline){
switch(rfork(RFPROC|RFMEM)){
@ -485,7 +485,7 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
continue;
if(s = pop3download(pop, m)) {
// message disappeared? unchain
/* message disappeared? unchain */
fprint(2, "download %d: %s\n", m->mesgno, s);
delmessage(mb, m);
mb->root->subname--;
@ -509,9 +509,9 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb)
return nil;
}
//
// delete marked messages
//
/* */
/* delete marked messages */
/* */
static void
pop3purge(Pop *pop, Mailbox *mb)
{
@ -554,7 +554,7 @@ pop3purge(Pop *pop, Mailbox *mb)
}
// connect to pop3 server, sync mailbox
/* connect to pop3 server, sync mailbox */
static char*
pop3sync(Mailbox *mb, int doplumb)
{
@ -625,7 +625,7 @@ pop3ctl(Mailbox *mb, int argc, char **argv)
return Epop3ctl;
}
// free extra memory associated with mb
/* free extra memory associated with mb */
static void
pop3close(Mailbox *mb)
{
@ -636,9 +636,9 @@ pop3close(Mailbox *mb)
free(pop);
}
//
// open mailboxes of the form /pop/host/user or /apop/host/user
//
/* */
/* open mailboxes of the form /pop/host/user or /apop/host/user */
/* */
char*
pop3mbox(Mailbox *mb, char *path)
{

View file

@ -53,12 +53,12 @@ enum {
Hcontent,
Hx,
Hprecedence,
Nhdr,
Nhdr
};
enum {
PGPsign = 1,
PGPencrypt = 2,
PGPencrypt = 2
};
char *hdrs[Nhdr] = {
@ -76,7 +76,7 @@ char *hdrs[Nhdr] = {
[Hmime] "mime-",
[Hcontent] "content-",
[Hx] "x-",
[Hprecedence] "precedence",
[Hprecedence] "precedence"
};
struct Ctype {
@ -92,7 +92,7 @@ Ctype ctype[] = {
{ "text/tab-separated-values", "tsv", 1, },
{ "text/richtext", "rtx", 1, },
{ "message/rfc822", "txt", 1, },
{ "", 0, 0, },
{ "", 0, 0, }
};
Ctype *mimetypes;
@ -153,7 +153,7 @@ enum
Ok = 0,
Nomessage = 1,
Nobody = 2,
Error = -1,
Error = -1
};
#pragma varargck type "Z" char*
@ -244,27 +244,27 @@ threadmain(int argc, char **argv)
subject = EARGF(usage());
break;
case 'F':
Fflag = 1; // file message
Fflag = 1; /* file message */
break;
case 'r':
rflag = 1; // for sendmail
rflag = 1; /* for sendmail */
break;
case 'd':
dflag = 1; // for sendmail
dflag = 1; /* for sendmail */
break;
case '#':
lbflag = 1; // for sendmail
lbflag = 1; /* for sendmail */
break;
case 'x':
xflag = 1; // for sendmail
xflag = 1; /* for sendmail */
break;
case 'n': // no standard input
case 'n': /* no standard input */
nflag = 1;
break;
case '8': // read recipients from rfc822 header
case '8': /* read recipients from rfc822 header */
eightflag = 1;
break;
case 'p': // pgp flag: encrypt, sign, or both
case 'p': /* pgp flag: encrypt, sign, or both */
if(pgpopts(EARGF(usage())) < 0)
sysfatal("bad pgp options");
break;
@ -302,8 +302,8 @@ threadmain(int argc, char **argv)
flags = 0;
headersrv = Nomessage;
if(!nflag && !xflag && !lbflag &&!dflag) {
// pass through headers, keeping track of which we've seen,
// perhaps building to list.
/* pass through headers, keeping track of which we've seen, */
/* perhaps building to list. */
holding = holdon();
headersrv = readheaders(&in, &flags, &hdrstring, eightflag ? &to : nil, 1);
if(rfc822syntaxerror){
@ -316,10 +316,10 @@ threadmain(int argc, char **argv)
}
switch(headersrv){
case Error: // error
case Error: /* error */
fatal("reading");
break;
case Nomessage: // no message, just exit mimicking old behavior
case Nomessage: /* no message, just exit mimicking old behavior */
noinput = 1;
if(first == nil)
threadexitsall(0);
@ -344,13 +344,13 @@ threadmain(int argc, char **argv)
s_free(hdrstring);
hdrstring = nil;
// read user's standard headers
/* read user's standard headers */
file = s_new();
mboxpath("headers", user, file, 0);
b = Bopen(s_to_c(file), OREAD);
if(b != nil){
switch(readheaders(b, &flags, &hdrstring, nil, 0)){
case Error: // error
case Error: /* error */
fatal("reading");
}
Bterm(b);
@ -361,7 +361,7 @@ threadmain(int argc, char **argv)
}
}
// add any headers we need
/* add any headers we need */
if((flags & (1<<Hdate)) == 0)
if(printdate(&out) < 0)
fatal("writing");
@ -381,7 +381,7 @@ threadmain(int argc, char **argv)
printinreplyto(&out, replymsg); /* ignore errors */
Bprint(&out, "MIME-Version: 1.0\n");
if(pgpflag){ // interpose pgp process between us and sendmail to handle body
if(pgpflag){ /* interpose pgp process between us and sendmail to handle body */
Bflush(&out);
Bterm(&out);
fd = pgpfilter(&pgppid, fd, pgpflag);
@ -389,7 +389,7 @@ threadmain(int argc, char **argv)
fatal("can't Binit 1: %r");
}
// if attachments, stick in multipart headers
/* if attachments, stick in multipart headers */
boundary = nil;
if(first != nil){
boundary = mkboundary();
@ -427,7 +427,7 @@ threadmain(int argc, char **argv)
threadexitsall(waitforsubprocs());
}
// evaluate pgp option string
/* evaluate pgp option string */
int
pgpopts(char *s)
{
@ -448,9 +448,9 @@ pgpopts(char *s)
return 0;
}
// read headers from stdin into a String, expanding local aliases,
// keep track of which headers are there, which addresses we have
// remove Bcc: line.
/* read headers from stdin into a String, expanding local aliases, */
/* keep track of which headers are there, which addresses we have */
/* remove Bcc: line. */
int
readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
{
@ -469,7 +469,7 @@ readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
seen = 1;
p[Blinelen(in)-1] = 0;
// coalesce multiline headers
/* coalesce multiline headers */
if((*p == ' ' || *p == '\t') && sline){
s_append(sline, "\n");
s_append(sline, p);
@ -478,7 +478,7 @@ readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
}
}
// process the current header, it's all been read
/* process the current header, it's all been read */
if(sline) {
assert(hdrtype != -1);
if(top){
@ -504,7 +504,7 @@ readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
if(p == nil)
break;
// if no :, it's not a header, seek back and break
/* if no :, it's not a header, seek back and break */
if(strchr(p, ':') == nil){
p[Blinelen(in)-1] = '\n';
Bseek(in, -Blinelen(in), 1);
@ -513,12 +513,12 @@ readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
sline = s_copy(p);
// classify the header. If we don't recognize it, break. This is
// to take care of user's that start messages with lines that contain
// ':'s but that aren't headers. This is a bit hokey. Since I decided
// to let users type headers, I need some way to distinguish. Therefore,
// marshal tries to know all likely headers and will indeed screw up if
// the user types an unlikely one. -- presotto
/* classify the header. If we don't recognize it, break. This is */
/* to take care of user's that start messages with lines that contain */
/* ':'s but that aren't headers. This is a bit hokey. Since I decided */
/* to let users type headers, I need some way to distinguish. Therefore, */
/* marshal tries to know all likely headers and will indeed screw up if */
/* the user types an unlikely one. -- presotto */
hdrtype = -1;
for(i = 0; i < nelem(hdrs); i++){
if(cistrncmp(hdrs[i], p, strlen(hdrs[i])) == 0){
@ -553,7 +553,7 @@ readheaders(Biobuf *in, int *fp, String **sp, Addr **top, int strict)
return Ok;
}
// pass the body to sendmail, make sure body starts and ends with a newline
/* pass the body to sendmail, make sure body starts and ends with a newline */
void
body(Biobuf *in, Biobuf *out, int docontenttype)
{
@ -564,7 +564,7 @@ body(Biobuf *in, Biobuf *out, int docontenttype)
len = 16*1024;
buf = emalloc(len);
// first char must be newline
/* first char must be newline */
i = Bgetc(in);
if(i > 0){
if(i != '\n')
@ -574,7 +574,7 @@ body(Biobuf *in, Biobuf *out, int docontenttype)
buf[n++] = '\n';
}
// read into memory
/* read into memory */
if(docontenttype){
while(docontenttype){
if(n == len){
@ -604,7 +604,7 @@ body(Biobuf *in, Biobuf *out, int docontenttype)
}
}
// write what we already read
/* write what we already read */
if(Bwrite(out, buf, n) < 0)
fatal("output error");
if(n > 0)
@ -613,7 +613,7 @@ body(Biobuf *in, Biobuf *out, int docontenttype)
lastchar = '\n';
// pass the rest
/* pass the rest */
for(;;){
n = Bread(in, buf, len);
if(n < 0)
@ -626,15 +626,15 @@ body(Biobuf *in, Biobuf *out, int docontenttype)
}
}
// pass the body to sendmail encoding with base64
//
// the size of buf is very important to enc64. Anything other than
// a multiple of 3 will cause enc64 to output a termination sequence.
// To ensure that a full buf corresponds to a multiple of complete lines,
// we make buf a multiple of 3*18 since that's how many enc64 sticks on
// a single line. This avoids short lines in the output which is pleasing
// but not necessary.
//
/* pass the body to sendmail encoding with base64 */
/* */
/* the size of buf is very important to enc64. Anything other than */
/* a multiple of 3 will cause enc64 to output a termination sequence. */
/* To ensure that a full buf corresponds to a multiple of complete lines, */
/* we make buf a multiple of 3*18 since that's how many enc64 sticks on */
/* a single line. This avoids short lines in the output which is pleasing */
/* but not necessary. */
/* */
void
body64(Biobuf *in, Biobuf *out)
{
@ -656,7 +656,7 @@ body64(Biobuf *in, Biobuf *out)
lastchar = '\n';
}
// pass message to sendmail, make sure body starts with a newline
/* pass message to sendmail, make sure body starts with a newline */
void
copy(Biobuf *in, Biobuf *out)
{
@ -682,7 +682,7 @@ attachment(Attach *a, Biobuf *out)
f = emalloc(sizeof *f);
Binit(f, a->fd, OREAD);
// if it's already mime encoded, just copy
/* if it's already mime encoded, just copy */
if(strcmp(a->type, "mime") == 0){
copy(f, out);
Bterm(f);
@ -690,7 +690,7 @@ attachment(Attach *a, Biobuf *out)
return;
}
// if it's not already mime encoded ...
/* if it's not already mime encoded ... */
if(strcmp(a->type, "text/plain") != 0)
Bprint(out, "Content-Type: %s\n", a->type);
@ -859,12 +859,12 @@ mkattach(char *file, char *type, int inline)
return a;
}
// pick a type depending on extension
/* pick a type depending on extension */
p = strchr(file, '.');
if(p != nil)
p++;
// check the builtin extensions
/* check the builtin extensions */
if(p != nil){
for(c = ctype; c->ext != nil; c++)
if(strcmp(p, c->ext) == 0){
@ -874,7 +874,7 @@ mkattach(char *file, char *type, int inline)
}
}
// try the mime types file
/* try the mime types file */
if(p != nil){
if(mimetypes == nil)
readmimetypes();
@ -886,8 +886,8 @@ mkattach(char *file, char *type, int inline)
}
}
// run file to figure out the type
a->type = "application/octet-stream"; // safest default
/* run file to figure out the type */
a->type = "application/octet-stream"; /* safest default */
if(pipe(pfd) < 0)
return a;
@ -934,7 +934,7 @@ mkboundary(void)
return estrdup(buf);
}
// copy types to two fd's
/* copy types to two fd's */
static void
tee(int in, int out1, int out2)
{
@ -962,7 +962,7 @@ teeproc(void *v)
write(a[2], "\n", 1);
}
// print the unix from line
/* print the unix from line */
int
printunixfrom(int fd)
{
@ -987,7 +987,7 @@ char *specialfile[] =
"names"
};
// return 1 if this is a special file
/* return 1 if this is a special file */
static int
special(String *s)
{
@ -1005,7 +1005,7 @@ special(String *s)
return 0;
}
// open the folder using the recipients account name
/* open the folder using the recipients account name */
static int
openfolder(char *rcvr)
{
@ -1019,7 +1019,7 @@ openfolder(char *rcvr)
file = s_new();
mboxpath("f", user, file, 0);
// if $mail/f exists, store there, otherwise in $mail
/* if $mail/f exists, store there, otherwise in $mail */
d = dirstat(s_to_c(file));
if(d == nil || d->qid.type != QTDIR){
scarey = 1;
@ -1056,7 +1056,7 @@ openfolder(char *rcvr)
return fd;
}
// start up sendmail and return an fd to talk to it with
/* start up sendmail and return an fd to talk to it with */
int
sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
{
@ -1127,8 +1127,8 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr)
return sfd;
}
// start up pgp process and return an fd to talk to it with.
// its standard output will be the original fd, which goes to sendmail.
/* start up pgp process and return an fd to talk to it with. */
/* its standard output will be the original fd, which goes to sendmail. */
int
pgpfilter(int *pid, int fd, int pgpflag)
{
@ -1172,7 +1172,7 @@ pgpfilter(int *pid, int fd, int pgpflag)
return pfd[1];
}
// wait for sendmail and pgp to exit; exit here if either failed
/* wait for sendmail and pgp to exit; exit here if either failed */
char*
waitforsubprocs(void)
{
@ -1312,9 +1312,9 @@ freealiases(Alias *a)
}
}
//
// read alias file
//
/* */
/* read alias file */
/* */
Alias*
readaliases(void)
{
@ -1328,7 +1328,7 @@ readaliases(void)
line = s_new();
token = s_new();
// open and get length
/* open and get length */
mboxpath("names", login, file, 0);
sp = s_allocinstack(s_to_c(file));
if(sp == nil)
@ -1336,7 +1336,7 @@ readaliases(void)
l = &first;
// read a line at a time.
/* read a line at a time. */
while(s_rdinstack(sp, s_restart(line))!=nil) {
s_restart(line);
a = emalloc(sizeof(Alias));
@ -1380,10 +1380,10 @@ newaddr(char *name)
return a;
}
//
// expand personal aliases since the names are meaningless in
// other contexts
//
/* */
/* expand personal aliases since the names are meaningless in */
/* other contexts */
/* */
Addr*
_expand(Addr *old, int *changedp)
{
@ -1458,7 +1458,7 @@ expand(int ac, char **av)
first = nil;
// make a list of the starting addresses
/* make a list of the starting addresses */
l = &first;
for(i = 0; i < ac; i++){
*l = newaddr(av[i]);
@ -1467,7 +1467,7 @@ expand(int ac, char **av)
l = &(*l)->next;
}
// recurse till we don't change any more
/* recurse till we don't change any more */
return unique(rexpand(first));
}
@ -1510,21 +1510,21 @@ s_copyn(char *s, int n)
return s_nappend(s_reset(nil), s, n);
}
// fetch the next token from an RFC822 address string
// we assume the header is RFC822-conformant in that
// we recognize escaping anywhere even though it is only
// supposed to be in quoted-strings, domain-literals, and comments.
//
// i'd use yylex or yyparse here, but we need to preserve
// things like comments, which i think it tosses away.
//
// we're not strictly RFC822 compliant. we misparse such nonsense as
//
// To: gre @ (Grace) plan9 . (Emlin) bell-labs.com
//
// make sure there's no whitespace in your addresses and
// you'll be fine.
//
/* fetch the next token from an RFC822 address string */
/* we assume the header is RFC822-conformant in that */
/* we recognize escaping anywhere even though it is only */
/* supposed to be in quoted-strings, domain-literals, and comments. */
/* */
/* i'd use yylex or yyparse here, but we need to preserve */
/* things like comments, which i think it tosses away. */
/* */
/* we're not strictly RFC822 compliant. we misparse such nonsense as */
/* */
/* To: gre @ (Grace) plan9 . (Emlin) bell-labs.com */
/* */
/* make sure there's no whitespace in your addresses and */
/* you'll be fine. */
/* */
enum {
Twhite,
Tcomment,
@ -1533,9 +1533,9 @@ enum {
Tleftangle,
Trightangle,
Terror,
Tend,
Tend
};
//char *ty82[] = {"white", "comment", "words", "comma", "<", ">", "err", "end"};
/*char *ty82[] = {"white", "comment", "words", "comma", "<", ">", "err", "end"}; */
#define ISWHITE(p) ((p)==' ' || (p)=='\t' || (p)=='\n' || (p)=='\r')
int
get822token(String **tok, char *p, char **pp)
@ -1551,7 +1551,7 @@ get822token(String **tok, char *p, char **pp)
*pp = nil;
return Tend;
case ' ': // get whitespace
case ' ': /* get whitespace */
case '\t':
case '\n':
case '\r':
@ -1560,7 +1560,7 @@ get822token(String **tok, char *p, char **pp)
p++;
break;
case '(': // get comment
case '(': /* get comment */
type = Tcomment;
for(p++; *p && *p != ')'; p++)
if(*p == '\\') {
@ -1589,7 +1589,7 @@ get822token(String **tok, char *p, char **pp)
type = Trightangle;
p++;
break;
default: // bunch of letters, perhaps quoted strings tossed in
default: /* bunch of letters, perhaps quoted strings tossed in */
type = Twords;
quoting = 0;
for(; *p && (quoting || (!ISWHITE(*p) && *p != '>' && *p != '<' && *p != ',')); p++) {
@ -1612,8 +1612,8 @@ get822token(String **tok, char *p, char **pp)
return type;
}
// expand local aliases in an RFC822 mail line
// add list of expanded addresses to to.
/* expand local aliases in an RFC822 mail line */
/* add list of expanded addresses to to. */
Addr*
expandline(String **s, Addr *to)
{
@ -1630,14 +1630,14 @@ expandline(String **s, Addr *to)
ns = s_copyn(s_to_c(*s), p-s_to_c(*s));
stok = nil;
nto = nil;
//
// the only valid mailbox namings are word
// and word* < addr >
// without comments this would be simple.
// we keep the following:
// lastword - current guess at the address
// sinceword - whitespace and comment seen since lastword
//
/* */
/* the only valid mailbox namings are word */
/* and word* < addr > */
/* without comments this would be simple. */
/* we keep the following: */
/* lastword - current guess at the address */
/* sinceword - whitespace and comment seen since lastword */
/* */
lastword = s_new();
sinceword = s_new();
inangle = 0;
@ -1710,7 +1710,7 @@ expandline(String **s, Addr *to)
if(!inangle)
nword++;
break;
case Terror: // give up, use old string, addrs
case Terror: /* give up, use old string, addrs */
Error:
ns = os;
os = nil;
@ -1775,7 +1775,7 @@ readmimetypes(void)
mimetypes[inuse].display = !strcmp(type, "text/plain");
inuse++;
// always make sure there's a terminator
/* always make sure there's a terminator */
mimetypes[inuse].ext = 0;
}
Bterm(b);
@ -1810,15 +1810,15 @@ erealloc(void *x, int n)
return x;
}
//
// Formatter for %"
// Use double quotes to protect white space, frogs, \ and "
//
/* */
/* Formatter for %" */
/* Use double quotes to protect white space, frogs, \ and " */
/* */
enum
{
Qok = 0,
Qquote,
Qbackslash,
Qbackslash
};
static int

View file

@ -31,7 +31,7 @@ struct Message {
String *path;
int id;
int len;
int fileno; // number of directory
int fileno; /* number of directory */
String *info;
char *from;
char *to;
@ -136,12 +136,12 @@ struct {
{ "|", 1, pipecmd, "|cmd pipe message body to a command" },
{ "||", 1, rpipecmd, "||cmd pipe raw message to a command" },
{ "!", 1, bangcmd, "!cmd run a command" },
{ nil, 0, nil, nil },
{ nil, 0, nil, nil }
};
enum
{
NARG= 32,
NARG= 32
};
struct Cmd {
@ -305,8 +305,8 @@ threadmain(int argc, char **argv)
s_append(prompt, ": ");
}
// leave space at the end of cmd line in case parsecmd needs to
// add a space after a '|' or '!'
/* leave space at the end of cmd line in case parsecmd needs to */
/* add a space after a '|' or '!' */
if(readline(s_to_c(prompt), cmdline, sizeof(cmdline)-1) == nil)
break;
err = parsecmd(cmdline, &cmd, top.child, cur);
@ -328,10 +328,10 @@ threadmain(int argc, char **argv)
if(cmd.delete){
dcmd(&cmd, x);
// dp acts differently than all other commands
// since its an old lesk idiom that people love.
// it deletes the current message, moves the current
// pointer ahead one and prints.
/* dp acts differently than all other commands */
/* since its an old lesk idiom that people love. */
/* it deletes the current message, moves the current */
/* pointer ahead one and prints. */
if(cmd.f == pcmd){
if(x->next == nil){
Bprint(&out, "!address\n");
@ -378,18 +378,18 @@ mkaddrs(char *t)
for(i=0; i+1<nf; i+=2){
if(i > 0)
fmtprint(&fmt, " ");
// if(f[i][0] == 0 || strcmp(f[i], f[i+1]) == 0)
/* if(f[i][0] == 0 || strcmp(f[i], f[i+1]) == 0) */
fmtprint(&fmt, "%s", f[i+1]);
// else
// fmtprint(&fmt, "%s <%s>", f[i], f[i+1]);
/* else */
/* fmtprint(&fmt, "%s <%s>", f[i], f[i+1]); */
}
free(f);
return fmtstrflush(&fmt);
}
//
// read the message info
//
/* */
/* read the message info */
/* */
Message*
file2message(Message *parent, char *name)
{
@ -462,9 +462,9 @@ freemessage(Message *m)
free(m);
}
//
// read a directory into a list of messages
//
/* */
/* read a directory into a list of messages */
/* */
int
dir2message(Message *parent, int reverse)
{
@ -478,7 +478,7 @@ dir2message(Message *parent, int reverse)
if(fd == nil)
return -1;
// count current entries
/* count current entries */
first = parent->child;
highest = newmsgs = 0;
for(last = parent->child; last != nil && last->next != nil; last = last->next)
@ -495,7 +495,7 @@ dir2message(Message *parent, int reverse)
if(atoi(d[i].name) <= highest)
continue;
m = file2message(parent, d[i].name);
// fprint(2,"returned from file2message\n");
/* fprint(2,"returned from file2message\n"); */
if(m == nil)
break;
newmsgs++;
@ -517,7 +517,7 @@ dir2message(Message *parent, int reverse)
fsclose(fd);
parent->child = first;
// renumber and file longest from
/* renumber and file longest from */
i = 1;
longestfrom = 12;
for(m = first; m != nil; m = m->next){
@ -530,16 +530,16 @@ dir2message(Message *parent, int reverse)
return newmsgs;
}
//
// point directly to a message
//
/* */
/* point directly to a message */
/* */
Message*
dosingleton(Message *parent, char *path)
{
char *p, *np;
Message *m;
// walk down to message and read it
/* walk down to message and read it */
if(strlen(path) < rootlen)
return nil;
if(path[rootlen] != '/')
@ -554,7 +554,7 @@ dosingleton(Message *parent, char *path)
parent->child = m;
m->id = 1;
// walk down to requested component
/* walk down to requested component */
while(np != nil){
*np = '/';
np = strchr(np+1, '/');
@ -569,9 +569,9 @@ dosingleton(Message *parent, char *path)
return m;
}
//
// read a file into a string
//
/* */
/* read a file into a string */
/* */
String*
file2string(String *dir, char *file)
{
@ -605,9 +605,9 @@ file2string(String *dir, char *file)
return s;
}
//
// get the length of a file
//
/* */
/* get the length of a file */
/* */
int
filelen(String *dir, char *file)
{
@ -627,9 +627,9 @@ filelen(String *dir, char *file)
return rv;
}
//
// walk the path name an element
//
/* */
/* walk the path name an element */
/* */
String*
extendpath(String *dir, char *name)
{
@ -720,21 +720,21 @@ cracktime(char *d, char *out, int len)
in[sizeof(in)-1] = 0;
n = getfields(in, f, 6, 1, " \t\r\n");
if(n != 6){
// unknown style
/* unknown style */
snprint(out, 16, "%10.10s", d);
return;
}
now = time(0);
memset(&tm, 0, sizeof tm);
if(strchr(f[0], ',') != nil && strchr(f[4], ':') != nil){
// 822 style
/* 822 style */
tm.year = atoi(f[3])-1900;
tm.mon = month(f[2]);
tm.mday = atoi(f[1]);
dtime = nosecs(f[4]);
then = tm2sec(&tm);
} else if(strchr(f[3], ':') != nil){
// unix style
/* unix style */
tm.year = atoi(f[5])-1900;
tm.mon = month(f[1]);
tm.mday = atoi(f[2]);
@ -826,12 +826,12 @@ snprintheader(char *buf, int len, Message *m)
String *id;
char *p, *q;;
// create id
/* create id */
id = s_new();
mkid(id, m);
if(*m->from == 0){
// no from
/* no from */
snprint(buf, len, "%-3s %s %6d %s",
s_to_c(id),
m->type,
@ -877,7 +877,7 @@ snprintHeader(char *buf, int len, int indent, Message *m)
char typeid[64];
char *p, *e;
// create id
/* create id */
id = s_new();
mkid(id, m);
@ -900,17 +900,17 @@ snprintHeader(char *buf, int len, int indent, Message *m)
char sstring[256];
// cmd := range cmd ' ' arg-list ;
// range := address
// | address ',' address
// | 'g' search ;
// address := msgno
// | search ;
// msgno := number
// | number '/' msgno ;
// search := '/' string '/'
// | '%' string '%' ;
//
/* cmd := range cmd ' ' arg-list ; */
/* range := address */
/* | address ',' address */
/* | 'g' search ; */
/* address := msgno */
/* | search ; */
/* msgno := number */
/* | number '/' msgno ; */
/* search := '/' string '/' */
/* | '%' string '%' ; */
/* */
Reprog*
parsesearch(char **pp)
{
@ -1067,9 +1067,9 @@ parseaddr(char **pp, Message *first, Message *cur, Message *unspec, Message **mp
return nil;
}
//
// search a message for a regular expression match
//
/* */
/* search a message for a regular expression match */
/* */
int
rawsearch(Message *m, Reprog *prog)
{
@ -1083,8 +1083,8 @@ rawsearch(Message *m, Reprog *prog)
if(fd == nil)
return 0;
// march through raw message 4096 bytes at a time
// with a 128 byte overlap to chain the re search.
/* march through raw message 4096 bytes at a time */
/* with a 128 byte overlap to chain the re search. */
rv = 0;
for(;;){
i = fsread(fd, buf, sizeof(buf)-1);
@ -1122,17 +1122,17 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
l = &cmd->msgs;
*l = nil;
// eat white space
/* eat white space */
while(*p == ' ')
p++;
// null command is a special case (advance and print)
/* null command is a special case (advance and print) */
if(*p == 0){
if(cur == &top){
// special case
/* special case */
m = first;
} else {
// walk to the next message even if we have to go up
/* walk to the next message even if we have to go up */
m = cur->next;
while(m == nil && cur->parent != nil){
cur = cur->parent;
@ -1148,11 +1148,11 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
return nil;
}
// global search ?
/* global search ? */
if(*p == 'g'){
p++;
// no search string means all messages
/* no search string means all messages */
if(*p != '/' && *p != '%'){
for(m = first; m != nil; m = m->next){
*l = m;
@ -1160,7 +1160,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
*l = nil;
}
} else {
// mark all messages matching this search string
/* mark all messages matching this search string */
c = *p;
prog = parsesearch(&p);
if(prog == nil)
@ -1187,13 +1187,13 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
}
} else {
// parse an address
/* parse an address */
s = e = nil;
err = parseaddr(&p, first, cur, cur, &s);
if(err != nil)
return err;
if(*p == ','){
// this is an address range
/* this is an address range */
if(s == &top)
s = first;
p++;
@ -1203,7 +1203,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
if(err != nil)
return err;
// select all messages in the range
/* select all messages in the range */
for(; s != nil; s = s->next){
*l = s;
l = &s->cmd;
@ -1214,7 +1214,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
if(s == nil)
return "null address range";
} else {
// single address
/* single address */
if(s != &top){
*l = s;
s->cmd = nil;
@ -1222,7 +1222,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
}
}
// insert a space after '!'s and '|'s
/* insert a space after '!'s and '|'s */
for(q = p; *q; q++)
if(*q != '!' && *q != '|')
break;
@ -1235,13 +1235,13 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
if(cmd->an == 0 || *cmd->av[0] == 0)
cmd->f = pcmd;
else {
// hack to allow all messages to start with 'd'
/* hack to allow all messages to start with 'd' */
if(*(cmd->av[0]) == 'd' && *(cmd->av[0]+1) != 0){
cmd->delete = 1;
cmd->av[0]++;
}
// search command table
/* search command table */
for(i = 0; cmdtab[i].cmd != nil; i++)
if(strcmp(cmd->av[0], cmdtab[i].cmd) == 0)
break;
@ -1256,7 +1256,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur)
return nil;
}
// inefficient read from standard input
/* inefficient read from standard input */
char*
readline(char *prompt, char *line, int len)
{
@ -1471,7 +1471,7 @@ pcmd(Cmd *x, Message *m)
} else if(strncmp(m->type, "multipart/", 10) == 0){
nm = m->child;
if(nm != nil){
// always print first part
/* always print first part */
pcmd(nil, nm);
for(nm = nm->next; nm != nil; nm = nm->next){
@ -1582,7 +1582,7 @@ quotecmd(Cmd *x, Message *m)
return m;
}
// really delete messages
/* really delete messages */
Message*
flushdeleted(Message *cur)
{
@ -1611,7 +1611,7 @@ flushdeleted(Message *cur)
continue;
}
// don't return a pointer to a deleted message
/* don't return a pointer to a deleted message */
if(m == cur)
cur = m->next;
@ -1629,7 +1629,7 @@ flushdeleted(Message *cur)
p = seprint(p, e, " %s", msg);
n++;
// unchain and free
/* unchain and free */
*l = m->next;
if(m->next)
m->next->prev = m->prev;
@ -1643,13 +1643,13 @@ flushdeleted(Message *cur)
if(deld)
Bprint(&out, "!%d message%s deleted\n", deld, plural(deld));
// renumber
/* renumber */
i = 1;
for(m = top.child; m != nil; m = m->next)
m->id = natural ? m->fileno : i++;
// if we're out of messages, go back to first
// if no first, return the fake first
/* if we're out of messages, go back to first */
/* if no first, return the fake first */
if(cur == nil){
if(top.child)
return top.child;
@ -1672,7 +1672,7 @@ qcmd(Cmd *x, Message *m)
Bflush(&out);
exitfs(0);
return nil; // not reached
return nil; /* not reached */
}
Message*
@ -1692,7 +1692,7 @@ xcmd(Cmd *x, Message *m)
USED(m);
exitfs(0);
return nil; // not reached
return nil; /* not reached */
}
Message*
@ -1776,7 +1776,7 @@ tomailer(char **av)
if(marshal == nil)
marshal = unsharp("#9/bin/upas/marshal");
// start the mailer and get out of the way
/* start the mailer and get out of the way */
switch(pid = fork()){
case -1:
fprint(2, "can't fork: %r\n");
@ -1816,9 +1816,9 @@ tomailer(char **av)
return 0;
}
//
// like tokenize but obey "" quoting
//
/* */
/* like tokenize but obey "" quoting */
/* */
int
tokenize822(char *str, char **args, int max)
{
@ -2077,7 +2077,7 @@ appendtofile(Message *m, char *part, char *base, int mbox)
if(mbox)
seek(out, 0, 2);
// put on a 'From ' line
/* put on a 'From ' line */
if(mbox){
while(m->parent != &top)
m = m->parent;
@ -2086,7 +2086,7 @@ appendtofile(Message *m, char *part, char *base, int mbox)
s_free(h);
}
// copy the message escaping what we have to ad adding newlines if we have to
/* copy the message escaping what we have to ad adding newlines if we have to */
if(mbox)
rv = appendfiletombox(in, out);
else
@ -2192,7 +2192,7 @@ char *specialfile[] =
"names"
};
// return 1 if this is a special file
/* return 1 if this is a special file */
static int
special(String *s)
{
@ -2210,7 +2210,7 @@ special(String *s)
return 0;
}
// open the folder using the recipients account name
/* open the folder using the recipients account name */
static String*
foldername(char *rcvr)
{
@ -2224,7 +2224,7 @@ foldername(char *rcvr)
mboxpath("f", user, file, 0);
d = dirstat(s_to_c(file));
// if $mail/f exists, store there, otherwise in $mail
/* if $mail/f exists, store there, otherwise in $mail */
s_restart(file);
if(d && d->qid.type == QTDIR){
scarey = 0;
@ -2363,7 +2363,7 @@ xpipecmd(Cmd *c, Message *m, char *part)
fd = fsopenfd(mailfs, s_to_c(path), OREAD);
s_free(path);
if(fd < 0){ // compatibility with older upas/fs
if(fd < 0){ /* compatibility with older upas/fs */
path = extendpath(m->path, "raw");
fd = fsopenfd(mailfs, s_to_c(path), OREAD);
s_free(path);
@ -2408,7 +2408,7 @@ closemb(void)
if(fd == nil)
sysfatal("can't open ctl: %r");
// close current mailbox
/* close current mailbox */
if(*mbname && strcmp(mbname, "mbox") != 0)
fsprint(fd, "close %s", mbname);
@ -2423,16 +2423,16 @@ switchmb(char *file, char *singleton)
String *path;
char buf[256];
// if the user didn't say anything and there
// is an mbox mounted already, use that one
// so that the upas/fs -fdefault default is honored.
/* if the user didn't say anything and there */
/* is an mbox mounted already, use that one */
/* so that the upas/fs -fdefault default is honored. */
if(0 && (file || (singleton && fsaccess(mailfs, singleton, 0) < 0))){
/* XXX all wrong */
fprint(2, "file=%s singleton=%s\n", file, singleton);
if(file == nil)
file = "mbox";
// close current mailbox
/* close current mailbox */
closemb();
didopen = 1;
@ -2442,10 +2442,10 @@ switchmb(char *file, char *singleton)
path = s_new();
// get an absolute path to the mail box
/* get an absolute path to the mail box */
if(strncmp(file, "./", 2) == 0){
// resolve path here since upas/fs doesn't know
// our working directory
/* resolve path here since upas/fs doesn't know */
/* our working directory */
if(getwd(buf, sizeof(buf)-strlen(file)) == nil){
fprint(2, "!can't get working directory: %s\n", buf);
return -1;
@ -2456,14 +2456,14 @@ switchmb(char *file, char *singleton)
mboxpath(file, user, path, 0);
}
// make up a handle to use when talking to fs
/* make up a handle to use when talking to fs */
p = strrchr(file, '/');
if(p == nil){
// if its in the mailbox directory, just use the name
/* if its in the mailbox directory, just use the name */
strncpy(mbname, file, sizeof(mbname));
mbname[sizeof(mbname)-1] = 0;
} else {
// make up a mailbox name
/* make up a mailbox name */
p = strrchr(s_to_c(path), '/');
p++;
if(*p == 0){
@ -2513,7 +2513,7 @@ switchmb(char *file, char *singleton)
return 0;
}
// like tokenize but for into lines
/* like tokenize but for into lines */
int
lineize(char *s, char **f, int n)
{

View file

@ -27,7 +27,7 @@ enum
NoEncoding,
QuotedPrintable,
QuotedPrintableU,
Base64,
Base64
};
char* decode(int, char*, int*);

View file

@ -6,7 +6,7 @@ enum
BoxChunk = 64,
MsgChunk = 256,
PartChunk = 4,
PartSubChunk = 4,
PartSubChunk = 4
};
Box **boxes;

View file

@ -11,7 +11,7 @@ enum
FlagMarked = 1<<8,
FlagNoSelect = 1<<9,
FlagUnMarked = 1<<10,
FlagRecent = 1<<11,
FlagRecent = 1<<11
};
typedef struct Box Box;

View file

@ -105,7 +105,7 @@ struct {
"big5", "big5",
"iso-2022-jp", "jis-kanji",
"windows-1251", "cp1251",
"koi8-r", "koi8",
"koi8-r", "koi8"
};
char*

View file

@ -77,7 +77,7 @@ enum
Qunixheader,
Qfile0 = Qbody,
Qnfile = Qunixheader+1-Qfile0,
Qnfile = Qunixheader+1-Qfile0
};
static char Egreg[] = "gone postal";
@ -189,7 +189,7 @@ static struct {
Qidstr, "idstr",
Qdesc, "desc",
Qencoding, "encoding",
Qcharset, "charset",
Qcharset, "charset"
};
char*
@ -334,9 +334,9 @@ static struct {
FlagNonJunk, "notjunk",
FlagReplied, "replied",
FlagFlagged, "flagged",
// FlagDeleted, "deleted",
/* FlagDeleted, "deleted", */
FlagDraft, "draft",
FlagSeen, "seen",
FlagSeen, "seen"
};
static void
@ -604,9 +604,9 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre
fmtprint(&fmt, "type %s\n", part->type);
if(part->lines)
fmtprint(&fmt, "lines %d\n", part->lines);
// fmtprint(&fmt, "disposition %s\n", "" /* disposition */);
// fmtprint(&fmt, "filename %s\n", "" /* filename */);
// fmtprint(&fmt, "digest %s\n", "" /* digest */);
/* fmtprint(&fmt, "disposition %s\n", "" /* disposition */); */
/* fmtprint(&fmt, "filename %s\n", "" /* filename */); */
/* fmtprint(&fmt, "digest %s\n", "" /* digest */); */
s = fmtstrflush(&fmt);
if(s == nil)
s = estrdup("");
@ -794,13 +794,13 @@ static int mimemsgdir[] = {
Qbody, Qbcc, Qcc, Qdate, Qfrom, Qheader, Qinfo,
Qinreplyto, Qlines, Qmimeheader, Qmessageid,
Qraw, Qrawunix, Qrawbody, Qrawheader,
Qreplyto, Qsender, Qsubject, Qto,
Qreplyto, Qsender, Qsubject, Qto
};
static int mimedir[] = {
Qtype,
Qbody,
Qmimeheader,
Qraw,
Qraw
};
int
@ -833,11 +833,11 @@ msggen(int i, Dir *d, void *aux)
enum
{
CMhangup,
CMhangup
};
static Cmdtab ctltab[] =
{
CMhangup, "hangup", 2,
CMhangup, "hangup", 2
};
enum
@ -848,7 +848,7 @@ enum
CMread,
CMsave,
CMjunk,
CMnonjunk,
CMnonjunk
};
static Cmdtab boxctltab[] =
{
@ -858,7 +858,7 @@ static Cmdtab boxctltab[] =
CMread, "read", 0,
CMsave, "save", 0,
CMjunk, "junk", 0,
CMnonjunk, "nonjunk", 0,
CMnonjunk, "nonjunk", 0
};
static void
@ -996,7 +996,7 @@ fswrite(Req *r)
}
nm = mkmsglist(box, cb->f+2, cb->nf-2, &m);
if(nm != cb->nf-2){
// free(m);
/* free(m); */
respond(r, Enomsg);
break;
}

View file

@ -50,7 +50,7 @@ static struct {
"\\NoInferiors", FlagNoInferiors,
"\\NoSelect", FlagNoSelect,
"\\Marked", FlagMarked,
"\\UnMarked", FlagUnMarked,
"\\UnMarked", FlagUnMarked
};
int chattyimap;
@ -775,7 +775,7 @@ enum
{
Qok = 0,
Qquote,
Qbackslash,
Qbackslash
};
static int
@ -1172,7 +1172,7 @@ static struct {
1, "EXISTS", "ANA", xexists,
1, "EXPUNGE", "ANA", xexpunge,
1, "FETCH", "ANAL", xfetch,
1, "RECENT", "ANA", xrecent,
1, "RECENT", "ANA", xrecent
};
static void
@ -1333,7 +1333,7 @@ static struct {
"RFC822.SIZE", xmsgrfc822size,
"ENVELOPE", xmsgenvelope,
"BODY", xmsgbody,
"BODY[", xmsgbodydata,
"BODY[", xmsgbodydata
};
static void
@ -1460,7 +1460,7 @@ static struct {
char *name;
int offset;
} paramtab[] = {
"charset", offsetof(Part, charset),
"charset", offsetof(Part, charset)
};
static void
@ -1641,7 +1641,7 @@ struct {
"PERMANENTFLAGS", 'L', xokpermflags,
"UNSEEN", 'N', xokunseen,
"READ-WRITE", 0, xokreadwrite,
"READ-ONLY", 0, xokreadonly,
"READ-ONLY", 0, xokreadonly
};
static void
@ -1695,24 +1695,24 @@ xokuidvalidity(Imap *z, Sx *sx)
static void
xokpermflags(Imap *z, Sx *sx)
{
// z->permflags = parseflags(sx);
/* z->permflags = parseflags(sx); */
}
static void
xokunseen(Imap *z, Sx *sx)
{
// z->unseen = sx->number;
/* z->unseen = sx->number; */
}
static void
xokreadwrite(Imap *z, Sx *sx)
{
// z->boxmode = ORDWR;
/* z->boxmode = ORDWR; */
}
static void
xokreadonly(Imap *z, Sx *sx)
{
// z->boxmode = OREAD;
/* z->boxmode = OREAD; */
}

View file

@ -8,7 +8,7 @@ enum
SxAtom,
SxString,
SxNumber,
SxList,
SxList
};
typedef struct Sx Sx;

View file

@ -54,7 +54,7 @@ Cmd cmdtab[] =
"top", 1, topcmd,
"uidl", 1, uidlcmd,
"user", 0, usercmd,
0, 0, 0,
0, 0, 0
};
static Biobuf in;
@ -729,7 +729,7 @@ enableaddr(void)
fd = create(buf, OREAD, 0666);
if(fd >= 0){
close(fd);
// syslog(0, "pop3", "ratified %s", peeraddr);
/* syslog(0, "pop3", "ratified %s", peeraddr); */
}
}
@ -784,7 +784,7 @@ passcmd(char *arg)
if((chs = auth_challenge("proto=apop role=server")) == nil)
return senderr("couldn't get apop challenge");
// hash challenge with secret and convert to ascii
/* hash challenge with secret and convert to ascii */
s = md5((uchar*)chs->chal, chs->nchal, 0, 0);
md5((uchar*)arg, strlen(arg), digest, s);
snprint(response, sizeof response, "%.*H", MD5dlen, digest);

View file

@ -7,7 +7,7 @@
enum {
Quanta = 8192,
Minbody = 6000,
HdrMax = 15,
HdrMax = 15
};
typedef struct keyword Keyword;
@ -65,7 +65,7 @@ Keyword keywords[] =
"hold", Hold,
"dump", Dump,
"loff", Lineoff,
0, Nactions,
0, Nactions
};
Patterns patterns[] = {
@ -74,7 +74,7 @@ Patterns patterns[] = {
[Hold] { "HOLD:", 0, 0 },
[SaveLine] { "LINE:", 0, 0 },
[Lineoff] { "LINEOFF:", 0, 0 },
[Nactions] { 0, 0, 0 },
[Nactions] { 0, 0, 0 }
};
static char* endofhdr(char*, char*);
@ -306,7 +306,7 @@ conv64(char *msg, char *end, char *buf, int bufsize)
char *cp;
len = end - msg;
i = (len*3)/4+1; // room for max chars + null
i = (len*3)/4+1; /* room for max chars + null */
cp = Malloc(i);
len = dec64((uchar*)cp, i, msg, len);
convert(cp, cp+len, buf, bufsize, 1);
@ -663,5 +663,5 @@ static uchar t64d[256] = {
/*E0*/ INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL,
INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL,
/*F0*/ INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL,
INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL,
INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL, INVAL
};

View file

@ -15,7 +15,7 @@ enum{
MaxHtml = 256,
Hdrsize = 4096,
Bodysize = 8192,
Maxread = 64*1024,
Maxread = 64*1024
};
typedef struct spat Spat;

View file

@ -171,7 +171,7 @@ static char *fieldname[] =
[MESSAGEID-WORD] "MESSAGEID",
[RECEIVED-WORD] "RECEIVED",
[MAILER-WORD] "MAILER",
[BADTOKEN-WORD] "BADTOKEN",
[BADTOKEN-WORD] "BADTOKEN"
};
#endif

View file

@ -6,7 +6,7 @@
enum
{
Nmx= 16,
Maxstring= 256,
Maxstring= 256
};
typedef struct Mx Mx;

View file

@ -603,7 +603,7 @@ static const short yyexca[] =
31, 72,
32, 72,
35, 72,
-2, 74,
-2, 74
};
#define YYNPROD 122
#define YYPRIVATE 57344

View file

@ -179,7 +179,7 @@ threadmain(int argc, char **argv)
if(*argv == 0)
usage();
addr = *argv++; argc--;
// expand $smtp if necessary
/* expand $smtp if necessary */
addr = expand_addr(addr);
farend = addr;
@ -359,7 +359,7 @@ dotls(char *me)
h = malloc(2*sizeof hash + 1);
if (h != nil) {
enc16(h, 2*sizeof hash + 1, hash, sizeof hash);
// print("x509 sha1=%s", h);
/* print("x509 sha1=%s", h); */
syslog(0, "smtp",
"remote cert. has bad thumbprint: x509 sha1=%s server=%q",
h, ddomain);

View file

@ -8,7 +8,7 @@ enum {
TRUSTED,
NONE,
MAXREJECTS = 100,
MAXREJECTS = 100
};

View file

@ -11,7 +11,7 @@ enum {
OURDOMS,
IP = 0,
STRING,
STRING
};
@ -29,7 +29,7 @@ static Keyword options[] = {
"defaultdomain", DOMNAME,
"ournets", OURNETS,
"ourdomains", OURDOMS,
0, NONE,
0, NONE
};
static Keyword actions[] = {
@ -38,7 +38,7 @@ static Keyword actions[] = {
"deny", DENIED,
"dial", DIALUP,
"delay", DELAY,
0, NONE,
0, NONE
};
static int hisaction;

View file

@ -41,18 +41,18 @@ static void writeheader(Part *p, int);
enum
{
// encodings
/* encodings */
Enone= 0,
Ebase64,
Equoted,
// disposition possibilities
/* disposition possibilities */
Dnone= 0,
Dinline,
Dfile,
Dignore,
PAD64= '=',
PAD64= '='
};
/*
@ -98,7 +98,7 @@ Hdef hdefs[] =
{ "content-type:", ctype, },
{ "content-transfer-encoding:", cencoding, },
{ "content-disposition:", cdisposition, },
{ 0, },
{ 0, }
};
/*
@ -926,7 +926,7 @@ struct Charset {
{
{ "us-ascii", 8, 1, },
{ "utf-8", 5, 0, },
{ "iso-8859-1", 10, 1, },
{ "iso-8859-1", 10, 1, }
};
/*
@ -951,7 +951,7 @@ tokenconvert(String *t)
e = token+len-2;
token += 2;
// bail if we don't understand the character set
/* bail if we don't understand the character set */
for(i = 0; i < nelem(charsets); i++)
if(cistrncmp(charsets[i].name, token, charsets[i].len) == 0)
if(token[charsets[i].len] == '?'){
@ -961,11 +961,11 @@ tokenconvert(String *t)
if(i >= nelem(charsets))
goto err;
// bail if it doesn't fit
/* bail if it doesn't fit */
if(strlen(token) > sizeof(decoded)-1)
goto err;
// bail if we don't understand the encoding
/* bail if we don't understand the encoding */
if(cistrncmp(token, "b?", 2) == 0){
token += 2;
len = dec64((uchar*)decoded, sizeof(decoded), token, e-token);
@ -1002,7 +1002,7 @@ err:
enum
{
Self= 1,
Hex= 2,
Hex= 2
};
uchar tableqp[256];
@ -1084,7 +1084,7 @@ decquoted(char *out, char *in, char *e)
if(in < e)
p = decquotedline(p, in, e-1);
// make sure we end with a new line
/* make sure we end with a new line */
if(*(p-1) != '\n'){
*p++ = '\n';
*p = 0;