From cbeb0b26e4c7caa8d1b47de791a7418dc20a4567 Mon Sep 17 00:00:00 2001 From: rsc Date: Sat, 1 Apr 2006 19:24:03 +0000 Subject: Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms. --- src/cmd/upas/marshal/marshal.c | 228 ++++++++++++++++++++--------------------- 1 file changed, 114 insertions(+), 114 deletions(-) (limited to 'src/cmd/upas/marshal/marshal.c') diff --git a/src/cmd/upas/marshal/marshal.c b/src/cmd/upas/marshal/marshal.c index da54c760..fb94fa61 100644 --- a/src/cmd/upas/marshal/marshal.c +++ b/src/cmd/upas/marshal/marshal.c @@ -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< 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 -- cgit v1.2.3