ref: e8db11ffda62be8c165341ffd91e94b68b1ac051
parent: 6d96112f6ce0be241bdd2e09d5c80af040852574
author: qwx <qwx@sciops.net>
date: Sun Sep 17 09:02:45 EDT 2023
page, png, riow, upas: remove some patches promoted to fork repo
--- a/page-del
+++ /dev/null
@@ -1,144 +1,0 @@
-diff 9d43029ff984435111eff658308a44b4f3eee1cc uncommitted
---- a//sys/src/cmd/page.c
-+++ b//sys/src/cmd/page.c
-@@ -74,7 +74,10 @@
- Czerox,
- Cwrite,
- Cext,
-+ Cpop,
- Cdummy2,
-+ Cdelete,
-+ Cdummy3,
- Cquit,
- };
-
-@@ -98,7 +101,10 @@
- [Czerox] "zerox", 'z', 0, 0,
- [Cwrite] "write", 'w', 0, 0,
- [Cext] "ext", 'x', 0, 0,
-+ [Cpop] "pop", 'p', 0, 0,
- [Cdummy2] "", 0, 0, 0,
-+ [Cdelete] "delete", 'D', 0, 0,
-+ [Cdummy3] "", 0, 0, 0,
- [Cquit] "quit", 'q', Kdel, Keof,
- };
-
-@@ -134,6 +140,7 @@
- void showpage(Page *);
- void drawpage(Page *);
- Point pagesize(Page *);
-+void drawlock(int);
-
- Page*
- addpage(Page *up, char *name, int (*popen)(Page *), void *pdata, int fd)
-@@ -987,6 +994,72 @@
- }
- }
-
-+/* doesn't actually free the page entry or touch links to avoid breakage */
-+Page*
-+freepage(Page *p, Page *prev)
-+{
-+ Page *next, *up;
-+
-+ drawlock(0);
-+ unloadpage(p);
-+ drawlock(1);
-+ if(p->fd >= 0)
-+ close(p->fd);
-+ p->fd = -1;
-+ /* not touching p->data */
-+ free(p->name);
-+ p->name = nil;
-+ p->open = nil;
-+ next = nextpage(p);
-+ up = p->up;
-+ if(up->down == p){
-+ if(up->tail != p)
-+ up->down = next;
-+ else
-+ up->down = nil;
-+ }else if(up->tail == p){
-+ up->tail = prev;
-+ prev->next = nil;
-+ }else
-+ prev->next = next;
-+ return next;
-+}
-+
-+Page*
-+poppage(Page *p, int del)
-+{
-+ Page *t, *prev, *next;
-+
-+ if(p == nil)
-+ return nil;
-+ if(p == root)
-+ return p;
-+ if(del){
-+ if(!(access(p->name, OREAD) == 0 && remove(p->name) == 0
-+ || p->data != nil && access(p->data, OREAD) == 0 && remove(p->data) == 0)){
-+ fprint(2, "remove %s: %r", p->name);
-+ return p;
-+ }
-+ }
-+ qlock(&pagelock);
-+ for(t = p->down, prev = p; t != nil && t->up != p->up; prev = t, t = next){
-+ qlock(t);
-+ next = freepage(t, prev);
-+ qunlock(t);
-+ }
-+ p->down = nil;
-+ prev = prevpage(p);
-+ next = freepage(p, prev);
-+ qunlock(&pagelock);
-+ qunlock(p);
-+ if(next != nil){
-+ forward = 1;
-+ return next;
-+ }
-+ forward = -1;
-+ return prev;
-+}
-+
- /*
- * A draw operation that touches only the area contained in bot but not in top.
- * mp and sp get aligned with bot.min.
-@@ -1462,8 +1535,10 @@
- {
- char buf[NPATH], *s;
- Point o;
-- int fd;
-+ int fd, del;
-+ Page *p;
-
-+ del = 0;
- switch(i){
- case Corigsize:
- pos = ZP;
-@@ -1547,6 +1622,25 @@
- break;
- case Csnarf:
- writeaddr(current, "/dev/snarf");
-+ break;
-+ case Cdelete:
-+ del = 1;
-+ /* wet floor */
-+ case Cpop:
-+ if(current == nil || !canqlock(current))
-+ break;
-+ if((p = poppage(current, del)) == current){
-+ qunlock(current);
-+ break;
-+ }
-+ if((current = p) == nil){
-+ drawlock(0);
-+ draw(screen, screen->r, paper, nil, ZP);
-+ drawframe(screen->r);
-+ drawlock(1);
-+ break;
-+ }
-+ showpage(current);
- break;
- case Cnext:
- forward = 1;
--- a/page-invert
+++ /dev/null
@@ -1,73 +1,0 @@
-diff 6e64d30454f71ecda88dba1bd792e97509115d73 uncommitted
---- a//sys/src/cmd/page.c
-+++ b//sys/src/cmd/page.c
-@@ -33,6 +33,7 @@
- int imode;
- int newwin;
- int rotate;
-+int invert;
- int viewgen;
- int forward; /* read ahead direction: >= 0 forwards, < 0 backwards */
- Point resize, pos;
-@@ -67,6 +68,7 @@
- Cfitheight,
- Crotate90,
- Cupsidedown,
-+ Cinvert,
- Cdummy1,
- Cnext,
- Cprev,
-@@ -91,6 +93,7 @@
- [Cfitheight] "fit height", 'h', 0, 0,
- [Crotate90] "rotate 90", 'r', 0, 0,
- [Cupsidedown] "upside down", 'u', 0, 0,
-+ [Cinvert] "invert", 'i', 0, 0,
- [Cdummy1] "", 0, 0, 0,
- [Cnext] "next", Kright, ' ', '\n',
- [Cprev] "prev", Kleft, Kbs, 0,
-@@ -894,6 +897,26 @@
- }
-
- void
-+invertimage(Image *i)
-+{
-+ int n, m;
-+ uchar *b;
-+ uintptr *buf, *p;
-+
-+ n = imagesize(i);
-+ if((buf = malloc(n)) == nil)
-+ return;
-+ unloadimage(i, i->r, (uchar*)buf, n);
-+ m = n;
-+ for(p=buf; m>=sizeof *p; m-=sizeof *p, p++)
-+ *p = ~*p;
-+ for(b=(uchar*)p; m>0; m--, b++)
-+ *b = ~*b;
-+ loadimage(i, i->r, (uchar*)buf, n);
-+ free(buf);
-+}
-+
-+void
- loadpage(Page *p)
- {
- int fd;
-@@ -913,6 +936,8 @@
- p->open = nil;
- else {
- lockdisplay(display);
-+ if(invert)
-+ invertimage(p->image);
- imemsize += imagesize(p->image);
- unlockdisplay(display);
- }
-@@ -1492,6 +1517,9 @@
- zoom = 1;
- resize = subpt(screen->r.max, screen->r.min);
- resize.x = 0;
-+ goto Unload;
-+ case Cinvert:
-+ invert = !invert;
- goto Unload;
- case Czoomin:
- case Czoomout:
--- a/png-maxmem
+++ /dev/null
@@ -1,14 +1,0 @@
-wtf?
-
-diff -r 813115218568 sys/src/cmd/jpg/readpng.c
---- a/sys/src/cmd/jpg/readpng.c Tue Jan 19 13:06:22 2016 +0100
-+++ b/sys/src/cmd/jpg/readpng.c Sat Jan 23 08:13:54 2016 +0100
-@@ -10,7 +10,7 @@
-
- enum
- {
-- IDATSIZE = 8*1024*1024,
-+ IDATSIZE = 64*1024*1024,
-
- /* filtering algorithms */
- FilterNone = 0, /* new[x][y] = buf[x][y] */
--- a/png-trns-unfinished
+++ /dev/null
@@ -1,87 +1,0 @@
-png: read mTRS chunks for indexed rgb24 images
-
-FIXME: UNFINISHED, surely breaks with other formats, and code is crap
-- then, don't check against apalsize (which should not exist) but
- channel/nout/... settings
-- implement support for other modes, if we can find test pictures
-
-diff -r 321912cfedf3 sys/src/cmd/jpg/readpng.c
---- a/sys/src/cmd/jpg/readpng.c Sun Jun 25 22:57:47 2017 +0200
-+++ b/sys/src/cmd/jpg/readpng.c Mon Jun 26 23:29:03 2017 +0200
-@@ -46,6 +46,8 @@
- int pass; /* adam7 pass#; 0 means no adam7 */
- uchar palette[3*256]; /* color palette */
- int palsize; /* number of palette entries */
-+ uchar apalette[256]; /* optional alpha values for palette */
-+ int hasapal;
- };
-
- struct ZlibR
-@@ -142,8 +144,18 @@
- z->w->palsize = 256;
- goto Again;
- }
-- if(type[0] & PropertyBit)
-- goto Again; /* skip auxiliary chunks fornow */
-+ if(type[0] & PropertyBit){
-+ /* FIXME: non-3 formats are unhandled */
-+ if(strcmp(type,"tRNS"))
-+ goto Again; /* skip auxiliary chunks fornow */
-+ if(z->w->chandesc != CRGBA32 || z->w->nchan != 1)
-+ goto Again; /* unimplemented */
-+ if(n > z->w->palsize)
-+ sysfatal("invalid tRNS chunk len %d", n);
-+ memcpy(z->w->apalette, z->p, n);
-+ z->w->hasapal = 1;
-+ goto Again;
-+ }
- if(strcmp(type,"IDAT")){
- sysfatal("unrecognized mandatory chunk %s", type);
- goto Again;
-@@ -258,7 +270,7 @@
- j >>= 8-z->bpc;
- if(j >= z->palsize)
- sysfatal("index %d >= palette size %d", j, z->palsize);
-- pixel[3] = pixel[1]; /* alpha */
-+ pixel[3] = z->hasapal ? z->apalette[j] : pixel[1]; /* alpha */
- pixel[0] = z->palette[3*j];
- pixel[1] = z->palette[3*j+1];
- pixel[2] = z->palette[3*j+2];
-@@ -272,6 +284,12 @@
- case CRGBA32:
- // print("%.2x%.2x%.2x%.2x ", pixel[0], pixel[1], pixel[2], pixel[3]);
- *w++ += pixel[3];
-+ if(z->hasapal){
-+ *w++ = pixel[2];
-+ *w++ = pixel[1];
-+ *w++ = pixel[0];
-+ break;
-+ }
- *w++ += (pixel[2]*pixel[3])/255;
- *w++ += (pixel[1]*pixel[3])/255;
- *w++ += (pixel[0]*pixel[3])/255;
-@@ -438,9 +456,14 @@
- case 3: /* indexed rgb with PLTE */
- if(bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8)
- sysfatal("invalid indexed rgb bpc %d", bpc);
-+ /* FIXME: conditially set CRGBA32? maybe pngmalloc directly to zw buffer, resize it
-+ * as needed, and set it before returning? or perhaps alloc maximal size,
-+ * and if there's no valid tRNS chunk, shrink it before returning image;
-+ * so, alloc max, but use minimal params before inflating... */
-+ /* FIXME: support other formats */
- image->nchans = 1;
-- image->chandesc = CRGB24;
-- nout = 3;
-+ image->chandesc = CRGBA32;
-+ nout = 4;
- nchan = 1;
- break;
- case 4: /* grey+alpha */
-@@ -478,6 +501,7 @@
- zw.ndata = image->chanlen;
- zw.chandesc = image->chandesc;
- zw.noutchan = nout;
-+ memset(zw.apalette, 0xff, sizeof zw.apalette);
-
- zw.dx = dx;
- zw.dy = dy;
--- a/riow-scrub-sticky
+++ /dev/null
@@ -1,16 +1,0 @@
-diff 502fe5af32a3d275aa89ffc834157bdbabc45c50 uncommitted
---- a//sys/src/cmd/riow.c
-+++ b//sys/src/cmd/riow.c
-@@ -37,12 +37,6 @@
-
- static char *sticky[32] = {
- "bar",
-- "cat clock",
-- "clock",
-- "faces",
-- "kbmap",
-- "stats",
-- "winwatch",
- nil,
- };
-
--- a/upas-ignore-certs
+++ /dev/null
@@ -1,116 +1,0 @@
-diff 251c3cfd610abd169676852d301a2aa1267c0e57 uncommitted
---- a/sys/src/cmd/upas/fs/dat.h
-+++ b/sys/src/cmd/upas/fs/dat.h
-@@ -342,8 +342,10 @@
- extern int plumbing;
- extern ulong msgallocd;
- extern ulong msgfreed;
-+extern int nocertcheck;
- extern Mailbox *mbl;
- extern Message *root;
-+extern char *logf;
-
- #define dprint(...) if(debug) fprint(2, __VA_ARGS__); else {}
- #define Topmsg(mb, m) (m->whole == mb->root)
---- a/sys/src/cmd/upas/fs/fs.c
-+++ b/sys/src/cmd/upas/fs/fs.c
-@@ -114,6 +114,7 @@
- int debug;
- int plumbing = 1;
- ulong cachetarg = Maxcache;
-+int nocertcheck; /* ignore unrecognized certs. Still logged */
- Mailbox *mbl;
-
- static int messagesize = 8*1024 + IOHDRSZ;
-@@ -203,7 +204,7 @@
- void
- usage(void)
- {
-- fprint(2, "usage: upas/fs [-DSbdlmnps] [-c cachetarg] [-f mboxfile] [-m mountpoint]\n");
-+ fprint(2, "usage: upas/fs [-CDSbdlmnps] [-c cachetarg] [-f mboxfile] [-m mountpoint]\n");
- exits("usage");
- }
-
-@@ -271,6 +272,9 @@
- v = argv;
-
- ARGBEGIN{
-+ case 'C':
-+ nocertcheck = 1;
-+ break;
- case 'D':
- Dflag = 1;
- break;
---- a/sys/src/cmd/upas/fs/mbox.c
-+++ b/sys/src/cmd/upas/fs/mbox.c
-@@ -1634,7 +1634,7 @@
- return i;
- }
-
--static char *logf = "fs";
-+char *logf = "fs";
-
- void
- logmsg(Message *m, char *fmt, ...)
---- a/sys/src/cmd/upas/fs/tls.c
-+++ b/sys/src/cmd/upas/fs/tls.c
-@@ -17,6 +17,10 @@
- close(ofd);
- return -1;
- }
-+ if(nocertcheck){
-+ syslog(Sflag, logf, "ignoring cert for %s", host);
-+ goto skip;
-+ }
- thumb = initThumbprints("/sys/lib/tls/mail", "/sys/lib/tls/mail.exclude", "x509");
- if(thumb != nil){
- if(!okCertificate(conn.cert, conn.certlen, thumb)){
-@@ -26,6 +30,7 @@
- }
- freeThumbprints(thumb);
- }
-+skip:
- free(conn.cert);
- free(conn.sessionID);
- return fd;
---- a/sys/src/cmd/upas/smtp/smtp.c
-+++ b/sys/src/cmd/upas/smtp/smtp.c
-@@ -46,6 +46,7 @@
- int quitting; /* when error occurs in quit */
- int tryauth; /* Try to authenticate, if supported */
- int trysecure; /* Try to use TLS if the other side supports it */
-+int nocertcheck; /* ignore unrecognized certs. Still logged */
-
- char *quitrv; /* deferred return value when in quit */
- char ddomain[1024]; /* domain name of destination machine */
-@@ -85,7 +86,7 @@
- void
- usage(void)
- {
-- fprint(2, "usage: smtp [-aAdfipst] [-b busted-mx] [-g gw] [-h host] "
-+ fprint(2, "usage: smtp [-aACdfipst] [-b busted-mx] [-g gw] [-h host] "
- "[-u user] [.domain] net!host[!service] sender rcpt-list\n");
- exits(Giveup);
- }
-@@ -187,6 +188,9 @@
- case 'u':
- user = EARGF(usage());
- break;
-+ case 'C':
-+ nocertcheck = 1;
-+ break;
- default:
- usage();
- break;
-@@ -415,6 +419,11 @@
- Bterm(&bin);
- Binit(&bin, fd, OREAD);
-
-+ if (nocertcheck) {
-+ syslog(0, "smtp", "ignoring cert for %s", ddomain);
-+ err = nil;
-+ goto Out;
-+ }
- goodcerts = initThumbprints(smtpthumbs, smtpexclthumbs, "x509");
- if (goodcerts == nil) {
- syslog(0, "smtp", "bad thumbprints in %s", smtpthumbs);