diff options
author | Dan Cross <cross@gajendra.net> | 2020-01-10 14:44:21 +0000 |
---|---|---|
committer | Dan Cross <cross@gajendra.net> | 2020-01-10 14:54:30 +0000 |
commit | fa325e9b42b0bdfb48857d1958d9fb7ceac55151 (patch) | |
tree | 81d26256d152435135bcb1ae43121979a49f5f2b /src/cmd/upas | |
parent | 77a0a5b5194d4441c86de097f2aae297cb75e2c2 (diff) | |
download | plan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.tar.gz plan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.tar.bz2 plan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.zip |
Trivial changes: whitespace and modes.
Remote whitespace at the ends of lines.
Remove blank lines from the ends of files.
Change modes on source files so that they
are not executable.
Signed-off-by: Dan Cross <cross@gajendra.net>
Diffstat (limited to 'src/cmd/upas')
54 files changed, 249 insertions, 273 deletions
diff --git a/src/cmd/upas/bayes/addhash.c b/src/cmd/upas/bayes/addhash.c index 6be960ff..3679b318 100644 --- a/src/cmd/upas/bayes/addhash.c +++ b/src/cmd/upas/bayes/addhash.c @@ -57,10 +57,9 @@ main(int argc, char **argv) if(fd < 0) sysfatal("could not open %s: %r\n", out); } - + Binit(&bout, fd, OWRITE); Bwritehash(&bout, &hash); Bterm(&bout); exits(0); } - diff --git a/src/cmd/upas/bayes/dfa.c b/src/cmd/upas/bayes/dfa.c index ce4dc58a..b038343b 100644 --- a/src/cmd/upas/bayes/dfa.c +++ b/src/cmd/upas/bayes/dfa.c @@ -268,7 +268,7 @@ set(Deter *d, u32int **tab, Rune r) } /* - * Compute the list of important characters. + * Compute the list of important characters. * Other characters behave like the ones that surround them. */ static void @@ -672,7 +672,7 @@ main(int argc, char **argv) dp = dregcvt(p); print("=== dfa\n"); dump(dp); - + for(i=2; i<argc; i++) print("match %d\n", dregexec(dp, argv[i], 0)); exits(0); diff --git a/src/cmd/upas/bayes/dfa.h b/src/cmd/upas/bayes/dfa.h index 28c43dbc..429f04e5 100644 --- a/src/cmd/upas/bayes/dfa.h +++ b/src/cmd/upas/bayes/dfa.h @@ -30,4 +30,3 @@ Dreprog* dregcvt(Reprog*); int dregexec(Dreprog*, char*, int); Dreprog* Breaddfa(Biobuf *b); void Bprintdfa(Biobuf*, Dreprog*); - diff --git a/src/cmd/upas/bayes/dump.c b/src/cmd/upas/bayes/dump.c index 404538c1..c753fb2c 100644 --- a/src/cmd/upas/bayes/dump.c +++ b/src/cmd/upas/bayes/dump.c @@ -60,7 +60,7 @@ main(int argc, char **argv) dp = dregcvt(p); print("=== dfa\n"); dump(dp); - + for(i=2; i<argc; i++) print("match %d\n", dregexec(dp, argv[i], 1)); exits(0); diff --git a/src/cmd/upas/bayes/msgclass.c b/src/cmd/upas/bayes/msgclass.c index 999ba50c..2e80202a 100644 --- a/src/cmd/upas/bayes/msgclass.c +++ b/src/cmd/upas/bayes/msgclass.c @@ -293,4 +293,3 @@ lockfile(char *s) close(fd); atexit(killtickle); } - diff --git a/src/cmd/upas/bayes/msgtok.c b/src/cmd/upas/bayes/msgtok.c index 122e0c64..fe147961 100644 --- a/src/cmd/upas/bayes/msgtok.c +++ b/src/cmd/upas/bayes/msgtok.c @@ -1,6 +1,6 @@ /* * RFC822 message tokenizer (really feature generator) for spam filter. - * + * * See Paul Graham's musings on spam filtering for theory. */ @@ -138,7 +138,7 @@ fprint(2, "«%s» %.2ux", p, p[0]); p[i] += 'a' - 'A'; */ if(tag){ - i = strlen(tag); + i = strlen(tag); memmove(buf, tag, i); memmove(buf+i, p, m[1]); buf[i+m[1]] = 0; @@ -242,5 +242,4 @@ trim(char *s) return 0; } return -1; -} - +} diff --git a/src/cmd/upas/bayes/regcomp.c b/src/cmd/upas/bayes/regcomp.c index 8afaf215..96fa2e6e 100644 --- a/src/cmd/upas/bayes/regcomp.c +++ b/src/cmd/upas/bayes/regcomp.c @@ -110,7 +110,7 @@ regerr2(char *s, int c) while(*s) *cp++ = *s++; *cp++ = c; - *cp = '\0'; + *cp = '\0'; rcerror(buf); } diff --git a/src/cmd/upas/bayes/regen.c b/src/cmd/upas/bayes/regen.c index cddf034a..d5f14cb5 100644 --- a/src/cmd/upas/bayes/regen.c +++ b/src/cmd/upas/bayes/regen.c @@ -8,7 +8,7 @@ * Regular expression for matching. */ -char *ignore[] = +char *ignore[] = { /* HTML that isn't A, IMG, or FONT */ /* Must have a space somewhere to avoid catching <email@address> */ @@ -122,7 +122,7 @@ buildre(Dreprog *re[3]) static char buf[16384], *s; re[0] = dregcomp("^From "); - + s = buf; for(i=0; i<nelem(keywords); i++){ if(i != 0) @@ -172,5 +172,3 @@ main(int argc, char **argv) Bprintdfa(&b, re[2]); exits(0); } - -
\ No newline at end of file diff --git a/src/cmd/upas/common/common.h b/src/cmd/upas/common/common.h index 7a26dea1..0fae80f8 100644 --- a/src/cmd/upas/common/common.h +++ b/src/cmd/upas/common/common.h @@ -18,7 +18,7 @@ enum Elemlen= 28, Errlen= 128, Pathlen= 256, - + RetryCode = 2 }; @@ -76,5 +76,3 @@ extern process *proc_start(char*, stream*, stream*, stream*, int, char*); extern int proc_wait(process*); extern int proc_free(process*); extern int proc_kill(process*); - - diff --git a/src/cmd/upas/common/config.c b/src/cmd/upas/common/config.c index 8d1e7a02..97ce9cc2 100644 --- a/src/cmd/upas/common/config.c +++ b/src/cmd/upas/common/config.c @@ -14,7 +14,7 @@ void upasconfig(void) { static int did; - + if(did) return; did = 1; diff --git a/src/cmd/upas/common/libsys.c b/src/cmd/upas/common/libsys.c index b439cfde..2ed19494 100644 --- a/src/cmd/upas/common/libsys.c +++ b/src/cmd/upas/common/libsys.c @@ -198,7 +198,7 @@ trylock(char *path) free(l); return 0; } - + /* fork process to keep lock alive */ switch(l->pid = rfork(RFPROC)){ default: @@ -470,7 +470,7 @@ sysnames_read(void) for(p=h->h_aliases; *p; p++) ; - + namev = malloc((2+p-h->h_aliases)*sizeof namev[0]); if(namev == 0) return 0; @@ -709,7 +709,7 @@ mboxpath(char *path, char *user, String *to, int dot) { char *dir; String *s; - + if (dot || *path=='/' || strncmp(path, "./", 2) == 0 || strncmp(path, "../", 3) == 0) { to = s_append(to, path); @@ -801,7 +801,7 @@ remoteaddr(int fd, char *dir) { char *raddr; NetConnInfo *nci; - + if((nci = getnetconninfo(dir, fd)) == nil) return nil; raddr = strdup(nci->raddr); diff --git a/src/cmd/upas/common/process.c b/src/cmd/upas/common/process.c index 56725a88..f593d551 100644 --- a/src/cmd/upas/common/process.c +++ b/src/cmd/upas/common/process.c @@ -18,7 +18,7 @@ instream(void) return 0; } rv->fp = &rv->bb; - rv->fd = pfd[0]; + rv->fd = pfd[0]; return rv; } diff --git a/src/cmd/upas/filterkit/list.c b/src/cmd/upas/filterkit/list.c index 1913c6de..51a50e98 100644 --- a/src/cmd/upas/filterkit/list.c +++ b/src/cmd/upas/filterkit/list.c @@ -286,7 +286,7 @@ add(char *pp, int argc, char **argv) s_free(s); } close(fd); - return nil; + return nil; } void diff --git a/src/cmd/upas/filterkit/readaddrs.c b/src/cmd/upas/filterkit/readaddrs.c index 9aadc1ab..6ab9ed95 100644 --- a/src/cmd/upas/filterkit/readaddrs.c +++ b/src/cmd/upas/filterkit/readaddrs.c @@ -32,7 +32,7 @@ tokenize822(char *str, char **args, int max) int intok = 0, inquote = 0; if(max <= 0) - return 0; + return 0; for(na=0; ;str++) switch(*str) { case ' ': diff --git a/src/cmd/upas/filterkit/token.c b/src/cmd/upas/filterkit/token.c index 4e91e261..86564c2b 100644 --- a/src/cmd/upas/filterkit/token.c +++ b/src/cmd/upas/filterkit/token.c @@ -18,7 +18,7 @@ mktoken(char *key, long thetime) uchar digest[SHA1dlen]; char token[64]; String *s; - + now = ctime(thetime); memset(now+11, ':', 8); hmac_sha1((uchar*)now, strlen(now), (uchar*)key, strlen(key), digest, nil); @@ -45,7 +45,7 @@ check_token(char *key, char *file) if(i < 0) return "no match"; buf[i] = 0; - + now = time(0); for(i = 0; i < 14; i++){ diff --git a/src/cmd/upas/fs/dat.h b/src/cmd/upas/fs/dat.h index 14208ed6..6264822d 100644 --- a/src/cmd/upas/fs/dat.h +++ b/src/cmd/upas/fs/dat.h @@ -218,4 +218,3 @@ void henter(ulong, char*, Qid, Message*, Mailbox*); void hfree(ulong, char*); ulong msgallocd, msgfreed; - diff --git a/src/cmd/upas/fs/fs.c b/src/cmd/upas/fs/fs.c index 9fa433d8..dc6ff3ba 100644 --- a/src/cmd/upas/fs/fs.c +++ b/src/cmd/upas/fs/fs.c @@ -760,7 +760,7 @@ rwalk(Fid *f) for(i = 0; i < thdr.nwname; i++){ rv = dowalk(f, thdr.wname[i]); if(rv != nil){ - if(nf != nil) + if(nf != nil) rclunk(nf); break; } @@ -827,7 +827,7 @@ readtopdir(Fid* dummy, uchar *buf, long off, int cnt, int blen) cnt -= m; } pos += m; - + for(mb = mbl; mb != nil; mb = mb->next){ mkstat(&d, mb, nil, Qmbox); m = convD2M(&d, &buf[n], blen-n); @@ -872,7 +872,7 @@ readmboxdir(Fid *f, uchar *buf, long off, int cnt, int blen) } else { msg = f->mb->root->part; pos = 0; - } + } for(; cnt > 0 && msg != nil; msg = msg->next){ /* act like deleted files aren't there */ @@ -1301,7 +1301,7 @@ struct Ignorance Ignorance *ignorance; /* - * read the file of headers to ignore + * read the file of headers to ignore */ void readignore(void) diff --git a/src/cmd/upas/fs/imap4.c b/src/cmd/upas/fs/imap4.c index 48119fa7..7fcc51b5 100644 --- a/src/cmd/upas/fs/imap4.c +++ b/src/cmd/upas/fs/imap4.c @@ -136,7 +136,7 @@ imapgrow(Imap *imap, int n) int i; if(imap->data == nil){ - imap->base = emalloc(n+1); + imap->base = emalloc(n+1); imap->data = imap->base; imap->size = n+1; } @@ -165,7 +165,7 @@ imap4resp(Imap *imap) ep = p+Blinelen(&imap->bin); while(ep > p && (ep[-1]=='\n' || ep[-1]=='\r')) *--ep = '\0'; - + if(imap->debug) fprint(2, "<- %s\n", p); strupr(p); @@ -186,7 +186,7 @@ imap4resp(Imap *imap) if(*p==' ') p++; verb = p; - + if(p = strchr(verb, ' ')) p++; else @@ -221,7 +221,7 @@ imap4resp(Imap *imap) /* <3031 bytes of data> */ /* ) */ if(strstr(p, "RFC822.SIZE") && strstr(p, "BODY[]")){ - if((q = strchr(p, '{')) + if((q = strchr(p, '{')) && (n=strtol(q+1, &en, 0), *en=='}')){ if(imap->data == nil || n >= imap->size) imapgrow(imap, n); @@ -268,7 +268,7 @@ imap4resp(Imap *imap) /* ) */ /* * 1 FETCH (UID 1 RFC822.HEADER "data") */ if(strstr(p, "RFC822.HEADER") || strstr(p, "RFC822.TEXT")){ - if((q = strchr(p, '{')) + if((q = strchr(p, '{')) && (n=strtol(q+1, &en, 0), *en=='}')){ if(imap->data == nil || n >= imap->size) imapgrow(imap, n); diff --git a/src/cmd/upas/fs/mbox.c b/src/cmd/upas/fs/mbox.c index 2f483747..b77306d6 100644 --- a/src/cmd/upas/fs/mbox.c +++ b/src/cmd/upas/fs/mbox.c @@ -721,7 +721,7 @@ ctype(Message *m, Header *h, char *p) p = skipwhite(p); p = getstring(p, m->type, 1); - + while(*p){ if(isattribute(&p, "boundary")){ s = s_new(); @@ -741,7 +741,7 @@ ctype(Message *m, Header *h, char *p) } else if(isattribute(&p, "charset")){ p = getstring(p, s_reset(m->charset), 0); } - + p = skiptosemi(p); } } @@ -1598,4 +1598,3 @@ date822tounix(char *s) *q = '\0'; return s_copy(p); } - diff --git a/src/cmd/upas/fs/pop3.c b/src/cmd/upas/fs/pop3.c index da8021dd..d41d2b48 100644 --- a/src/cmd/upas/fs/pop3.c +++ b/src/cmd/upas/fs/pop3.c @@ -506,7 +506,7 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb) (Qid){PATH(mb->id, Qmbox), mb->vers, QTDIR}, nil, mb); } - return nil; + return nil; } /* */ @@ -695,4 +695,3 @@ pop3mbox(Mailbox *mb, char *path) return nil; } - diff --git a/src/cmd/upas/fs/strtotm.c b/src/cmd/upas/fs/strtotm.c index bcf0bcee..09a7914d 100644 --- a/src/cmd/upas/fs/strtotm.c +++ b/src/cmd/upas/fs/strtotm.c @@ -20,7 +20,7 @@ skipwhite(char *q) static char* months[] = { "jan", "feb", "mar", "apr", - "may", "jun", "jul", "aug", + "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; @@ -81,7 +81,7 @@ strtotm(char *p, Tm *tmp) continue; /* look for time zone [A-Z][A-Z]T */ - if(q-p==3 && 'A' <= p[0] && p[0] <= 'Z' + if(q-p==3 && 'A' <= p[0] && p[0] <= 'Z' && 'A' <= p[1] && p[1] <= 'Z' && p[2] == 'T'){ strecpy(tm.zone, tm.zone+4, p); continue; diff --git a/src/cmd/upas/fs/tester.c b/src/cmd/upas/fs/tester.c index 3d24012e..30c15b31 100644 --- a/src/cmd/upas/fs/tester.c +++ b/src/cmd/upas/fs/tester.c @@ -51,7 +51,7 @@ info(int indent, int mno, Message *m) info(indent+1, i++, nm); } } - + void main(int argc, char **argv) diff --git a/src/cmd/upas/marshal/marshal.c b/src/cmd/upas/marshal/marshal.c index 8ebd3957..e83328e9 100644 --- a/src/cmd/upas/marshal/marshal.c +++ b/src/cmd/upas/marshal/marshal.c @@ -334,7 +334,7 @@ threadmain(int argc, char **argv) close(fd); threadexitsall(waitforsubprocs()); } - + if(Binit(&out, fd, OWRITE) < 0) fatal("can't Binit 1: %r"); @@ -689,7 +689,7 @@ attachment(Attach *a, Biobuf *out) free(f); return; } - + /* if it's not already mime encoded ... */ if(strcmp(a->type, "text/plain") != 0) Bprint(out, "Content-Type: %s\n", a->type); @@ -822,7 +822,7 @@ int mopen(char *file, int mode) { int fd; - + if((fd = open(file, mode)) >= 0) return fd; if(strncmp(file, "Mail/", 5) == 0 && mountmail() >= 0 && (fd = fsopenfd(mailfs, file+5, mode)) >= 0) @@ -890,7 +890,7 @@ mkattach(char *file, char *type, int inline) a->type = "application/octet-stream"; /* safest default */ if(pipe(pfd) < 0) return a; - + xfd[0] = mopen(file, OREAD); xfd[1] = pfd[0]; xfd[2] = dup(2, -1); @@ -955,7 +955,7 @@ static void teeproc(void *v) { int *a; - + a = v; tee(a[0], a[1], a[2]); write(a[2], "\n", 1); @@ -1094,7 +1094,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) if(pipe(pfd) < 0) fatal("pipe: %r"); - + xfd[0] = pfd[0]; xfd[1] = dup(1, -1); xfd[2] = dup(2, -1); @@ -1122,7 +1122,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) proccreate(teeproc, targ, STACK); sfd = pfd[1]; } - + return sfd; } @@ -1348,7 +1348,7 @@ readaliases(void) addr->next = 0; *al = addr; al = &addr->next; - } + } if(a->addr == nil || a->addr->next == nil){ freealias(a); continue; @@ -1592,7 +1592,7 @@ get822token(String **tok, char *p, char **pp) type = Twords; quoting = 0; for(; *p && (quoting || (!ISWHITE(*p) && *p != '>' && *p != '<' && *p != ',')); p++) { - if(*p == '"') + if(*p == '"') quoting = !quoting; if(*p == '\\') { if(*(p+1) == '\0') { @@ -1609,7 +1609,7 @@ get822token(String **tok, char *p, char **pp) *pp = p; *tok = s_copyn(op, p-op); return type; -} +} /* expand local aliases in an RFC822 mail line */ /* add list of expanded addresses to to. */ @@ -1717,7 +1717,7 @@ expandline(String **s, Addr *to) nto = nil; werrstr("rfc822 syntax error"); rfc822syntaxerror = 1; - goto Break2; + goto Break2; } } Break2: @@ -1893,7 +1893,7 @@ hard: fmtprint(fmt, "=%.2uX", (uchar)*p); else fmtrune(fmt, (uchar)*p); - } + } fmtprint(fmt, "?="); return 0; } diff --git a/src/cmd/upas/misc/mail.c b/src/cmd/upas/misc/mail.c index 20cf2397..bf2cff56 100644 --- a/src/cmd/upas/misc/mail.c +++ b/src/cmd/upas/misc/mail.c @@ -48,4 +48,3 @@ main (argc, argv) perror (realprog); exit (1); } - diff --git a/src/cmd/upas/ml/common.c b/src/cmd/upas/ml/common.c index 307a4925..c389d639 100644 --- a/src/cmd/upas/ml/common.c +++ b/src/cmd/upas/ml/common.c @@ -185,7 +185,7 @@ sendnotification(char *addr, char *listname, int rem) fprint(pfd[1], "the word 'remove' in the subject or body.\n"); } close(pfd[1]); - + /* wait for mailer to end */ while(w = wait()){ if(w->msg != nil && w->msg[0]) diff --git a/src/cmd/upas/ml/ml.c b/src/cmd/upas/ml/ml.c index 8dad0517..a135b051 100644 --- a/src/cmd/upas/ml/ml.c +++ b/src/cmd/upas/ml/ml.c @@ -56,7 +56,7 @@ main(int argc, char **argv) if(s_read_line(&in, firstline) == nil) sysfatal("reading input: %r"); - /* read up to the first 128k of the message. more is redculous. + /* read up to the first 128k of the message. more is redculous. Not if word documents are distributed. Upped it to 2MB (pb) */ if(s_read(&in, msg, 2*1024*1024) <= 0) sysfatal("reading input: %r"); diff --git a/src/cmd/upas/ned/nedmail.c b/src/cmd/upas/ned/nedmail.c index ef0f731c..6acd73e4 100644 --- a/src/cmd/upas/ned/nedmail.c +++ b/src/cmd/upas/ned/nedmail.c @@ -212,7 +212,7 @@ plural(int n) if (n == 1) return ""; - return "s"; + return "s"; } void @@ -366,7 +366,7 @@ mkaddrs(char *t) int i, nf, inquote; char **f, *s; Fmt fmt; - + inquote = 0; nf = 2; for(s=t; *s; s++){ @@ -402,7 +402,7 @@ file2message(Message *parent, char *name) String *path; char *f[30], *s, *t; int i, nf; - + m = mallocz(sizeof(Message), 1); if(m == nil) return nil; @@ -425,7 +425,7 @@ file2message(Message *parent, char *name) if(t == nil) continue; *t++ = 0; - + if(strcmp(s, "from") == 0) m->from = mkaddrs(t); else if(strcmp(s, "to") == 0) @@ -475,7 +475,7 @@ dir2message(Message *parent, int reverse) { int i, n, highest, newmsgs; CFid *fd; - + Dir *d; Message *first, *last, *m; @@ -972,7 +972,7 @@ parseaddr(char **pp, Message *first, Message *cur, Message *unspec, Message **mp goto number; } *mp = unspec; - break; + break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = strtoul(p, pp, 10); @@ -1191,7 +1191,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) free(prog); } } else { - + /* parse an address */ s = e = nil; err = parseaddr(&p, first, cur, cur, &s); @@ -1207,7 +1207,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) err = parseaddr(&p, first, cur, last, &e); if(err != nil) return err; - + /* select all messages in the range */ for(; s != nil; s = s->next){ *l = s; @@ -1258,7 +1258,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) } cmd->f = cmdtab[i].f; } - return nil; + return nil; } /* inefficient read from standard input */ @@ -1511,7 +1511,7 @@ pcmd(Cmd *x, Message *m) Bprint(&out, "\n!--- using plumber to display message of type %s\n", m->type); else Bprint(&out, "\n!--- cannot display messages of type %s\n", m->type); - + return m; } @@ -1684,7 +1684,7 @@ Message* ycmd(Cmd *x, Message *m) { USED(x); - + doflush = 1; return icmd(nil, m); @@ -1839,7 +1839,7 @@ tokenize822(char *str, char **args, int max) int intok = 0, inquote = 0; if(max <= 0) - return 0; + return 0; for(na=0; ;str++) switch(*str) { case ' ': @@ -2452,9 +2452,9 @@ switchmb(char *file, char *singleton) fd = open("/mail/fs/ctl", ORDWR); if(fd < 0) sysfatal("can't open /mail/fs/ctl: %r"); - + path = s_new(); - + /* get an absolute path to the mail box */ if(strncmp(file, "./", 2) == 0){ /* resolve path here since upas/fs doesn't know */ @@ -2468,7 +2468,7 @@ switchmb(char *file, char *singleton) } else { mboxpath(file, user, path, 0); } - + /* make up a handle to use when talking to fs */ p = strrchr(file, '/'); if(p == nil){ diff --git a/src/cmd/upas/nfs/box.c b/src/cmd/upas/nfs/box.c index 202111f8..a3525f0f 100644 --- a/src/cmd/upas/nfs/box.c +++ b/src/cmd/upas/nfs/box.c @@ -30,7 +30,7 @@ Box* subbox(Box *b, char *elem) { int i; - + for(i=0; i<b->nsub; i++) if(b->sub[i] && strcmp(b->sub[i]->elem, elem) == 0) return b->sub[i]; @@ -41,7 +41,7 @@ Box* boxbyid(uint id) { int i; - + /* LATER: replace with binary search */ for(i=0; i<nboxes; i++) if(boxes[i] && boxes[i]->id == id) @@ -54,10 +54,10 @@ boxcreate(char *name) { char *p; Box *b, *bb; - + if((b = boxbyname(name)) != nil) return b; - + b = emalloc(sizeof *b); b->id = ++boxid; b->time = time(0); @@ -87,7 +87,7 @@ void boxfree(Box *b) { int i; - + if(b == nil) return; for(i=0; i<b->nmsg; i++) @@ -100,12 +100,12 @@ Part* partcreate(Msg *m, Part *pp) { Part *p; - + if(m->npart%PartChunk == 0) m->part = erealloc(m->part, (m->npart+PartChunk)*sizeof m->part[0]); p = emalloc(sizeof *p); p->msg = m; - p->ix = m->npart; + p->ix = m->npart; m->part[m->npart++] = p; if(pp){ if(pp->nsub%PartSubChunk == 0) @@ -121,7 +121,7 @@ void partfree(Part *p) { int i; - + if(p == nil) return; for(i=0; i<p->nsub; i++) @@ -145,7 +145,7 @@ void msgfree(Msg *m) { int i; - + if(m == nil) return; for(i=0; i<m->npart; i++) @@ -162,7 +162,7 @@ msgplumb(Msg *m, int delete) Plumbattr a[10]; char buf[256], date[40]; int ai; - + if(m == nil || m->npart < 1 || m->part[0]->hdr == nil) return; if(m->box && strcmp(m->box->name, "mbox") != 0) @@ -176,7 +176,7 @@ msgplumb(Msg *m, int delete) ai = 0; a[ai].name = "filetype"; a[ai].value = "mail"; - + a[++ai].name = "mailtype"; a[ai].value = delete?"delete":"new"; a[ai-1].next = &a[ai]; @@ -198,15 +198,15 @@ msgplumb(Msg *m, int delete) a[ai].value = m->part[0]->hdr->digest; a[ai-1].next = &a[ai]; } - + strcpy(date, ctime(m->date)); date[strlen(date)-1] = 0; /* newline */ a[++ai].name = "date"; a[ai].value = date; a[ai-1].next = &a[ai]; - + a[ai].next = nil; - + p.attr = a; #ifdef PLAN9PORT snprint(buf, sizeof buf, "Mail/%s/%ud", m->box->name, m->id); @@ -215,7 +215,7 @@ msgplumb(Msg *m, int delete) #endif p.ndata = strlen(buf); p.data = buf; - + if(fd < 0) fd = plumbopen("send", OWRITE); if(fd < 0) @@ -229,7 +229,7 @@ Msg* msgcreate(Box *box) { Msg *m; - + m = emalloc(sizeof *m); m->box = box; partcreate(m, nil); @@ -319,4 +319,3 @@ boxinit(void) rootbox->name = estrdup(""); rootbox->time = time(0); } - diff --git a/src/cmd/upas/nfs/box.h b/src/cmd/upas/nfs/box.h index 9ca3b8f9..bbb3851e 100644 --- a/src/cmd/upas/nfs/box.h +++ b/src/cmd/upas/nfs/box.h @@ -31,7 +31,7 @@ struct Box Msg** msg; /* array of messages (can have nils) */ uint nmsg; - + char* imapname; /* name on IMAP server */ u32int validity; /* IMAP validity number */ uint uidnext; /* IMAP expected next uid */ @@ -73,7 +73,7 @@ struct Msg uint flags; /* FlagDeleted etc. */ uint date; /* smtp envelope date */ uint size; - + Part** part; /* message subparts - part[0] is root */ uint npart; }; @@ -132,4 +132,3 @@ extern Box** boxes; extern uint nboxes; extern Box* rootbox; - diff --git a/src/cmd/upas/nfs/decode.c b/src/cmd/upas/nfs/decode.c index 3f8c4c68..0ad78ec4 100644 --- a/src/cmd/upas/nfs/decode.c +++ b/src/cmd/upas/nfs/decode.c @@ -25,7 +25,7 @@ _decqp(uchar *out, int lim, char *in, int n, int underscores) { char *p, *ep; uchar *eout, *out0; - + out0 = out; eout = out+lim; for(p=in, ep=in+n; p<ep && out<eout; ){ @@ -73,7 +73,7 @@ decode(int kind, char *s, int *len) *len = l; t[l] = 0; return t; - + case Base64: l = strlen(s)+1; t = emalloc(l); @@ -127,7 +127,7 @@ static void twriter(void *v) { Writeargs *w; - + w = v; write(w->fd, w->s, strlen(w->s)); close(w->fd); @@ -216,13 +216,13 @@ unrfc2047(char *s) int len; Rune r; Fmt fmt; - + if(s == nil) return nil; if(strstr(s, "=?") == nil) return s; - + fmtstrinit(&fmt); for(p=s; *p; ){ /* =?charset?e?text?= */ @@ -270,7 +270,7 @@ unrfc2047(char *s) } #ifdef TEST -char *test[] = +char *test[] = { "hello world", "hello =?iso-8859-1?q?this is some text?=", @@ -288,7 +288,7 @@ void threadmain(int argc, char **argv) { int i; - + for(i=0; i<nelem(test); i++) print("%s\n\t%s\n", test[i], unrfc2047(estrdup(test[i]))); threadexitsall(0); diff --git a/src/cmd/upas/nfs/fs.c b/src/cmd/upas/nfs/fs.c index 69cd6b5a..361a3561 100644 --- a/src/cmd/upas/nfs/fs.c +++ b/src/cmd/upas/nfs/fs.c @@ -1,8 +1,8 @@ /* * Mail file system. - * + * * Serve the bulk of requests out of memory, so they can - * be in the main loop (will never see their flushes). + * be in the main loop (will never see their flushes). * Some requests do block and they get handled in * separate threads. They're all okay to give up on * early, though, so we just respond saying interrupted @@ -16,7 +16,7 @@ TO DO: digest disposition filename - + ctl messages fetch mail on demand @@ -48,7 +48,7 @@ enum Qbcc, Qinreplyto, Qmessageid, - + /* part data - same order as stuct Part */ Qtype, Qidstr, @@ -60,7 +60,7 @@ enum Qrawheader, Qrawbody, Qmimeheader, - + /* part numbers - same order as struct Part */ Qsize, Qlines, @@ -75,7 +75,7 @@ enum Qrawunix, Qunixdate, Qunixheader, - + Qfile0 = Qbody, Qnfile = Qunixheader+1-Qfile0 }; @@ -98,7 +98,7 @@ void responderror(Req *r) { char e[ERRMAX]; - + rerrstr(e, sizeof e); respond(r, e); } @@ -132,7 +132,7 @@ Qid qid(int ctl, Box *box, Msg *msg, Part *part) { Qid q; - + q.type = 0; if(ctl == Qroot || ctl == Qbox || ctl == Qmsg) q.type = QTDIR; @@ -150,7 +150,7 @@ parseqid(Qid q, Box **box, Msg **msg, Part **part) { *msg = nil; *part = nil; - + *box = boxbyid(qboxid(q)); if(*box){ *msg = msgbyid(*box, qmsgid(q)); @@ -198,7 +198,7 @@ char* nameoftype(int t) { int i; - + for(i=0; i<nelem(typenames); i++) if(typenames[i].type == t) return typenames[i].name; @@ -209,7 +209,7 @@ int typeofname(char *name) { int i; - + for(i=0; i<nelem(typenames); i++) if(strcmp(typenames[i].name, name) == 0) return typenames[i].type; @@ -246,7 +246,7 @@ fswalk1(Fid *fid, char *name, void *arg) Part *p, *part; USED(arg); - + switch(type = parseqid(fid->qid, &box, &msg, &part)){ case Qroot: if(strcmp(name, "..") == 0) @@ -347,7 +347,7 @@ addaddrs(Fmt *fmt, char *prefix, char *addrs) char **f; int i, nf, inquote; char *p, *sep; - + if(addrs == nil) return; addrs = estrdup(addrs); @@ -409,7 +409,7 @@ mkbody(Part *p, Qid q) } static Qid ZQ; - + static int filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *freeme, int force, Qid q) { @@ -444,7 +444,7 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre } *pp = ((char**)&part->hdr->date)[type-Qdate]; return 0; - + case Qunixdate: strcpy(buf, ctime(msg->date)); *pp = buf; @@ -630,7 +630,7 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre if(part->hdr->from==nil || (part->hdr->sender && strcmp(part->hdr->sender, part->hdr->from) != 0)) addaddrs(&fmt, "Sender", part->hdr->sender); - if(part->hdr->from==nil + if(part->hdr->from==nil || (part->hdr->replyto && strcmp(part->hdr->replyto, part->hdr->from) != 0)) addaddrs(&fmt, "Reply-To", part->hdr->replyto); fmtprint(&fmt, "Subject: %s\n", part->hdr->subject); @@ -681,7 +681,7 @@ filldir(Dir *d, int type, Box *box, Msg *msg, Part *part) case Qsearch: d->mode = 0666; break; - + case Qflags: d->mode = 0666; goto msgfile; @@ -736,7 +736,7 @@ filldir(Dir *d, int type, Box *box, Msg *msg, Part *part) } return 0; } - + static void fsstat(Req *r) { @@ -744,7 +744,7 @@ fsstat(Req *r) Box *box; Msg *msg; Part *part; - + type = parseqid(r->fid->qid, &box, &msg, &part); if(filldir(&r->d, type, box, msg, part) < 0) responderror(r); @@ -756,7 +756,7 @@ int rootgen(int i, Dir *d, void *aux) { USED(aux); - + if(i == 0) return filldir(d, Qctl, nil, nil, nil); i--; @@ -786,17 +786,17 @@ boxgen(int i, Dir *d, void *aux) } static int msgdir[] = { - Qtype, - Qbody, Qbcc, Qcc, Qdate, Qflags, Qfrom, Qheader, Qinfo, - Qinreplyto, Qlines, Qmimeheader, Qmessageid, + Qtype, + Qbody, Qbcc, Qcc, Qdate, Qflags, Qfrom, Qheader, Qinfo, + Qinreplyto, Qlines, Qmimeheader, Qmessageid, Qraw, Qrawunix, Qrawbody, Qrawheader, Qreplyto, Qsender, Qsubject, Qto, Qunixdate, Qunixheader }; static int mimemsgdir[] = { - Qtype, - Qbody, Qbcc, Qcc, Qdate, Qfrom, Qheader, Qinfo, - Qinreplyto, Qlines, Qmimeheader, Qmessageid, + Qtype, + Qbody, Qbcc, Qcc, Qdate, Qfrom, Qheader, Qinfo, + Qinreplyto, Qlines, Qmimeheader, Qmessageid, Qraw, Qrawunix, Qrawbody, Qrawheader, Qreplyto, Qsender, Qsubject, Qto }; @@ -808,14 +808,14 @@ static int mimedir[] = { Qmimeheader, Qraw }; - + int msggen(int i, Dir *d, void *aux) { Box *box; Msg *msg; Part *part; - + part = aux; msg = part->msg; box = msg->box; @@ -875,7 +875,7 @@ fsread(Req *r) Box *box; Msg *msg; Part *part; - + switch(type = parseqid(r->fid->qid, &box, &msg, &part)){ case Qroot: dirread9p(r, rootgen, nil); @@ -906,7 +906,7 @@ fsread(Req *r) dirread9p(r, msggen, part); respond(r, nil); return; - + case Qctl: case Qboxctl: respond(r, Egreg); @@ -937,7 +937,7 @@ mkmsglist(Box *box, char **f, int nf, Msg ***mm) { int i, nm; Msg **m; - + m = emalloc(nf*sizeof m[0]); nm = 0; for(i=0; i<nf; i++) @@ -1012,7 +1012,7 @@ fswrite(Req *r) respond(r, nil); free(m); break; - + case CMjunk: flag = FlagJunk; goto flagit; @@ -1188,7 +1188,7 @@ static void fsthread(void *v) { Req *r; - + r = v; switch(r->ifcall.type){ case Tread: @@ -1255,10 +1255,9 @@ fsinit0(void) /* bad planning - clash with lib9pclient */ fs.write = fssend; fs.stat = fssend; fs.destroyfid = fsdestroyfid; - + rootqid = qid(Qroot, nil, nil, nil); - + fsreqchan = chancreate(sizeof(void*), 0); mailthread(fsrecv, nil); } - diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c index ef76487b..5249e2e7 100644 --- a/src/cmd/upas/nfs/imap.c +++ b/src/cmd/upas/nfs/imap.c @@ -41,7 +41,7 @@ struct Imap static struct { char *name; int flag; -} flagstab[] = +} flagstab[] = { "Junk", FlagJunk, "NonJunk", FlagNonJunk, @@ -116,20 +116,20 @@ imapconnect(char *server, int mode, char *root, char *user) z->fd = -1; z->autoreconnect = 0; z->io = ioproc(); - + qlock(&z->lk); if(imapreconnect(z) < 0){ free(z); return nil; } - + z->r.l = &z->rlk; z->autoreconnect = 1; qunlock(&z->lk); - + proccreate(imaptimerproc, z, STACK); mailthread(imaprefreshthread, z); - + return z; } @@ -231,7 +231,7 @@ getboxes(Imap *z) { int i; Box **r, **w, **e; - + for(i=0; i<nboxes; i++){ boxes[i]->mark = 1; boxes[i]->exists = 0; @@ -260,10 +260,10 @@ getbox(Imap *z, Box *b) { int i; Msg **r, **w, **e; - + if(b == nil) return 0; - + for(i=0; i<b->nmsg; i++) b->msg[i]->imapid = 0; if(imapcmd(z, b, "UID FETCH 1:* FLAGS") < 0) @@ -294,7 +294,7 @@ static void imaptimerproc(void *v) { Imap *z; - + z = v; for(;;){ sleep(60*1000); @@ -323,13 +323,13 @@ static void imaprefreshthread(void *v) { Imap *z; - + z = v; for(;;){ qlock(z->r.l); rsleep(&z->r); qunlock(z->r.l); - + qlock(&z->lk); if(z->inbox) checkbox(z, z->inbox); @@ -347,7 +347,7 @@ imapvcmdsx0(Imap *z, char *fmt, va_list arg, int dotag) Fmt f; int len; Sx *sx; - + if(canqlock(&z->lk)) abort(); @@ -380,7 +380,7 @@ imapcmdsx0(Imap *z, char *fmt, ...) { va_list arg; Sx *sx; - + va_start(arg, fmt); sx = imapvcmdsx0(z, fmt, arg, 1); va_end(arg); @@ -395,7 +395,7 @@ imapvcmdsx(Imap *z, Box *b, char *fmt, va_list arg, int dotag) { int tries; Sx *sx; - + tries = 0; z->nextbox = b; @@ -478,7 +478,7 @@ static Sx* imapwaitsx(Imap *z) { Sx *sx; - + while((sx = zBrdsx(z)) != nil){ if(chattyimap) fprint(2, "<| %#$\n", sx); @@ -534,7 +534,7 @@ static void fetch1(Imap *z, Part *p, char *s) { qlock(&z->lk); - imapcmd(z, p->msg->box, "UID FETCH %d BODY[%s]", + imapcmd(z, p->msg->box, "UID FETCH %d BODY[%s]", p->msg->imapuid, bodyname(p, s)); qunlock(&z->lk); } @@ -569,7 +569,7 @@ imaplistcmd(Imap *z, Box *box, char *before, Msg **m, uint nm, char *after) int i, r; char *cmd; Fmt fmt; - + if(nm == 0) return 0; @@ -582,7 +582,7 @@ imaplistcmd(Imap *z, Box *box, char *before, Msg **m, uint nm, char *after) } fmtprint(&fmt, " %s", after); cmd = fmtstrflush(&fmt); - + r = 0; if(imapcmd(z, box, "%s", cmd) < 0) r = -1; @@ -595,7 +595,7 @@ imapcopylist(Imap *z, char *nbox, Msg **m, uint nm) { int rv; char *name, *p; - + if(nm == 0) return 0; @@ -617,7 +617,7 @@ int imapremovelist(Imap *z, Msg **m, uint nm) { int rv; - + if(nm == 0) return 0; @@ -636,7 +636,7 @@ imapflaglist(Imap *z, int op, int flag, Msg **m, uint nm) char *mod, *s, *sep; int i, rv; Fmt fmt; - + if(op > 0) mod = "+"; else if(op == 0) @@ -655,7 +655,7 @@ imapflaglist(Imap *z, int op, int flag, Msg **m, uint nm) } fmtprint(&fmt, ")"); s = fmtstrflush(&fmt); - + qlock(&z->lk); rv = imaplistcmd(z, m[0]->box, "UID STORE", m, nm, s); qunlock(&z->lk); @@ -726,7 +726,7 @@ _ioimapdial(va_list *arg) { char *server; int mode; - + server = va_arg(*arg, char*); mode = va_arg(*arg, int); return imapdial(server, mode); @@ -742,7 +742,7 @@ _ioBrdsx(va_list *arg) { Biobuf *b; Sx **sx; - + b = va_arg(*arg, Biobuf*); sx = va_arg(*arg, Sx**); *sx = Brdsx(b); @@ -779,12 +779,12 @@ imapdial(char *server, int mode) int fd[3]; char *tmp; char *fpath; - + switch(mode){ default: case Unencrypted: return dial(netmkaddr(server, "tcp", "143"), nil, nil, nil); - + case Starttls: werrstr("starttls not supported"); return -1; @@ -818,7 +818,7 @@ imapdial(char *server, int mode) free(tmp); close(p[0]); return p[1]; - + case Cmd: if(pipe(p) < 0) return -1; @@ -912,7 +912,7 @@ static int sxmatch(Sx *sx, char *fmt) { int i; - + for(i=0; fmt[i]; i++){ if(fmt[i] == '*') fmt--; /* like i-- but better */ @@ -994,7 +994,7 @@ static int isatom(Sx *v, char *name) { int n; - + if(v == nil || v->type != SxAtom) return 0; n = strlen(name); @@ -1021,7 +1021,7 @@ isnumber(Sx *sx) static int isnil(Sx *v) { - return v == nil || + return v == nil || (v->type==SxList && v->nsx == 0) || (v->type==SxAtom && strcmp(v->data, "NIL") == 0); } @@ -1036,7 +1036,7 @@ static uint parseflags(Sx *v) { int f, i, j; - + if(v->type != SxList){ warn("malformed flags: %$", v); return 0; @@ -1051,13 +1051,13 @@ parseflags(Sx *v) } return f; } - + static char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; static int parsemon(char *s) { int i; - + for(i=0; months[i]; i+=3) if(memcmp(s, months+i, 3) == 0) return i/3; @@ -1071,13 +1071,13 @@ parsedate(Sx *v) uint t; int delta; char *p; - + if(v->type != SxString || !stringmatch("01-Aaa-1111 01:11:11 +1111", v->data)){ bad: warn("bad date: %$", v); return 0; } - + /* cannot use atoi because 09 is malformed octal! */ memset(&tm, 0, sizeof tm); p = v->data; @@ -1095,7 +1095,7 @@ parsedate(Sx *v) delta = ((p[22]-'0')*10+p[23]-'0')*3600 + ((p[24]-'0')*10+p[25]-'0')*60; if(p[21] == '-') delta = -delta; - + t -= delta; return t; } @@ -1123,7 +1123,7 @@ parseenvelope(Sx *v) Hdr *hdr; uchar digest[16]; DigestState ds; - + if(v->type != SxList || !sxmatch(v, "SSLLLLLLSS")){ warn("bad envelope: %$", v); return nil; @@ -1140,7 +1140,7 @@ parseenvelope(Sx *v) hdr->bcc = copyaddrs(v->sx[7]); hdr->inreplyto = unrfc2047(nstring(v->sx[8])); hdr->messageid = unrfc2047(nstring(v->sx[9])); - + memset(&ds, 0, sizeof ds); hash(&ds, "date", hdr->date); hash(&ds, "subject", hdr->subject); @@ -1162,7 +1162,7 @@ static void strlwr(char *s) { char *t; - + if(s == nil) return; for(t=s; *t; t++) @@ -1174,7 +1174,7 @@ static void nocr(char *s) { char *r, *w; - + if(s == nil) return; for(r=w=s; *r; r++) @@ -1191,7 +1191,7 @@ gsub(char *s, char *a, char *b) { char *p, *t, *w, *last; int n; - + n = 0; for(p=s; (p=strstr(p, a)) != nil; p+=strlen(a)) n++; @@ -1256,7 +1256,7 @@ unexpected(Imap *z, Sx *sx) name = sx->sx[1]->data; }else return; - + for(i=0; i<nelem(unextab); i++){ if(unextab[i].num == num && cistrcmp(unextab[i].name, name) == 0){ if(unextab[i].fmt && !sxmatch(sx, unextab[i].fmt)){ @@ -1304,9 +1304,9 @@ xlist(Imap *z, Sx *sx) free(s); s = t; } - - /* - * Plan 9 calls the main mailbox mbox. + + /* + * Plan 9 calls the main mailbox mbox. * Rename any existing mbox by appending a $. */ if(!inbox && strncmp(s, "mbox", 4) == 0 && alldollars(s+4)){ @@ -1352,7 +1352,7 @@ xflags(Imap *z, Sx *sx) /* * This response contains in sx->sx[2] the list of flags * that can be validly attached to messages in z->box. - * We don't have any use for this list, since we + * We don't have any use for this list, since we * use only the standard flags. */ } @@ -1396,7 +1396,7 @@ static void xsearch(Imap *z, Sx *sx) { int i; - + free(z->uid); z->uid = emalloc((sx->nsx-2)*sizeof z->uid[0]); z->nuid = sx->nsx-2; @@ -1404,7 +1404,7 @@ xsearch(Imap *z, Sx *sx) z->uid[i] = sx->sx[i+2]->number; } -/* +/* * Table-driven FETCH message info parser. */ static void xmsgflags(Msg*, Sx*, Sx*); @@ -1496,7 +1496,7 @@ static char* nstring(Sx *v) { char *p; - + if(isnil(v)) return estrdup(""); p = v->data; @@ -1511,7 +1511,7 @@ copyaddrs(Sx *v) char *name, *email, *host, *mbox; int i; Fmt fmt; - + if(v->nsx == 0) return nil; @@ -1565,7 +1565,7 @@ parseparams(Part *part, Sx *v) { int i, j; char *s, *t, **p; - + if(isnil(v)) return; if(v->nsx%2){ @@ -1586,7 +1586,7 @@ parseparams(Part *part, Sx *v) } free(s); free(t); - } + } } static void @@ -1594,7 +1594,7 @@ parsestructure(Part *part, Sx *v) { int i; char *s, *t; - + if(isnil(v)) return; if(v->type != SxList){ @@ -1627,7 +1627,7 @@ parsestructure(Part *part, Sx *v) strlwr(t); free(part->type); part->type = esmprint("%s/%s", s, t); - if(v->nsx < 7 || !islist(v->sx[2]) || !isstring(v->sx[3]) + if(v->nsx < 7 || !islist(v->sx[2]) || !isstring(v->sx[3]) || !isstring(v->sx[4]) || !isstring(v->sx[5]) || !isnumber(v->sx[6])) goto bad; parseparams(part, v->sx[2]); @@ -1676,13 +1676,13 @@ xmsgbodydata(Msg *msg, Sx *k, Sx *v) int i; char *name, *p; Part *part; - + name = k->data; name += 5; /* body[ */ p = strchr(name, ']'); if(p) *p = 0; - + /* now name is something like 1 or 3.2.MIME - walk down parts from root */ part = msg->part[0]; @@ -1777,7 +1777,7 @@ xokuidvalidity(Imap *z, Sx *sx) { int i; Box *b; - + if((b=z->box) == nil) return; if(b->validity != sx->number){ @@ -1822,4 +1822,3 @@ xokreadonly(Imap *z, Sx *sx) USED(sx); /* z->boxmode = OREAD; */ } - diff --git a/src/cmd/upas/nfs/main.c b/src/cmd/upas/nfs/main.c index ebcf701c..c72a4849 100644 --- a/src/cmd/upas/nfs/main.c +++ b/src/cmd/upas/nfs/main.c @@ -67,13 +67,13 @@ threadmain(int argc, char **argv) break; }ARGEND - quotefmtinstall(); + quotefmtinstall(); fmtinstall('$', sxfmt); if(argc != 1) usage(); server = argv[0]; - + mailthreadinit(); boxinit(); fsinit0(); @@ -82,4 +82,3 @@ threadmain(int argc, char **argv) sysfatal("imapconnect: %r"); threadpostmountsrv(&fs, srvname, mtpt, 0); } - diff --git a/src/cmd/upas/nfs/mbox.c b/src/cmd/upas/nfs/mbox.c index 5f90f0a2..1b60ffa6 100644 --- a/src/cmd/upas/nfs/mbox.c +++ b/src/cmd/upas/nfs/mbox.c @@ -8,7 +8,7 @@ static void markboxes(int mark) { Mailbox *b; - + for(i=0; i<nbox; i++) if(box[i]) box[i]->mark = mark; @@ -18,7 +18,7 @@ static void sweepboxes(void) { Mailbox *b; - + for(i=0; i<nbox; i++) if(box[i] && box[i]->mark){ freembox(box[i]); @@ -30,7 +30,7 @@ static Mailbox* mboxbyname(char *name) { int i; - + for(i=0; i<nbox; i++) if(box[i] && strcmp(box[i]->name, name) == 0) return box[i]; @@ -49,7 +49,7 @@ static Mailbox* mboxcreate(char *name) { Mailbox *b; - + b = emalloc(sizeof *b); b->name = estrdup(name); if(nbox%64 == 0) diff --git a/src/cmd/upas/nfs/msg.c b/src/cmd/upas/nfs/msg.c index f4a26862..622841a6 100644 --- a/src/cmd/upas/nfs/msg.c +++ b/src/cmd/upas/nfs/msg.c @@ -6,4 +6,3 @@ cache flushes optionally to disk before being tossed out reload from disk, then from server - diff --git a/src/cmd/upas/nfs/sx.c b/src/cmd/upas/nfs/sx.c index 65d338c2..55e2934e 100644 --- a/src/cmd/upas/nfs/sx.c +++ b/src/cmd/upas/nfs/sx.c @@ -7,7 +7,7 @@ Brdsx(Biobuf *b) { Sx **sx, *x; int nsx; - + nsx = 0; sx = nil; while((x = Brdsx1(b)) != nil){ @@ -21,11 +21,11 @@ Brdsx(Biobuf *b) return x; } -int +int sxwalk(Sx *sx) { int i, n; - + if(sx == nil) return 1; switch(sx->type){ @@ -46,7 +46,7 @@ void freesx(Sx *sx) { int i; - + if(sx == nil) return; switch(sx->type){ @@ -70,7 +70,7 @@ Brdsx1(Biobuf *b) char *s; vlong n; Sx *x; - + c = Bgetc(b); if(c == ' ') c = Bgetc(b); @@ -144,7 +144,7 @@ Brdsx1(Biobuf *b) s = emalloc(1); s[0] = c; nbr = 0; - while((c = Bgetc(b)) >= 0 && c > ' ' && !strchr("(){}", c)){ + while((c = Bgetc(b)) >= 0 && c > ' ' && !strchr("(){}", c)){ /* allow embedded brackets as in BODY[] */ if(c == '['){ if(s[0] == '[') @@ -169,7 +169,7 @@ Brdsx1(Biobuf *b) x->type = SxAtom; x->data = s; x->ndata = len; - return x; + return x; } int @@ -177,7 +177,7 @@ sxfmt(Fmt *fmt) { int i, paren; Sx *sx; - + sx = va_arg(fmt->args, Sx*); if(sx == nil) return 0; @@ -211,7 +211,7 @@ sxfmt(Fmt *fmt) int oksx(Sx *sx) { - return sx->nsx >= 2 - && sx->sx[1]->type == SxAtom + return sx->nsx >= 2 + && sx->sx[1]->type == SxAtom && cistrcmp(sx->sx[1]->data, "OK") == 0; } diff --git a/src/cmd/upas/nfs/sx.h b/src/cmd/upas/nfs/sx.h index 38a801d4..696b5a70 100644 --- a/src/cmd/upas/nfs/sx.h +++ b/src/cmd/upas/nfs/sx.h @@ -28,4 +28,3 @@ void freesx(Sx*); int oksx(Sx*); int sxfmt(Fmt*); int sxwalk(Sx*); - diff --git a/src/cmd/upas/nfs/thread.c b/src/cmd/upas/nfs/thread.c index bb40def1..b4c893ee 100644 --- a/src/cmd/upas/nfs/thread.c +++ b/src/cmd/upas/nfs/thread.c @@ -13,7 +13,7 @@ void mailthread(void (*fn)(void*), void *arg) { New n; - + n.fn = fn; n.arg = arg; send(mailthreadchan, &n); @@ -23,7 +23,7 @@ void mailproc(void *v) { New n; - + USED(v); while(recv(mailthreadchan, &n) == 1) threadcreate(n.fn, n.arg, STACK); @@ -35,4 +35,3 @@ mailthreadinit(void) mailthreadchan = chancreate(sizeof(New), 0); proccreate(mailproc, nil, STACK); } - diff --git a/src/cmd/upas/nfs/util.c b/src/cmd/upas/nfs/util.c index ac9deba8..048eef05 100644 --- a/src/cmd/upas/nfs/util.c +++ b/src/cmd/upas/nfs/util.c @@ -4,7 +4,7 @@ void warn(char *fmt, ...) { va_list arg; - + va_start(arg, fmt); fprint(2, "warning: "); vfprint(2, fmt, arg); diff --git a/src/cmd/upas/pop3/pop3.c b/src/cmd/upas/pop3/pop3.c index af674368..4974a8b5 100644 --- a/src/cmd/upas/pop3/pop3.c +++ b/src/cmd/upas/pop3/pop3.c @@ -63,7 +63,7 @@ static int passwordinclear; static int didtls; typedef struct Msg Msg; -struct Msg +struct Msg { int upasnum; char digest[64]; @@ -575,7 +575,7 @@ stlscmd(char*) Binit(&out, 1, OWRITE); didtls = 1; return 0; -} +} static int topcmd(char *arg) @@ -643,7 +643,7 @@ uidlcmd(char *arg) return senderr("no such message"); sendok("%d %s", n+1, msg[n].digest); } - return 0; + return 0; } static char* @@ -746,7 +746,7 @@ dologin(char *response) if(tries++ >= 5){ senderr("authentication failed: %r; server exiting"); exits(nil); - } + } return senderr("authentication failed"); } @@ -801,4 +801,3 @@ apopcmd(char *arg) return -1; return dologin(resp); } - diff --git a/src/cmd/upas/scanmail/common.c b/src/cmd/upas/scanmail/common.c index 2e368504..30301424 100644 --- a/src/cmd/upas/scanmail/common.c +++ b/src/cmd/upas/scanmail/common.c @@ -277,7 +277,7 @@ htmlchk(char **msg, char *end) p = *msg; if(ishtml == 0){ ishtml = htmlmatch(htmlcmds, p, end, &n); - + /* If not an HTML keyword, check if it's * an HTML comment (<!comment>). if so, * skip over it; otherwise copy it in. @@ -287,7 +287,7 @@ htmlchk(char **msg, char *end) } else if(htmlmatch(hrefs, p, end, &n)) /* if special HTML string */ return '<'; /* copy it */ - + /* * this is an uninteresting HTML command; skip over it. */ diff --git a/src/cmd/upas/scanmail/testscan.c b/src/cmd/upas/scanmail/testscan.c index 48cd4bbf..79399c8b 100644 --- a/src/cmd/upas/scanmail/testscan.c +++ b/src/cmd/upas/scanmail/testscan.c @@ -110,7 +110,7 @@ main(int argc, char *argv[]) exits("open"); } Binit(&bin, fd, OREAD); - } else + } else Binit(&bin, 0, OREAD); *body = 0; diff --git a/src/cmd/upas/send/bind.c b/src/cmd/upas/send/bind.c index 8a8fc8ea..05327975 100644 --- a/src/cmd/upas/send/bind.c +++ b/src/cmd/upas/send/bind.c @@ -130,4 +130,3 @@ forward_loop(char *addr, char *system) return 1; return 0; } - diff --git a/src/cmd/upas/send/main.c b/src/cmd/upas/send/main.c index 6c455833..15a2026e 100644 --- a/src/cmd/upas/send/main.c +++ b/src/cmd/upas/send/main.c @@ -122,7 +122,7 @@ main(int argc, char *argv[]) /* * If this is a gateway, translate the sender address into a local - * address. This only happens if mail to the local address is + * address. This only happens if mail to the local address is * forwarded to the sender. */ gateway(mp); diff --git a/src/cmd/upas/send/message.c b/src/cmd/upas/send/message.c index 3ec8d706..60dd050b 100644 --- a/src/cmd/upas/send/message.c +++ b/src/cmd/upas/send/message.c @@ -224,7 +224,7 @@ rfc822cruft(message *mp) if(p->addr){ cp = skipequiv(s_to_c(p->s)); s_append(body, cp); - } else + } else s_append(body, s_to_c(p->s)); }else{ s_putc(body, p->c); @@ -494,7 +494,7 @@ int isutf8(String *s) { char *p; - + for(p = s_to_c(s); *p; p++) if(*p&0x80) return 1; diff --git a/src/cmd/upas/send/rewrite.c b/src/cmd/upas/send/rewrite.c index 3f30d4f3..3b19da27 100644 --- a/src/cmd/upas/send/rewrite.c +++ b/src/cmd/upas/send/rewrite.c @@ -3,7 +3,7 @@ extern int debug; -/* +/* * Routines for dealing with the rewrite rules. */ @@ -249,7 +249,7 @@ substitute(String *source, Resub *subexp, message *mp) char *s; char *sp; String *stp; - + if(source == 0) return 0; sp = s_to_c(source); @@ -292,7 +292,7 @@ substitute(String *source, Resub *subexp, message *mp) s_putc(stp, *sp); break; } - } else if(*sp == '&') { + } else if(*sp == '&') { if(subexp[0].s.sp != 0) for (s = subexp[0].s.sp; s < subexp[0].e.ep; s++) @@ -345,4 +345,3 @@ dumprules(void) fprint(2, " '%s'\n", rp->repl2 ? rp->repl2->base:"..."); } } - diff --git a/src/cmd/upas/send/skipequiv.c b/src/cmd/upas/send/skipequiv.c index f40181ad..d5bf0bb1 100644 --- a/src/cmd/upas/send/skipequiv.c +++ b/src/cmd/upas/send/skipequiv.c @@ -41,7 +41,7 @@ okfile(char *cp, Biobuf *fp) len = strlen(cp); Bseek(fp, 0, 0); - + /* one iteration per system name in the file */ while(buf = Brdline(fp, '\n')) { ep = &buf[Blinelen(fp)]; diff --git a/src/cmd/upas/smtp/mxdial.c b/src/cmd/upas/smtp/mxdial.c index 56962dcd..f7a009af 100644 --- a/src/cmd/upas/smtp/mxdial.c +++ b/src/cmd/upas/smtp/mxdial.c @@ -171,7 +171,7 @@ mxlookup(DS *ds, char *domain) { int i, n, nmx; Ndbtuple *t, *tmx, *tpref, *tip; - + strcpy(domain, ds->host); ds->netdir = "/net"; nmx = 0; @@ -184,7 +184,7 @@ mxlookup(DS *ds, char *domain) nmx++; break; } - } + } } ndbfree(t); } @@ -216,14 +216,14 @@ mxlookup(DS *ds, char *domain) strncpy(mx[i].ip, tip->val, sizeof(mx[i].ip)-1); ndbfree(t); continue; - + no: /* remove mx[i] and go around again */ nmx--; mx[i] = mx[nmx]; i--; } - return nmx; + return nmx; } static int diff --git a/src/cmd/upas/smtp/smtp.c b/src/cmd/upas/smtp/smtp.c index 92873723..88d7f7a4 100644 --- a/src/cmd/upas/smtp/smtp.c +++ b/src/cmd/upas/smtp/smtp.c @@ -60,7 +60,7 @@ void usage(void) { fprint(2, "usage: smtp [-adips] [-uuser] [-hhost] [.domain] net!host[!service] sender rcpt-list\n"); - threadexitsall(Giveup); + threadexitsall(Giveup); } int @@ -656,7 +656,7 @@ data(String *from, Biobuf *b) nbytes += Bprint(&bout, "Message-ID: <%s@%s>\r\n", id, hostdomain); if(debug) Bprint(&berr, "Message-ID: <%s@%s>\r\n", id, hostdomain); - } + } if(originator==0){ nbytes += Bprint(&bout, "From: %s\r\n", s_to_c(fromline)); @@ -687,7 +687,7 @@ data(String *from, Biobuf *b) /* * send body */ - + putcrnl(uneaten, buf+n - uneaten); nbytes += buf+n - uneaten; if(eof == 0){ @@ -1109,14 +1109,14 @@ dBputc(int x) return Bputc(&bout, x); } -char* +char* expand_addr(char *addr) { static char buf[256]; char *p, *q, *name, *sys; Ndbtuple *t; Ndb *db; - + p = strchr(addr, '!'); if(p){ q = strchr(p+1, '!'); @@ -1131,7 +1131,7 @@ expand_addr(char *addr) name++; if(q) *q = 0; - + sys = sysname(); db = ndbopen(0); t = ndbipinfo(db, "sys", sys, &name, 1); @@ -1141,7 +1141,7 @@ expand_addr(char *addr) *q = '!'; return addr; } - + *(name-1) = 0; if(q) *q = '!'; diff --git a/src/cmd/upas/smtp/smtpd.c b/src/cmd/upas/smtp/smtpd.c index e59dbddd..df722c10 100644 --- a/src/cmd/upas/smtp/smtpd.c +++ b/src/cmd/upas/smtp/smtpd.c @@ -304,7 +304,7 @@ hello(String *himp, int extended) if (extended) { if(tlscert != nil) reply("250-STARTTLS\r\n"); - if (passwordinclear) + if (passwordinclear) reply("250 AUTH CRAM-MD5 PLAIN LOGIN\r\n"); else reply("250 AUTH CRAM-MD5\r\n"); @@ -1101,7 +1101,7 @@ sendermxcheck(void) * Could add an option with the remote IP address * to allow validatesender to implement SPF eventually. */ - execl(validate, "validatesender", + execl(validate, "validatesender", "-n", nci->root, senddom, user, nil); threadexitsall("exec validatesender: %r"); default: @@ -1165,7 +1165,7 @@ data(void) reply("450 %s\r\n", errx); for(l=rcvers.first; l; l=l->next) syslog(0, "smtpd", "[%s/%s] %s -> %s sendercheck: %s", - him, nci->rsys, s_to_c(senders.first->p), + him, nci->rsys, s_to_c(senders.first->p), s_to_c(l->p), errx); rejectcount++; return; @@ -1214,7 +1214,7 @@ data(void) code = 554; } else { syslog(0, "smtpd", "++[%s/%s] %s %s %s%s%sreturned %#q %s", him, nci->rsys, - s_to_c(senders.first->p), s_to_c(cmd), + s_to_c(senders.first->p), s_to_c(cmd), piperror ? "error during pipemsg: " : "", piperror ? piperror : "", piperror ? "; " : "", diff --git a/src/cmd/upas/smtp/smtpd.h b/src/cmd/upas/smtp/smtpd.h index bb982a2f..9f8cdffa 100644 --- a/src/cmd/upas/smtp/smtpd.h +++ b/src/cmd/upas/smtp/smtpd.h @@ -11,7 +11,7 @@ enum { MAXREJECTS = 100 }; - + typedef struct Link Link; typedef struct List List; diff --git a/src/cmd/upas/smtp/spam.c b/src/cmd/upas/smtp/spam.c index 723e341d..2422dfe9 100644 --- a/src/cmd/upas/smtp/spam.c +++ b/src/cmd/upas/smtp/spam.c @@ -26,7 +26,7 @@ static Keyword options[] = { "norelay", NORELAY, "verifysenderdom", DNSVERIFY, "saveblockedmsg", SAVEBLOCK, - "defaultdomain", DOMNAME, + "defaultdomain", DOMNAME, "ournets", OURNETS, "ourdomains", OURDOMS, 0, NONE @@ -84,7 +84,7 @@ getaction(char *s, char *type) return ACCEPT; for(k = actions; k->name != 0; k++){ - snprint(buf, sizeof buf, "%s/mail/ratify/%s/%s/%s", + snprint(buf, sizeof buf, "%s/mail/ratify/%s/%s/%s", get9root(), k->name, type, s); if(access(buf,0) >= 0) return k->code; @@ -435,7 +435,7 @@ cidrcheck(char *cp) if((v4peerip&m) == a) return 1; cp += strlen(cp)+1; - } + } return 0; } @@ -508,7 +508,7 @@ recipok(char *user) int pid; Waitmsg *w; static int beenhere; - + if(!beenhere){ beenhere++; validator = unsharp(validator); diff --git a/src/cmd/upas/vf/unvf.c b/src/cmd/upas/vf/unvf.c index aecbca62..7269da90 100644 --- a/src/cmd/upas/vf/unvf.c +++ b/src/cmd/upas/vf/unvf.c @@ -15,10 +15,10 @@ main(void) Biobuf b, b1; char *p, *encoding; int e, len; - + Binit(&b, 0, OREAD); Binit(&b1, 1, OWRITE); - + /* header */ encoding = nil; while((p = Brdstr(&b, '\n', 1)) != nil){ @@ -58,7 +58,7 @@ main(void) } /* - * decode quoted + * decode quoted */ enum { @@ -153,4 +153,3 @@ decquoted(char *out, char *in, char *e) return p - out; } - diff --git a/src/cmd/upas/vf/vf.c b/src/cmd/upas/vf/vf.c index fb54d4a1..5aab37fe 100644 --- a/src/cmd/upas/vf/vf.c +++ b/src/cmd/upas/vf/vf.c @@ -213,7 +213,7 @@ part(Part *pp) passnotheader(); return part(p); } else { - /* + /* * This is the meat. This may be an executable. * if so, wrap it and change its type */ @@ -390,7 +390,7 @@ save(Part *p, char *file) Bprint(&out, "\n"); Bterm(&out); close(fd); - + memset(&out, 0, sizeof out); Binit(&out, 1, OWRITE); return 0; @@ -404,7 +404,7 @@ savetmp(Part *p) { char buf[40], *name; int fd; - + strcpy(buf, "/var/tmp/vf.XXXXXXXXXXX"); if((fd = mkstemp(buf)) < 0){ fprint(2, "error creating temporary file: %r\n"); @@ -439,7 +439,7 @@ runchecker(Part *p) char *name; Waitmsg *w; static char *val; - + if(val == nil) val = unsharp("#9/mail/lib/validateattachment"); if(val == nil || access(val, AEXEC) < 0) @@ -503,7 +503,7 @@ problemchild(Part *p) if(justreject) return p; - + syslog(0, "mail", "vf wrapped %s %s", p->type?s_to_c(p->type):"?", p->filename?s_to_c(p->filename):"?"); @@ -591,7 +591,7 @@ isattribute(char **pp, char *attr) } /* - * parse content type header + * parse content type header */ static void ctype(Part *p, Hdef *h, char *cp) @@ -605,7 +605,7 @@ ctype(Part *p, Hdef *h, char *cp) cp = getstring(cp, p->type, 1); if(badtype(s_to_c(p->type))) p->badtype = 1; - + while(*cp){ if(isattribute(&cp, "boundary")){ s = s_new(); @@ -627,13 +627,13 @@ ctype(Part *p, Hdef *h, char *cp) p->charset = s_new(); cp = getstring(cp, s_reset(p->charset), 0); } - + cp = skiptosemi(cp); } } /* - * parse content encoding header + * parse content encoding header */ static void cencoding(Part *m, Hdef *h, char *p) @@ -647,7 +647,7 @@ cencoding(Part *m, Hdef *h, char *p) } /* - * parse content disposition header + * parse content disposition header */ static void cdisposition(Part *p, Hdef *h, char *cp) @@ -1006,7 +1006,7 @@ err: } /* - * decode quoted + * decode quoted */ enum { |