add -W to specify window size.
various other little fixes.
This commit is contained in:
parent
3d72637f9b
commit
be36ff6885
36 changed files with 332 additions and 304 deletions
3
bin/9c
3
bin/9c
|
|
@ -12,7 +12,10 @@ usegcc()
|
||||||
-Wno-switch \
|
-Wno-switch \
|
||||||
-Wno-comment \
|
-Wno-comment \
|
||||||
-Wno-sign-compare \
|
-Wno-sign-compare \
|
||||||
|
-fno-omit-frame-pointer \
|
||||||
"
|
"
|
||||||
|
# want to put -fno-optimize-sibling-calls here but
|
||||||
|
# that option only works with gcc3+ it seems
|
||||||
cflags="$ngflags -ggdb"
|
cflags="$ngflags -ggdb"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ if(! ~ $tag(1) */){
|
||||||
|
|
||||||
echo -n , | wr addr
|
echo -n , | wr addr
|
||||||
ls -pF $tag(1) | sed 's/\*$//' |
|
ls -pF $tag(1) | sed 's/\*$//' |
|
||||||
9grep -v '^\.|\.o$|^o\.' |
|
9grep -v '^''?\.|\.o$|^''?o\.' |
|
||||||
mc | wr data
|
mc | wr data
|
||||||
echo -n '#0' | wr addr
|
echo -n '#0' | wr addr
|
||||||
echo -n 'dot=addr' | wr ctl
|
echo -n 'dot=addr' | wr ctl
|
||||||
|
|
|
||||||
|
|
@ -526,6 +526,8 @@ char *getsnarf(void);
|
||||||
void putsnarf(char*);
|
void putsnarf(char*);
|
||||||
|
|
||||||
void drawtopwindow(void);
|
void drawtopwindow(void);
|
||||||
|
void drawresizewindow(Rectangle);
|
||||||
|
extern char *winsize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Port magic.
|
* Port magic.
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ extern int netcrypt(void*, void*);
|
||||||
extern void p9notejmp(void*, p9jmp_buf, int);
|
extern void p9notejmp(void*, p9jmp_buf, int);
|
||||||
extern void perror(const char*);
|
extern void perror(const char*);
|
||||||
extern int postnote(int, int, char *);
|
extern int postnote(int, int, char *);
|
||||||
extern double pow10(int);
|
extern double p9pow10(int);
|
||||||
/* extern int putenv(char*, char*); <stdlib.h. */
|
/* extern int putenv(char*, char*); <stdlib.h. */
|
||||||
/* extern void qsort(void*, long, long, int (*)(void*, void*)); <stdlib.h> */
|
/* extern void qsort(void*, long, long, int (*)(void*, void*)); <stdlib.h> */
|
||||||
/* extern int p9setjmp(p9jmp_buf); */
|
/* extern int p9setjmp(p9jmp_buf); */
|
||||||
|
|
@ -417,6 +417,7 @@ extern void needstack(int);
|
||||||
#define jmp_buf p9jmp_buf
|
#define jmp_buf p9jmp_buf
|
||||||
#define syslog p9syslog
|
#define syslog p9syslog
|
||||||
#define time p9time
|
#define time p9time
|
||||||
|
#define pow10 p9pow10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -556,6 +557,7 @@ extern void freenetconninfo(NetConnInfo*);
|
||||||
#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
|
#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
|
||||||
#define OCEXEC 32 /* or'ed in, close on exec */
|
#define OCEXEC 32 /* or'ed in, close on exec */
|
||||||
#define ORCLOSE 64 /* or'ed in, remove on close */
|
#define ORCLOSE 64 /* or'ed in, remove on close */
|
||||||
|
#define ODIRECT 128 /* or'ed in, bypass the cache */
|
||||||
#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
|
#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
|
||||||
|
|
||||||
#define AEXIST 0 /* accessible: exists */
|
#define AEXIST 0 /* accessible: exists */
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ int threadrecvfd(int);
|
||||||
long threadwrite(int, const void*, long);
|
long threadwrite(int, const void*, long);
|
||||||
int threadsendfd(int, int);
|
int threadsendfd(int, int);
|
||||||
int threadsetgrp(int); /* set thread group, return old */
|
int threadsetgrp(int); /* set thread group, return old */
|
||||||
void threadsetname(char *name);
|
void threadsetname(char *fmt, ...);
|
||||||
void threadsleep(int);
|
void threadsleep(int);
|
||||||
Channel* threadwaitchan(void);
|
Channel* threadwaitchan(void);
|
||||||
int tprivalloc(void);
|
int tprivalloc(void);
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ Cursor whitearrow = {
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: 9term [-ars] [cmd ...]\n");
|
fprint(2, "usage: 9term [-ars] [-W winsize] [cmd ...]\n");
|
||||||
threadexitsall("usage");
|
threadexitsall("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,6 +215,9 @@ threadmain(int argc, char *argv[])
|
||||||
case 'w': /* started from "rio" window manager */
|
case 'w': /* started from "rio" window manager */
|
||||||
use9wm = 1;
|
use9wm = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
if(font)
|
if(font)
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,7 @@ ttt=ttt->sub;
|
||||||
name, nameof(tt, 0));
|
name, nameof(tt, 0));
|
||||||
Bprint(b, "\tindent_%s(addr+%lud, indent+\" \");\n",
|
Bprint(b, "\tindent_%s(addr+%lud, indent+\" \");\n",
|
||||||
nameof(tt, 1), t->val[j]);
|
nameof(tt, 1), t->val[j]);
|
||||||
Bprint(b, "\tprint(indent, \"\t}\\n\");\n");
|
Bprint(b, "\tprint(indent, \"}\\n\");\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,9 +96,14 @@ threadmain(int argc, char *argv[])
|
||||||
if(loadfile == nil)
|
if(loadfile == nil)
|
||||||
goto Usage;
|
goto Usage;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
winsize = ARGF();
|
||||||
|
if(winsize == nil)
|
||||||
|
goto Usage;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Usage:
|
Usage:
|
||||||
fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile\n");
|
fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile -W winsize\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,21 +109,20 @@ xnet(int first)
|
||||||
totinb = 0;
|
totinb = 0;
|
||||||
totoub = 0;
|
totoub = 0;
|
||||||
for(i=0; i<nline; i++){
|
for(i=0; i<nline; i++){
|
||||||
|
if((q = strchr(line[i], ':')) != nil)
|
||||||
|
*q = ' ';
|
||||||
tokens(i);
|
tokens(i);
|
||||||
if(ntok < 8+8)
|
if(ntok < 8+8)
|
||||||
continue;
|
continue;
|
||||||
if(strncmp(tok[0], "eth", 3) != 0)
|
if(strncmp(tok[0], "eth", 3) != 0)
|
||||||
continue;
|
continue;
|
||||||
q = strchr(tok[0], ':');
|
inb = atoll(tok[1]);
|
||||||
*q++ = 0;
|
oub = atoll(tok[9]);
|
||||||
tok[0] = q;
|
in = atoll(tok[2]);
|
||||||
inb = atoll(tok[0]);
|
ou = atoll(tok[10]);
|
||||||
oub = atoll(tok[8]);
|
|
||||||
in = atoll(tok[1]);
|
|
||||||
ou = atoll(tok[9]);
|
|
||||||
b = inb+oub;
|
b = inb+oub;
|
||||||
p = in+ou;
|
p = in+ou;
|
||||||
e = atoll(tok[2])+atoll(tok[10]);
|
e = atoll(tok[3])+atoll(tok[11]);
|
||||||
totb += b;
|
totb += b;
|
||||||
totp += p;
|
totp += p;
|
||||||
tote += e;
|
tote += e;
|
||||||
|
|
|
||||||
|
|
@ -1956,7 +1956,7 @@ void usage(void)
|
||||||
int i;
|
int i;
|
||||||
fprintf(stderr,"Usage %s [options] [infile]\n", argv0);
|
fprintf(stderr,"Usage %s [options] [infile]\n", argv0);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"option ::= -l logfile | -m\n"
|
"option ::= -W winsize | -l logfile | -m\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Read a polygonal line graph in an ASCII format (one x y pair per line, delimited\n"
|
"Read a polygonal line graph in an ASCII format (one x y pair per line, delimited\n"
|
||||||
"by spaces with a label after each polyline), and view it interactively. Use\n"
|
"by spaces with a label after each polyline), and view it interactively. Use\n"
|
||||||
|
|
@ -1981,6 +1981,9 @@ void main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 'l': logfil = fopen(ARGF(),"w");
|
case 'l': logfil = fopen(ARGF(),"w");
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
default: usage();
|
default: usage();
|
||||||
} ARGEND
|
} ARGEND
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: img [file]\n");
|
fprint(2, "usage: img [-W winsize] [file]\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,6 +29,9 @@ main(int argc, char **argv)
|
||||||
Event e;
|
Event e;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
@ -48,6 +51,8 @@ main(int argc, char **argv)
|
||||||
if((image=readimage(display, fd, 0)) == nil)
|
if((image=readimage(display, fd, 0)) == nil)
|
||||||
sysfatal("readimage: %r");
|
sysfatal("readimage: %r");
|
||||||
|
|
||||||
|
drawresizewindow(Rect(0,0,Dx(image->r),Dy(image->r)));
|
||||||
|
|
||||||
einit(Emouse|Ekeyboard);
|
einit(Emouse|Ekeyboard);
|
||||||
eresized(0);
|
eresized(0);
|
||||||
for(;;){
|
for(;;){
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ update1(Graph *g, long v, ulong vmax)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: stats [-O] [-S scale] [-LY] [-%s] [machine...]\n", argchars);
|
fprint(2, "usage: stats [-O] [-S scale] [-LY] [-W winsize] [-%s] [machine...]\n", argchars);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -710,6 +710,9 @@ threadmain(int argc, char *argv[])
|
||||||
case 'O':
|
case 'O':
|
||||||
oldsystem = 1;
|
oldsystem = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if(nargs>=sizeof args || strchr(argchars, ARGC())==nil)
|
if(nargs>=sizeof args || strchr(argchars, ARGC())==nil)
|
||||||
usage();
|
usage();
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,13 @@ void buttons(int);
|
||||||
void drawall(void);
|
void drawall(void);
|
||||||
void tclose1(Thing*);
|
void tclose1(Thing*);
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: tweak [-W winsize] file...\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -178,6 +185,13 @@ main(int argc, char *argv[])
|
||||||
Event e;
|
Event e;
|
||||||
Thing *t;
|
Thing *t;
|
||||||
|
|
||||||
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
}ARGEND
|
||||||
mag = Mag;
|
mag = Mag;
|
||||||
if(initdraw(error, 0, "tweak") < 0){
|
if(initdraw(error, 0, "tweak") < 0){
|
||||||
fprint(2, "tweak: initdraw failed: %r\n");
|
fprint(2, "tweak: initdraw failed: %r\n");
|
||||||
|
|
@ -191,7 +205,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
einit(Emouse|Ekeyboard);
|
einit(Emouse|Ekeyboard);
|
||||||
eresized(0);
|
eresized(0);
|
||||||
i = 1;
|
i = 0;
|
||||||
setjmp(err);
|
setjmp(err);
|
||||||
for(; i<argc; i++){
|
for(; i<argc; i++){
|
||||||
file = argv[i];
|
file = argv[i];
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,13 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: bmp -39cdektv -W winsize [file.bmp ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -50,6 +57,9 @@ main(int argc, char *argv[])
|
||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
||||||
threeflag++;
|
threeflag++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
@ -89,8 +99,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: bmp -39cdektv [file.bmp ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
err = nil;
|
err = nil;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,14 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: gif -39cdektv -W winsize [file.gif ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -63,6 +71,9 @@ main(int argc, char *argv[])
|
||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
||||||
threeflag++;
|
threeflag++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
@ -102,8 +113,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: gif -39cdektv [file.gif ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
err = nil;
|
err = nil;
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ Bgeticon(Biobuf *b, Icon *icon)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: %s [file]\n", argv0);
|
fprint(2, "usage: %s -W winsize [file]\n", argv0);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -444,6 +444,9 @@ main(int argc, char **argv)
|
||||||
Event e;
|
Event e;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
debug = 1;
|
debug = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,13 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: jpg -39cdefFkJrtv -W winsize [file.jpg ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -54,6 +61,9 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
yflag = 0;
|
yflag = 0;
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'c': /* produce encoded, compressed, bitmap file; no display by default */
|
case 'c': /* produce encoded, compressed, bitmap file; no display by default */
|
||||||
cflag++;
|
cflag++;
|
||||||
dflag++;
|
dflag++;
|
||||||
|
|
@ -110,8 +120,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: jpg -39cdefFkJrtv [file.jpg ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
if(yflag==0 && dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */
|
if(yflag==0 && dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,13 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: png -39cdekrtv -W winsize [file.png ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +58,9 @@ main(int argc, char *argv[])
|
||||||
char buf[12+1];
|
char buf[12+1];
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'c': /* produce encoded, compressed, bitmap file; no display by default */
|
case 'c': /* produce encoded, compressed, bitmap file; no display by default */
|
||||||
cflag++;
|
cflag++;
|
||||||
dflag++;
|
dflag++;
|
||||||
|
|
@ -96,8 +106,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: png -39cdekrtv [file.png ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
if(dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */
|
if(dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,13 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: ppm -39cdektv -W winsize [file.ppm ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -48,6 +55,9 @@ main(int argc, char *argv[])
|
||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
||||||
threeflag++;
|
threeflag++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
@ -87,8 +97,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: ppm -39cdektv [file.ppm ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
err = nil;
|
err = nil;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,13 @@ eresized(int new)
|
||||||
flushimage(display, 1);
|
flushimage(display, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprint(2, "usage: yuv -39cdektv -W winsize [file.yuv ...]\n");
|
||||||
|
exits("usage");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -50,6 +57,9 @@ main(int argc, char *argv[])
|
||||||
char *err;
|
char *err;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
|
case 'W':
|
||||||
|
winsize = EARGF(usage());
|
||||||
|
break;
|
||||||
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
|
||||||
threeflag++;
|
threeflag++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
@ -89,8 +99,7 @@ main(int argc, char *argv[])
|
||||||
outchan = CMAP8;
|
outchan = CMAP8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: yuv -39cdektv [file.yuv ...]\n");
|
usage();
|
||||||
exits("usage");
|
|
||||||
}ARGEND;
|
}ARGEND;
|
||||||
|
|
||||||
err = nil;
|
err = nil;
|
||||||
|
|
|
||||||
245
src/cmd/mc.c
245
src/cmd/mc.c
|
|
@ -1,245 +0,0 @@
|
||||||
/*
|
|
||||||
* mc - columnate
|
|
||||||
*
|
|
||||||
* mc[-][-LINEWIDTH][-t][file...]
|
|
||||||
* - causes break on colon
|
|
||||||
* -LINEWIDTH sets width of line in which to columnate(default 80)
|
|
||||||
* -t suppresses expanding multiple blanks into tabs
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <u.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/termios.h>
|
|
||||||
#include <libc.h>
|
|
||||||
#include <draw.h>
|
|
||||||
#include <bio.h>
|
|
||||||
|
|
||||||
#define WIDTH 80
|
|
||||||
#define TAB 4
|
|
||||||
#define WORD_ALLOC_QUANTA 1024
|
|
||||||
#define ALLOC_QUANTA 4096
|
|
||||||
|
|
||||||
int linewidth=WIDTH;
|
|
||||||
int colonflag=0;
|
|
||||||
int tabflag=0; /* -t flag turned off forever */
|
|
||||||
Rune *cbuf, *cbufp;
|
|
||||||
Rune **word;
|
|
||||||
int maxwidth=0;
|
|
||||||
int nalloc=ALLOC_QUANTA;
|
|
||||||
int nwalloc=WORD_ALLOC_QUANTA;
|
|
||||||
int nchars=0;
|
|
||||||
int nwords=0;
|
|
||||||
Biobuf bin;
|
|
||||||
Biobuf bout;
|
|
||||||
|
|
||||||
void getwidth(void), readbuf(int), error(char *);
|
|
||||||
void scanwords(void), columnate(void), morechars(void);
|
|
||||||
|
|
||||||
void
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int lineset;
|
|
||||||
int ifd;
|
|
||||||
|
|
||||||
lineset = 0;
|
|
||||||
Binit(&bout, 1, OWRITE);
|
|
||||||
while(argc > 1 && argv[1][0] == '-'){
|
|
||||||
--argc; argv++;
|
|
||||||
switch(argv[0][1]){
|
|
||||||
case '\0':
|
|
||||||
colonflag = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
tabflag = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
linewidth = atoi(&argv[0][1]);
|
|
||||||
if(linewidth <= 1)
|
|
||||||
linewidth = WIDTH;
|
|
||||||
lineset = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(lineset == 0)
|
|
||||||
getwidth();
|
|
||||||
cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf));
|
|
||||||
word = malloc(WORD_ALLOC_QUANTA*(sizeof *word));
|
|
||||||
if(word == 0 || cbuf == 0)
|
|
||||||
error("out of memory");
|
|
||||||
if(argc == 1)
|
|
||||||
readbuf(0);
|
|
||||||
else{
|
|
||||||
for(i = 1; i < argc; i++){
|
|
||||||
if((ifd = open(*++argv, OREAD)) == -1)
|
|
||||||
fprint(2, "mc: can't open %s (%r)\n", *argv);
|
|
||||||
else{
|
|
||||||
readbuf(ifd);
|
|
||||||
Bflush(&bin);
|
|
||||||
close(ifd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
columnate();
|
|
||||||
exits(0);
|
|
||||||
}
|
|
||||||
void
|
|
||||||
error(char *s)
|
|
||||||
{
|
|
||||||
fprint(2, "mc: %s\n", s);
|
|
||||||
exits(s);
|
|
||||||
}
|
|
||||||
void
|
|
||||||
readbuf(int fd)
|
|
||||||
{
|
|
||||||
int lastwascolon = 0;
|
|
||||||
long c;
|
|
||||||
int linesiz = 0;
|
|
||||||
|
|
||||||
Binit(&bin, fd, OREAD);
|
|
||||||
do{
|
|
||||||
if(nchars++ >= nalloc)
|
|
||||||
morechars();
|
|
||||||
*cbufp++ = c = Bgetrune(&bin);
|
|
||||||
linesiz++;
|
|
||||||
if(c == '\t') {
|
|
||||||
cbufp[-1] = L' ';
|
|
||||||
while(linesiz%TAB != 0) {
|
|
||||||
if(nchars++ >= nalloc)
|
|
||||||
morechars();
|
|
||||||
*cbufp++ = L' ';
|
|
||||||
linesiz++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(colonflag && c == ':')
|
|
||||||
lastwascolon++;
|
|
||||||
else if(lastwascolon){
|
|
||||||
if(c == '\n'){
|
|
||||||
--nchars; /* skip newline */
|
|
||||||
*cbufp = L'\0';
|
|
||||||
while(nchars > 0 && cbuf[--nchars] != '\n')
|
|
||||||
;
|
|
||||||
if(nchars)
|
|
||||||
nchars++;
|
|
||||||
columnate();
|
|
||||||
if (nchars)
|
|
||||||
Bputc(&bout, '\n');
|
|
||||||
Bprint(&bout, "%S", cbuf+nchars);
|
|
||||||
nchars = 0;
|
|
||||||
cbufp = cbuf;
|
|
||||||
}
|
|
||||||
lastwascolon = 0;
|
|
||||||
}
|
|
||||||
if(c == '\n')
|
|
||||||
linesiz = 0;
|
|
||||||
}while(c >= 0);
|
|
||||||
}
|
|
||||||
void
|
|
||||||
scanwords(void)
|
|
||||||
{
|
|
||||||
Rune *p, *q;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
nwords=0;
|
|
||||||
maxwidth=0;
|
|
||||||
for(p = q = cbuf, i = 0; i < nchars; i++){
|
|
||||||
if(*p++ == L'\n'){
|
|
||||||
if(nwords >= nwalloc){
|
|
||||||
nwalloc += WORD_ALLOC_QUANTA;
|
|
||||||
if((word = realloc(word, nwalloc*sizeof(*word)))==0)
|
|
||||||
error("out of memory");
|
|
||||||
}
|
|
||||||
word[nwords++] = q;
|
|
||||||
p[-1] = L'\0';
|
|
||||||
if(p-q > maxwidth)
|
|
||||||
maxwidth = p-q;
|
|
||||||
q = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
columnate(void)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
int words_per_line;
|
|
||||||
int nlines;
|
|
||||||
int col;
|
|
||||||
int endcol;
|
|
||||||
|
|
||||||
|
|
||||||
scanwords();
|
|
||||||
if(nwords==0)
|
|
||||||
return;
|
|
||||||
words_per_line = linewidth/maxwidth;
|
|
||||||
if(words_per_line <= 0)
|
|
||||||
words_per_line = 1;
|
|
||||||
nlines=(nwords+words_per_line-1)/words_per_line;
|
|
||||||
for(i = 0; i < nlines; i++){
|
|
||||||
col = endcol = 0;
|
|
||||||
for(j = i; j < nwords; j += nlines){
|
|
||||||
endcol += maxwidth;
|
|
||||||
Bprint(&bout, "%S", word[j]);
|
|
||||||
col += word[j+1]-word[j]-1;
|
|
||||||
if(j+nlines < nwords){
|
|
||||||
if(tabflag) {
|
|
||||||
int tabcol = (col|(TAB-1))+1;
|
|
||||||
while(tabcol <= endcol){
|
|
||||||
Bputc(&bout, '\t');
|
|
||||||
col = tabcol;
|
|
||||||
tabcol += TAB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(col < endcol){
|
|
||||||
Bputc(&bout, ' ');
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Bputc(&bout, '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
morechars(void)
|
|
||||||
{
|
|
||||||
nalloc += ALLOC_QUANTA;
|
|
||||||
if((cbuf = realloc(cbuf, nalloc*sizeof(*cbuf))) == 0)
|
|
||||||
error("out of memory");
|
|
||||||
cbufp = cbuf+nchars-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These routines discover the width of the display.
|
|
||||||
* It takes some work. If we do the easy calls to the
|
|
||||||
* draw library, the screen flashes due to repainting
|
|
||||||
* when mc exits.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
windowrect(struct winsize *ws)
|
|
||||||
{
|
|
||||||
int tty;
|
|
||||||
|
|
||||||
if((tty = open("/dev/tty", OWRITE)) < 0)
|
|
||||||
tty = 1;
|
|
||||||
|
|
||||||
if(ioctl(tty, TIOCGWINSZ, ws) < 0){
|
|
||||||
if(tty != 1)
|
|
||||||
close(tty);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(tty != 1)
|
|
||||||
close(tty);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
getwidth(void)
|
|
||||||
{
|
|
||||||
struct winsize ws;
|
|
||||||
|
|
||||||
if(windowrect(&ws) < 0)
|
|
||||||
return;
|
|
||||||
linewidth = ws.ws_col;
|
|
||||||
}
|
|
||||||
|
|
@ -149,6 +149,7 @@ main(int arc, char *arv[]){
|
||||||
fd = dup(0, -1); /* because openpl will close 0! */
|
fd = dup(0, -1); /* because openpl will close 0! */
|
||||||
dflag=0;
|
dflag=0;
|
||||||
oflag="";
|
oflag="";
|
||||||
|
winsize = "512x512";
|
||||||
for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){
|
for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){
|
||||||
case 'd': dflag=1; break;
|
case 'd': dflag=1; break;
|
||||||
case 'o': oflag=arv[i]+2; break;
|
case 'o': oflag=arv[i]+2; break;
|
||||||
|
|
@ -168,7 +169,6 @@ main(int arc, char *arv[]){
|
||||||
case 'D': break;
|
case 'D': break;
|
||||||
case 'd': break;
|
case 'd': break;
|
||||||
case 'o': break;
|
case 'o': break;
|
||||||
case 'W': break;
|
|
||||||
case 's': break;
|
case 's': break;
|
||||||
case 'e': erase(); break;
|
case 'e': erase(); break;
|
||||||
case 'C': closepl(); break;
|
case 'C': closepl(); break;
|
||||||
|
|
@ -177,6 +177,7 @@ main(int arc, char *arv[]){
|
||||||
case 'f': cfill(ap+1); break;
|
case 'f': cfill(ap+1); break;
|
||||||
case 'p': pen(ap+1); break;
|
case 'p': pen(ap+1); break;
|
||||||
case 'g': grade(atof(ap+1)); break;
|
case 'g': grade(atof(ap+1)); break;
|
||||||
|
case 'W': winsize = ap+1; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((bp = Bopen(arv[1], OREAD)) == 0) {
|
else if ((bp = Bopen(arv[1], OREAD)) == 0) {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ File *lastfile;
|
||||||
Disk *disk;
|
Disk *disk;
|
||||||
long seq;
|
long seq;
|
||||||
|
|
||||||
|
char *winsize;
|
||||||
|
|
||||||
Rune baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
|
Rune baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
|
||||||
|
|
||||||
void usage(void);
|
void usage(void);
|
||||||
|
|
@ -82,6 +84,10 @@ main(int argc, char *argv[])
|
||||||
argc--;
|
argc--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'W':
|
||||||
|
--argc, argv++;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dprint("sam: unknown flag %c\n", argv[0][1]);
|
dprint("sam: unknown flag %c\n", argv[0][1]);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
|
|
@ -101,7 +107,7 @@ main(int argc, char *argv[])
|
||||||
if(home == 0)
|
if(home == 0)
|
||||||
home = "/";
|
home = "/";
|
||||||
if(!dflag)
|
if(!dflag)
|
||||||
startup(machine, Rflag, arg, ap);
|
startup(machine, Rflag, arg, argv);
|
||||||
notify(notifyf);
|
notify(notifyf);
|
||||||
getcurwd();
|
getcurwd();
|
||||||
if(argc>1){
|
if(argc>1){
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,15 @@ static char *exname;
|
||||||
void
|
void
|
||||||
getscreen(int argc, char **argv)
|
getscreen(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
USED(argc);
|
/* not exactly right */
|
||||||
USED(argv);
|
for(i=0; i<argc-1; i++){
|
||||||
|
if(strcmp(argv[i], "-W") == 0)
|
||||||
|
winsize = argv[i+1];
|
||||||
|
}
|
||||||
|
|
||||||
if(initdraw(panic1, nil, "sam") < 0){
|
if(initdraw(panic1, nil, "sam") < 0){
|
||||||
fprint(2, "samterm: initdraw: %r\n");
|
fprint(2, "samterm: initdraw: %r\n");
|
||||||
threadexitsall("init");
|
threadexitsall("init");
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,12 @@ threadmain(int argc, char *argv[])
|
||||||
Bprint(bout, "prev: %V\n", root.prev);
|
Bprint(bout, "prev: %V\n", root.prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprint(2, "read...\n");
|
||||||
n = vtread(z, root.score, VtDirType, buf, bsize);
|
n = vtread(z, root.score, VtDirType, buf, bsize);
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
sysfatal("could not read root dir");
|
sysfatal("could not read root dir");
|
||||||
|
|
||||||
|
fprint(2, "...\n");
|
||||||
/* fake up top level source */
|
/* fake up top level source */
|
||||||
memset(&source, 0, sizeof(source));
|
memset(&source, 0, sizeof(source));
|
||||||
memmove(source.score, root.score, VtScoreSize);
|
memmove(source.score, root.score, VtScoreSize);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define _GNU_SOURCE /* for Linux O_DIRECT */
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#define NOPLAN9DEFINES
|
#define NOPLAN9DEFINES
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
@ -25,6 +26,10 @@ p9create(char *path, int mode, ulong perm)
|
||||||
}else{
|
}else{
|
||||||
umode = (mode&3)|O_CREAT|O_TRUNC;
|
umode = (mode&3)|O_CREAT|O_TRUNC;
|
||||||
mode &= ~(3|OTRUNC);
|
mode &= ~(3|OTRUNC);
|
||||||
|
if(mode&ODIRECT){
|
||||||
|
umode |= O_DIRECT;
|
||||||
|
mode &= ~ODIRECT;
|
||||||
|
}
|
||||||
if(mode&OEXCL){
|
if(mode&OEXCL){
|
||||||
umode |= O_EXCL;
|
umode |= O_EXCL;
|
||||||
mode &= ~OEXCL;
|
mode &= ~OEXCL;
|
||||||
|
|
|
||||||
|
|
@ -167,3 +167,4 @@ HFILES=\
|
||||||
%.$O: utf/%.c
|
%.$O: utf/%.c
|
||||||
$CC $CFLAGS utf/$stem.c
|
$CC $CFLAGS utf/$stem.c
|
||||||
|
|
||||||
|
rendez-Linux.$O: rendez-futex.c rendez-signal.c
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#define _GNU_SOURCE /* for Linux O_DIRECT */
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#define NOPLAN9DEFINES
|
#define NOPLAN9DEFINES
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
@ -16,6 +17,10 @@ p9open(char *name, int mode)
|
||||||
umode |= O_TRUNC;
|
umode |= O_TRUNC;
|
||||||
mode ^= OTRUNC;
|
mode ^= OTRUNC;
|
||||||
}
|
}
|
||||||
|
if(mode&ODIRECT){
|
||||||
|
umode |= O_DIRECT;
|
||||||
|
mode ^= ODIRECT;
|
||||||
|
}
|
||||||
if(mode){
|
if(mode){
|
||||||
werrstr("mode not supported");
|
werrstr("mode not supported");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,10 @@ getqlp(void)
|
||||||
for(p = op+1; ; p++){
|
for(p = op+1; ; p++){
|
||||||
if(p == &ql.x[nelem(ql.x)])
|
if(p == &ql.x[nelem(ql.x)])
|
||||||
p = ql.x;
|
p = ql.x;
|
||||||
if(p == op)
|
if(p == op){
|
||||||
|
fprint(2, "qlock: out of qlp\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
if(_tas(&(p->inuse)) == 0){
|
if(_tas(&(p->inuse)) == 0){
|
||||||
ql.p = p;
|
ql.p = p;
|
||||||
p->next = nil;
|
p->next = nil;
|
||||||
|
|
@ -233,8 +235,10 @@ wunlock(RWLock *q)
|
||||||
QLp *p;
|
QLp *p;
|
||||||
|
|
||||||
lock(&q->lock);
|
lock(&q->lock);
|
||||||
if(q->writer == 0)
|
if(q->writer == 0){
|
||||||
|
fprint(2, "wunlock: not holding lock\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
p = q->head;
|
p = q->head;
|
||||||
if(p == nil){
|
if(p == nil){
|
||||||
q->writer = 0;
|
q->writer = 0;
|
||||||
|
|
@ -252,8 +256,10 @@ wunlock(RWLock *q)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p->state != QueuingR)
|
if(p->state != QueuingR){
|
||||||
|
fprint(2, "wunlock: bad state\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
/* wake waiting readers */
|
/* wake waiting readers */
|
||||||
while(q->head != nil && q->head->state == QueuingR){
|
while(q->head != nil && q->head->state == QueuingR){
|
||||||
|
|
@ -274,12 +280,16 @@ rsleep(Rendez *r)
|
||||||
{
|
{
|
||||||
QLp *t, *me;
|
QLp *t, *me;
|
||||||
|
|
||||||
if(!r->l)
|
if(!r->l){
|
||||||
|
fprint(2, "rsleep: no lock\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
lock(&r->l->lock);
|
lock(&r->l->lock);
|
||||||
/* we should hold the qlock */
|
/* we should hold the qlock */
|
||||||
if(!r->l->locked)
|
if(!r->l->locked){
|
||||||
|
fprint(2, "rsleep: not locked\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
/* add ourselves to the wait list */
|
/* add ourselves to the wait list */
|
||||||
me = getqlp();
|
me = getqlp();
|
||||||
|
|
@ -309,8 +319,10 @@ rsleep(Rendez *r)
|
||||||
while((*_rendezvousp)((ulong)me, 0x23456) == ~0)
|
while((*_rendezvousp)((ulong)me, 0x23456) == ~0)
|
||||||
;
|
;
|
||||||
me->inuse = 0;
|
me->inuse = 0;
|
||||||
if(!r->l->locked)
|
if(!r->l->locked){
|
||||||
|
fprint(2, "rsleep: not locked after wakeup\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -323,11 +335,15 @@ rwakeup(Rendez *r)
|
||||||
* put on front so guys that have been waiting will not get starved
|
* put on front so guys that have been waiting will not get starved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!r->l)
|
if(!r->l){
|
||||||
|
fprint(2, "rwakeup: no lock\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
lock(&r->l->lock);
|
lock(&r->l->lock);
|
||||||
if(!r->l->locked)
|
if(!r->l->locked){
|
||||||
|
fprint(2, "rwakeup: not locked\n");
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
t = r->head;
|
t = r->head;
|
||||||
if(t == nil){
|
if(t == nil){
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@
|
||||||
#include <cursor.h>
|
#include <cursor.h>
|
||||||
#include "x11-memdraw.h"
|
#include "x11-memdraw.h"
|
||||||
|
|
||||||
|
char *winsize;
|
||||||
|
static int parsewinsize(char*, Rectangle*, int*);
|
||||||
|
|
||||||
static Memimage *xattach(char*);
|
static Memimage *xattach(char*);
|
||||||
static void plan9cmap(void);
|
static void plan9cmap(void);
|
||||||
static int setupcmap(XWindow);
|
static int setupcmap(XWindow);
|
||||||
|
|
@ -180,7 +183,7 @@ static Memimage*
|
||||||
xattach(char *label)
|
xattach(char *label)
|
||||||
{
|
{
|
||||||
char *argv[2], *disp;
|
char *argv[2], *disp;
|
||||||
int i, n, xrootid;
|
int i, n, xrootid, havemin;
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
XClassHint classhint;
|
XClassHint classhint;
|
||||||
XDrawable pmid;
|
XDrawable pmid;
|
||||||
|
|
@ -318,8 +321,14 @@ xattach(char *label)
|
||||||
* This is arbitrary. In theory we should read the
|
* This is arbitrary. In theory we should read the
|
||||||
* command line and allow the traditional X options.
|
* command line and allow the traditional X options.
|
||||||
*/
|
*/
|
||||||
r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
|
if(winsize){
|
||||||
|
if(parsewinsize(winsize, &r, &havemin) < 0)
|
||||||
|
sysfatal("%r");
|
||||||
|
}else{
|
||||||
|
r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
|
||||||
HeightOfScreen(xscreen)*3/4);
|
HeightOfScreen(xscreen)*3/4);
|
||||||
|
havemin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&attr, 0, sizeof attr);
|
memset(&attr, 0, sizeof attr);
|
||||||
attr.colormap = _x.cmap;
|
attr.colormap = _x.cmap;
|
||||||
|
|
@ -353,7 +362,14 @@ xattach(char *label)
|
||||||
name.nitems = strlen((char*)name.value);
|
name.nitems = strlen((char*)name.value);
|
||||||
|
|
||||||
memset(&normalhint, 0, sizeof normalhint);
|
memset(&normalhint, 0, sizeof normalhint);
|
||||||
normalhint.flags = USSize|PMaxSize;
|
normalhint.flags = PSize|PMaxSize;
|
||||||
|
if(winsize){
|
||||||
|
normalhint.flags &= ~PSize;
|
||||||
|
normalhint.flags |= USSize;
|
||||||
|
normalhint.width = Dx(r);
|
||||||
|
normalhint.height = Dy(r);
|
||||||
|
}
|
||||||
|
|
||||||
normalhint.max_width = WidthOfScreen(xscreen);
|
normalhint.max_width = WidthOfScreen(xscreen);
|
||||||
normalhint.max_height = HeightOfScreen(xscreen);
|
normalhint.max_height = HeightOfScreen(xscreen);
|
||||||
|
|
||||||
|
|
@ -382,6 +398,15 @@ xattach(char *label)
|
||||||
);
|
);
|
||||||
XFlush(_x.display);
|
XFlush(_x.display);
|
||||||
|
|
||||||
|
if(havemin){
|
||||||
|
XWindowChanges ch;
|
||||||
|
|
||||||
|
memset(&ch, 0, sizeof ch);
|
||||||
|
ch.x = r.min.x;
|
||||||
|
ch.y = r.min.y;
|
||||||
|
XConfigureWindow(_x.display, _x.drawable, CWX|CWY, &ch);
|
||||||
|
fprint(2, "havemin %d %d\n", r.min.x, r.min.y);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Look up clipboard atom.
|
* Look up clipboard atom.
|
||||||
*/
|
*/
|
||||||
|
|
@ -783,3 +808,73 @@ xreplacescreenimage(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parsewinsize(char *s, Rectangle *r, int *havemin)
|
||||||
|
{
|
||||||
|
char c, *os;
|
||||||
|
int i, j, k, l;
|
||||||
|
|
||||||
|
os = s;
|
||||||
|
*havemin = 0;
|
||||||
|
*r = Rect(0,0,0,0);
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
i = strtol(s, &s, 0);
|
||||||
|
if(*s == 'x'){
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
j = strtol(s, &s, 0);
|
||||||
|
r->max.x = i;
|
||||||
|
r->max.y = j;
|
||||||
|
if(*s == 0)
|
||||||
|
return 0;
|
||||||
|
if(*s != '@')
|
||||||
|
goto oops;
|
||||||
|
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
i = strtol(s, &s, 0);
|
||||||
|
if(*s != ',' && *s != ' ')
|
||||||
|
goto oops;
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
j = strtol(s, &s, 0);
|
||||||
|
if(*s != 0)
|
||||||
|
goto oops;
|
||||||
|
*r = rectaddpt(*r, Pt(i,j));
|
||||||
|
*havemin = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c = *s;
|
||||||
|
if(c != ' ' && c != ',')
|
||||||
|
goto oops;
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
j = strtol(s, &s, 0);
|
||||||
|
if(*s != c)
|
||||||
|
goto oops;
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
k = strtol(s, &s, 0);
|
||||||
|
if(*s != c)
|
||||||
|
goto oops;
|
||||||
|
s++;
|
||||||
|
if(!isdigit(*s))
|
||||||
|
goto oops;
|
||||||
|
l = strtol(s, &s, 0);
|
||||||
|
if(*s != 0)
|
||||||
|
goto oops;
|
||||||
|
*r = Rect(i,j,k,l);
|
||||||
|
*havemin = 1;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
oops:
|
||||||
|
werrstr("bad syntax in window size '%s'", os);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,18 @@ drawtopwindow(void)
|
||||||
XFlush(_x.display);
|
XFlush(_x.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawresizewindow(Rectangle r)
|
||||||
|
{
|
||||||
|
// XConfigureRequestEvent e;
|
||||||
|
XWindowChanges e;
|
||||||
|
int value_mask;
|
||||||
|
|
||||||
|
memset(&e, 0, sizeof e);
|
||||||
|
value_mask = CWWidth|CWHeight;
|
||||||
|
// e.x = r.min.x;
|
||||||
|
// e.y = r.min.y;
|
||||||
|
e.width = Dx(r);
|
||||||
|
e.height = Dy(r);
|
||||||
|
XConfigureWindow(_x.display, _x.drawable, value_mask, &e);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ dwarfget128(DwarfBuf *b)
|
||||||
{n1++;
|
{n1++;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
c &= ~0x80;
|
||||||
d = *b->p++;
|
d = *b->p++;
|
||||||
c |= (d&0x7F)<<7;
|
c |= (d&0x7F)<<7;
|
||||||
if(!(d&0x80))
|
if(!(d&0x80))
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,7 @@ _newproc(void (*f)(void *arg), void *arg, uint stacksize, char *name, int grp, i
|
||||||
else
|
else
|
||||||
*_threadpq.tail = p;
|
*_threadpq.tail = p;
|
||||||
_threadpq.tail = &p->next;
|
_threadpq.tail = &p->next;
|
||||||
|
|
||||||
if(_threadprocs == 1)
|
if(_threadprocs == 1)
|
||||||
_threadmultiproc();
|
_threadmultiproc();
|
||||||
_threadprocs++;
|
_threadprocs++;
|
||||||
|
|
|
||||||
|
|
@ -52,20 +52,20 @@ threadgetgrp(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
threadsetname(char *name)
|
threadsetname(char *fmt, ...)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int fd, n;
|
|
||||||
char buf[128], *s;
|
|
||||||
*/
|
|
||||||
Proc *p;
|
Proc *p;
|
||||||
Thread *t;
|
Thread *t;
|
||||||
|
va_list arg;
|
||||||
|
|
||||||
p = _threadgetproc();
|
p = _threadgetproc();
|
||||||
t = p->thread;
|
t = p->thread;
|
||||||
if (t->cmdname)
|
if (t->cmdname)
|
||||||
free(t->cmdname);
|
free(t->cmdname);
|
||||||
t->cmdname = strdup(name);
|
va_start(arg, fmt);
|
||||||
|
t->cmdname = vsmprint(fmt, arg);
|
||||||
|
va_end(fmt);
|
||||||
|
|
||||||
/* Plan 9 only
|
/* Plan 9 only
|
||||||
if(p->nthreads == 1){
|
if(p->nthreads == 1){
|
||||||
snprint(buf, sizeof buf, "#p/%d/args", getpid());
|
snprint(buf, sizeof buf, "#p/%d/args", getpid());
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ threadmain(int argc, char **argv)
|
||||||
buffer = atoi(ARGF());
|
buffer = atoi(ARGF());
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
fn=proccreate;
|
fn = proccreate;
|
||||||
break;
|
break;
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ typedef struct VtSconn VtSconn;
|
||||||
struct VtSconn
|
struct VtSconn
|
||||||
{
|
{
|
||||||
int ctl;
|
int ctl;
|
||||||
|
int ref;
|
||||||
|
QLock lk;
|
||||||
char dir[NETPATHLEN];
|
char dir[NETPATHLEN];
|
||||||
VtSrv *srv;
|
VtSrv *srv;
|
||||||
VtConn *c;
|
VtConn *c;
|
||||||
|
|
@ -29,6 +31,27 @@ struct VtSrv
|
||||||
static void listenproc(void*);
|
static void listenproc(void*);
|
||||||
static void connproc(void*);
|
static void connproc(void*);
|
||||||
|
|
||||||
|
static void
|
||||||
|
scincref(VtSconn *sc)
|
||||||
|
{
|
||||||
|
qlock(&sc->lk);
|
||||||
|
sc->ref++;
|
||||||
|
qunlock(&sc->lk);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
scdecref(VtSconn *sc)
|
||||||
|
{
|
||||||
|
qlock(&sc->lk);
|
||||||
|
if(--sc->ref > 0){
|
||||||
|
qunlock(&sc->lk);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(sc->c)
|
||||||
|
vtfreeconn(sc->c);
|
||||||
|
vtfree(sc);
|
||||||
|
}
|
||||||
|
|
||||||
VtSrv*
|
VtSrv*
|
||||||
vtlisten(char *addr)
|
vtlisten(char *addr)
|
||||||
{
|
{
|
||||||
|
|
@ -55,14 +78,13 @@ listenproc(void *v)
|
||||||
|
|
||||||
srv = v;
|
srv = v;
|
||||||
for(;;){
|
for(;;){
|
||||||
fprint(2, "listen for venti\n");
|
|
||||||
ctl = listen(srv->adir, dir);
|
ctl = listen(srv->adir, dir);
|
||||||
if(ctl < 0){
|
if(ctl < 0){
|
||||||
srv->dead = 1;
|
srv->dead = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprint(2, "got one\n");
|
|
||||||
sc = vtmallocz(sizeof(VtSconn));
|
sc = vtmallocz(sizeof(VtSconn));
|
||||||
|
sc->ref = 1;
|
||||||
sc->ctl = ctl;
|
sc->ctl = ctl;
|
||||||
sc->srv = srv;
|
sc->srv = srv;
|
||||||
strcpy(sc->dir, dir);
|
strcpy(sc->dir, dir);
|
||||||
|
|
@ -82,8 +104,8 @@ connproc(void *v)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
r = nil;
|
r = nil;
|
||||||
c = nil;
|
|
||||||
sc = v;
|
sc = v;
|
||||||
|
sc->c = nil;
|
||||||
fprint(2, "new call %s on %d\n", sc->dir, sc->ctl);
|
fprint(2, "new call %s on %d\n", sc->dir, sc->ctl);
|
||||||
fd = accept(sc->ctl, sc->dir);
|
fd = accept(sc->ctl, sc->dir);
|
||||||
close(sc->ctl);
|
close(sc->ctl);
|
||||||
|
|
@ -122,7 +144,9 @@ connproc(void *v)
|
||||||
break;
|
break;
|
||||||
r->rx.tag = r->tx.tag;
|
r->rx.tag = r->tx.tag;
|
||||||
r->sc = sc;
|
r->sc = sc;
|
||||||
|
scincref(sc);
|
||||||
if(_vtqsend(sc->srv->q, r) < 0){
|
if(_vtqsend(sc->srv->q, r) < 0){
|
||||||
|
scdecref(sc);
|
||||||
fprint(2, "hungup queue\n");
|
fprint(2, "hungup queue\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -136,10 +160,8 @@ out:
|
||||||
vtfcallclear(&r->tx);
|
vtfcallclear(&r->tx);
|
||||||
vtfree(r);
|
vtfree(r);
|
||||||
}
|
}
|
||||||
if(c)
|
|
||||||
vtfreeconn(c);
|
|
||||||
fprint(2, "freed %s\n", sc->dir);
|
fprint(2, "freed %s\n", sc->dir);
|
||||||
vtfree(sc);
|
scdecref(sc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,6 +189,7 @@ vtrespond(VtReq *r)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vtsend(sc->c, p);
|
vtsend(sc->c, p);
|
||||||
|
scdecref(sc);
|
||||||
vtfcallclear(&r->tx);
|
vtfcallclear(&r->tx);
|
||||||
vtfcallclear(&r->rx);
|
vtfcallclear(&r->rx);
|
||||||
vtfree(r);
|
vtfree(r);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue