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>
This commit is contained in:
Dan Cross 2020-01-10 14:44:21 +00:00
parent 77a0a5b519
commit fa325e9b42
1021 changed files with 5688 additions and 6193 deletions

View File

@ -42,7 +42,7 @@ g% cdsector 3149 | xd -b # 0x0c4d
55 aa - magic 55 aa - magic
0000020 88 - 88 = bootable 0000020 88 - 88 = bootable
03 - 3 = 2.88MB diskette 03 - 3 = 2.88MB diskette
00 00 - load segment 0 means default 0x7C0 00 00 - load segment 0 means default 0x7C0
00 - system type (byte 5 of boot image) 00 - system type (byte 5 of boot image)
00 - unused (0) 00 - unused (0)
@ -58,13 +58,13 @@ g% cdsector `{h2d 0c4e} | xd -b
1+0 records out 1+0 records out
0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00 0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00
0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00 0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00
0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
31 c0 31 c0
FREEBSD FREEBSD
0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00 0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00
0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00 0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00
0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
31 c0 31 c0
DOS 5 DOS 5
@ -171,7 +171,7 @@ Cupdatebootcat(Cdimg *cd)
Cputc(cd, 0); /* unused */ Cputc(cd, 0); /* unused */
Cputnl(cd, 1, 2); /* 512-byte sector count for load */ Cputnl(cd, 1, 2); /* 512-byte sector count for load */
Cputnl(cd, cd->bootdirec->block, 4); /* ptr to disk image */ Cputnl(cd, cd->bootdirec->block, 4); /* ptr to disk image */
Cwseek(cd, o); Cwseek(cd, o);
} }
void void

View File

@ -125,7 +125,7 @@ opencd(char *file, Cdinfo info)
} }
/* lowercase because of isostring */ /* lowercase because of isostring */
if(strstr(cd->iso.systemid, "iso9660") == nil if(strstr(cd->iso.systemid, "iso9660") == nil
&& strstr(cd->iso.systemid, "utf8") == nil) { && strstr(cd->iso.systemid, "utf8") == nil) {
werrstr("unknown systemid %s", cd->iso.systemid); werrstr("unknown systemid %s", cd->iso.systemid);
free(cd); free(cd);
@ -133,7 +133,7 @@ opencd(char *file, Cdinfo info)
close(xfd); close(xfd);
return nil; return nil;
} }
if(strstr(cd->iso.systemid, "plan 9")) if(strstr(cd->iso.systemid, "plan 9"))
cd->flags |= CDplan9; cd->flags |= CDplan9;
if(strstr(cd->iso.systemid, "iso9660")) if(strstr(cd->iso.systemid, "iso9660"))
@ -307,7 +307,7 @@ parsedesc(Voldesc *v, Cvoldesc *cv, char *(*string)(uchar*, int))
v->biblio = string(cv->biblio, sizeof cv->biblio); v->biblio = string(cv->biblio, sizeof cv->biblio);
v->notice = string(cv->notice, sizeof cv->notice); v->notice = string(cv->notice, sizeof cv->notice);
} }
static int static int
readisodesc(Cdimg *cd, Voldesc *v) readisodesc(Cdimg *cd, Voldesc *v)
{ {
@ -629,4 +629,3 @@ Clinelen(Cdimg *cd)
{ {
return Blinelen(&cd->brd); return Blinelen(&cd->brd);
} }

View File

@ -86,9 +86,9 @@ walkdirec(Direc *d, char *name)
* Add the file ``name'' with attributes d to the * Add the file ``name'' with attributes d to the
* directory ``root''. Name may contain multiple * directory ``root''. Name may contain multiple
* elements; all but the last must exist already. * elements; all but the last must exist already.
* *
* The child lists are kept sorted by utfname. * The child lists are kept sorted by utfname.
*/ */
Direc* Direc*
adddirec(Direc *root, char *name, XDir *d) adddirec(Direc *root, char *name, XDir *d)
{ {
@ -130,7 +130,7 @@ adddirec(Direc *root, char *name, XDir *d)
return nd; return nd;
} }
/* /*
* Copy the tree src into dst. * Copy the tree src into dst.
*/ */
void void
@ -219,4 +219,3 @@ dsort(Direc *d, int (*cmp)(const void*, const void*))
for(i=0; i<n; i++) for(i=0; i<n; i++)
dsort(&d->child[i], cmp); dsort(&d->child[i], cmp);
} }

View File

@ -348,7 +348,7 @@ adddumpdir(Direc *root, ulong now, XDir *dir)
Tm tm; Tm tm;
tm = *localtime(now); tm = *localtime(now);
sprint(buf, "%d", tm.year+1900); sprint(buf, "%d", tm.year+1900);
if((dyear = walkdirec(root, buf)) == nil) { if((dyear = walkdirec(root, buf)) == nil) {
dyear = adddirec(root, buf, dir); dyear = adddirec(root, buf, dir);
@ -406,7 +406,7 @@ hasdump(Cdimg *cd)
} }
return 0; return 0;
} }
Direc Direc
readdumpdirs(Cdimg *cd, XDir *dir, char *(*cvt)(uchar*, int)) readdumpdirs(Cdimg *cd, XDir *dir, char *(*cvt)(uchar*, int))
{ {
@ -500,7 +500,7 @@ readdumpconform(Cdimg *cd)
if(tokenize(p, f, 2) != 2 || (f[0][0] != 'D' && f[0][0] != 'F') if(tokenize(p, f, 2) != 2 || (f[0][0] != 'D' && f[0][0] != 'F')
|| strlen(f[0]) != 7 || !isalldigit(f[0]+1)) || strlen(f[0]) != 7 || !isalldigit(f[0]+1))
break; break;
addtx(atom(f[1]), atom(f[0])); addtx(atom(f[1]), atom(f[0]));
} }
} }

View File

@ -168,7 +168,7 @@ main(int argc, char **argv)
Cwseek(cd, cd->nextblock*Blocksize); Cwseek(cd, cd->nextblock*Blocksize);
goto Dofix; goto Dofix;
} }
dumpname = adddumpdir(&idumproot, now, &dir); dumpname = adddumpdir(&idumproot, now, &dir);
/* note that we assume all names are conforming and thus sorted */ /* note that we assume all names are conforming and thus sorted */
if(cd->flags & CDjoliet) { if(cd->flags & CDjoliet) {
@ -192,7 +192,7 @@ main(int argc, char **argv)
findbootimage(cd, &iroot); findbootimage(cd, &iroot);
Cupdatebootcat(cd); Cupdatebootcat(cd);
} }
/* create Joliet tree */ /* create Joliet tree */
if(cd->flags & CDjoliet) if(cd->flags & CDjoliet)
copydirec(&jroot, &iroot); copydirec(&jroot, &iroot);
@ -235,14 +235,14 @@ main(int argc, char **argv)
* Write incremental _conform.map block. * Write incremental _conform.map block.
*/ */
wrconform(cd, cd->nconform, &cblock, &clength); wrconform(cd, cd->nconform, &cblock, &clength);
/* jump here if we're just fixing up the cd */ /* jump here if we're just fixing up the cd */
Dofix: Dofix:
/* /*
* Write null dump header block; everything after this will be * Write null dump header block; everything after this will be
* overwritten at the next dump. Because of this, it needs to be * overwritten at the next dump. Because of this, it needs to be
* reconstructable. We reconstruct the _conform.map and dump trees * reconstructable. We reconstruct the _conform.map and dump trees
* from the header blocks in dump.c, and we reconstruct the path * from the header blocks in dump.c, and we reconstruct the path
* tables by walking the cd. * tables by walking the cd.
*/ */
newnull = Cputdumpblock(cd); newnull = Cputdumpblock(cd);
@ -254,12 +254,12 @@ Dofix:
dir.mode = 0444; dir.mode = 0444;
if(cd->flags & (CDconform|CDjoliet)) { if(cd->flags & (CDconform|CDjoliet)) {
if(!mk9660 && cd->nconform == 0){ if(!mk9660 && cd->nconform == 0){
block = cblock; block = cblock;
length = clength; length = clength;
}else }else
wrconform(cd, 0, &block, &length); wrconform(cd, 0, &block, &length);
if(mk9660) if(mk9660)
{ {
idumproot = iroot; idumproot = iroot;
jdumproot = jroot; jdumproot = jroot;
@ -315,11 +315,11 @@ Dofix:
copybutname(r, &jroot); copybutname(r, &jroot);
} }
} }
writedumpdirs(cd, &idumproot, Cputisodir); writedumpdirs(cd, &idumproot, Cputisodir);
if(cd->flags & CDjoliet) if(cd->flags & CDjoliet)
writedumpdirs(cd, &jdumproot, Cputjolietdir); writedumpdirs(cd, &jdumproot, Cputjolietdir);
/* /*
* Patch in new root directory entry. * Patch in new root directory entry.
*/ */
@ -330,7 +330,7 @@ Dofix:
setvolsize(cd, cd->jolietsvd, cd->nextblock*Blocksize); setvolsize(cd, cd->jolietsvd, cd->nextblock*Blocksize);
} }
} }
writepathtables(cd); writepathtables(cd);
if(!mk9660){ if(!mk9660){
/* /*
@ -341,16 +341,16 @@ Dofix:
if(cd->nulldump && maxsize && Cwoffset(cd) > maxsize){ if(cd->nulldump && maxsize && Cwoffset(cd) > maxsize){
fprint(2, "too big; writing old tree back\n"); fprint(2, "too big; writing old tree back\n");
status = "cd too big; aborted"; status = "cd too big; aborted";
rmdumpdir(&idumproot, dumpname); rmdumpdir(&idumproot, dumpname);
rmdumpdir(&jdumproot, dumpname); rmdumpdir(&jdumproot, dumpname);
cd->nextblock = cd->nulldump+1; cd->nextblock = cd->nulldump+1;
cd->nulldump = 0; cd->nulldump = 0;
Cwseek(cd, cd->nextblock*Blocksize); Cwseek(cd, cd->nextblock*Blocksize);
goto Dofix; goto Dofix;
} }
/* /*
* Write old null header block; this commits all our changes. * Write old null header block; this commits all our changes.
*/ */
@ -399,4 +399,3 @@ addprotofile(char *new, char *old, Dir *d, void *a)
free(name); free(name);
} }

View File

@ -31,7 +31,7 @@ isostring(uchar *buf, int len)
return q; return q;
} }
int int
isisofrog(char c) isisofrog(char c)
{ {
if(c >= '0' && c <= '9') if(c >= '0' && c <= '9')
@ -85,7 +85,7 @@ isbadiso9660(char *s)
/* /*
* ISO9660 name comparison * ISO9660 name comparison
* *
* The standard algorithm is as follows: * The standard algorithm is as follows:
* Take the filenames without extensions, pad the shorter with 0x20s (spaces), * Take the filenames without extensions, pad the shorter with 0x20s (spaces),
* and do strcmp. If they are equal, go on. * and do strcmp. If they are equal, go on.
@ -169,7 +169,7 @@ Cputisopvd(Cdimg *cd, Cdinfo info)
strcat(buf, "iso9660"); strcat(buf, "iso9660");
else else
strcat(buf, "utf8"); strcat(buf, "utf8");
struprcpy(buf, buf); struprcpy(buf, buf);
Cputs(cd, buf, 32); Cputs(cd, buf, 32);

View File

@ -89,7 +89,7 @@ struct Voldesc {
ulong mpathloc; ulong mpathloc;
/* root of file tree */ /* root of file tree */
Direc root; Direc root;
}; };
/* /*
@ -116,7 +116,7 @@ struct Cdimg {
ulong bootimageptr; ulong bootimageptr;
Direc *bootdirec; Direc *bootdirec;
char *bootimage; char *bootimage;
Biobuf brd; Biobuf brd;
Biobuf bwr; Biobuf bwr;
@ -406,7 +406,7 @@ int Cputisodir(Cdimg*, Direc*, int, int, int);
int Cputjolietdir(Cdimg*, Direc*, int, int, int); int Cputjolietdir(Cdimg*, Direc*, int, int, int);
void Cputendvd(Cdimg*); void Cputendvd(Cdimg*);
enum { enum {
Blocksize = 2048, Blocksize = 2048,
Ndirblock = 16, /* directory blocks allocated at once */ Ndirblock = 16, /* directory blocks allocated at once */

View File

@ -26,15 +26,15 @@ jolietstring(uchar *buf, int len)
} }
/* /*
* Joliet name validity check * Joliet name validity check
* *
* Joliet names have length at most 128 bytes (64 runes), * Joliet names have length at most 128 bytes (64 runes),
* and cannot contain '*', '/', ':', ';', '?', or '\'. * and cannot contain '*', '/', ':', ';', '?', or '\'.
*/ */
int int
isjolietfrog(Rune r) isjolietfrog(Rune r)
{ {
return r=='*' || r=='/' || r==':' return r=='*' || r=='/' || r==':'
|| r==';' || r=='?' || r=='\\'; || r==';' || r=='?' || r=='\\';
} }
@ -58,7 +58,7 @@ isbadjoliet(char *s)
* The standard algorithm is the ISO9660 algorithm but * The standard algorithm is the ISO9660 algorithm but
* on the encoded Runes. Runes are encoded in big endian * on the encoded Runes. Runes are encoded in big endian
* format, so we can just use runecmp. * format, so we can just use runecmp.
* *
* Padding is with zeros, but that still doesn't affect us. * Padding is with zeros, but that still doesn't affect us.
*/ */
@ -135,4 +135,3 @@ Cputjolietsvd(Cdimg *cd, Cdinfo info)
Cputc(cd, 1); /* file structure version */ Cputc(cd, 1); /* file structure version */
Cpadblock(cd); Cpadblock(cd);
} }

View File

@ -9,7 +9,7 @@
* Add the requisite path tables to the CD image. * Add the requisite path tables to the CD image.
* They get put on the end once everything else is done. * They get put on the end once everything else is done.
* We use the path table itself as a queue in the breadth-first * We use the path table itself as a queue in the breadth-first
* traversal of the tree. * traversal of the tree.
* *
* The only problem with this is that the path table does not * The only problem with this is that the path table does not
* store the lengths of the directories. So we keep an explicit * store the lengths of the directories. So we keep an explicit

View File

@ -36,4 +36,3 @@ runecmp(Rune *s, Rune *t)
s++, t++; s++, t++;
return *s - *t; return *s - *t;
} }

View File

@ -43,11 +43,11 @@ setcelen(Cdimg *cd, ulong woffset, ulong len)
* Rock Ridge data is put into little blockettes, which can be * Rock Ridge data is put into little blockettes, which can be
* at most 256 bytes including a one-byte length. Some number * at most 256 bytes including a one-byte length. Some number
* of blockettes get packed together into a normal 2048-byte block. * of blockettes get packed together into a normal 2048-byte block.
* Blockettes cannot cross block boundaries. * Blockettes cannot cross block boundaries.
* *
* A Cbuf is a blockette buffer. Len contains * A Cbuf is a blockette buffer. Len contains
* the length of the buffer written so far, and we can * the length of the buffer written so far, and we can
* write up to 254-28. * write up to 254-28.
* *
* We only have one active Cbuf at a time; cdimg.rrcontin is the byte * We only have one active Cbuf at a time; cdimg.rrcontin is the byte
* offset of the beginning of that Cbuf. * offset of the beginning of that Cbuf.
@ -94,7 +94,7 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite)
/* /*
* the current blockette is full; update cd->rrcontin and then * the current blockette is full; update cd->rrcontin and then
* write a CE record to finish it. Unfortunately we need to * write a CE record to finish it. Unfortunately we need to
* figure out which block will be next before we write the CE. * figure out which block will be next before we write the CE.
*/ */
end = Cwoffset(cd)+28; end = Cwoffset(cd)+28;
@ -134,13 +134,13 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite)
return cn; return cn;
} }
/* /*
* Put down the name, but we might need to break it * Put down the name, but we might need to break it
* into chunks so that each chunk fits in 254-28-5 bytes. * into chunks so that each chunk fits in 254-28-5 bytes.
* What a crock. * What a crock.
* *
* The new Plan 9 format uses strings of this form too, * The new Plan 9 format uses strings of this form too,
* since they're already there. * since they're already there.
*/ */
Cbuf* Cbuf*
@ -211,7 +211,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen)
what |= RR_SL; what |= RR_SL;
m = CputsuspRR(cd, what, 0); m = CputsuspRR(cd, what, 0);
cp = ensurespace(cd, m, cp, &cn, dowrite); cp = ensurespace(cd, m, cp, &cn, dowrite);
CputsuspRR(cd, what, dowrite); CputsuspRR(cd, what, dowrite);
if(what & RR_PX) { if(what & RR_PX) {
@ -235,7 +235,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen)
/* /*
* Put down the symbolic link. This is even more of a crock. * Put down the symbolic link. This is even more of a crock.
* Not only are the individual elements potentially split, * Not only are the individual elements potentially split,
* but the whole path itself can be split across SL blocks. * but the whole path itself can be split across SL blocks.
* To keep the code simple as possible (really), we write * To keep the code simple as possible (really), we write
* only one element per SL block, wasting 6 bytes per element. * only one element per SL block, wasting 6 bytes per element.
@ -382,7 +382,7 @@ CputsuspSP(Cdimg *cd, int dowrite)
{ {
assert(cd!=0); assert(cd!=0);
if(dowrite) { if(dowrite) {
chat("writing SUSP SP record\n"); chat("writing SUSP SP record\n");
Cputc(cd, 'S'); /* SP field marker */ Cputc(cd, 'S'); /* SP field marker */
Cputc(cd, 'P'); Cputc(cd, 'P');
@ -406,7 +406,7 @@ CputsuspST(Cdimg *cd, int dowrite)
Cputc(cd, 'S'); /* ST field marker */ Cputc(cd, 'S'); /* ST field marker */
Cputc(cd, 'T'); Cputc(cd, 'T');
Cputc(cd, 4); /* Length */ Cputc(cd, 4); /* Length */
Cputc(cd, 1); /* Version */ Cputc(cd, 1); /* Version */
} }
return 4; return 4;
} }
@ -484,7 +484,7 @@ CputrripPX(Cdimg *cd, Direc *d, int dot, int dowrite)
Cputc(cd, 'X'); Cputc(cd, 'X');
Cputc(cd, 36); /* Length */ Cputc(cd, 36); /* Length */
Cputc(cd, 1); /* Version */ Cputc(cd, 1); /* Version */
Cputn(cd, mode(d, dot), 4); /* POSIX File mode */ Cputn(cd, mode(d, dot), 4); /* POSIX File mode */
Cputn(cd, nlink(d), 4); /* POSIX st_nlink */ Cputn(cd, nlink(d), 4); /* POSIX st_nlink */
Cputn(cd, d?d->uidno:0, 4); /* POSIX st_uid */ Cputn(cd, d?d->uidno:0, 4); /* POSIX st_uid */
@ -514,7 +514,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
Cputc(cd, 5+7*length); /* Length */ Cputc(cd, 5+7*length); /* Length */
Cputc(cd, 1); /* Version */ Cputc(cd, 1); /* Version */
Cputc(cd, type); /* Flags (types) */ Cputc(cd, type); /* Flags (types) */
if (type & TFcreation) if (type & TFcreation)
Cputdate(cd, d?d->ctime:0); Cputdate(cd, d?d->ctime:0);
if (type & TFmodify) if (type & TFmodify)
@ -523,7 +523,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
Cputdate(cd, d?d->atime:0); Cputdate(cd, d?d->atime:0);
if (type & TFattributes) if (type & TFattributes)
Cputdate(cd, d?d->ctime:0); Cputdate(cd, d?d->ctime:0);
/* if (type & TFbackup) */ /* if (type & TFbackup) */
/* Cputdate(cd, 0); */ /* Cputdate(cd, 0); */
/* if (type & TFexpiration) */ /* if (type & TFexpiration) */
@ -566,7 +566,7 @@ static long
mode(Direc *d, int dot) mode(Direc *d, int dot)
{ {
long mode; long mode;
if (!d) if (!d)
return 0; return 0;
@ -582,13 +582,13 @@ mode(Direc *d, int dot)
mode = S_IFDIR | (0755); mode = S_IFDIR | (0755);
mode &= POSIXMODEMASK; mode &= POSIXMODEMASK;
/* Botch: not all POSIX types supported yet */ /* Botch: not all POSIX types supported yet */
assert(mode & (S_IFDIR|S_IFREG)); assert(mode & (S_IFDIR|S_IFREG));
chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name); chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name);
return mode; return mode;
} }
static long static long
@ -610,4 +610,3 @@ nlink(Direc *d) /* Trump up the nlink field for POSIX compliance */
return n; return n;
} }

View File

@ -39,7 +39,7 @@ atom(char *str)
{ {
uint h; uint h;
Stringtab *tab; Stringtab *tab;
h = hash(str) % nelem(stab); h = hash(str) % nelem(stab);
for(tab=stab[h]; tab; tab=tab->link) for(tab=stab[h]; tab; tab=tab->link)
if(strcmp(str, tab->str) == 0) if(strcmp(str, tab->str) == 0)

View File

@ -90,7 +90,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc)
assert(start != 0); assert(start != 0);
Cwseek(cd, start*Blocksize); Cwseek(cd, start*Blocksize);
s = md5(nil, 0, nil, nil); s = md5(nil, 0, nil, nil);
length = 0; length = 0;
while((n = Bread(b, buf, sizeof buf)) > 0) { while((n = Bread(b, buf, sizeof buf)) > 0) {
@ -123,7 +123,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc)
} }
/* /*
* Write a directory tree. We work from the leaves, * Write a directory tree. We work from the leaves,
* and patch the dotdot pointers afterward. * and patch the dotdot pointers afterward.
*/ */
static void static void

View File

@ -14,7 +14,7 @@
* tarring up a Plan 9 distribution CD, we now use 16 128kb * tarring up a Plan 9 distribution CD, we now use 16 128kb
* buffers. This works for ISO9660 because data is required * buffers. This works for ISO9660 because data is required
* to be laid out contiguously; effectively we're doing agressive * to be laid out contiguously; effectively we're doing agressive
* readahead. Because the buffers are so big and the typical * readahead. Because the buffers are so big and the typical
* disk accesses so concentrated, it's okay that we have so few * disk accesses so concentrated, it's okay that we have so few
* of them. * of them.
* *

View File

@ -138,13 +138,13 @@ main(int argc, char **argv)
open("/dev/null", OWRITE); open("/dev/null", OWRITE);
if(pipe(pipefd) < 0) if(pipe(pipefd) < 0)
panic(1, "pipe"); panic(1, "pipe");
if(post9pservice(pipefd[0], srvname, mtpt) < 0) if(post9pservice(pipefd[0], srvname, mtpt) < 0)
sysfatal("post9pservice: %r"); sysfatal("post9pservice: %r");
close(pipefd[0]); close(pipefd[0]);
} }
srvfd = pipefd[1]; srvfd = pipefd[1];
switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC)){ switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC)){
case -1: case -1:
panic(1, "fork"); panic(1, "fork");

View File

@ -167,4 +167,3 @@ clean(Xfile *f)
f->qid = (Qid){0,0,0}; f->qid = (Qid){0,0,0};
return f; return f;
} }

View File

@ -94,7 +94,7 @@ threadmain(int argc, char **argv)
threadexitsall(0); threadexitsall(0);
} }
} }
usage(); usage();
} }
CFsys* CFsys*
@ -168,7 +168,7 @@ xread(int argc, char **argv)
fsclose(fid); fsclose(fid);
if(n < 0) if(n < 0)
sysfatal("read error: %r"); sysfatal("read error: %r");
threadexitsall(0); threadexitsall(0);
} }
void void
@ -192,7 +192,7 @@ xreadfd(int argc, char **argv)
sysfatal("write error: %r"); sysfatal("write error: %r");
if(n < 0) if(n < 0)
sysfatal("read error: %r"); sysfatal("read error: %r");
threadexitsall(0); threadexitsall(0);
} }
void void
@ -246,7 +246,7 @@ xwrite(int argc, char **argv)
if(n < 0) if(n < 0)
sysfatal("read error: %r"); sysfatal("read error: %r");
fsclose(fid); fsclose(fid);
threadexitsall(0); threadexitsall(0);
} }
void void
@ -270,7 +270,7 @@ xwritefd(int argc, char **argv)
sysfatal("write error: %r"); sysfatal("write error: %r");
if(n < 0) if(n < 0)
sysfatal("read error: %r"); sysfatal("read error: %r");
threadexitsall(0); threadexitsall(0);
} }
void void
@ -331,7 +331,7 @@ xrdwr(int argc, char **argv)
fprint(2, "write: %r\n"); fprint(2, "write: %r\n");
} }
fsclose(fid); fsclose(fid);
threadexitsall(0); threadexitsall(0);
} }
void void
@ -346,10 +346,10 @@ xcreate(int argc, char **argv)
default: default:
usage(); usage();
}ARGEND }ARGEND
if(argc == 0) if(argc == 0)
usage(); usage();
for(i=0; i<argc; i++){ for(i=0; i<argc; i++){
fs = xparse(argv[i], &p); fs = xparse(argv[i], &p);
if((fid=fscreate(fs, p, OREAD, 0666)) == nil) if((fid=fscreate(fs, p, OREAD, 0666)) == nil)
@ -371,10 +371,10 @@ xrm(int argc, char **argv)
default: default:
usage(); usage();
}ARGEND }ARGEND
if(argc == 0) if(argc == 0)
usage(); usage();
for(i=0; i<argc; i++){ for(i=0; i<argc; i++){
fs = xparse(argv[i], &p); fs = xparse(argv[i], &p);
if(fsremove(fs, p) < 0) if(fsremove(fs, p) < 0)
@ -389,7 +389,7 @@ rdcon(void *v)
int n; int n;
char buf[4096]; char buf[4096];
CFid *fid; CFid *fid;
fid = v; fid = v;
for(;;){ for(;;){
n = read(0, buf, sizeof buf); n = read(0, buf, sizeof buf);
@ -408,7 +408,7 @@ xcon(int argc, char **argv)
char buf[4096], *r, *w, *e; char buf[4096], *r, *w, *e;
int n, nocr; int n, nocr;
CFid *fid; CFid *fid;
nocr = 1; nocr = 1;
ARGBEGIN{ ARGBEGIN{
@ -438,12 +438,12 @@ xcon(int argc, char **argv)
threadexitsall(0); threadexitsall(0);
} }
fsclose(fid); fsclose(fid);
threadexitsall(0); threadexitsall(0);
} }
static char *mon[] = static char *mon[] =
{ {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}; };
@ -454,7 +454,7 @@ timefmt(Fmt *fmt)
ulong u; ulong u;
static ulong time0; static ulong time0;
Tm *tm; Tm *tm;
if(time0 == 0) if(time0 == 0)
time0 = time(0); time0 = time(0);
u = va_arg(fmt->args, ulong); u = va_arg(fmt->args, ulong);
@ -470,7 +470,7 @@ static int
dircmp(const void *va, const void *vb) dircmp(const void *va, const void *vb)
{ {
Dir *a, *b; Dir *a, *b;
a = (Dir*)va; a = (Dir*)va;
b = (Dir*)vb; b = (Dir*)vb;
return strcmp(a->name, b->name); return strcmp(a->name, b->name);
@ -480,7 +480,7 @@ static int
timecmp(const void *va, const void *vb) timecmp(const void *va, const void *vb)
{ {
Dir *a, *b; Dir *a, *b;
a = (Dir*)va; a = (Dir*)va;
b = (Dir*)vb; b = (Dir*)vb;
if(a->mtime < b->mtime) if(a->mtime < b->mtime)
@ -520,12 +520,12 @@ xls(int argc, char **argv)
tflag = 1; tflag = 1;
break; break;
}ARGEND }ARGEND
fmtinstall('D', dirfmt); fmtinstall('D', dirfmt);
fmtinstall('M', dirmodefmt); fmtinstall('M', dirmodefmt);
quotefmtinstall(); quotefmtinstall();
fmtinstall('T', timefmt); fmtinstall('T', timefmt);
if(argc == 0){ if(argc == 0){
argv = dot; argv = dot;
argc = 1; argc = 1;
@ -600,4 +600,3 @@ xls(int argc, char **argv)
} }
threadexitsall(err); threadexitsall(err);
} }

View File

@ -55,7 +55,7 @@ errstr2errno(void)
{ {
char e[ERRMAX]; char e[ERRMAX];
int i, len; int i, len;
if(errno != EPLAN9) if(errno != EPLAN9)
return errno; return errno;
@ -70,4 +70,3 @@ errstr2errno(void)
return errortab[i].err; return errortab[i].err;
return ERANGE; /* who knows - be blatantly wrong */ return ERANGE; /* who knows - be blatantly wrong */
} }

View File

@ -15,7 +15,7 @@ allocfusemsg(void)
{ {
FuseMsg *m; FuseMsg *m;
void *vbuf; void *vbuf;
lock(&fusemsglock); lock(&fusemsglock);
if((m = fusemsglist) != nil){ if((m = fusemsglist) != nil){
fusemsglist = m->next; fusemsglist = m->next;
@ -46,7 +46,7 @@ readfusemsg(void)
{ {
FuseMsg *m; FuseMsg *m;
int n, nn; int n, nn;
m = allocfusemsg(); m = allocfusemsg();
/* /*
* The FUSE kernel device apparently guarantees * The FUSE kernel device apparently guarantees
@ -84,7 +84,7 @@ readfusemsg(void)
sysfatal("readfusemsg: got %d wanted %d", sysfatal("readfusemsg: got %d wanted %d",
n, m->hdr->len); n, m->hdr->len);
m->hdr->len -= sizeof(*m->hdr); m->hdr->len -= sizeof(*m->hdr);
/* /*
* Paranoia. * Paranoia.
* Make sure lengths are long enough. * Make sure lengths are long enough.
@ -125,7 +125,7 @@ readfusemsg(void)
if(((char*)m->tx)[m->hdr->len-1] != 0 if(((char*)m->tx)[m->hdr->len-1] != 0
|| memchr(m->tx, 0, m->hdr->len-1) == 0) || memchr(m->tx, 0, m->hdr->len-1) == 0)
goto bad; goto bad;
break; break;
case FUSE_MKNOD: case FUSE_MKNOD:
if(m->hdr->len <= sizeof(struct fuse_mknod_in) if(m->hdr->len <= sizeof(struct fuse_mknod_in)
|| ((char*)m->tx)[m->hdr->len-1] != 0) || ((char*)m->tx)[m->hdr->len-1] != 0)
@ -219,7 +219,7 @@ readfusemsg(void)
} }
/* /*
* Reply to FUSE request m using additonal * Reply to FUSE request m using additonal
* argument buffer arg of size narg bytes. * argument buffer arg of size narg bytes.
* Perhaps should free the FuseMsg here? * Perhaps should free the FuseMsg here?
*/ */
@ -229,7 +229,7 @@ replyfuse(FuseMsg *m, void *arg, int narg)
struct iovec vec[2]; struct iovec vec[2];
struct fuse_out_header hdr; struct fuse_out_header hdr;
int nvec; int nvec;
hdr.len = sizeof hdr + narg; hdr.len = sizeof hdr + narg;
hdr.error = 0; hdr.error = 0;
hdr.unique = m->hdr->unique; hdr.unique = m->hdr->unique;
@ -255,7 +255,7 @@ void
replyfuseerrno(FuseMsg *m, int e) replyfuseerrno(FuseMsg *m, int e)
{ {
struct fuse_out_header hdr; struct fuse_out_header hdr;
hdr.len = sizeof hdr; hdr.len = sizeof hdr;
hdr.error = -e; /* FUSE sends negative errnos. */ hdr.error = -e; /* FUSE sends negative errnos. */
hdr.unique = m->hdr->unique; hdr.unique = m->hdr->unique;
@ -307,12 +307,12 @@ initfuse(char *mtpt)
/* /*
* Complain if the kernel is too new. * Complain if the kernel is too new.
* We could forge ahead, but at least the one time I tried, * We could forge ahead, but at least the one time I tried,
* the kernel rejected the newer version by making the * the kernel rejected the newer version by making the
* writev fail in replyfuse, which is a much more confusing * writev fail in replyfuse, which is a much more confusing
* error message. In the future, might be nice to try to * error message. In the future, might be nice to try to
* support older versions that differ only slightly. * support older versions that differ only slightly.
*/ */
if(tx->major < FUSE_KERNEL_VERSION if(tx->major < FUSE_KERNEL_VERSION
|| (tx->major == FUSE_KERNEL_VERSION && tx->minor < FUSE_KERNEL_MINOR_VERSION)) || (tx->major == FUSE_KERNEL_VERSION && tx->minor < FUSE_KERNEL_MINOR_VERSION))
sysfatal("fuse: too kernel version %d.%d older than program version %d.%d", sysfatal("fuse: too kernel version %d.%d older than program version %d.%d",
tx->major, tx->minor, FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); tx->major, tx->minor, FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
@ -386,7 +386,7 @@ fusefmt(Fmt *fmt)
} }
case FUSE_SYMLINK: { case FUSE_SYMLINK: {
char *old, *new; char *old, *new;
old = a; old = a;
new = a + strlen(a) + 1; new = a + strlen(a) + 1;
fmtprint(fmt, "Symlink nodeid %#llux old %#q new %#q", fmtprint(fmt, "Symlink nodeid %#llux old %#q new %#q",
@ -455,7 +455,7 @@ fusefmt(Fmt *fmt)
case FUSE_RELEASE: { case FUSE_RELEASE: {
struct fuse_release_in *tx = a; struct fuse_release_in *tx = a;
fmtprint(fmt, "Release nodeid %#llux fh %#llux flags %#ux", fmtprint(fmt, "Release nodeid %#llux fh %#llux flags %#ux",
hdr->nodeid, tx->fh, tx->flags); hdr->nodeid, tx->fh, tx->flags);
break; break;
} }
case FUSE_FSYNC: { case FUSE_FSYNC: {
@ -516,7 +516,7 @@ fusefmt(Fmt *fmt)
case FUSE_RELEASEDIR: { case FUSE_RELEASEDIR: {
struct fuse_release_in *tx = a; struct fuse_release_in *tx = a;
fmtprint(fmt, "Releasedir nodeid %#llux fh %#llux flags %#ux", fmtprint(fmt, "Releasedir nodeid %#llux fh %#llux flags %#ux",
hdr->nodeid, tx->fh, tx->flags); hdr->nodeid, tx->fh, tx->flags);
break; break;
} }
case FUSE_FSYNCDIR: { case FUSE_FSYNCDIR: {
@ -554,7 +554,7 @@ fusefmt(Fmt *fmt)
case FUSE_LOOKUP: { case FUSE_LOOKUP: {
/* /*
* For a negative entry, can send back ENOENT * For a negative entry, can send back ENOENT
* or rx->ino == 0. * or rx->ino == 0.
* In protocol version 7.4 and before, can only use * In protocol version 7.4 and before, can only use
* the ENOENT method. * the ENOENT method.
* Presumably the benefit of sending rx->ino == 0 * Presumably the benefit of sending rx->ino == 0
@ -571,7 +571,7 @@ fusefmt(Fmt *fmt)
rx->attr_valid+rx->attr_valid_nsec*1e-9); rx->attr_valid+rx->attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->attr.ino, rx->attr.size, rx->attr.blocks, rx->attr.ino, rx->attr.size, rx->attr.blocks,
rx->attr.atime+rx->attr.atimensec*1e-9, rx->attr.atime+rx->attr.atimensec*1e-9,
rx->attr.mtime+rx->attr.mtimensec*1e-9, rx->attr.mtime+rx->attr.mtimensec*1e-9,
rx->attr.ctime+rx->attr.ctimensec*1e-9, rx->attr.ctime+rx->attr.ctimensec*1e-9,
rx->attr.mode, rx->attr.nlink, rx->attr.uid, rx->attr.mode, rx->attr.nlink, rx->attr.uid,
@ -592,7 +592,7 @@ fusefmt(Fmt *fmt)
rx->attr_valid+rx->attr_valid_nsec*1e-9); rx->attr_valid+rx->attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->attr.ino, rx->attr.size, rx->attr.blocks, rx->attr.ino, rx->attr.size, rx->attr.blocks,
rx->attr.atime+rx->attr.atimensec*1e-9, rx->attr.atime+rx->attr.atimensec*1e-9,
rx->attr.mtime+rx->attr.mtimensec*1e-9, rx->attr.mtime+rx->attr.mtimensec*1e-9,
rx->attr.ctime+rx->attr.ctimensec*1e-9, rx->attr.ctime+rx->attr.ctimensec*1e-9,
rx->attr.mode, rx->attr.nlink, rx->attr.uid, rx->attr.mode, rx->attr.nlink, rx->attr.uid,
@ -733,7 +733,7 @@ fusefmt(Fmt *fmt)
rx->e.attr_valid+rx->e.attr_valid_nsec*1e-9); rx->e.attr_valid+rx->e.attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->e.attr.ino, rx->e.attr.size, rx->e.attr.blocks, rx->e.attr.ino, rx->e.attr.size, rx->e.attr.blocks,
rx->e.attr.atime+rx->e.attr.atimensec*1e-9, rx->e.attr.atime+rx->e.attr.atimensec*1e-9,
rx->e.attr.mtime+rx->e.attr.mtimensec*1e-9, rx->e.attr.mtime+rx->e.attr.mtimensec*1e-9,
rx->e.attr.ctime+rx->e.attr.ctimensec*1e-9, rx->e.attr.ctime+rx->e.attr.ctimensec*1e-9,
rx->e.attr.mode, rx->e.attr.nlink, rx->e.attr.uid, rx->e.attr.mode, rx->e.attr.nlink, rx->e.attr.uid,
@ -753,7 +753,7 @@ fusefmt(Fmt *fmt)
/* /*
* Mounts a fuse file system on mtpt and returns * Mounts a fuse file system on mtpt and returns
* a file descriptor for the corresponding fuse * a file descriptor for the corresponding fuse
* message conversation. * message conversation.
*/ */
int int
@ -762,7 +762,7 @@ mountfuse(char *mtpt)
#if defined(__linux__) #if defined(__linux__)
int p[2], pid, fd; int p[2], pid, fd;
char buf[20]; char buf[20];
if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0) if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0)
return -1; return -1;
pid = fork(); pid = fork();
@ -783,11 +783,11 @@ mountfuse(char *mtpt)
#elif defined(__FreeBSD__) && !defined(__APPLE__) #elif defined(__FreeBSD__) && !defined(__APPLE__)
int pid, fd; int pid, fd;
char buf[20]; char buf[20];
if((fd = open("/dev/fuse", ORDWR)) < 0) if((fd = open("/dev/fuse", ORDWR)) < 0)
return -1; return -1;
snprint(buf, sizeof buf, "%d", fd); snprint(buf, sizeof buf, "%d", fd);
pid = fork(); pid = fork();
if(pid < 0) if(pid < 0)
return -1; return -1;
@ -903,7 +903,7 @@ mountfuse(char *mtpt)
_exit(1); _exit(1);
} }
return fd; return fd;
#else #else
werrstr("cannot mount fuse on this system"); werrstr("cannot mount fuse on this system");
return -1; return -1;

View File

@ -14,7 +14,7 @@
* writing the 9P connection. Thus the many threads in the * writing the 9P connection. Thus the many threads in the
* request proc can do 9P interactions without blocking. * request proc can do 9P interactions without blocking.
*/ */
#define _GNU_SOURCE 1 /* for O_DIRECTORY on Linux */ #define _GNU_SOURCE 1 /* for O_DIRECTORY on Linux */
#include "a.h" #include "a.h"
@ -165,16 +165,16 @@ init9p(char *addr, char *spec)
/* /*
* FUSE uses nodeids to refer to active "struct inodes" * FUSE uses nodeids to refer to active "struct inodes"
* (9P's unopened fids). FUSE uses fhs to refer to active * (9P's unopened fids). FUSE uses fhs to refer to active
* "struct fuse_files" (9P's opened fids). The choice of * "struct fuse_files" (9P's opened fids). The choice of
* numbers is up to us except that nodeid 1 is the root directory. * numbers is up to us except that nodeid 1 is the root directory.
* We use the same number space for both and call the * We use the same number space for both and call the
* bookkeeping structure a FuseFid. * bookkeeping structure a FuseFid.
* *
* FUSE requires nodeids to have associated generation * FUSE requires nodeids to have associated generation
* numbers. If we reuse a nodeid, we have to bump the * numbers. If we reuse a nodeid, we have to bump the
* generation number to guarantee that the nodeid,gen * generation number to guarantee that the nodeid,gen
* combination is never reused. * combination is never reused.
* *
* There are also inode numbers returned in directory reads * There are also inode numbers returned in directory reads
* and file attributes, but these do NOT need to match the nodeids. * and file attributes, but these do NOT need to match the nodeids.
* We use a combination of qid.path and qid.type as the inode * We use a combination of qid.path and qid.type as the inode
@ -192,7 +192,7 @@ struct Fusefid
int id; int id;
int gen; int gen;
int isnodeid; int isnodeid;
/* directory read state */ /* directory read state */
Dir *d0; Dir *d0;
Dir *d; Dir *d;
@ -208,7 +208,7 @@ Fusefid*
allocfusefid(void) allocfusefid(void)
{ {
Fusefid *f; Fusefid *f;
if((f = freefusefidlist) == nil){ if((f = freefusefidlist) == nil){
f = emalloc(sizeof *f); f = emalloc(sizeof *f);
fusefid = erealloc(fusefid, (nfusefid+1)*sizeof *fusefid); fusefid = erealloc(fusefid, (nfusefid+1)*sizeof *fusefid);
@ -247,7 +247,7 @@ uvlong
_alloc(CFid *fid, int isnodeid) _alloc(CFid *fid, int isnodeid)
{ {
Fusefid *ff; Fusefid *ff;
ff = allocfusefid(); ff = allocfusefid();
ff->fid = fid; ff->fid = fid;
ff->isnodeid = isnodeid; ff->isnodeid = isnodeid;
@ -283,7 +283,7 @@ CFid*
_lookupcfid(uvlong id, int isnodeid) _lookupcfid(uvlong id, int isnodeid)
{ {
Fusefid *ff; Fusefid *ff;
if((ff = lookupfusefid(id, isnodeid)) == nil) if((ff = lookupfusefid(id, isnodeid)) == nil)
return nil; return nil;
return ff->fid; return ff->fid;
@ -360,7 +360,7 @@ fuselookup(FuseMsg *m)
CFid *fid, *newfid; CFid *fid, *newfid;
Dir *d; Dir *d;
struct fuse_entry_out out; struct fuse_entry_out out;
name = m->tx; name = m->tx;
if((fid = nodeid2fid(m->hdr->nodeid)) == nil){ if((fid = nodeid2fid(m->hdr->nodeid)) == nil){
replyfuseerrno(m, ESTALE); replyfuseerrno(m, ESTALE);
@ -392,7 +392,7 @@ fuselookup(FuseMsg *m)
/* /*
* Forget. Reference-counted clunk for nodeids. * Forget. Reference-counted clunk for nodeids.
* Does not send a reply. * Does not send a reply.
* Each lookup response gives the kernel an additional reference * Each lookup response gives the kernel an additional reference
* to the returned nodeid. Forget says "drop this many references * to the returned nodeid. Forget says "drop this many references
* to this nodeid". Our fuselookup, when presented with the same query, * to this nodeid". Our fuselookup, when presented with the same query,
* does not return the same results (it allocates a new nodeid for each * does not return the same results (it allocates a new nodeid for each
@ -423,7 +423,7 @@ fuseforget(FuseMsg *m)
* Getattr. * Getattr.
* Replies with a fuse_attr_out structure giving the * Replies with a fuse_attr_out structure giving the
* attr for the requested nodeid in out.attr. * attr for the requested nodeid in out.attr.
* Out.attr_valid and out.attr_valid_nsec give * Out.attr_valid and out.attr_valid_nsec give
* the amount of time that the attributes can * the amount of time that the attributes can
* be cached. * be cached.
* *
@ -479,7 +479,7 @@ fusesetattr(FuseMsg *m)
/* /*
* Special case: Linux issues a size change to * Special case: Linux issues a size change to
* truncate a file before opening it OTRUNC. * truncate a file before opening it OTRUNC.
* Synthetic file servers (e.g., plumber) honor * Synthetic file servers (e.g., plumber) honor
* open(OTRUNC) but not wstat. * open(OTRUNC) but not wstat.
*/ */
if(in->valid == FATTR_SIZE && in->size == 0){ if(in->valid == FATTR_SIZE && in->size == 0){
@ -554,7 +554,7 @@ _fuseopenfid(uvlong nodeid, int isdir, int openmode, int *err)
*err = errstr2errno(); *err = errstr2errno();
return nil; return nil;
} }
if(fsfopen(newfid, openmode) < 0){ if(fsfopen(newfid, openmode) < 0){
*err = errstr2errno(); *err = errstr2errno();
fsclose(newfid); fsclose(newfid);
@ -617,7 +617,7 @@ _fuseopen(FuseMsg *m, int isdir)
return; return;
} }
out.fh = allocfh(fid); out.fh = allocfh(fid);
out.open_flags = FOPEN_DIRECT_IO; /* no page cache */ out.open_flags = FOPEN_DIRECT_IO; /* no page cache */
replyfuse(m, &out, sizeof out); replyfuse(m, &out, sizeof out);
} }
@ -696,7 +696,7 @@ fusemkdir(FuseMsg *m)
CFid *fid; CFid *fid;
int err; int err;
char *name; char *name;
in = m->tx; in = m->tx;
name = (char*)(in+1); name = (char*)(in+1);
if((fid = _fusecreate(m->hdr->nodeid, name, in->mode, 1, OREAD, &out, &err)) == nil){ if((fid = _fusecreate(m->hdr->nodeid, name, in->mode, 1, OREAD, &out, &err)) == nil){
@ -716,7 +716,7 @@ fusecreate(FuseMsg *m)
CFid *fid; CFid *fid;
int err, openmode, flags; int err, openmode, flags;
char *name; char *name;
in = m->tx; in = m->tx;
flags = in->flags; flags = in->flags;
openmode = in->flags&3; openmode = in->flags&3;
@ -740,7 +740,7 @@ fusecreate(FuseMsg *m)
} }
/* /*
* Access. * Access.
* Lib9pclient implements this just as Plan 9 does, * Lib9pclient implements this just as Plan 9 does,
* by opening the file (or not) and then closing it. * by opening the file (or not) and then closing it.
*/ */
@ -760,7 +760,7 @@ fuseaccess(FuseMsg *m)
ORDWR, ORDWR,
ORDWR ORDWR
}; };
in = m->tx; in = m->tx;
if(in->mask >= nelem(a2o)){ if(in->mask >= nelem(a2o)){
replyfuseerrno(m, EINVAL); replyfuseerrno(m, EINVAL);
@ -791,7 +791,7 @@ fuserelease(FuseMsg *m)
{ {
struct fuse_release_in *in; struct fuse_release_in *in;
Fusefid *ff; Fusefid *ff;
in = m->tx; in = m->tx;
if((ff = lookupfusefid(in->fh, 0)) != nil) if((ff = lookupfusefid(in->fh, 0)) != nil)
freefusefid(ff); freefusefid(ff);
@ -864,7 +864,7 @@ fusereadlink(FuseMsg *m)
return; return;
} }
/* /*
* Readdir. * Readdir.
* Read from file handle in->fh at offset in->offset for size in->size. * Read from file handle in->fh at offset in->offset for size in->size.
* We truncate size to maxwrite just to keep the buffer reasonable. * We truncate size to maxwrite just to keep the buffer reasonable.
@ -884,12 +884,12 @@ fusereaddir(FuseMsg *m)
uchar *buf, *p, *ep; uchar *buf, *p, *ep;
int n; int n;
Fusefid *ff; Fusefid *ff;
in = m->tx; in = m->tx;
if((ff = lookupfusefid(in->fh, 0)) == nil){ if((ff = lookupfusefid(in->fh, 0)) == nil){
replyfuseerrno(m, ESTALE); replyfuseerrno(m, ESTALE);
return; return;
} }
if(in->offset == 0){ if(in->offset == 0){
fsseek(ff->fid, 0, 0); fsseek(ff->fid, 0, 0);
free(ff->d0); free(ff->d0);
@ -922,7 +922,7 @@ fusereaddir(FuseMsg *m)
break; break;
ff->d = ff->d0; ff->d = ff->d0;
} }
out: out:
replyfuse(m, buf, p - buf); replyfuse(m, buf, p - buf);
free(buf); free(buf);
} }
@ -958,7 +958,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep)
uchar *p; uchar *p;
struct fuse_dirent *de; struct fuse_dirent *de;
int pad, size; int pad, size;
p = *pp; p = *pp;
size = FUSE_NAME_OFFSET + strlen(d->name); size = FUSE_NAME_OFFSET + strlen(d->name);
pad = 0; pad = 0;
@ -981,7 +981,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep)
* Write. * Write.
* Write from file handle in->fh at offset in->offset for size in->size. * Write from file handle in->fh at offset in->offset for size in->size.
* Don't know what in->write_flags means. * Don't know what in->write_flags means.
* *
* Apparently implementations are allowed to buffer these writes * Apparently implementations are allowed to buffer these writes
* and wait until Flush is sent, but FUSE docs say flush may be * and wait until Flush is sent, but FUSE docs say flush may be
* called zero, one, or even more times per close. So better do the * called zero, one, or even more times per close. So better do the
@ -996,7 +996,7 @@ fusewrite(FuseMsg *m)
void *a; void *a;
CFid *fid; CFid *fid;
int n; int n;
in = m->tx; in = m->tx;
a = in+1; a = in+1;
if((fid = fh2fid(in->fh)) == nil){ if((fid = fh2fid(in->fh)) == nil){
@ -1018,7 +1018,7 @@ fusewrite(FuseMsg *m)
/* /*
* Flush. Supposed to flush any buffered writes. Don't use this. * Flush. Supposed to flush any buffered writes. Don't use this.
* *
* Flush is a total crock. It gets called on close() of a file descriptor * Flush is a total crock. It gets called on close() of a file descriptor
* associated with this open file. Some open files have multiple file * associated with this open file. Some open files have multiple file
* descriptors and thus multiple closes of those file descriptors. * descriptors and thus multiple closes of those file descriptors.
@ -1027,7 +1027,7 @@ fusewrite(FuseMsg *m)
* closed explicitly. For those files, Flush is never called. * closed explicitly. For those files, Flush is never called.
* Even more amusing, Flush gets called before close() of read-only * Even more amusing, Flush gets called before close() of read-only
* file descriptors too! * file descriptors too!
* *
* This is just a bad idea. * This is just a bad idea.
*/ */
void void
@ -1044,7 +1044,7 @@ _fuseremove(FuseMsg *m, int isdir)
{ {
char *name; char *name;
CFid *fid, *newfid; CFid *fid, *newfid;
name = m->tx; name = m->tx;
if((fid = nodeid2fid(m->hdr->nodeid)) == nil){ if((fid = nodeid2fid(m->hdr->nodeid)) == nil){
replyfuseerrno(m, ESTALE); replyfuseerrno(m, ESTALE);
@ -1105,7 +1105,7 @@ fuserename(FuseMsg *m)
char *before, *after; char *before, *after;
CFid *fid, *newfid; CFid *fid, *newfid;
Dir d; Dir d;
in = m->tx; in = m->tx;
if(in->newdir != m->hdr->nodeid){ if(in->newdir != m->hdr->nodeid){
replyfuseerrno(m, EXDEV); replyfuseerrno(m, EXDEV);
@ -1146,7 +1146,7 @@ fusefsync(FuseMsg *m)
struct fuse_fsync_in *in; struct fuse_fsync_in *in;
CFid *fid; CFid *fid;
Dir d; Dir d;
in = m->tx; in = m->tx;
if((fid = fh2fid(in->fh)) == nil){ if((fid = fh2fid(in->fh)) == nil){
replyfuseerrno(m, ESTALE); replyfuseerrno(m, ESTALE);
@ -1181,7 +1181,7 @@ void
fusestatfs(FuseMsg *m) fusestatfs(FuseMsg *m)
{ {
struct fuse_statfs_out out; struct fuse_statfs_out out;
memset(&out, 0, sizeof out); memset(&out, 0, sizeof out);
replyfuse(m, &out, sizeof out); replyfuse(m, &out, sizeof out);
} }
@ -1215,7 +1215,7 @@ struct {
{ FUSE_FSYNC, fusefsync }, { FUSE_FSYNC, fusefsync },
/* /*
* FUSE_SETXATTR, FUSE_GETXATTR, FUSE_LISTXATTR, and * FUSE_SETXATTR, FUSE_GETXATTR, FUSE_LISTXATTR, and
* FUSE_REMOVEXATTR are unimplemented. * FUSE_REMOVEXATTR are unimplemented.
* FUSE will stop sending these requests after getting * FUSE will stop sending these requests after getting
* an -ENOSYS reply (see dispatch below). * an -ENOSYS reply (see dispatch below).
*/ */
@ -1237,7 +1237,7 @@ fusethread(void *v)
FuseMsg *m; FuseMsg *m;
m = v; m = v;
if((uint)m->hdr->opcode >= nelem(fusehandlers) if((uint)m->hdr->opcode >= nelem(fusehandlers)
|| !fusehandlers[m->hdr->opcode]){ || !fusehandlers[m->hdr->opcode]){
replyfuseerrno(m, ENOSYS); replyfuseerrno(m, ENOSYS);
return; return;
@ -1267,7 +1267,7 @@ fusedispatch(void *v)
case FUSE_FORGET: case FUSE_FORGET:
fusehandlers[m->hdr->opcode](m); fusehandlers[m->hdr->opcode](m);
break; break;
default: default:
threadcreate(fusethread, m, STACK); threadcreate(fusethread, m, STACK);
} }
} }

View File

@ -185,7 +185,7 @@ threadmain(int argc, char **argv)
logging++; logging++;
break; break;
}ARGEND }ARGEND
if(attached && !versioned){ if(attached && !versioned){
fprint(2, "-A must be used with -M\n"); fprint(2, "-A must be used with -M\n");
usage(); usage();
@ -258,7 +258,7 @@ mainproc(void *v)
/* if(rootfid) */ /* if(rootfid) */
/* dorootstat(); */ /* dorootstat(); */
threadcreate(listenthread, nil, STACK); threadcreate(listenthread, nil, STACK);
threadexits(0); threadexits(0);
} }
@ -302,7 +302,7 @@ listenthread(void *arg)
c->outqdead = chancreate(sizeof(void*), 0); c->outqdead = chancreate(sizeof(void*), 0);
if(verbose) fprint(2, "%T incoming call on %s\n", c->dir); if(verbose) fprint(2, "%T incoming call on %s\n", c->dir);
threadcreate(connthread, c, STACK); threadcreate(connthread, c, STACK);
} }
} }
void void
@ -348,7 +348,7 @@ char*
estrdup(char *s) estrdup(char *s)
{ {
char *t; char *t;
t = emalloc(strlen(s)+1); t = emalloc(strlen(s)+1);
strcpy(t, s); strcpy(t, s);
return t; return t;
@ -713,7 +713,7 @@ openfdthread(void *v)
chanfree(c->internal); chanfree(c->internal);
c->internal = 0; c->internal = 0;
free(c); free(c);
} }
int int
xopenfd(Msg *m) xopenfd(Msg *m)
@ -868,7 +868,7 @@ outputthread(void *arg)
closeioproc(io); closeioproc(io);
fprint(2, "%T output eof\n"); fprint(2, "%T output eof\n");
threadexitsall(0); threadexitsall(0);
} }
void void
inputthread(void *arg) inputthread(void *arg)
@ -1041,7 +1041,7 @@ msgnew(int x)
* Clear data associated with connections, so that * Clear data associated with connections, so that
* if all msgs have been msgcleared, the connection * if all msgs have been msgcleared, the connection
* can be freed. Note that this does *not* free the tpkt * can be freed. Note that this does *not* free the tpkt
* and rpkt; they are freed in msgput with the msg itself. * and rpkt; they are freed in msgput with the msg itself.
* The io write thread might still be holding a ref to msg * The io write thread might still be holding a ref to msg
* even once the connection has finished with it. * even once the connection has finished with it.
*/ */
@ -1080,7 +1080,7 @@ msgput(Msg *m)
if(m == nil) if(m == nil)
return; return;
if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n", if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n",
getcallerpc(&m), m, m->tag, m->ctag, m->ref); getcallerpc(&m), m, m->tag, m->ctag, m->ref);
assert(m->ref > 0); assert(m->ref > 0);
if(--m->ref > 0) if(--m->ref > 0)
@ -1296,7 +1296,7 @@ repack(Fcall *f, uchar **ppkt)
{ {
uint n, nn; uint n, nn;
uchar *pkt; uchar *pkt;
pkt = *ppkt; pkt = *ppkt;
n = GBIT32(pkt); n = GBIT32(pkt);
nn = sizeS2M(f); nn = sizeS2M(f);
@ -1305,7 +1305,7 @@ repack(Fcall *f, uchar **ppkt)
pkt = emalloc(nn); pkt = emalloc(nn);
*ppkt = pkt; *ppkt = pkt;
} }
n = convS2M(f, pkt, nn); n = convS2M(f, pkt, nn);
if(n <= BIT16SZ) if(n <= BIT16SZ)
sysfatal("convS2M conversion error"); sysfatal("convS2M conversion error");
if(n != nn) if(n != nn)
@ -1401,13 +1401,13 @@ ioaccept(Ioproc *io, int fd, char *dir)
int int
timefmt(Fmt *fmt) timefmt(Fmt *fmt)
{ {
static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
vlong ns; vlong ns;
Tm tm; Tm tm;
ns = nsec(); ns = nsec();
tm = *localtime(time(0)); tm = *localtime(time(0));
return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d",
mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec,
(int)(ns%1000000000)/1000000); (int)(ns%1000000000)/1000000);
} }

View File

@ -51,13 +51,13 @@ void
threadmain(int argc, char *argv[]) threadmain(int argc, char *argv[])
{ {
char *p; char *p;
rfork(RFNOTEG); rfork(RFNOTEG);
font = nil; font = nil;
_wantfocuschanges = 1; _wantfocuschanges = 1;
mainpid = getpid(); mainpid = getpid();
messagesize = 8192; messagesize = 8192;
ARGBEGIN{ ARGBEGIN{
default: default:
usage(); usage();
@ -80,7 +80,7 @@ threadmain(int argc, char *argv[])
winsize = EARGF(usage()); winsize = EARGF(usage());
break; break;
}ARGEND }ARGEND
if(fontname) if(fontname)
putenv("font", fontname); putenv("font", fontname);
@ -92,7 +92,7 @@ threadmain(int argc, char *argv[])
if(maxtab <= 0) if(maxtab <= 0)
maxtab = 4; maxtab = 4;
free(p); free(p);
startdir = "."; startdir = ".";
if(initdraw(derror, fontname, "9term") < 0) if(initdraw(derror, fontname, "9term") < 0)
@ -100,7 +100,7 @@ threadmain(int argc, char *argv[])
notify(hangupnote); notify(hangupnote);
noteenable("sys: child"); noteenable("sys: child");
mousectl = initmouse(nil, screen); mousectl = initmouse(nil, screen);
if(mousectl == nil) if(mousectl == nil)
error("cannot find mouse"); error("cannot find mouse");
@ -181,13 +181,13 @@ void
resizethread(void *v) resizethread(void *v)
{ {
Point p; Point p;
USED(v); USED(v);
for(;;){ for(;;){
p = stringsize(display->defaultfont, "0"); p = stringsize(display->defaultfont, "0");
if(p.x && p.y) if(p.x && p.y)
updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x, updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x,
Dx(screen->r), Dy(screen->r)); Dx(screen->r), Dy(screen->r));
wresize(w, screen, 0); wresize(w, screen, 0);
flushimage(display, 1); flushimage(display, 1);
@ -197,7 +197,7 @@ resizethread(void *v)
sysfatal("can't reattach to window"); sysfatal("can't reattach to window");
} }
} }
void void
mousethread(void *v) mousethread(void *v)
{ {
@ -229,7 +229,7 @@ mousethread(void *v)
bouncemouse(mouse); bouncemouse(mouse);
} }
} }
void void
wborder(Window *w, int type) wborder(Window *w, int type)
{ {
@ -405,7 +405,7 @@ rcoutputproc(void *arg)
Conswritemesg cwm; Conswritemesg cwm;
Rune *r; Rune *r;
Stringpair pair; Stringpair pair;
i = 0; i = 0;
cnt = 0; cnt = 0;
for(;;){ for(;;){
@ -432,11 +432,11 @@ rcoutputproc(void *arg)
if(nb < cnt) if(nb < cnt)
memmove(data, data+nb, cnt-nb); memmove(data, data+nb, cnt-nb);
cnt -= nb; cnt -= nb;
nr = label(r, nr); nr = label(r, nr);
if(nr == 0) if(nr == 0)
continue; continue;
recv(w->conswrite, &cwm); recv(w->conswrite, &cwm);
pair.s = r; pair.s = r;
pair.ns = nr; pair.ns = nr;
@ -448,7 +448,7 @@ void
winterrupt(Window *w) winterrupt(Window *w)
{ {
char rubout[1]; char rubout[1];
USED(w); USED(w);
rubout[0] = getintr(sfd); rubout[0] = getintr(sfd);
write(rcfd, rubout, 1); write(rcfd, rubout, 1);
@ -474,7 +474,7 @@ label(Rune *sr, int n)
{ {
Rune *sl, *el, *er, *r; Rune *sl, *el, *er, *r;
char *p, *dir; char *p, *dir;
er = sr+n; er = sr+n;
for(r=er-1; r>=sr; r--) for(r=er-1; r>=sr; r--)
if(*r == '\007') if(*r == '\007')
@ -527,7 +527,7 @@ rcinputproc(void *arg)
recv(w->consread, &crm); recv(w->consread, &crm);
c1 = crm.c1; c1 = crm.c1;
c2 = crm.c2; c2 = crm.c2;
pair.s = data; pair.s = data;
pair.ns = sizeof data; pair.ns = sizeof data;
send(c1, &pair); send(c1, &pair);
@ -547,7 +547,7 @@ void
rioputsnarf(void) rioputsnarf(void)
{ {
char *s; char *s;
s = smprint("%.*S", nsnarf, snarf); s = smprint("%.*S", nsnarf, snarf);
if(s){ if(s){
putsnarf(s); putsnarf(s);
@ -648,7 +648,7 @@ textproc(void *arg)
for(x=0; x<p-buf; x+=n) for(x=0; x<p-buf; x+=n)
if((n = write(fd, buf+x, (p-x)-buf)) <= 0) if((n = write(fd, buf+x, (p-x)-buf)) <= 0)
goto break2; goto break2;
if(i >= end) if(i >= end)
break; break;
p = buf; p = buf;
@ -664,4 +664,3 @@ textproc(void *arg)
break2: break2:
close(fd); close(fd);
} }

View File

@ -84,4 +84,3 @@ getintr(int fd)
return 0x7F; return 0x7F;
return ttmode.c_cc[VINTR]; return ttmode.c_cc[VINTR];
} }

View File

@ -20,7 +20,7 @@ static char *abc =
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"; "0123456789";
static char *_123 = static char *_123 =
"0123456789" "0123456789"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@ -111,4 +111,3 @@ getintr(int fd)
return 0x7F; return 0x7F;
return ttmode.c_cc[VINTR]; return ttmode.c_cc[VINTR];
} }

View File

@ -91,8 +91,8 @@ struct Mouseinfo
ulong counter; /* serial no. of last mouse event we received */ ulong counter; /* serial no. of last mouse event we received */
ulong lastcounter; /* serial no. of last mouse event sent to client */ ulong lastcounter; /* serial no. of last mouse event sent to client */
int lastb; /* last button state we received */ int lastb; /* last button state we received */
uchar qfull; /* filled the queue; no more recording until client comes back */ uchar qfull; /* filled the queue; no more recording until client comes back */
}; };
struct Window struct Window
{ {

View File

@ -48,121 +48,121 @@ Cursor sightcursor = {
Cursor whitearrow = { Cursor whitearrow = {
{0, 0}, {0, 0},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC,
0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, }, 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, },
{0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C, {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C,
0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C, 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C,
0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C, 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C,
0xD3, 0xB8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, } 0xD3, 0xB8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, }
}; };
Cursor query = { Cursor query = {
{-7,-7}, {-7,-7},
{0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe,
0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8,
0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0,
0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, }, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, },
{0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c,
0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0,
0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80,
0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, }
}; };
Cursor tl = { Cursor tl = {
{-4, -4}, {-4, -4},
{0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff, {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff,
0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff, 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff,
0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x1f, 0x00, }, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x1f, 0x00, },
{0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00, {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00,
0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00, 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00,
0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, } 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, }
}; };
Cursor t = { Cursor t = {
{-7, -8}, {-7, -8},
{0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0,
0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f, 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f,
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80,
0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }
}; };
Cursor tr = { Cursor tr = {
{-11, -4}, {-11, -4},
{0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1, {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1,
0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88, 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88,
0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88,
0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xf8, }, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xf8, },
{0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e, {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e,
0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70, 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70,
0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, } 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, }
}; };
Cursor r = { Cursor r = {
{-8, -7}, {-8, -7},
{0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58, {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58,
0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02, 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02,
0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58, 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58,
0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x07, 0xc0, }, 0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x07, 0xc0, },
{0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc, 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc,
0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80, 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, }
}; };
Cursor br = { Cursor br = {
{-11, -11}, {-11, -11},
{0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05, 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05,
0xff, 0xe1, 0x00, 0x31, 0x00, 0x41, 0x00, 0x7f, }, 0xff, 0xe1, 0x00, 0x31, 0x00, 0x41, 0x00, 0x7f, },
{0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa, 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa,
0x00, 0x1e, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0x00, } 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0x00, }
}; };
Cursor b = { Cursor b = {
{-7, -7}, {-7, -7},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70, 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70,
0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, }, 0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe,
0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }
}; };
Cursor bl = { Cursor bl = {
{-4, -11}, {-4, -11},
{0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01, 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01,
0x87, 0xff, 0x8c, 0x00, 0x82, 0x00, 0xfe, 0x00, }, 0x87, 0xff, 0x8c, 0x00, 0x82, 0x00, 0xfe, 0x00, },
{0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe, 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe,
0x78, 0x00, 0x70, 0x00, 0x7c, 0x00, 0x00, 0x0, } 0x78, 0x00, 0x70, 0x00, 0x7c, 0x00, 0x00, 0x0, }
}; };
Cursor l = { Cursor l = {
{-7, -7}, {-7, -7},
{0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20, {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20,
0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20, 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20,
0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20, 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20,
0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x03, 0xe0, }, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x03, 0xe0, },
{0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0,
0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0,
0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0, 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0,
0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, } 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, }
}; };

View File

@ -39,4 +39,3 @@ int intrc(void);
void rioputsnarf(void); void rioputsnarf(void);
void riogetsnarf(void); void riogetsnarf(void);

View File

@ -13,7 +13,7 @@ void*
p9malloc(ulong n) p9malloc(ulong n)
{ {
void *v; void *v;
if(n == 0) if(n == 0)
n++; n++;
lock(&malloclock); lock(&malloclock);
@ -38,7 +38,7 @@ void*
p9calloc(ulong a, ulong b) p9calloc(ulong a, ulong b)
{ {
void *v; void *v;
if(a*b == 0) if(a*b == 0)
a = b = 1; a = b = 1;
@ -53,11 +53,10 @@ void*
p9realloc(void *v, ulong n) p9realloc(void *v, ulong n)
{ {
void *vv; void *vv;
lock(&malloclock); lock(&malloclock);
vv = realloc(v, n); vv = realloc(v, n);
unlock(&malloclock); unlock(&malloclock);
print("p9realloc %p %lud => %p; pc %lux\n", v, n, vv, getcallerpc(&v)); print("p9realloc %p %lud => %p; pc %lux\n", v, n, vv, getcallerpc(&v));
return vv; return vv;
} }

View File

@ -69,15 +69,15 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
} }
/* /*
* notedisable("sys: window size change"); * notedisable("sys: window size change");
* *
* Can't disable because will be inherited by other programs * Can't disable because will be inherited by other programs
* like if you run an xterm from the prompt, and then xterm's * like if you run an xterm from the prompt, and then xterm's
* resizes won't get handled right. Sigh. * resizes won't get handled right. Sigh.
* *
* Can't not disable because when we stty below we'll get a * Can't not disable because when we stty below we'll get a
* signal, which will drop us into the thread library note handler, * signal, which will drop us into the thread library note handler,
* which will get all confused because we just forked and thus * which will get all confused because we just forked and thus
* have an unknown pid. * have an unknown pid.
* *
* So disable it internally. ARGH! * So disable it internally. ARGH!
*/ */
@ -145,7 +145,7 @@ echoed(char *p, int n)
if(echo.w+n > sizeof echo.buf) if(echo.w+n > sizeof echo.buf)
n = 0; n = 0;
memmove(echo.buf+echo.w, p, n); memmove(echo.buf+echo.w, p, n);
echo.w += n; echo.w += n;
unlock(&echo.l); unlock(&echo.l);
} }

View File

@ -146,4 +146,3 @@ runetobyte(Rune *r, int n, int *ip)
*ip = m; *ip = m;
return s; return s;
} }

View File

@ -134,7 +134,7 @@ threadmain(int argc, char **argv)
char buf1[128]; char buf1[128];
CFsys *fs; CFsys *fs;
char *dump; char *dump;
dump = onestring(argc, argv); dump = onestring(argc, argv);
ARGBEGIN{ ARGBEGIN{
@ -215,7 +215,7 @@ threadmain(int argc, char **argv)
fswrite(ctlfd, buf, strlen(buf)); fswrite(ctlfd, buf, strlen(buf));
sprint(buf, "scroll"); sprint(buf, "scroll");
fswrite(ctlfd, buf, strlen(buf)); fswrite(ctlfd, buf, strlen(buf));
updatewinsize(25, 80, 0, 0); updatewinsize(25, 80, 0, 0);
proccreate(stdoutproc, nil, STACK); proccreate(stdoutproc, nil, STACK);
stdinproc(nil); stdinproc(nil);
@ -225,7 +225,7 @@ void
error(char *s, ...) error(char *s, ...)
{ {
va_list arg; va_list arg;
if(s){ if(s){
va_start(arg, s); va_start(arg, s);
s = vsmprint(s, arg); s = vsmprint(s, arg);
@ -378,11 +378,11 @@ stdinproc(void *v)
fprint(2, "shift typing %d... ", e.q1-e.q0); fprint(2, "shift typing %d... ", e.q1-e.q0);
q.p += e.q1-e.q0; q.p += e.q1-e.q0;
break; break;
case 'i': case 'i':
case 'd': /* tag */ case 'd': /* tag */
break; break;
default: default:
goto Unknown; goto Unknown;
} }
@ -484,7 +484,7 @@ dropcr(char *p, int n)
{ {
int i; int i;
char *w, *r, *q; char *w, *r, *q;
r = p; r = p;
w = p; w = p;
for(i=0; i<n; i++) { for(i=0; i<n; i++) {
@ -538,15 +538,15 @@ stdoutproc(void *v)
n = read(fd1, buf+npart, 8192); n = read(fd1, buf+npart, 8192);
if(n <= 0) if(n <= 0)
error(nil); error(nil);
n = echocancel(buf+npart, n); n = echocancel(buf+npart, n);
if(n == 0) if(n == 0)
continue; continue;
n = dropcrnl(buf+npart, n); n = dropcrnl(buf+npart, n);
if(n == 0) if(n == 0)
continue; continue;
n = dropcr(buf+npart, n); n = dropcr(buf+npart, n);
if(n == 0) if(n == 0)
continue; continue;
@ -581,13 +581,13 @@ stdoutproc(void *v)
buf[n] = 0; buf[n] = 0;
n = label(buf, n); n = label(buf, n);
buf[n] = 0; buf[n] = 0;
// clumsy but effective: notice password // clumsy but effective: notice password
// prompts so we can disable echo. // prompts so we can disable echo.
password = 0; password = 0;
if(cistrstr(buf, "password") || cistrstr(buf, "passphrase")) { if(cistrstr(buf, "password") || cistrstr(buf, "passphrase")) {
int i; int i;
i = n; i = n;
while(i > 0 && buf[i-1] == ' ') while(i > 0 && buf[i-1] == ' ')
i--; i--;
@ -743,7 +743,7 @@ void
sendtype(int fd0) sendtype(int fd0)
{ {
int i, n, nr, raw; int i, n, nr, raw;
raw = israw(fd0); raw = israw(fd0);
while(ntypebreak || (raw && ntypeb > 0)){ while(ntypebreak || (raw && ntypeb > 0)){
for(i=0; i<ntypeb; i++) for(i=0; i<ntypeb; i++)

View File

@ -101,7 +101,7 @@ wsetname(Window *w)
{ {
int i, n; int i, n;
char err[ERRMAX]; char err[ERRMAX];
n = sprint(w->name, "window.%d.%d", w->id, w->namecount++); n = sprint(w->name, "window.%d.%d", w->id, w->namecount++);
for(i='A'; i<='Z'; i++){ for(i='A'; i<='Z'; i++){
if(nameimage(w->i, w->name, 1) > 0) if(nameimage(w->i, w->name, 1) > 0)
@ -224,7 +224,7 @@ winctl(void *arg)
crm.c2 = chancreate(sizeof(Stringpair), 0); crm.c2 = chancreate(sizeof(Stringpair), 0);
cwrm.c1 = chancreate(sizeof(Stringpair), 0); cwrm.c1 = chancreate(sizeof(Stringpair), 0);
cwrm.c2 = chancreate(sizeof(Stringpair), 0); cwrm.c2 = chancreate(sizeof(Stringpair), 0);
alts[WKey].c = w->ck; alts[WKey].c = w->ck;
alts[WKey].v = &kbdr; alts[WKey].v = &kbdr;
@ -803,7 +803,7 @@ wbswidth(Window *w, Rune c)
if(r == '\n'){ /* eat at most one more character */ if(r == '\n'){ /* eat at most one more character */
if(q == w->q0 && c != '\r') /* eat the newline */ if(q == w->q0 && c != '\r') /* eat the newline */
--q; --q;
break; break;
} }
if(c == 0x17){ if(c == 0x17){
eq = isalnum(r); eq = isalnum(r);
@ -1382,15 +1382,15 @@ wsetpid(Window *w, int pid, int dolabel)
} }
} }
static Rune left1[] = { static Rune left1[] = {
'{', '[', '(', '<', 0xAB, '{', '[', '(', '<', 0xAB,
0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea, 0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea,
0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b, 0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b,
0 0
}; };
static Rune right1[] = { static Rune right1[] = {
'}', ']', ')', '>', 0xBB, '}', ']', ')', '>', 0xBB,
0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb, 0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb,
0xfe5a, 0xfe5c, 0xfe5e, 0xff09, 0xff3d, 0xff5d, 0xfe5a, 0xfe5c, 0xfe5e, 0xff09, 0xff3d, 0xff5d,
0 0
}; };

View File

@ -635,7 +635,7 @@ includepipe(Node *r, Node *args)
if(pipe(pip) < 0) if(pipe(pip) < 0)
error("pipe: %r"); error("pipe: %r");
pid = fork(); pid = fork();
switch(pid) { switch(pid) {
case -1: case -1:
@ -657,7 +657,7 @@ includepipe(Node *r, Node *args)
close(pip[1]); close(pip[1]);
pushfd(pip[0]); pushfd(pip[0]);
isave = interactive; isave = interactive;
interactive = 0; interactive = 0;
r->store.u.ival = yyparse(); r->store.u.ival = yyparse();
@ -746,7 +746,7 @@ doaccess(Node *r, Node *args)
r->op = OCONST; r->op = OCONST;
r->type = TINT; r->type = TINT;
r->store.fmt = 'D'; r->store.fmt = 'D';
r->store.u.ival = 0; r->store.u.ival = 0;
if(access(res.store.u.string->string, 4) == 0) if(access(res.store.u.string->string, 4) == 0)
r->store.u.ival = 1; r->store.u.ival = 1;
} }
@ -974,7 +974,7 @@ map(Node *r, Node *args)
i = findseg(m, nam, fil); i = findseg(m, nam, fil);
} }
if(i < 0) if(i < 0)
error("%s %s is not a map entry", nam, fil); error("%s %s is not a map entry", nam, fil);
l = l->next; l = l->next;
if(l->type != TINT) if(l->type != TINT)
error("map entry not int"); error("map entry not int");
@ -1008,7 +1008,7 @@ map(Node *r, Node *args)
} }
} }
void void
flatten(Node **av, Node *n) flatten(Node **av, Node *n)
{ {
if(n == 0) if(n == 0)
@ -1086,7 +1086,7 @@ strace(Node *r, Node *args)
l = l->next; l = l->next;
} }
regs.rw = straceregrw; regs.rw = straceregrw;
tracelist = 0; tracelist = 0;
if(stacktrace(cormap, &regs, trlist) <= 0) if(stacktrace(cormap, &regs, trlist) <= 0)
error("no stack frame"); error("no stack frame");
@ -1482,7 +1482,7 @@ pcfile(Node *r, Node *args)
if(p == 0) if(p == 0)
error("pcfile(addr): funny file %s", buf); error("pcfile(addr): funny file %s", buf);
*p = '\0'; *p = '\0';
r->store.u.string = strnode(buf); r->store.u.string = strnode(buf);
} }
void void
@ -1507,7 +1507,7 @@ pcline(Node *r, Node *args)
p = strrchr(buf, ':'); p = strrchr(buf, ':');
if(p == 0) if(p == 0)
error("pcline(addr): funny file %s", buf); error("pcline(addr): funny file %s", buf);
r->store.u.ival = atoi(p+1); r->store.u.ival = atoi(p+1);
} }
void void

View File

@ -46,9 +46,9 @@ odot(Node *n, Node *r)
error("no tag for (expr).%s", s); error("no tag for (expr).%s", s);
/* Propagate types */ /* Propagate types */
if(t->type) if(t->type)
r->store.comt = t->type->lt; r->store.comt = t->type->lt;
addr = res.store.u.ival+t->offset; addr = res.store.u.ival+t->offset;
if(t->fmt == 'a') { if(t->fmt == 'a') {
r->op = OCONST; r->op = OCONST;
@ -56,7 +56,7 @@ odot(Node *n, Node *r)
r->type = TINT; r->type = TINT;
r->store.u.ival = addr; r->store.u.ival = addr;
} }
else else
indir(cormap, addr, t->fmt, r); indir(cormap, addr, t->fmt, r);
} }
@ -74,7 +74,7 @@ buildtype(Node *m, int d)
switch(m->op) { switch(m->op) {
case OLIST: case OLIST:
buildtype(m->left, d); buildtype(m->left, d);
buildtype(m->right, d); buildtype(m->right, d);
break; break;
@ -90,7 +90,7 @@ buildtype(Node *m, int d)
t->offset = m->store.u.ival; t->offset = m->store.u.ival;
if(m->left) { if(m->left) {
t->type = m->left->sym; t->type = m->left->sym;
t->fmt = 'a'; t->fmt = 'a';
} }
else { else {
t->type = 0; t->type = 0;
@ -101,7 +101,7 @@ buildtype(Node *m, int d)
*tail = t; *tail = t;
tail = &t->next; tail = &t->next;
} }
} }
void void

View File

@ -74,7 +74,7 @@ chklval(Node *lp)
if(lp->op == OCALL){ if(lp->op == OCALL){
s = chklval(lp->left); s = chklval(lp->left);
if(strcmp(s->name, "var") == 0 if(strcmp(s->name, "var") == 0
&& (lp->builtin || s->proc == 0)){ && (lp->builtin || s->proc == 0)){
if(lp->right == 0) if(lp->right == 0)
error("var(string): arg count"); error("var(string): arg count");
@ -85,7 +85,7 @@ chklval(Node *lp)
} }
} }
error("need l-value"); error("need l-value");
return nil; return nil;
} }
void void
@ -177,7 +177,7 @@ oframe(Node *n, Node *res)
lp = n->left; lp = n->left;
if(localaddr(cormap, acidregs, p, lp->sym->name, &ival) < 0) if(localaddr(cormap, acidregs, p, lp->sym->name, &ival) < 0)
error("colon: %r"); error("colon: %r");
res->store.u.ival = ival; res->store.u.ival = ival;
res->op = OCONST; res->op = OCONST;
res->store.fmt = 'X'; res->store.fmt = 'X';
@ -397,7 +397,7 @@ oadd(Node *n, Node *res)
if(r.type == TSTRING) { if(r.type == TSTRING) {
res->type = TSTRING; res->type = TSTRING;
res->store.fmt = 's'; res->store.fmt = 's';
res->store.u.string = stradd(l.store.u.string, r.store.u.string); res->store.u.string = stradd(l.store.u.string, r.store.u.string);
break; break;
} }
error("bad rhs for +"); error("bad rhs for +");
@ -916,7 +916,7 @@ oeinc(Node *n, Node *res)
v->store.u.ival -= fmtsize(v); v->store.u.ival -= fmtsize(v);
else else
v->store.u.ival += fmtsize(v); v->store.u.ival += fmtsize(v);
break; break;
case TFLOAT: case TFLOAT:
if(n->op == OEDEC) if(n->op == OEDEC)
v->store.u.fval--; v->store.u.fval--;
@ -944,7 +944,7 @@ opinc(Node *n, Node *res)
v->store.u.ival -= fmtsize(v); v->store.u.ival -= fmtsize(v);
else else
v->store.u.ival += fmtsize(v); v->store.u.ival += fmtsize(v);
break; break;
case TFLOAT: case TFLOAT:
if(n->op == OPDEC) if(n->op == OPDEC)
v->store.u.fval--; v->store.u.fval--;

View File

@ -61,7 +61,7 @@ kinit(void)
initcmap(); initcmap();
for(i = 0; keywds[i].name; i++) for(i = 0; keywds[i].name; i++)
enter(keywds[i].name, keywds[i].terminal); enter(keywds[i].name, keywds[i].terminal);
} }
@ -415,7 +415,7 @@ loop:
return numsym('.'); return numsym('.');
return '.'; return '.';
case '(': case '(':
case ')': case ')':
case '[': case '[':
@ -671,7 +671,7 @@ delsym(Lsym *s)
for(q = s->name; *q; q++) for(q = s->name; *q; q++)
h = h*3 + *q; h = h*3 + *q;
h %= Hashsize; h %= Hashsize;
if(hash[h] == s) if(hash[h] == s)
hash[h] = s->hash; hash[h] = s->hash;
else{ else{

View File

@ -54,7 +54,7 @@ build(Node *n)
l = al(res.type); l = al(res.type);
l->store = res.store; l->store = res.store;
*tail = l; *tail = l;
tail = &l->next; tail = &l->next;
} }
} }

View File

@ -92,7 +92,7 @@ main(int argc, char *argv[])
default: default:
usage(); usage();
}ARGEND }ARGEND
USED(pid); USED(pid);
fmtinstall('Z', Zfmt); fmtinstall('Z', Zfmt);
@ -198,7 +198,7 @@ attachfiles(int argc, char **argv)
pid = 0; pid = 0;
interactive = 0; interactive = 0;
USED(pid); USED(pid);
if(setjmp(err)) if(setjmp(err))
return -1; return -1;

View File

@ -29,7 +29,7 @@ sproc(int xpid)
free(correg); free(correg);
correg = regs; correg = regs;
}else{ }else{
/* XXX should only change register set here if cormap already mapped */ /* XXX should only change register set here if cormap already mapped */
if(xpid <= 0) if(xpid <= 0)
error("bad pid"); error("bad pid");
unmapproc(cormap); unmapproc(cormap);
@ -245,4 +245,3 @@ getstatus(int pid)
{ {
return "unknown"; return "unknown";
} }

View File

@ -40,7 +40,7 @@ unique(char *buf, Symbol *s)
if(l == 0) if(l == 0)
l = enter(buf, Tid); l = enter(buf, Tid);
s->aux = l; s->aux = l;
return l; return l;
} }
void void
@ -122,22 +122,22 @@ addvarsym(Fhdr *fp)
tl->store.u.l = list; tl->store.u.l = list;
list->store.u.string = strnode(buf); list->store.u.string = strnode(buf);
list->store.fmt = 's'; list->store.fmt = 's';
list->next = al(TINT); list->next = al(TINT);
list = list->next; list = list->next;
list->store.fmt = 'c'; list->store.fmt = 'c';
list->store.u.ival = s.type; list->store.u.ival = s.type;
list->next = al(TINT); list->next = al(TINT);
list = list->next; list = list->next;
list->store.fmt = 'X'; list->store.fmt = 'X';
list->store.u.ival = v; list->store.u.ival = v;
list->next = al(TSTRING); list->next = al(TSTRING);
list = list->next; list = list->next;
list->store.fmt = 's'; list->store.fmt = 's';
list->store.u.string = file; list->store.u.string = file;
list->next = al(TSTRING); list->next = al(TSTRING);
list = list->next; list = list->next;
list->store.fmt = 's'; list->store.fmt = 's';

View File

@ -9,7 +9,7 @@ enum
Base, Base,
Enum, Enum,
Aggr, Aggr,
Function, Function,
Pointer, Pointer,
Array, Array,
Range, Range,
@ -92,4 +92,3 @@ int Bfmt(Fmt*);
#ifdef VARARGCK #ifdef VARARGCK
#pragma varargck type "B" char* #pragma varargck type "B" char*
#endif #endif

View File

@ -183,4 +183,3 @@ ds2acid(Dwarf *d, DwarfSym *s, Biobuf *b, char *fn)
break; break;
} }
} }

View File

@ -64,7 +64,7 @@ main(int argc, char **argv)
} }
have = 1; have = 1;
} }
if(!have){ if(!have){
Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]); Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]);
/* fprint(2, "no debugging symbols in %s\n", argv[i]); */ /* fprint(2, "no debugging symbols in %s\n", argv[i]); */
@ -75,4 +75,3 @@ main(int argc, char **argv)
Bterm(&b); Bterm(&b);
exits(0); exits(0);
} }

View File

@ -192,7 +192,7 @@ parsenum(char *p, int *n1, int *n2, char **pp)
/* /*
attr ::= '@' text ';' attr ::= '@' text ';'
text is text is
'a' integer (alignment) 'a' integer (alignment)
'p' integer (pointer class) 'p' integer (pointer class)
'P' (packed type) 'P' (packed type)
@ -237,7 +237,7 @@ static Basic baseints[] =
/*13*/ 8, 'f', /* double */ /*13*/ 8, 'f', /* double */
/*14*/ 10, 'f', /* long double */ /*14*/ 10, 'f', /* long double */
/*15*/ 4, 'd', /* int32 */ /*15*/ 4, 'd', /* int32 */
/*16*/ 4, 'd', /* bool32 */ /*16*/ 4, 'd', /* bool32 */
/*17*/ 2, 'f', /* short real */ /*17*/ 2, 'f', /* short real */
/*18*/ 4, 'f', /* real */ /*18*/ 4, 'f', /* real */
/*19*/ 4, 'x', /* stringptr */ /*19*/ 4, 'x', /* stringptr */
@ -391,7 +391,7 @@ parsedefn(char *p, Type *t, char **pp)
t->ty = Pointer; t->ty = Pointer;
t->sub = parseinfo(p+1, &p); t->sub = parseinfo(p+1, &p);
break; break;
case 'a': /* array */ case 'a': /* array */
case 'P': /* packed array */ case 'P': /* packed array */
t->ty = Pointer; t->ty = Pointer;
tt = newtype(); tt = newtype();
@ -422,7 +422,7 @@ parsedefn(char *p, Type *t, char **pp)
} }
semi(&p); semi(&p);
break; break;
case 's': /* struct */ case 's': /* struct */
case 'u': /* union */ case 'u': /* union */
p++; p++;
@ -532,7 +532,7 @@ parsedefn(char *p, Type *t, char **pp)
} }
/* /*
bound ::= bound ::=
'A' offset (bound is on stack by ref at offset offset from arg list) 'A' offset (bound is on stack by ref at offset offset from arg list)
| 'T' offset (bound is on stack by val at offset offset from arg list) | 'T' offset (bound is on stack by val at offset offset from arg list)
| 'a' regnum (bound passed by reference in register) | 'a' regnum (bound passed by reference in register)
@ -642,7 +642,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
fno++; fno++;
if((f = findftypes(dir, sym.name)) == nil){ if((f = findftypes(dir, sym.name)) == nil){
static int cannotprint; static int cannotprint;
if(cannotprint++ == 0) if(cannotprint++ == 0)
fprint(2, "cannot find remembered %s\n", sym.name); fprint(2, "cannot find remembered %s\n", sym.name);
continue; continue;
@ -673,7 +673,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
} }
if(setjmp(kaboom)){ if(setjmp(kaboom)){
static int cannotparse; static int cannotparse;
if(cannotparse++ == 0) if(cannotparse++ == 0)
fprint(2, "cannot parse %s\n", name); fprint(2, "cannot parse %s\n", name);
continue; continue;
@ -683,7 +683,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
continue; continue;
if(*p != 0){ if(*p != 0){
static int extradesc; static int extradesc;
if(extradesc++ == 0) if(extradesc++ == 0)
fprint(2, "extra desc '%s' in '%s'\n", p, desc); fprint(2, "extra desc '%s' in '%s'\n", p, desc);
} }

View File

@ -95,7 +95,7 @@ typebynum(uint n1, uint n2)
t->n2 = n2; t->n2 = n2;
addhash(t); addhash(t);
return t; return t;
} }
Type* Type*
newtype(void) newtype(void)
@ -251,10 +251,10 @@ cleanstl(char *name)
{ {
char *b, *p; char *b, *p;
static char buf[65536]; /* These can be huge. */ static char buf[65536]; /* These can be huge. */
if(strchr(name, '<') == nil) if(strchr(name, '<') == nil)
return nonempty(name); return nonempty(name);
b = buf; b = buf;
for(p = name; *p != 0; p++){ for(p = name; *p != 0; p++){
switch(*p){ switch(*p){
@ -443,7 +443,7 @@ char*
mkname(char *prefix, char *name) mkname(char *prefix, char *name)
{ {
static char buf[65536]; static char buf[65536];
snprint(buf, sizeof buf, "%s%s", prefix, name); snprint(buf, sizeof buf, "%s%s", prefix, name);
return buf; return buf;
} }
@ -630,7 +630,7 @@ ttt=ttt->sub;
if(nprint == 0) if(nprint == 0)
Bprint(b, "\t'X' 0 __dummy;\n"); Bprint(b, "\t'X' 0 __dummy;\n");
Bprint(b, "};\n\n"); Bprint(b, "};\n\n");
name = nameof(t, 1); /* might have smashed it */ name = nameof(t, 1); /* might have smashed it */
Bprint(b, "defn %B(addr) { %B(addr, \"\"); }\n", name, mkname("indent_", name)); Bprint(b, "defn %B(addr) { %B(addr, \"\"); }\n", name, mkname("indent_", name));
Bprint(b, "defn %B(addr, indent) {\n", mkname("indent_", name)); Bprint(b, "defn %B(addr, indent) {\n", mkname("indent_", name));
@ -675,13 +675,13 @@ ttt=ttt->sub;
} }
Bprint(b, "};\n\n"); Bprint(b, "};\n\n");
break; break;
case Enum: case Enum:
name = nameof(t, 1); name = nameof(t, 1);
Bprint(b, "// enum %s\n", name); Bprint(b, "// enum %s\n", name);
for(j=0; j<t->n; j++) for(j=0; j<t->n; j++)
Bprint(b, "%B = %ld;\n", fixname(t->tname[j]), t->val[j]); Bprint(b, "%B = %ld;\n", fixname(t->tname[j]), t->val[j]);
Bprint(b, "%B = {\n", mkname("vals_", name)); Bprint(b, "%B = {\n", mkname("vals_", name));
for(j=0; j<t->n; j++) for(j=0; j<t->n; j++)
Bprint(b, "\t%lud,\n", t->val[j]); Bprint(b, "\t%lud,\n", t->val[j]);
@ -738,7 +738,7 @@ printtypes(Biobuf *b)
* only take one type of a given name; acid is going to do this anyway, * only take one type of a given name; acid is going to do this anyway,
* and this will reduce the amount of code we output considerably. * and this will reduce the amount of code we output considerably.
* we could run a DFA equivalence relaxation sort of algorithm * we could run a DFA equivalence relaxation sort of algorithm
* to find the actual equivalence classes, and then rename types * to find the actual equivalence classes, and then rename types
* appropriately, but this will do for now. * appropriately, but this will do for now.
*/ */
all = emalloc(n*sizeof(all[0])); all = emalloc(n*sizeof(all[0]));

View File

@ -68,7 +68,7 @@ Bfmt(Fmt *fmt)
{ {
int i; int i;
char *s, *t; char *s, *t;
if(!isBfrog['.']){ if(!isBfrog['.']){
for(i=0; i<256; i++) for(i=0; i<256; i++)
if(i != '_' && i != '$' && i < Runeself && !isalnum(i)) if(i != '_' && i != '$' && i < Runeself && !isalnum(i))

View File

@ -968,69 +968,69 @@ Cursor boxcursor = {
Cursor2 boxcursor2 = { Cursor2 boxcursor2 = {
{-15, -15}, {-15, -15},
{0xFF, 0xFF, 0xFF, 0xFF, {0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF}, 0xFF, 0xFF, 0xFF, 0xFF},
{0x00, 0x00, 0x00, 0x00, {0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x3F, 0xFF, 0xFF, 0xFC, 0x3F, 0xFF, 0xFF, 0xFC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00} 0x00, 0x00, 0x00, 0x00}
}; };
@ -1047,7 +1047,7 @@ iconinit(void)
tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue); tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue);
tagcols[TEXT] = display->black; tagcols[TEXT] = display->black;
tagcols[HTEXT] = display->black; tagcols[HTEXT] = display->black;
/* Yellow */ /* Yellow */
textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite); textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow); textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
@ -1055,7 +1055,7 @@ iconinit(void)
textcols[TEXT] = display->black; textcols[TEXT] = display->black;
textcols[HTEXT] = display->black; textcols[HTEXT] = display->black;
} }
r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1); r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1);
if(button && eqrect(r, button->r)) if(button && eqrect(r, button->r))
return; return;
@ -1169,4 +1169,3 @@ timefmt(Fmt *f)
return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d", return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d",
tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec); tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec);
} }

View File

@ -89,19 +89,19 @@ coladd(Column *c, Window *w, Window *clone, int y)
/* /*
* figure out where to split v to make room for w * figure out where to split v to make room for w
*/ */
/* new window stops where next window begins */ /* new window stops where next window begins */
if(i < c->nw) if(i < c->nw)
ymax = c->w[i]->r.min.y-Border; ymax = c->w[i]->r.min.y-Border;
else else
ymax = c->r.max.y; ymax = c->r.max.y;
/* new window must start after v's tag ends */ /* new window must start after v's tag ends */
y = max(y, v->tagtop.max.y+Border); y = max(y, v->tagtop.max.y+Border);
/* new window must start early enough to end before ymax */ /* new window must start early enough to end before ymax */
y = min(y, ymax - minht); y = min(y, ymax - minht);
/* if y is too small, too many windows in column */ /* if y is too small, too many windows in column */
if(y < v->tagtop.max.y+Border) if(y < v->tagtop.max.y+Border)
buggered = 1; buggered = 1;
@ -118,7 +118,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
r1.min.y = winresize(v, r1, FALSE, FALSE); r1.min.y = winresize(v, r1, FALSE, FALSE);
r1.max.y = r1.min.y+Border; r1.max.y = r1.min.y+Border;
draw(screen, r1, display->black, nil, ZP); draw(screen, r1, display->black, nil, ZP);
/* /*
* leave r with w's coordinates * leave r with w's coordinates
*/ */
@ -142,7 +142,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
c->nw++; c->nw++;
c->w[i] = w; c->w[i] = w;
c->safe = TRUE; c->safe = TRUE;
/* if there were too many windows, redraw the whole column */ /* if there were too many windows, redraw the whole column */
if(buggered) if(buggered)
colresize(c, c->r); colresize(c, c->r);

View File

@ -633,8 +633,8 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
/* /*
* The editoutlk exists only so that we can tell when * The editoutlk exists only so that we can tell when
* the editout file has been closed. It can get closed *after* * the editout file has been closed. It can get closed *after*
* the process exits because, since the process cannot be * the process exits because, since the process cannot be
* connected directly to editout (no 9P kernel support), * connected directly to editout (no 9P kernel support),
* the process is actually connected to a pipe to another * the process is actually connected to a pipe to another
* process (arranged via 9pserve) that reads from the pipe * process (arranged via 9pserve) that reads from the pipe
* and then writes the data in the pipe to editout using * and then writes the data in the pipe to editout using
@ -704,7 +704,7 @@ printposn(Text *t, int mode)
if (t != nil && t->file != nil && t->file->name != nil) if (t != nil && t->file != nil && t->file->name != nil)
warning(nil, "%.*S:", t->file->nname, t->file->name); warning(nil, "%.*S:", t->file->nname, t->file->name);
switch(mode) { switch(mode) {
case PosnChars: case PosnChars:
warning(nil, "#%d", addr.r.q0); warning(nil, "#%d", addr.r.q0);
@ -712,7 +712,7 @@ printposn(Text *t, int mode)
warning(nil, ",#%d", addr.r.q1); warning(nil, ",#%d", addr.r.q1);
warning(nil, "\n"); warning(nil, "\n");
return; return;
default: default:
case PosnLine: case PosnLine:
l1 = 1+nlcount(t, 0, addr.r.q0, nil); l1 = 1+nlcount(t, 0, addr.r.q0, nil);

View File

@ -515,7 +515,7 @@ parsecmd(int nest)
if(nextc() == 'g') if(nextc() == 'g')
cmd.flag = getch(); cmd.flag = getch();
} }
} }
} }
} }
@ -613,7 +613,7 @@ simpleaddr(void)
addr.num = getnum(1); addr.num = getnum(1);
break; break;
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
addr.num = getnum(1); addr.num = getnum(1);
addr.type='l'; addr.type='l';
break; break;

View File

@ -243,7 +243,7 @@ elogapply(File *f)
* but using coordinates relative to the unmodified buffer. As we apply the log, * but using coordinates relative to the unmodified buffer. As we apply the log,
* we have to update the coordinates to be relative to the modified buffer. * we have to update the coordinates to be relative to the modified buffer.
* Textinsert and textdelete will do this for us; our only work is to apply the * Textinsert and textdelete will do this for us; our only work is to apply the
* convention that an insertion at t->q0==t->q1 is intended to select the * convention that an insertion at t->q0==t->q1 is intended to select the
* inserted text. * inserted text.
*/ */
@ -337,7 +337,7 @@ elogapply(File *f)
} }
fbuffree(buf); fbuffree(buf);
elogterm(f); elogterm(f);
/* /*
* Bad addresses will cause bufload to crash, so double check. * Bad addresses will cause bufload to crash, so double check.
* If changes were out of order, we expect problems so don't complain further. * If changes were out of order, we expect problems so don't complain further.

View File

@ -463,7 +463,7 @@ fsyswalk(Xfid *x, Fid *f)
qunlock(&row.lk); qunlock(&row.lk);
dir = dirtabw; dir = dirtabw;
goto Accept; goto Accept;
Regular: Regular:
if(strcmp(x->fcall.wname[i], "new") == 0){ if(strcmp(x->fcall.wname[i], "new") == 0){
if(w) if(w)

View File

@ -20,7 +20,7 @@ struct Log
Rendez r; Rendez r;
vlong start; // msg[0] corresponds to 'start' in the global sequence of events vlong start; // msg[0] corresponds to 'start' in the global sequence of events
// queued events (nev=entries in ev, mev=capacity of p) // queued events (nev=entries in ev, mev=capacity of p)
char **ev; char **ev;
int nev; int nev;
@ -30,7 +30,7 @@ struct Log
Fid **f; Fid **f;
int nf; int nf;
int mf; int mf;
// active (blocked) reads waiting for events // active (blocked) reads waiting for events
Xfid **read; Xfid **read;
int nread; int nread;
@ -43,7 +43,7 @@ void
xfidlogopen(Xfid *x) xfidlogopen(Xfid *x)
{ {
qlock(&eventlog.lk); qlock(&eventlog.lk);
if(eventlog.nf >= eventlog.mf) { if(eventlog.nf >= eventlog.mf) {
eventlog.mf = eventlog.mf*2; eventlog.mf = eventlog.mf*2;
if(eventlog.mf == 0) if(eventlog.mf == 0)
eventlog.mf = 8; eventlog.mf = 8;
@ -78,20 +78,20 @@ xfidlogread(Xfid *x)
Fcall fc; Fcall fc;
qlock(&eventlog.lk); qlock(&eventlog.lk);
if(eventlog.nread >= eventlog.mread) { if(eventlog.nread >= eventlog.mread) {
eventlog.mread = eventlog.mread*2; eventlog.mread = eventlog.mread*2;
if(eventlog.mread == 0) if(eventlog.mread == 0)
eventlog.mread = 8; eventlog.mread = 8;
eventlog.read = erealloc(eventlog.read, eventlog.mread*sizeof eventlog.read[0]); eventlog.read = erealloc(eventlog.read, eventlog.mread*sizeof eventlog.read[0]);
} }
eventlog.read[eventlog.nread++] = x; eventlog.read[eventlog.nread++] = x;
if(eventlog.r.l == nil) if(eventlog.r.l == nil)
eventlog.r.l = &eventlog.lk; eventlog.r.l = &eventlog.lk;
x->flushed = FALSE; x->flushed = FALSE;
while(x->f->logoff >= eventlog.start+eventlog.nev && !x->flushed) while(x->f->logoff >= eventlog.start+eventlog.nev && !x->flushed)
rsleep(&eventlog.r); rsleep(&eventlog.r);
for(i=0; i<eventlog.nread; i++) { for(i=0; i<eventlog.nread; i++) {
if(eventlog.read[i] == x) { if(eventlog.read[i] == x) {
eventlog.read[i] = eventlog.read[--eventlog.nread]; eventlog.read[i] = eventlog.read[--eventlog.nread];
@ -112,7 +112,7 @@ xfidlogread(Xfid *x)
fc.data = p; fc.data = p;
fc.count = strlen(p); fc.count = strlen(p);
respond(x, &fc, nil); respond(x, &fc, nil);
free(p); free(p);
} }
void void
@ -177,7 +177,7 @@ xfidlog(Window *w, char *op)
eventlog.start += n; eventlog.start += n;
memmove(eventlog.ev, eventlog.ev+n, eventlog.nev*sizeof eventlog.ev[0]); memmove(eventlog.ev, eventlog.ev+n, eventlog.nev*sizeof eventlog.ev[0]);
} }
// Otherwise grow. // Otherwise grow.
if(eventlog.nev >= eventlog.mev) { if(eventlog.nev >= eventlog.mev) {
eventlog.mev = eventlog.mev*2; eventlog.mev = eventlog.mev*2;

View File

@ -178,4 +178,3 @@ extern int shortmenu;
extern CFsys *mailfs; extern CFsys *mailfs;
extern CFsys *acmefs; extern CFsys *acmefs;

View File

@ -67,7 +67,7 @@ char*
readbody(char *type, char *dir, int *np) readbody(char *type, char *dir, int *np)
{ {
char *body; char *body;
body = readfile(dir, "body", np); body = readfile(dir, "body", np);
if(body != nil && strcmp(type, "text/html") == 0) if(body != nil && strcmp(type, "text/html") == 0)
return formathtml(body, np); return formathtml(body, np);

View File

@ -558,16 +558,16 @@ mainctl(void *v)
Unknown: Unknown:
print("unknown message %c%c\n", e->c1, e->c2); print("unknown message %c%c\n", e->c1, e->c2);
break; break;
case 'E': /* write to body; can't affect us */ case 'E': /* write to body; can't affect us */
break; break;
case 'F': /* generated by our actions; ignore */ case 'F': /* generated by our actions; ignore */
break; break;
case 'K': /* type away; we don't care */ case 'K': /* type away; we don't care */
break; break;
case 'M': case 'M':
switch(e->c2){ switch(e->c2){
case 'x': case 'x':
@ -597,7 +597,7 @@ mainctl(void *v)
if(na) if(na)
free(s); free(s);
break; break;
case 'l': case 'l':
case 'L': case 'L':
buf = nil; buf = nil;
@ -628,17 +628,16 @@ mainctl(void *v)
winwriteevent(w, e); winwriteevent(w, e);
free(buf); free(buf);
break; break;
case 'I': /* modify away; we don't care */ case 'I': /* modify away; we don't care */
case 'D': case 'D':
case 'd': case 'd':
case 'i': case 'i':
break; break;
default: default:
goto Unknown; goto Unknown;
} }
} }
} }
} }

View File

@ -85,7 +85,7 @@ mkaddrs(char *t, char **colon)
int i, nf, inquote; int i, nf, inquote;
char **f, *s; char **f, *s;
Fmt fmt; Fmt fmt;
inquote = 0; inquote = 0;
nf = 2; nf = 2;
for(s=t; *s; s++){ for(s=t; *s; s++){
@ -127,7 +127,7 @@ loadinfo(Message *m, char *dir)
data = readfile(dir, "info", &n); data = readfile(dir, "info", &n);
if(data == nil) if(data == nil)
return 0; return 0;
p = data; p = data;
while((s = line(p, &p)) != nil && *s != 0){ while((s = line(p, &p)) != nil && *s != 0){
t = strchr(s, ' '); t = strchr(s, ' ');
@ -282,7 +282,7 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
if (m->level != 1){ if (m->level != 1){
m->recursed = 1; m->recursed = 1;
readmbox(m, dir, m->name); readmbox(m, dir, m->name);
} }
return 1; return 1;
} }
@ -351,7 +351,7 @@ readfile(char *dir, char *name, int *np)
fsseek(fid, 0, 0); fsseek(fid, 0, 0);
free(d); free(d);
d = fsdirfstat(fid); d = fsdirfstat(fid);
} }
free(file); free(file);
len = 0; len = 0;
if(d != nil) if(d != nil)
@ -400,13 +400,13 @@ info(Message *m, int ind, int ogf)
i = estrdup(s); i = estrdup(s);
return i; return i;
} }
i = estrdup(""); i = estrdup("");
i = eappend(i, "\t", p); i = eappend(i, "\t", p);
i = egrow(i, "\t", stripdate(m->date)); i = egrow(i, "\t", stripdate(m->date));
if(ind == 0){ if(ind == 0){
if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 && if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 &&
strncmp(m->type, "multipart/", 10)!=0) strncmp(m->type, "multipart/", 10)!=0)
i = egrow(i, "\t(", estrstrdup(m->type, ")")); i = egrow(i, "\t(", estrstrdup(m->type, ")"));
}else if(strncmp(m->type, "multipart/", 10) != 0) }else if(strncmp(m->type, "multipart/", 10) != 0)
@ -647,7 +647,7 @@ mesgsave(Message *m, char *s, int save)
} }
return 1; return 1;
} }
t = estrstrdup(mbox.name, m->name); t = estrstrdup(mbox.name, m->name);
raw = readfile(t, "raw", &n); raw = readfile(t, "raw", &n);
unixheader = readfile(t, "unixheader", &k); unixheader = readfile(t, "unixheader", &k);
@ -1160,7 +1160,7 @@ tokenizec(char *str, char **args, int max, char *splitc)
if(max <= 0) if(max <= 0)
return 0; return 0;
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */ /* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */
/* splitc = ","; */ /* splitc = ","; */
for(na=0; *str != '\0';str++){ for(na=0; *str != '\0';str++){

View File

@ -78,7 +78,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
Plumbattr *a; Plumbattr *a;
quotereply = (label[0] == 'Q'); quotereply = (label[0] == 'Q');
if(quotereply && m && m->replywinid > 0){ if(quotereply && m && m->replywinid > 0){
snprint(buf, sizeof buf, "%d/body", m->replywinid); snprint(buf, sizeof buf, "%d/body", m->replywinid);
if((fd = fsopen(acmefs, buf, OWRITE)) != nil){ if((fd = fsopen(acmefs, buf, OWRITE)) != nil){
@ -88,7 +88,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
return; return;
} }
} }
r = emalloc(sizeof(Message)); r = emalloc(sizeof(Message));
r->isreply = 1; r->isreply = 1;
if(m != nil) if(m != nil)
@ -212,7 +212,7 @@ execproc(void *v)
q[0] = e->q[0]; q[0] = e->q[0];
q[1] = e->q[1]; q[1] = e->q[1];
prog = e->prog; /* known not to be malloc'ed */ prog = e->prog; /* known not to be malloc'ed */
fd[0] = dup(p[0], -1); fd[0] = dup(p[0], -1);
if(q[0]) if(q[0])
fd[1] = dup(q[1], -1); fd[1] = dup(q[1], -1);
@ -224,7 +224,7 @@ execproc(void *v)
free(e->argv); free(e->argv);
chanfree(e->sync); chanfree(e->sync);
free(e); free(e);
threadexec(nil, fd, prog, argv); threadexec(nil, fd, prog, argv);
close(fd[0]); close(fd[0]);
close(fd[1]); close(fd[1]);

View File

@ -104,4 +104,3 @@ ctlprint(CFid *fd, char *fmt, ...)
if(n <= 0) if(n <= 0)
error("control file write error: %r"); error("control file write error: %r");
} }

View File

@ -196,7 +196,7 @@ wingeter(Window *w, char *buf, int *nb)
while(!fullrune(buf, n)) while(!fullrune(buf, n))
buf[n++] = wingetec(w); buf[n++] = wingetec(w);
chartorune(&r, buf); chartorune(&r, buf);
} }
*nb = n; *nb = n;
return r; return r;
} }

View File

@ -388,7 +388,7 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
textscrdraw(u); textscrdraw(u);
} }
} }
} }
if(q0 < t->iq1) if(q0 < t->iq1)
t->iq1 += n; t->iq1 += n;
@ -549,7 +549,7 @@ textbswidth(Text *t, Rune c)
if(r == '\n'){ /* eat at most one more character */ if(r == '\n'){ /* eat at most one more character */
if(q == t->q0) /* eat the newline */ if(q == t->q0) /* eat the newline */
--q; --q;
break; break;
} }
if(c == 0x17){ if(c == 0x17){
eq = isalnum(r); eq = isalnum(r);
@ -771,7 +771,7 @@ texttype(Text *t, Rune r)
case Kcmd+'Z': /* %-shift-Z: redo */ case Kcmd+'Z': /* %-shift-Z: redo */
typecommit(t); typecommit(t);
undo(t, nil, nil, FALSE, 0, nil, 0); undo(t, nil, nil, FALSE, 0, nil, 0);
return; return;
Tagdown: Tagdown:
/* expand tag to show all text */ /* expand tag to show all text */
@ -780,7 +780,7 @@ texttype(Text *t, Rune r)
winresize(t->w, t->w->r, FALSE, TRUE); winresize(t->w, t->w->r, FALSE, TRUE);
} }
return; return;
Tagup: Tagup:
/* shrink tag to single line */ /* shrink tag to single line */
if(t->w->tagexpand){ if(t->w->tagexpand){
@ -1192,7 +1192,7 @@ void
textsetselect(Text *t, uint q0, uint q1) textsetselect(Text *t, uint q0, uint q1)
{ {
int p0, p1, ticked; int p0, p1, ticked;
/* t->fr.p0 and t->fr.p1 are always right; t->q0 and t->q1 may be off */ /* t->fr.p0 and t->fr.p1 are always right; t->q0 and t->q1 may be off */
t->q0 = q0; t->q0 = q0;
t->q1 = q1; t->q1 = q1;
@ -1345,7 +1345,7 @@ textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask)
{ {
uint p0, p1; uint p0, p1;
int buts; int buts;
p0 = xselect(&t->fr, mousectl, high, &p1); p0 = xselect(&t->fr, mousectl, high, &p1);
buts = mousectl->m.buttons; buts = mousectl->m.buttons;
if((buts & mask) == 0){ if((buts & mask) == 0){
@ -1412,7 +1412,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1)
if(textclickhtmlmatch(t, q0, q1)) if(textclickhtmlmatch(t, q0, q1))
return; return;
for(i=0; left[i]!=nil; i++){ for(i=0; left[i]!=nil; i++){
q = *q0; q = *q0;
l = left[i]; l = left[i];
@ -1444,7 +1444,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1)
return; return;
} }
} }
/* try filling out word to right */ /* try filling out word to right */
while(*q1<t->file->b.nc && isalnum(textreadc(t, *q1))) while(*q1<t->file->b.nc && isalnum(textreadc(t, *q1)))
(*q1)++; (*q1)++;
@ -1518,7 +1518,7 @@ static int
ishtmlend(Text *t, uint q, uint *q0) ishtmlend(Text *t, uint q, uint *q0)
{ {
int c, c1, c2; int c, c1, c2;
if(q < 2) if(q < 2)
return 0; return 0;
if(textreadc(t, --q) != '>') if(textreadc(t, --q) != '>')
@ -1546,7 +1546,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1)
{ {
int depth, n; int depth, n;
uint q, nq; uint q, nq;
q = *q0; q = *q0;
// after opening tag? scan forward for closing tag // after opening tag? scan forward for closing tag
if(ishtmlend(t, q, nil) == 1) { if(ishtmlend(t, q, nil) == 1) {
@ -1583,7 +1583,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1)
q--; q--;
} }
} }
return 0; return 0;
} }

View File

@ -132,7 +132,7 @@ errorwin(Mntdir *md, int owner)
} }
/* /*
* Incoming window should be locked. * Incoming window should be locked.
* It will be unlocked and returned window * It will be unlocked and returned window
* will be locked in its place. * will be locked in its place.
*/ */
@ -189,7 +189,7 @@ void
addwarningtext(Mntdir *md, Rune *r, int nr) addwarningtext(Mntdir *md, Rune *r, int nr)
{ {
Warning *warn; Warning *warn;
for(warn = warnings; warn; warn=warn->next){ for(warn = warnings; warn; warn=warn->next){
if(warn->md == md){ if(warn->md == md){
bufinsert(&warn->buf, warn->buf.nc, r, nr); bufinsert(&warn->buf, warn->buf.nc, r, nr);

View File

@ -97,7 +97,7 @@ windrawbutton(Window *w)
{ {
Image *b; Image *b;
Rectangle br; Rectangle br;
b = button; b = button;
if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache)) if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache))
b = modbutton; b = modbutton;
@ -112,7 +112,7 @@ delrunepos(Window *w)
{ {
int n; int n;
Rune rune; Rune rune;
for(n=0; n<w->tag.file->b.nc; n++) { for(n=0; n<w->tag.file->b.nc; n++) {
bufread(&w->tag.file->b, n, &rune, 1); bufread(&w->tag.file->b, n, &rune, 1);
if(rune == ' ') if(rune == ' ')
@ -128,7 +128,7 @@ void
movetodel(Window *w) movetodel(Window *w)
{ {
int n; int n;
n = delrunepos(w); n = delrunepos(w);
if(n < 0) if(n < 0)
return; return;
@ -153,7 +153,7 @@ wintaglines(Window *w, Rectangle r)
textresize(&w->tag, r, TRUE); textresize(&w->tag, r, TRUE);
w->tag.fr.noredraw = 0; w->tag.fr.noredraw = 0;
w->tagsafe = FALSE; w->tagsafe = FALSE;
if(!w->tagexpand) { if(!w->tagexpand) {
/* use just as many lines as needed to show the Del */ /* use just as many lines as needed to show the Del */
n = delrunepos(w); n = delrunepos(w);
@ -162,7 +162,7 @@ wintaglines(Window *w, Rectangle r)
p = subpt(frptofchar(&w->tag.fr, n), w->tag.fr.r.min); p = subpt(frptofchar(&w->tag.fr, n), w->tag.fr.r.min);
return 1 + p.y / w->tag.fr.font->height; return 1 + p.y / w->tag.fr.font->height;
} }
/* can't use more than we have */ /* can't use more than we have */
if(w->tag.fr.nlines >= w->tag.fr.maxlines) if(w->tag.fr.nlines >= w->tag.fr.maxlines)
return w->tag.fr.maxlines; return w->tag.fr.maxlines;
@ -224,7 +224,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
moveto(mousectl, p); moveto(mousectl, p);
} }
} }
/* If needed, resize & redraw body. */ /* If needed, resize & redraw body. */
r1 = r; r1 = r;
r1.min.y = y; r1.min.y = y;
@ -293,7 +293,7 @@ winunlock(Window *w)
void void
winmousebut(Window *w) winmousebut(Window *w)
{ {
moveto(mousectl, addpt(w->tag.scrollr.min, moveto(mousectl, addpt(w->tag.scrollr.min,
divpt(Pt(Dx(w->tag.scrollr), font->height), 2))); divpt(Pt(Dx(w->tag.scrollr), font->height), 2)));
} }
@ -673,7 +673,7 @@ winctlprint(Window *w, char *buf, int fonts)
sprint(buf, "%11d %11d %11d %11d %11d ", w->id, w->tag.file->b.nc, sprint(buf, "%11d %11d %11d %11d %11d ", w->id, w->tag.file->b.nc,
w->body.file->b.nc, w->isdir, w->dirty); w->body.file->b.nc, w->isdir, w->dirty);
if(fonts) if(fonts)
return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r), return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r),
w->body.reffont->f->name, w->body.fr.maxtab); w->body.reffont->f->name, w->body.fr.maxtab);
return buf; return buf;
} }

View File

@ -17,7 +17,7 @@ cosadd(int n, ...)
int i; int i;
double sum, a1, a2; double sum, a1, a2;
va_list arg; va_list arg;
sum = 0; sum = 0;
cp = cacp; cp = cacp;
va_start(arg, n); va_start(arg, n);

View File

@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r"); sysfatal("%r");
s = smprint("key %A p=%lB q=%lB alpha=%lB key=%lB\n", s = smprint("key %A p=%lB q=%lB alpha=%lB key=%lB\n",
a, a,
key->pub.p, key->pub.q, key->pub.alpha, key->pub.key); key->pub.p, key->pub.q, key->pub.alpha, key->pub.key);
if(s == nil) if(s == nil)
sysfatal("smprint: %r"); sysfatal("smprint: %r");

View File

@ -18,7 +18,7 @@ main(int argc, char **argv)
DSApriv *k; DSApriv *k;
char *comment; char *comment;
uchar buf[8192], *p; uchar buf[8192], *p;
fmtinstall('B', mpfmt); fmtinstall('B', mpfmt);
fmtinstall('[', encodefmt); fmtinstall('[', encodefmt);
comment = ""; comment = "";

View File

@ -43,6 +43,6 @@ main(int argc, char **argv)
if(write(1, s, strlen(s)) != strlen(s)) if(write(1, s, strlen(s)) != strlen(s))
sysfatal("write: %r"); sysfatal("write: %r");
exits(nil); exits(nil);
} }

View File

@ -30,10 +30,10 @@ threadmain(int argc, char **argv)
uchar digest[SHA1dlen]; uchar digest[SHA1dlen];
AuthRpc *rpc; AuthRpc *rpc;
Fmt fmt; Fmt fmt;
fmtinstall('[', encodefmt); fmtinstall('[', encodefmt);
fmtinstall('H', encodefmt); fmtinstall('H', encodefmt);
verify = 0; verify = 0;
id = ""; id = "";
ARGBEGIN{ ARGBEGIN{
@ -46,7 +46,7 @@ threadmain(int argc, char **argv)
default: default:
usage(); usage();
}ARGEND }ARGEND
if(argc != 1) if(argc != 1)
usage(); usage();
key = argv[0]; key = argv[0];
@ -68,7 +68,7 @@ threadmain(int argc, char **argv)
auth_freerpc(rpc); auth_freerpc(rpc);
threadexits("rpc"); threadexits("rpc");
} }
print("+%s\n", id); print("+%s\n", id);
Binit(&b, 0, OREAD); Binit(&b, 0, OREAD);
@ -96,7 +96,7 @@ keytomp(Attr *a, char *name)
{ {
char *p; char *p;
mpint *m; mpint *m;
p = _strfindattr(a, name); p = _strfindattr(a, name);
if(p == nil) if(p == nil)
sysfatal("missing key attribute %s", name); sysfatal("missing key attribute %s", name);
@ -117,7 +117,7 @@ doVerify(void)
Attr *a; Attr *a;
DSAsig dsig; DSAsig dsig;
DSApub dkey; DSApub dkey;
a = _parseattr(key); a = _parseattr(key);
if(a == nil) if(a == nil)
sysfatal("invalid key"); sysfatal("invalid key");
@ -159,7 +159,7 @@ end:
if(dsaverify(&dkey, &dsig, betomp(digest, sizeof digest, nil)) < 0) if(dsaverify(&dkey, &dsig, betomp(digest, sizeof digest, nil)) < 0)
sysfatal("signature failed to verify: %r"); sysfatal("signature failed to verify: %r");
write(1, text, strlen(text)); write(1, text, strlen(text));
threadexitsall(0); threadexitsall(0);
} }
@ -169,7 +169,7 @@ getline(int *np)
{ {
char *p; char *p;
int n; int n;
if((p = Brdline(&b, '\n')) == nil) if((p = Brdline(&b, '\n')) == nil)
return nil; return nil;
n = Blinelen(&b); n = Blinelen(&b);

View File

@ -10,7 +10,7 @@
* S -> C: ok * S -> C: ok
* *
* Note that this is the protocol between factotum and the local * Note that this is the protocol between factotum and the local
* program, not between the two factotums. The information * program, not between the two factotums. The information
* exchanged here is wrapped in the APOP protocol by the local * exchanged here is wrapped in the APOP protocol by the local
* programs. * programs.
* *
@ -42,7 +42,7 @@ apopclient(Conv *c)
Attr *attr; Attr *attr;
DigestState *ds; DigestState *ds;
Key *k; Key *k;
chal = nil; chal = nil;
k = nil; k = nil;
res = nil; res = nil;
@ -328,7 +328,7 @@ apopresp(ServerState *s, char *user, char *resp)
} }
static Role static Role
apoproles[] = apoproles[] =
{ {
"client", apopclient, "client", apopclient,
"server", apopserver, "server", apopserver,
@ -350,4 +350,3 @@ Proto cram = {
apopcheck, apopcheck,
nil nil
}; };

View File

@ -53,7 +53,7 @@ addattrs(Attr *a, Attr *b)
break; break;
} }
} }
return a; return a;
} }
void void
@ -201,7 +201,7 @@ matchattr(Attr *pat, Attr *a0, Attr *a1)
break; break;
} }
} }
return 1; return 1;
} }
Attr* Attr*

View File

@ -1,6 +1,6 @@
/* /*
* CHAP, MSCHAP * CHAP, MSCHAP
* *
* The client does not authenticate the server, hence no CAI * The client does not authenticate the server, hence no CAI
* *
* Protocol: * Protocol:
@ -51,7 +51,7 @@ nthash(uchar hash[MShashlen], char *passwd)
{ {
uchar buf[512]; uchar buf[512];
int i; int i;
for(i=0; *passwd && i<sizeof(buf); passwd++) { for(i=0; *passwd && i<sizeof(buf); passwd++) {
buf[i++] = *passwd; buf[i++] = *passwd;
buf[i++] = 0; buf[i++] = 0;
@ -96,7 +96,7 @@ mschalresp(uchar resp[MSresplen], uchar hash[MShashlen], uchar chal[MSchallen])
{ {
int i; int i;
uchar buf[21]; uchar buf[21];
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
memcpy(buf, hash, MShashlen); memcpy(buf, hash, MShashlen);
@ -404,7 +404,7 @@ chapresp(ServerState *s, char *user, char *resp)
} }
static Role static Role
chaproles[] = chaproles[] =
{ {
"client", chapclient, "client", chapclient,
"server", chapserver, "server", chapserver,
@ -424,5 +424,3 @@ Proto mschap = {
"user? !password?", "user? !password?",
chapcheck chapcheck
}; };

View File

@ -268,4 +268,3 @@ convbadkey(Conv *c, Key *k, char *msg, Attr *a)
return -1; return -1;
return 0; return 0;
} }

View File

@ -168,7 +168,7 @@ main(int argc, char **argv)
/* start up a process to pass along notes */ /* start up a process to pass along notes */
lclnoteproc(data); lclnoteproc(data);
/* /*
* Wait for the other end to execute and start our file service * Wait for the other end to execute and start our file service
* of /mnt/term * of /mnt/term
*/ */
@ -246,7 +246,7 @@ old9p(int fd)
close(fd); close(fd);
close(p[0]); close(p[0]);
} }
return p[1]; return p[1];
} }
/* Invoked with stdin, stdout and stderr connected to the network connection */ /* Invoked with stdin, stdout and stderr connected to the network connection */
@ -392,7 +392,7 @@ readstr(int fd, char *str, int len)
while(len) { while(len) {
n = read(fd, str, 1); n = read(fd, str, 1);
if(n < 0) if(n < 0)
return -1; return -1;
if(*str == '\0') if(*str == '\0')
return 0; return 0;
@ -659,7 +659,7 @@ rmtnoteproc(void)
syslog(0, "cpu", "cpu -R: can't open %s", rmtnotefile); syslog(0, "cpu", "cpu -R: can't open %s", rmtnotefile);
_exits(0); _exits(0);
} }
for(;;){ for(;;){
n = read(fd, buf, sizeof(buf)-1); n = read(fd, buf, sizeof(buf)-1);
if(n <= 0){ if(n <= 0){

View File

@ -57,7 +57,7 @@ struct Conv
Req *req; /* 9P call to read response */ Req *req; /* 9P call to read response */
Channel *keywait; /* wait here for key confirmation */ Channel *keywait; /* wait here for key confirmation */
}; };
struct Key struct Key

View File

@ -3,7 +3,7 @@
/* /*
* DSA signing and verification * DSA signing and verification
* *
* Sign: * Sign:
* start p=xxx q=xxx alpha=xxx key=xxx * start p=xxx q=xxx alpha=xxx key=xxx
* write msg * write msg
@ -14,10 +14,10 @@
* write msg * write msg
* write signature(msg) * write signature(msg)
* read ok or fail * read ok or fail
* *
* all numbers are hexadecimal bigints parsable with strtomp. * all numbers are hexadecimal bigints parsable with strtomp.
*/ */
static int static int
xdsasign(Conv *c) xdsasign(Conv *c)
{ {
@ -58,7 +58,7 @@ xdsasign(Conv *c)
} }
/* /*
* convert to canonical form (lower case) * convert to canonical form (lower case)
* for use in attribute matches. * for use in attribute matches.
*/ */
static void static void
@ -78,11 +78,11 @@ readdsapriv(Key *k)
priv = dsaprivalloc(); priv = dsaprivalloc();
if((a=strfindattr(k->attr, "p"))==nil if((a=strfindattr(k->attr, "p"))==nil
|| (priv->pub.p=strtomp(a, nil, 16, nil))==nil) || (priv->pub.p=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->attr, "q"))==nil if((a=strfindattr(k->attr, "q"))==nil
|| (priv->pub.q=strtomp(a, nil, 16, nil))==nil) || (priv->pub.q=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
@ -90,15 +90,15 @@ readdsapriv(Key *k)
werrstr("dsa: p or q not prime"); werrstr("dsa: p or q not prime");
goto Error; goto Error;
} }
if((a=strfindattr(k->attr, "alpha"))==nil if((a=strfindattr(k->attr, "alpha"))==nil
|| (priv->pub.alpha=strtomp(a, nil, 16, nil))==nil) || (priv->pub.alpha=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->attr, "key"))==nil if((a=strfindattr(k->attr, "key"))==nil
|| (priv->pub.key=strtomp(a, nil, 16, nil))==nil) || (priv->pub.key=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->privattr, "!secret"))==nil if((a=strfindattr(k->privattr, "!secret"))==nil
|| (priv->secret=strtomp(a, nil, 16, nil))==nil) || (priv->secret=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
@ -113,7 +113,7 @@ static int
dsacheck(Key *k) dsacheck(Key *k)
{ {
static int first = 1; static int first = 1;
if(first){ if(first){
fmtinstall('B', mpfmt); fmtinstall('B', mpfmt);
first = 0; first = 0;
@ -134,7 +134,7 @@ dsaclose(Key *k)
} }
static Role static Role
dsaroles[] = dsaroles[] =
{ {
"sign", xdsasign, "sign", xdsasign,
0 0
@ -147,4 +147,3 @@ Proto dsa = {
dsacheck, dsacheck,
dsaclose dsaclose
}; };

View File

@ -65,7 +65,7 @@ rootdirgen(int n, Dir *dir, void *v)
if(n > 0) if(n > 0)
return -1; return -1;
fillstat(dir, factname, QTDIR, Qfactotum, DMDIR|0555); fillstat(dir, factname, QTDIR, Qfactotum, DMDIR|0555);
return 0; return 0;
} }
@ -224,7 +224,7 @@ convlist(int i, char *a, uint nn)
memmove(a, buf, n); memmove(a, buf, n);
return n; return n;
} }
static void static void
fskickreply(Conv *c) fskickreply(Conv *c)
{ {
@ -250,7 +250,7 @@ fskickreply(Conv *c)
respond(r, nil); respond(r, nil);
c->nreply = 0; c->nreply = 0;
} }
/* /*
* Some of the file system work happens in the fs proc, but * Some of the file system work happens in the fs proc, but
* fsopen, fsread, fswrite, fsdestroyfid, and fsflush happen in * fsopen, fsread, fswrite, fsdestroyfid, and fsflush happen in
@ -305,7 +305,7 @@ fsopen(Req *r)
c->kickreply = fskickreply; c->kickreply = fskickreply;
r->fid->aux = c; r->fid->aux = c;
} }
respond(r, nil); respond(r, nil);
} }
@ -538,4 +538,3 @@ fsinit0(void)
fs.destroyfid = fssendclunk; fs.destroyfid = fssendclunk;
fs.start = fsstart; fs.start = fsstart;
} }

View File

@ -2,7 +2,7 @@
* HTTPDIGEST - MD5 challenge/response authentication (RFC 2617) * HTTPDIGEST - MD5 challenge/response authentication (RFC 2617)
* *
* Client protocol: * Client protocol:
* write challenge: nonce method uri * write challenge: nonce method uri
* read response: 2*MD5dlen hex digits * read response: 2*MD5dlen hex digits
* *
* Server protocol: * Server protocol:
@ -22,10 +22,10 @@ hdclient(Conv *c)
char *realm, *passwd, *user, *f[4], *s, resp[MD5dlen*2+1]; char *realm, *passwd, *user, *f[4], *s, resp[MD5dlen*2+1];
int ret; int ret;
Key *k; Key *k;
ret = -1; ret = -1;
s = nil; s = nil;
c->state = "keylookup"; c->state = "keylookup";
k = keyfetch(c, "%A", c->attr); k = keyfetch(c, "%A", c->attr);
if(k == nil) if(k == nil)
@ -45,7 +45,7 @@ hdclient(Conv *c)
digest(user, realm, passwd, f[0], f[1], f[2], resp); digest(user, realm, passwd, f[0], f[1], f[2], resp);
convwrite(c, resp, strlen(resp)); convwrite(c, resp, strlen(resp));
ret = 0; ret = 0;
out: out:
free(s); free(s);
keyclose(k); keyclose(k);
@ -103,7 +103,7 @@ digest(char *user, char *realm, char *passwd,
strtolower(dig); strtolower(dig);
} }
static Role hdroles[] = static Role hdroles[] =
{ {
"client", hdclient, "client", hdclient,
0 0

View File

@ -161,7 +161,7 @@ keyreplace(Conv *c, Key *k, char *fmt, ...)
sysfatal("out of memory"); sysfatal("out of memory");
va_end(arg); va_end(arg);
/* replace prompted values with prompts */ /* replace prompted values with prompts */
a = copyattr(k->attr); a = copyattr(k->attr);
bp = parseattr(k->proto->keyprompt); bp = parseattr(k->proto->keyprompt);
for(b=bp; b; b=b->next){ for(b=bp; b; b=b->next){
@ -204,7 +204,7 @@ keyevict(Conv *c, Key *k, char *fmt, ...)
sysfatal("out of memory"); sysfatal("out of memory");
va_end(arg); va_end(arg);
/* replace prompted values with prompts */ /* replace prompted values with prompts */
a = copyattr(k->attr); a = copyattr(k->attr);
bp = parseattr(k->proto->keyprompt); bp = parseattr(k->proto->keyprompt);
for(b=bp; b; b=b->next){ for(b=bp; b; b=b->next){

View File

@ -118,4 +118,3 @@ flog(char *fmt, ...)
lbvappend(&logbuf, fmt, arg); lbvappend(&logbuf, fmt, arg);
va_end(arg); va_end(arg);
} }

View File

@ -142,7 +142,7 @@ sendkey(Attr *attr)
int rv; int rv;
char buf[8192]; char buf[8192];
CFid *fid; CFid *fid;
fid = nsopen("factotum", nil, "ctl", OWRITE); fid = nsopen("factotum", nil, "ctl", OWRITE);
if(fid == nil) if(fid == nil)
sysfatal("opening factotum/ctl: %r"); sysfatal("opening factotum/ctl: %r");

View File

@ -9,7 +9,7 @@
* C->S: proto dom NUL * C->S: proto dom NUL
* [negotiated proto continues] * [negotiated proto continues]
*/ */
extern Proto p9sk1, p9sk2, p9cr; extern Proto p9sk1, p9sk2, p9cr;
static Proto* okproto[] = static Proto* okproto[] =
@ -111,7 +111,7 @@ p9anyserver(Conv *c)
} }
ret = 0; ret = 0;
out: out:
free(s); free(s);
freeattr(attr); freeattr(attr);
@ -222,7 +222,7 @@ found:
/* f[i] is the chosen protocol, q the chosen domain */ /* f[i] is the chosen protocol, q the chosen domain */
attr = addattr(attr, "proto=%q dom=%q", f[i], q); attr = addattr(attr, "proto=%q dom=%q", f[i], q);
c->state = "write choice"; c->state = "write choice";
/* have a key: go for it */ /* have a key: go for it */
choice = estrappend(nil, "%q %q", f[i], q); choice = estrappend(nil, "%q %q", f[i], q);
if(convwrite(c, choice, strlen(choice)+1) < 0){ if(convwrite(c, choice, strlen(choice)+1) < 0){
@ -258,7 +258,7 @@ out:
} }
static Role static Role
p9anyroles[] = p9anyroles[] =
{ {
"client", p9anyclient, "client", p9anyclient,
"server", p9anyserver, "server", p9anyserver,
@ -269,4 +269,3 @@ Proto p9any = {
"p9any", "p9any",
p9anyroles p9anyroles
}; };

View File

@ -9,7 +9,7 @@
* S -> C: ok or bad * S -> C: ok or bad
* *
* Note that this is the protocol between factotum and the local * Note that this is the protocol between factotum and the local
* program, not between the two factotums. The information * program, not between the two factotums. The information
* exchanged here is wrapped in other protocols by the local * exchanged here is wrapped in other protocols by the local
* programs. * programs.
*/ */
@ -317,7 +317,7 @@ p9crresp(ServerState *s, uchar *resp, int resplen)
static int static int
p9response(char *pw, uchar *chal, uchar *resp) p9response(char *pw, uchar *chal, uchar *resp)
{ {
char key[DESKEYLEN]; char key[DESKEYLEN];
uchar buf[8]; uchar buf[8];
ulong x; ulong x;
@ -338,7 +338,7 @@ static int
vncresponse(char *pw, uchar *chal, uchar *resp) vncresponse(char *pw, uchar *chal, uchar *resp)
{ {
DESstate des; DESstate des;
memmove(resp, chal, MAXCHAL); memmove(resp, chal, MAXCHAL);
setupDESstate(&des, 0, nil); // XXX put key in for 0 setupDESstate(&des, 0, nil); // XXX put key in for 0
desECBencrypt(resp, MAXCHAL, &des); desECBencrypt(resp, MAXCHAL, &des);

View File

@ -93,7 +93,7 @@ p9skclient(Conv *c)
k = keyfetch(c, "%A", a); k = keyfetch(c, "%A", a);
if(k == nil) if(k == nil)
goto out; goto out;
/* relay ticket request to auth server, get tickets */ /* relay ticket request to auth server, get tickets */
strcpy(tr.hostid, strfindattr(k->attr, "user")); strcpy(tr.hostid, strfindattr(k->attr, "user"));
if(speakfor) if(speakfor)
@ -329,7 +329,7 @@ p9sk1close(Key *k)
} }
static Role static Role
p9sk1roles[] = p9sk1roles[] =
{ {
"client", p9skclient, "client", p9skclient,
"server", p9skserver, "server", p9skserver,
@ -337,7 +337,7 @@ p9sk1roles[] =
}; };
static Role static Role
p9sk2roles[] = p9sk2roles[] =
{ {
"client", p9skclient, "client", p9skclient,
"server", p9skserver, "server", p9skserver,
@ -356,4 +356,3 @@ Proto p9sk2 = {
"p9sk2", "p9sk2",
p9sk2roles p9sk2roles
}; };

View File

@ -15,12 +15,12 @@ static int
passproto(Conv *c) passproto(Conv *c)
{ {
Key *k; Key *k;
k = keyfetch(c, "%A", c->attr); k = keyfetch(c, "%A", c->attr);
if(k == nil) if(k == nil)
return -1; return -1;
c->state = "write"; c->state = "write";
convprint(c, "%q %q", convprint(c, "%q %q",
strfindattr(k->attr, "user"), strfindattr(k->attr, "user"),
strfindattr(k->privattr, "!password")); strfindattr(k->privattr, "!password"));
return 0; return 0;

View File

@ -12,7 +12,7 @@
* *
* We sign hashes of messages instead of the messages * We sign hashes of messages instead of the messages
* themselves. * themselves.
* *
* The hashes are encoded in ASN.1 DER to identify * The hashes are encoded in ASN.1 DER to identify
* the signature type, and then prefixed with 0x01 PAD 0x00 * the signature type, and then prefixed with 0x01 PAD 0x00
* where PAD is as many 0xFF bytes as desired. * where PAD is as many 0xFF bytes as desired.
@ -138,7 +138,7 @@ mptoberjust(mpint *b, uchar *buf, uint len)
#define O3(x) \ #define O3(x) \
(((x)>>14)&0x7F)|0x80, \ (((x)>>14)&0x7F)|0x80, \
(((x)>>7)&0x7F)|0x80, \ (((x)>>7)&0x7F)|0x80, \
((x)&0x7F) ((x)&0x7F)
uchar oidsha1[] = { O0(1, 3), 14, 3, 2, 26 }; uchar oidsha1[] = { O0(1, 3), 14, 3, 2, 26 };
uchar oidmd2[] = { O0(1, 2), O2(840), O3(113549), 2, 2 }; uchar oidmd2[] = { O0(1, 2), O2(840), O3(113549), 2, 2 };
uchar oidmd5[] = { O0(1, 2), O2(840), O3(113549), 2, 5 }; uchar oidmd5[] = { O0(1, 2), O2(840), O3(113549), 2, 5 };
@ -174,11 +174,11 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
sysfatal("bad alg in mkasn1"); sysfatal("bad alg in mkasn1");
return -1; return -1;
} }
p = asn1; p = asn1;
*p++ = 0x30; /* sequence */ *p++ = 0x30; /* sequence */
p++; p++;
*p++ = 0x30; /* another sequence */ *p++ = 0x30; /* another sequence */
p++; p++;
@ -186,12 +186,12 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
*p++ = olen; *p++ = olen;
memmove(p, obj, olen); memmove(p, obj, olen);
p += olen; p += olen;
*p++ = 0x05; /* null */ *p++ = 0x05; /* null */
*p++ = 0; *p++ = 0;
asn1[3] = p - (asn1+4); /* end of inner sequence */ asn1[3] = p - (asn1+4); /* end of inner sequence */
*p++ = 0x04; /* octet string */ *p++ = 0x04; /* octet string */
*p++ = dlen; *p++ = dlen;
memmove(p, d, dlen); memmove(p, d, dlen);
@ -200,4 +200,3 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
asn1[1] = p - (asn1+2); /* end of outer sequence */ asn1[1] = p - (asn1+2); /* end of outer sequence */
return p-asn1; return p-asn1;
} }

View File

@ -32,7 +32,7 @@
* done [haveai] - authentication is done [haveai: you can get an ai with authinfo] * done [haveai] - authentication is done [haveai: you can get an ai with authinfo]
*/ */
char *rpcname[] = char *rpcname[] =
{ {
"unknown", "unknown",
"authinfo", "authinfo",
@ -196,7 +196,7 @@ rpcexec(Conv *c)
rpcrespond(c, "error conversation not successful"); rpcrespond(c, "error conversation not successful");
else{ else{
/* make up an auth info using the attr */ /* make up an auth info using the attr */
p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3, p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3,
strfindattr(c->attr, "cuid"), strfindattr(c->attr, "cuid"),
strfindattr(c->attr, "suid"), strfindattr(c->attr, "suid"),
strfindattr(c->attr, "cap"), strfindattr(c->attr, "cap"),
@ -341,4 +341,3 @@ convAI2M(uchar *p, int n, char *cuid, char *suid, char *cap, char *hex)
werrstr("authinfo too big"); werrstr("authinfo too big");
return p; return p;
} }

View File

@ -3,7 +3,7 @@
/* /*
* RSA authentication. * RSA authentication.
* *
* Encrypt/Decrypt: * Encrypt/Decrypt:
* start n=xxx ek=xxx * start n=xxx ek=xxx
* write msg * write msg
@ -13,7 +13,7 @@
* start n=xxx ek=xxx * start n=xxx ek=xxx
* write hash(msg) * write hash(msg)
* read signature(hash(msg)) * read signature(hash(msg))
* *
* Verify: * Verify:
* start n=xxx ek=xxx * start n=xxx ek=xxx
* write hash(msg) * write hash(msg)
@ -44,14 +44,14 @@ xrsadecrypt(Conv *c)
if(k == nil) if(k == nil)
goto out; goto out;
key = k->priv; key = k->priv;
/* make sure have private half if needed */ /* make sure have private half if needed */
role = strfindattr(c->attr, "role"); role = strfindattr(c->attr, "role");
if(strcmp(role, "decrypt") == 0 && !key->c2){ if(strcmp(role, "decrypt") == 0 && !key->c2){
werrstr("missing private half of key -- cannot decrypt"); werrstr("missing private half of key -- cannot decrypt");
goto out; goto out;
} }
/* read text */ /* read text */
c->state = "read"; c->state = "read";
if((n=convreadm(c, &txt)) < 0) if((n=convreadm(c, &txt)) < 0)
@ -60,7 +60,7 @@ xrsadecrypt(Conv *c)
convprint(c, "data too short"); convprint(c, "data too short");
goto out; goto out;
} }
/* encrypt/decrypt */ /* encrypt/decrypt */
m = betomp((uchar*)txt, n, nil); m = betomp((uchar*)txt, n, nil);
if(m == nil) if(m == nil)
@ -72,7 +72,7 @@ xrsadecrypt(Conv *c)
if(mm == nil) if(mm == nil)
goto out; goto out;
n = mptobe(mm, (uchar*)buf, sizeof buf, nil); n = mptobe(mm, (uchar*)buf, sizeof buf, nil);
/* send response */ /* send response */
c->state = "write"; c->state = "write";
convwrite(c, buf, n); convwrite(c, buf, n);
@ -98,7 +98,7 @@ xrsasign(Conv *c)
char *sig2; char *sig2;
ret = -1; ret = -1;
/* fetch key */ /* fetch key */
c->state = "keylookup"; c->state = "keylookup";
k = keylookup("%A", c->attr); k = keylookup("%A", c->attr);
@ -112,7 +112,7 @@ xrsasign(Conv *c)
werrstr("missing private half of key -- cannot sign"); werrstr("missing private half of key -- cannot sign");
goto out; goto out;
} }
/* get hash type from key */ /* get hash type from key */
hash = strfindattr(k->attr, "hash"); hash = strfindattr(k->attr, "hash");
if(hash == nil) if(hash == nil)
@ -144,7 +144,7 @@ xrsasign(Conv *c)
/* read signature */ /* read signature */
if((n = convreadm(c, &sig2)) < 0) if((n = convreadm(c, &sig2)) < 0)
goto out; goto out;
/* verify */ /* verify */
if(rsaverify(&key->pub, hashfn, digest, dlen, (uchar*)sig2, n) == 0) if(rsaverify(&key->pub, hashfn, digest, dlen, (uchar*)sig2, n) == 0)
convprint(c, "ok"); convprint(c, "ok");
@ -160,7 +160,7 @@ out:
} }
/* /*
* convert to canonical form (lower case) * convert to canonical form (lower case)
* for use in attribute matches. * for use in attribute matches.
*/ */
static void static void
@ -180,22 +180,22 @@ readrsapriv(Key *k)
priv = rsaprivalloc(); priv = rsaprivalloc();
if((a=strfindattr(k->attr, "ek"))==nil if((a=strfindattr(k->attr, "ek"))==nil
|| (priv->pub.ek=strtomp(a, nil, 16, nil))==nil) || (priv->pub.ek=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->attr, "n"))==nil if((a=strfindattr(k->attr, "n"))==nil
|| (priv->pub.n=strtomp(a, nil, 16, nil))==nil) || (priv->pub.n=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if(k->privattr == nil) /* only public half */ if(k->privattr == nil) /* only public half */
return priv; return priv;
if((a=strfindattr(k->privattr, "!p"))==nil if((a=strfindattr(k->privattr, "!p"))==nil
|| (priv->p=strtomp(a, nil, 16, nil))==nil) || (priv->p=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->privattr, "!q"))==nil if((a=strfindattr(k->privattr, "!q"))==nil
|| (priv->q=strtomp(a, nil, 16, nil))==nil) || (priv->q=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
@ -203,19 +203,19 @@ readrsapriv(Key *k)
werrstr("rsa: p or q not prime"); werrstr("rsa: p or q not prime");
goto Error; goto Error;
} }
if((a=strfindattr(k->privattr, "!kp"))==nil if((a=strfindattr(k->privattr, "!kp"))==nil
|| (priv->kp=strtomp(a, nil, 16, nil))==nil) || (priv->kp=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->privattr, "!kq"))==nil if((a=strfindattr(k->privattr, "!kq"))==nil
|| (priv->kq=strtomp(a, nil, 16, nil))==nil) || (priv->kq=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->privattr, "!c2"))==nil if((a=strfindattr(k->privattr, "!c2"))==nil
|| (priv->c2=strtomp(a, nil, 16, nil))==nil) || (priv->c2=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
if((a=strfindattr(k->privattr, "!dk"))==nil if((a=strfindattr(k->privattr, "!dk"))==nil
|| (priv->dk=strtomp(a, nil, 16, nil))==nil) || (priv->dk=strtomp(a, nil, 16, nil))==nil)
goto Error; goto Error;
strlwr(a); strlwr(a);
@ -230,7 +230,7 @@ static int
rsacheck(Key *k) rsacheck(Key *k)
{ {
static int first = 1; static int first = 1;
if(first){ if(first){
fmtinstall('B', mpfmt); fmtinstall('B', mpfmt);
first = 0; first = 0;
@ -251,7 +251,7 @@ rsaclose(Key *k)
} }
static Role static Role
rsaroles[] = rsaroles[] =
{ {
"sign", xrsasign, "sign", xrsasign,
"verify", xrsasign, /* public operation */ "verify", xrsasign, /* public operation */

View File

@ -659,4 +659,3 @@ Out:
free(sta); free(sta);
return rv; return rv;
} }

View File

@ -7,4 +7,3 @@
#include <thread.h> #include <thread.h>
#include <fcall.h> #include <fcall.h>
#include <9p.h> #include <9p.h>

View File

@ -50,5 +50,3 @@ estrappend(char *s, char *fmt, ...)
free(t); free(t);
return s; return s;
} }

View File

@ -11,11 +11,11 @@ wepclient(Conv *c)
char *dev, buf[128], *p, *kp; char *dev, buf[128], *p, *kp;
Key *k; Key *k;
int ret, fd, cfd; int ret, fd, cfd;
fd = cfd = -1; fd = cfd = -1;
ret = -1; ret = -1;
dev = nil; dev = nil;
if((k = keylookup("%A !key1?", c->attr)) == nil if((k = keylookup("%A !key1?", c->attr)) == nil
&& (k = keylookup("%A !key2?", c->attr)) == nil && (k = keylookup("%A !key2?", c->attr)) == nil
&& (k = keylookup("%A !key3?", c->attr)) == nil){ && (k = keylookup("%A !key3?", c->attr)) == nil){
@ -73,7 +73,7 @@ static Role weproles[] = {
0 0
}; };
Proto wep = Proto wep =
{ {
"wep", "wep",
weproles, weproles,

View File

@ -9,7 +9,7 @@ xioproc(void)
{ {
Ioproc *c; Ioproc *c;
int i; int i;
for(i=0; i<ncache; i++){ for(i=0; i<ncache; i++){
if(c = cache[i]){ if(c = cache[i]){
cache[i] = nil; cache[i] = nil;
@ -162,4 +162,3 @@ xioasgetticket(int fd, char *trbuf, char *tbuf)
n = 0; n = 0;
return n; return n;
} }

View File

@ -41,7 +41,7 @@ void
readln(char *prompt, char *buf, int nbuf, int secret) readln(char *prompt, char *buf, int nbuf, int secret)
{ {
char *p; char *p;
p = readcons(prompt, nil, secret); p = readcons(prompt, nil, secret);
if(p == nil) if(p == nil)
sysfatal("user terminated input"); sysfatal("user terminated input");

View File

@ -30,5 +30,3 @@ main(int argc, char **argv)
write(1, buf, n); write(1, buf, n);
print("\n"); print("\n");
} }

View File

@ -109,27 +109,27 @@ getkey(int argc, char **argv, int needprivate, Attr **pa)
} }
if((key->kp = strtomp(p, &p, 16, nil)) == nil || *p != 0){ if((key->kp = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !kp\n"); fprint(2, "warning: bad !kp\n");
regen = 1; regen = 1;
goto regen; goto regen;
} }
if((p = _strfindattr(a, "!kq")) == nil){ if((p = _strfindattr(a, "!kq")) == nil){
fprint(2, "warning: no !kq\n"); fprint(2, "warning: no !kq\n");
regen = 1; regen = 1;
goto regen; goto regen;
} }
if((key->kq = strtomp(p, &p, 16, nil)) == nil || *p != 0){ if((key->kq = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !kq\n"); fprint(2, "warning: bad !kq\n");
regen = 1; regen = 1;
goto regen; goto regen;
} }
if((p = _strfindattr(a, "!c2")) == nil){ if((p = _strfindattr(a, "!c2")) == nil){
fprint(2, "warning: no !c2\n"); fprint(2, "warning: no !c2\n");
regen = 1; regen = 1;
goto regen; goto regen;
} }
if((key->c2 = strtomp(p, &p, 16, nil)) == nil || *p != 0){ if((key->c2 = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !c2\n"); fprint(2, "warning: bad !c2\n");
regen = 1; regen = 1;
goto regen; goto regen;
} }
regen: regen:
@ -285,7 +285,7 @@ uchar*
putmp2(uchar *p, mpint *b) putmp2(uchar *p, mpint *b)
{ {
int bits, n; int bits, n;
if(mpcmp(b, mpzero) == 0) if(mpcmp(b, mpzero) == 0)
return put4(p, 0); return put4(p, 0);
bits = mpsignif(b); bits = mpsignif(b);

View File

@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r"); sysfatal("%r");
s = smprint("key %A size=%d ek=%lB n=%lB\n", s = smprint("key %A size=%d ek=%lB n=%lB\n",
a, a,
mpsignif(key->pub.n), key->pub.ek, key->pub.n); mpsignif(key->pub.n), key->pub.ek, key->pub.n);
if(s == nil) if(s == nil)
sysfatal("smprint: %r"); sysfatal("smprint: %r");

View File

@ -19,7 +19,7 @@ main(int argc, char **argv)
{ {
RSApriv *k; RSApriv *k;
char *comment; char *comment;
fmtinstall('B', mpfmt); fmtinstall('B', mpfmt);
fmtinstall('[', encodefmt); fmtinstall('[', encodefmt);
comment = ""; comment = "";
@ -42,7 +42,7 @@ main(int argc, char **argv)
if(ssh2){ if(ssh2){
uchar buf[8192], *p; uchar buf[8192], *p;
p = buf; p = buf;
p = put4(p, 7); p = put4(p, 7);
p = putn(p, "ssh-rsa", 7); p = putn(p, "ssh-rsa", 7);

View File

@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r"); sysfatal("%r");
s = smprint("key %A size=%d ek=%lB !dk=%lB n=%lB !p=%lB !q=%lB !kp=%lB !kq=%lB !c2=%lB\n", s = smprint("key %A size=%d ek=%lB !dk=%lB n=%lB !p=%lB !q=%lB !kp=%lB !kq=%lB !c2=%lB\n",
a, a,
mpsignif(key->pub.n), key->pub.ek, mpsignif(key->pub.n), key->pub.ek,
key->dk, key->pub.n, key->p, key->q, key->dk, key->pub.n, key->p, key->q,
key->kp, key->kq, key->c2); key->kp, key->kq, key->c2);

View File

@ -55,6 +55,6 @@ main(int argc, char **argv)
if(write(1, s, strlen(s)) != strlen(s)) if(write(1, s, strlen(s)) != strlen(s))
sysfatal("write: %r"); sysfatal("write: %r");
exits(nil); exits(nil);
} }

View File

@ -211,4 +211,3 @@ readstr(SConn *conn, char *s)
} }
return n; return n;
} }

Some files were not shown because too many files have changed in this diff Show More