summaryrefslogtreecommitdiff
path: root/appl
diff options
context:
space:
mode:
Diffstat (limited to 'appl')
-rw-r--r--appl/charon/mkfile2
-rw-r--r--appl/cmd/gunzip.b2
-rw-r--r--appl/cmd/mkfile1
-rw-r--r--appl/cmd/uniq.b15
-rw-r--r--appl/cmd/whois.b89
-rw-r--r--appl/svc/httpd/httpd.b4
-rw-r--r--appl/svc/httpd/httpd.suff3
-rw-r--r--appl/wm/memory.b6
-rw-r--r--appl/wm/view.b33
9 files changed, 143 insertions, 12 deletions
diff --git a/appl/charon/mkfile b/appl/charon/mkfile
index 6345f815..05ac5cb6 100644
--- a/appl/charon/mkfile
+++ b/appl/charon/mkfile
@@ -86,7 +86,7 @@ $ROOT/dis/charon.dis: charon.dis
charon.dis: $MODULES $SYS_MODULES
img.dis: img.b $MODULE $SYS_MODULE
- limbo $LIMBOFLAGS -c -gw img.b
+ limbo $LIMBOFLAGS -gw img.b
nuke:V:
rm -f $ROOT/dis/charon.dis
diff --git a/appl/cmd/gunzip.b b/appl/cmd/gunzip.b
index 6cb9eaf8..06ccd4a5 100644
--- a/appl/cmd/gunzip.b
+++ b/appl/cmd/gunzip.b
@@ -34,7 +34,7 @@ init(nil: ref Draw->Context, argv: list of string)
if (bufio == nil)
fatal(sys->sprint("cannot load %s: %r", Bufio->PATH));
str = load String String->PATH;
- if (bufio == nil)
+ if (str == nil)
fatal(sys->sprint("cannot load %s: %r", String->PATH));
inflate = load Filter INFLATEPATH;
if (inflate == nil)
diff --git a/appl/cmd/mkfile b/appl/cmd/mkfile
index a158edaa..a3cc6c09 100644
--- a/appl/cmd/mkfile
+++ b/appl/cmd/mkfile
@@ -170,6 +170,7 @@ TARG=\
wav2iaf.dis\
wc.dis\
webgrab.dis\
+ whois.dis\
wish.dis\
wmexport.dis\
wmimport.dis\
diff --git a/appl/cmd/uniq.b b/appl/cmd/uniq.b
index 4442c22f..9846e69f 100644
--- a/appl/cmd/uniq.b
+++ b/appl/cmd/uniq.b
@@ -13,7 +13,7 @@ Uniq: module
usage()
{
- fail("usage", sys->sprint("usage: uniq [-ud] [file]"));
+ fail("usage", sys->sprint("usage: uniq [-udc] [file]"));
}
init(nil : ref Draw->Context, args : list of string)
@@ -31,6 +31,7 @@ init(nil : ref Draw->Context, args : list of string)
uflag := 0;
dflag := 0;
+ cflag := 0;
arg->init(args);
while ((opt := arg->opt()) != 0) {
case opt {
@@ -38,6 +39,8 @@ init(nil : ref Draw->Context, args : list of string)
uflag = 1;
'd' =>
dflag = 1;
+ 'c' =>
+ cflag = 1;
* =>
usage();
}
@@ -61,14 +64,20 @@ init(nil : ref Draw->Context, args : list of string)
if (s == prev)
n++;
else {
- if ((uflag && n == 1) || (dflag && n > 1))
+ if ((uflag && n == 1) || (dflag && n > 1)) {
+ if(cflag)
+ prev = string n + "\t" + prev;
stdout.puts(prev);
+ }
n = 1;
prev = s;
}
}
- if ((uflag && n == 1) || (dflag && n > 1))
+ if ((uflag && n == 1) || (dflag && n > 1)) {
+ if(cflag)
+ prev = string n + "\t" + prev;
stdout.puts(prev);
+ }
stdout.close();
}
diff --git a/appl/cmd/whois.b b/appl/cmd/whois.b
new file mode 100644
index 00000000..f89fb601
--- /dev/null
+++ b/appl/cmd/whois.b
@@ -0,0 +1,89 @@
+implement Whois;
+
+include "sys.m"; sys: Sys;
+include "draw.m";
+include "dial.m"; dial: Dial;
+include "arg.m";
+
+Whois: module {
+ init: fn(nil: ref Draw->Context, args: list of string);
+};
+
+init(nil: ref Draw->Context, args: list of string) {
+ sys = load Sys Sys->PATH;
+ dial = load Dial Dial->PATH;
+ arg := load Arg Arg->PATH;
+
+ addr := "tcp!whois.iana.org!43";
+ expect_refer := 5;
+
+ arg->init(args);
+ arg->setusage("whois [-a addr] [-n] host");
+ while((opt := arg->opt()) != 0) {
+ case opt {
+ 'a' =>
+ addr = dial->netmkaddr(arg->earg(), "tcp", "43");
+ 'n' =>
+ expect_refer = 0;
+ * =>
+ arg->usage();
+ }
+ }
+
+ args = arg->argv();
+ if(len args != 1)
+ arg->usage();
+
+ host := hd args;
+ fd := whois(addr, host);
+
+ buf := array[512] of byte;
+ stdout := sys->fildes(1);
+ while((i := sys->read(fd, buf, len buf)) > 0) {
+ if(expect_refer) {
+ ls := sys->tokenize(string buf[0:i], "\n").t1;
+ newaddr: string = nil;
+ while(ls != nil) {
+ l := hd ls;
+ (n, rs) := sys->tokenize(l, " \t");
+ if(n == 2 && hd rs == "refer:") {
+ newaddr = dial->netmkaddr(hd tl rs, "tcp", "43");
+ break;
+ } else if(n == 3 && hd rs == "Whois" && hd tl rs == "Server:") {
+ newaddr = dial->netmkaddr(hd tl tl rs, "tcp", "43");
+ break;
+ }
+ ls = tl ls;
+ }
+ if(newaddr != nil) {
+ fd = whois(newaddr, host);
+ expect_refer--;
+ continue;
+ }
+ }
+ sys->write(stdout, buf, i);
+ }
+ if(i < 0) {
+ sys->fprint(sys->fildes(2), "whois: reading info: %r\n");
+ raise "fail:errors";
+ }
+}
+
+whois(addr: string, host: string): ref Sys->FD
+{
+ sys->print("[using server %s]\n", addr);
+ conn := dial->dial(addr, nil);
+ if(conn == nil) {
+ sys->fprint(sys->fildes(2), "whois: dialing %s: %r\n", addr);
+ raise "fail:errors";
+ }
+
+ fd := conn.dfd;
+ i := sys->fprint(fd, "%s\r\n", host);
+ if(i != len host + 2) {
+ sys->fprint(sys->fildes(2), "whois: sending name: %r\n");
+ raise "fail:errors";
+ }
+
+ return fd;
+}
diff --git a/appl/svc/httpd/httpd.b b/appl/svc/httpd/httpd.b
index db570a74..20d48f10 100644
--- a/appl/svc/httpd/httpd.b
+++ b/appl/svc/httpd/httpd.b
@@ -506,8 +506,8 @@ senddir(g: ref Private_info,vers,uri: string, fd: ref FD, mydir: ref Dir)
g.bout.puts("<table>\n");
for(i := 0; i < n; i++){
(typ, enc) := classify(a[i]);
- g.bout.puts(sys->sprint("<tr><td><a href=\"%s%s\">%s</A></td>",
- myname, a[i].name, a[i].name));
+ g.bout.puts(sys->sprint("<tr><td><a href=\"%s\">%s</A></td>",
+ a[i].name, a[i].name));
if(typ != nil){
if(typ.generic!=nil)
g.bout.puts(sys->sprint("<td>%s", typ.generic));
diff --git a/appl/svc/httpd/httpd.suff b/appl/svc/httpd/httpd.suff
index dbc599d2..110e4726 100644
--- a/appl/svc/httpd/httpd.suff
+++ b/appl/svc/httpd/httpd.suff
@@ -15,6 +15,7 @@
.bcpio application x-bcpio - # [Mosaic]
.bib text plain - # BibTex input
.c text plain - # C program
+.css text css - # CSS
.c++ text plain - # C++ program
.cc text plain - # [Mosaic]
.cdf application x-netcdf -
@@ -76,6 +77,7 @@
.rfr text plain - # refer
.rgb image x-rgb - # [Mosaic]
.roff application x-troff - # [Mosaic]
+.rss application rss+xml - # RSS feeds
.rtf application rtf - # [Mosaic]
.rtx text richtext - # MIME richtext [Mosaic]
.sh application x-shar -
@@ -83,6 +85,7 @@
.snd audio basic -
.sv4cpio application x-sv4cpio - # [Mosaic]
.sv4crc application x-sv4crc - # [Mosaic]
+.svg image svg+xml - # SVG images
.t application x-troff - # [Mosaic]
.tar application x-tar - # [Mosaic]
.taz application x-tar x-compress
diff --git a/appl/wm/memory.b b/appl/wm/memory.b
index 6bbfa68b..77221a8f 100644
--- a/appl/wm/memory.b
+++ b/appl/wm/memory.b
@@ -109,9 +109,9 @@ realinit(ctxt: ref Draw->Context)
maxx+x,
a[i].y + 8);
cmd(t, s);
- s = sys->sprint(".c itemconfigure %s -text '%s", a[i].tagsz, string a[i].size);
+ s = sys->sprint(".c itemconfigure %s -text '%s", a[i].tagsz, sizestr(a[i].size));
cmd(t, s);
- s = sys->sprint(".c itemconfigure %s -text '%d", a[i].tagiu, a[i].allocs-a[i].frees);
+ s = sys->sprint(".c itemconfigure %s -text '%s", a[i].tagiu, sizestr(a[i].allocs-a[i].frees));
cmd(t, s);
}
cmd(t, "update");
@@ -163,7 +163,7 @@ initdraw(n: int): int
sizestr(n: int): string
{
- if ((n / 1024) % 1024 == 0)
+ if ((n / 1024) % 1024 == 0 || n > (100 * 1024 * 1024))
return string (n / (1024 * 1024)) + "M";
return string (n / 1024) + "K";
}
diff --git a/appl/wm/view.b b/appl/wm/view.b
index c96ef87d..8e847e55 100644
--- a/appl/wm/view.b
+++ b/appl/wm/view.b
@@ -178,13 +178,42 @@ readimages(file: string, errdiff: int) : (array of ref Image, array of ref Image
# if transparency is enabled, errdiff==1 is probably a mistake,
# but there's no easy solution.
- (ims[i], err2) = imageremap->remap(ai[i], display, errdiff);
+ (ims[i], err2) = remap(ai[i], display, errdiff);
if(ims[i] == nil)
return(nil, nil, err2);
}
return (ims, masks, nil);
}
+remap(raw: ref RImagefile->Rawimage, display: ref Draw->Display, errdiff: int): (ref Draw->Image, string)
+{
+ case raw.chandesc {
+ RImagefile->CRGB =>
+ r := chanstopix(raw.chans, raw.r.dx(), raw.r.dy());
+ im := display.newimage(raw.r, Draw->RGB24, 0, Draw->White);
+ im.writepixels(im.r, r);
+ return (im, "");
+ * =>
+ return imageremap->remap(raw, display, errdiff);
+ }
+}
+
+chanstopix(chans : array of array of byte, width, height: int): array of byte
+{
+ r := chans[0];
+ g := chans[1];
+ b := chans[2];
+
+ rgb := array [3*len r] of byte;
+ bix := 0;
+ for (i := 0; i < len r ; i++) {
+ rgb[bix++] = b[i];
+ rgb[bix++] = g[i];
+ rgb[bix++] = r[i];
+ }
+ return rgb;
+}
+
viewcfg := array[] of {
"panel .p",
"menu .m",
@@ -212,7 +241,7 @@ timer(dt: int, ticks, pidc: chan of int)
view(ctxt: ref Context, ims, masks: array of ref Image, file: string)
{
file = lastcomponent(file);
- (t, titlechan) := tkclient->toplevel(ctxt, "", "view: "+file, Tkclient->Hide);
+ (t, titlechan) := tkclient->toplevel(ctxt, "", "view: "+file, Tkclient->Appl);
cmd := chan of string;
tk->namechan(t, cmd, "cmd");