Reorg
This commit is contained in:
parent
2df2758496
commit
522b0689c3
@ -71,6 +71,7 @@ long Bread(Biobuf*, void*, long);
|
|||||||
off_t Bseek(Biobuf*, off_t, int);
|
off_t Bseek(Biobuf*, off_t, int);
|
||||||
int Bterm(Biobuf*);
|
int Bterm(Biobuf*);
|
||||||
int Bungetc(Biobuf*);
|
int Bungetc(Biobuf*);
|
||||||
|
int Bungetrune(Biobuf*);
|
||||||
long Bwrite(Biobuf*, void*, long);
|
long Bwrite(Biobuf*, void*, long);
|
||||||
char* Brdstr(Biobuf*, int, int);
|
char* Brdstr(Biobuf*, int, int);
|
||||||
long Bgetrune(Biobuf*);
|
long Bgetrune(Biobuf*);
|
||||||
|
|||||||
19
src/Makefile
Normal file
19
src/Makefile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
DIRS=\
|
||||||
|
lib9\
|
||||||
|
libbio\
|
||||||
|
libdraw\
|
||||||
|
libfmt\
|
||||||
|
libframe\
|
||||||
|
libregexp\
|
||||||
|
libthread\
|
||||||
|
libutf\
|
||||||
|
mk\
|
||||||
|
sam\
|
||||||
|
samterm\
|
||||||
|
|
||||||
|
clean all install:
|
||||||
|
for i in $(DIRS); \
|
||||||
|
do \
|
||||||
|
(echo $$i; cd $$i; $(MAKE) $*); \
|
||||||
|
done
|
||||||
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# this works in gnu make
|
# this works in gnu make
|
||||||
SYSNAME:=${shell uname}
|
SYSNAME:=${shell uname}
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
||||||
@ -10,11 +9,13 @@ OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|||||||
# the gnu rules will mess up bsd but not vice versa,
|
# the gnu rules will mess up bsd but not vice versa,
|
||||||
# hence the gnu rules come first.
|
# hence the gnu rules come first.
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
X11=/usr/X11R6
|
||||||
|
LDFLAGS=
|
||||||
|
CFLAGS=
|
||||||
|
|
||||||
PREFIX=/usr/local
|
include $(9SRC)/Make.$(SYSNAME)-$(OBJTYPE)
|
||||||
|
LDFLAGS+=-L$(9SRC)/lib
|
||||||
|
|
||||||
|
CLEANFILES=*.$O
|
||||||
NUKEFILES=
|
NUKEFILES=
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
10
src/Makeone
Normal file
10
src/Makeone
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
$(TARG): $(OFILES)
|
||||||
|
$(CC) -o $(TARG) $(OFILES) $(LDFLAGS)
|
||||||
|
|
||||||
|
CLEANFILES+=$(TARG)
|
||||||
|
|
||||||
|
include $(9SRC)/Makecommon
|
||||||
|
|
||||||
|
install: $(TARG)
|
||||||
|
cp $(TARG) $(9SRC)/bin
|
||||||
|
|
||||||
7
src/Makesyslib
Normal file
7
src/Makesyslib
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
all: $(9SRC)/lib/$(LIB)
|
||||||
|
|
||||||
|
$(9SRC)/lib/$(LIB): $(OFILES)
|
||||||
|
$(AR) $(ARFLAGS) $(9SRC)/lib/$(LIB) $(OFILES)
|
||||||
|
|
||||||
|
include $(9SRC)/Makecommon
|
||||||
|
|
||||||
@ -1,27 +1,7 @@
|
|||||||
|
9SRC=..
|
||||||
# this works in gnu make
|
include $(9SRC)/Makehdr
|
||||||
SYSNAME:=${shell uname}
|
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
|
||||||
|
|
||||||
# this works in bsd make
|
|
||||||
SYSNAME!=uname
|
|
||||||
OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|
||||||
|
|
||||||
# the gnu rules will mess up bsd but not vice versa,
|
|
||||||
# hence the gnu rules come first.
|
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
|
||||||
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
NUKEFILES=
|
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
TARG=mk
|
TARG=mk
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/mk
|
|
||||||
NAME=mk
|
|
||||||
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
arc.$O\
|
arc.$O\
|
||||||
@ -51,67 +31,7 @@ HFILES=\
|
|||||||
mk.h\
|
mk.h\
|
||||||
fns.h\
|
fns.h\
|
||||||
|
|
||||||
all: $(TARG)
|
LDFLAGS+=-lregexp9 -lbio -lfmt -lutf
|
||||||
|
|
||||||
TGZFILES+=mk.pdf
|
include $(9SRC)/Makeone
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man1 || mkdir $(PREFIX)/man/man1
|
|
||||||
test -d $(PREFIX)/doc || mkdir $(PREFIX)/doc
|
|
||||||
install -m 0755 mk $(PREFIX)/bin/mk
|
|
||||||
cat mk.1 | sed 's;DOCPREFIX;$(PREFIX);g' >mk.1a
|
|
||||||
install -m 0644 mk.1a $(PREFIX)/man/man1/mk.1
|
|
||||||
install -m 0644 mk.pdf $(PREFIX)/doc/mk.pdf
|
|
||||||
|
|
||||||
|
|
||||||
$(TARG): $(OFILES)
|
|
||||||
$(CC) -o $(TARG) $(OFILES) -L$(PREFIX)/lib -lregexp9 -lbio -lfmt -lutf
|
|
||||||
|
|
||||||
|
|
||||||
.c.$O:
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
%.$O: %.c
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
|
|
||||||
$(OFILES): $(HFILES)
|
|
||||||
|
|
||||||
tgz:
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
mkdir $(NAME)-$(VERSION)
|
|
||||||
cp Makefile Make.* README LICENSE NOTICE *.[ch137] rpm.spec bundle.ports $(TGZFILES) $(NAME)-$(VERSION)
|
|
||||||
tar cf - $(NAME)-$(VERSION) | gzip >$(NAME)-$(VERSION).tgz
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OFILES) $(LIB)
|
|
||||||
|
|
||||||
nuke:
|
|
||||||
rm -f $(OFILES) *.tgz *.rpm $(NUKEFILES)
|
|
||||||
|
|
||||||
rpm:
|
|
||||||
make tgz
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/src/RPM/SOURCES
|
|
||||||
rpm -ba rpm.spec
|
|
||||||
cp /usr/src/RPM/SRPMS/$(NAME)-$(VERSION)-1.src.rpm .
|
|
||||||
cp /usr/src/RPM/RPMS/i586/$(NAME)-$(VERSION)-1.i586.rpm .
|
|
||||||
scp *.rpm rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
PORTDIR=/usr/ports/$(PORTPLACE)
|
|
||||||
|
|
||||||
ports:
|
|
||||||
make tgz
|
|
||||||
rm -rf $(PORTDIR)
|
|
||||||
mkdir $(PORTDIR)
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/ports/distfiles
|
|
||||||
cat bundle.ports | (cd $(PORTDIR) && awk '$$1=="---" && $$3=="---" { ofile=$$2; next} {if(ofile) print >ofile}')
|
|
||||||
(cd $(PORTDIR); make makesum)
|
|
||||||
(cd $(PORTDIR); make)
|
|
||||||
(cd $(PORTDIR); /usr/local/bin/portlint)
|
|
||||||
rm -rf $(PORTDIR)/work
|
|
||||||
shar `find $(PORTDIR)` > ports.shar
|
|
||||||
(cd $(PORTDIR); tar cf - *) | gzip >$(NAME)-$(VERSION)-ports.tgz
|
|
||||||
scp *.tgz rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
.phony: all clean nuke install tgz rpm ports
|
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
TARG=mk
|
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/mk
|
|
||||||
NAME=mk
|
|
||||||
|
|
||||||
OFILES=\
|
|
||||||
arc.$O\
|
|
||||||
archive.$O\
|
|
||||||
bufblock.$O\
|
|
||||||
env.$O\
|
|
||||||
file.$O\
|
|
||||||
graph.$O\
|
|
||||||
job.$O\
|
|
||||||
lex.$O\
|
|
||||||
main.$O\
|
|
||||||
match.$O\
|
|
||||||
mk.$O\
|
|
||||||
parse.$O\
|
|
||||||
recipe.$O\
|
|
||||||
rule.$O\
|
|
||||||
run.$O\
|
|
||||||
sh.$O\
|
|
||||||
shprint.$O\
|
|
||||||
symtab.$O\
|
|
||||||
var.$O\
|
|
||||||
varsub.$O\
|
|
||||||
word.$O\
|
|
||||||
unix.$O\
|
|
||||||
|
|
||||||
HFILES=\
|
|
||||||
mk.h\
|
|
||||||
fns.h\
|
|
||||||
|
|
||||||
all: $(TARG)
|
|
||||||
|
|
||||||
TGZFILES+=mk.pdf
|
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man1 || mkdir $(PREFIX)/man/man1
|
|
||||||
test -d $(PREFIX)/doc || mkdir $(PREFIX)/doc
|
|
||||||
install -m 0755 mk $(PREFIX)/bin/mk
|
|
||||||
cat mk.1 | sed 's;DOCPREFIX;$(PREFIX);g' >mk.1a
|
|
||||||
install -m 0644 mk.1a $(PREFIX)/man/man1/mk.1
|
|
||||||
install -m 0644 mk.pdf $(PREFIX)/doc/mk.pdf
|
|
||||||
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
--- Makefile ---
|
|
||||||
# New ports collection makefile for: mk
|
|
||||||
# Date Created: 11 Feb 2003
|
|
||||||
# Whom: rsc
|
|
||||||
#
|
|
||||||
# THIS LINE NEEDS REPLACING. IT'S HERE TO GET BY PORTLINT
|
|
||||||
# $FreeBSD: ports/devel/mk/Makefile,v 1.1 2003/02/12 00:51:22 rsc Exp $
|
|
||||||
|
|
||||||
PORTNAME= mk
|
|
||||||
PORTVERSION= 2.0
|
|
||||||
CATEGORIES= devel
|
|
||||||
MASTER_SITES= http://pdos.lcs.mit.edu/~rsc/software/
|
|
||||||
EXTRACT_SUFX= .tgz
|
|
||||||
|
|
||||||
MAINTAINER= rsc@post.harvard.edu
|
|
||||||
|
|
||||||
DEPENDS= ${PORTSDIR}/devel/libutf \
|
|
||||||
${PORTSDIR}/devel/libfmt \
|
|
||||||
${PORTSDIR}/devel/libbio \
|
|
||||||
${PORTSDIR}/devel/libregexp9
|
|
||||||
|
|
||||||
MAN1= mk.1
|
|
||||||
USE_REINPLACE= yes
|
|
||||||
|
|
||||||
.include <bsd.port.pre.mk>
|
|
||||||
|
|
||||||
post-patch:
|
|
||||||
${REINPLACE_CMD} -e 's,$$(PREFIX),${PREFIX},g' ${WRKSRC}/Makefile
|
|
||||||
|
|
||||||
.include <bsd.port.post.mk>
|
|
||||||
--- pkg-comment ---
|
|
||||||
Streamlined replacement for make
|
|
||||||
--- pkg-descr ---
|
|
||||||
Mk is a streamlined replacement for make, written for
|
|
||||||
Tenth Edition Research Unix by Andrew Hume.
|
|
||||||
|
|
||||||
WWW: http://pdos.lcs.mit.edu/~rsc/software/#mk
|
|
||||||
|
|
||||||
Russ Cox
|
|
||||||
rsc@post.harvard.edu
|
|
||||||
--- pkg-plist ---
|
|
||||||
bin/mk
|
|
||||||
doc/mk.pdf
|
|
||||||
--- /dev/null ---
|
|
||||||
This is just a way to make sure blank lines don't
|
|
||||||
creep into pkg-plist.
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
all:V: Makefile Make.FreeBSD-386 Make.Linux-386 Make.HP-UX-9000 Make.OSF1-alpha \
|
|
||||||
Make.SunOS-sun4u Make.SunOS-sun4u-cc Make.SunOS-sun4u-gcc \
|
|
||||||
Make.NetBSD-386 Make.Darwin-PowerMacintosh
|
|
||||||
|
|
||||||
Makefile:D: ../libutf/Makefile.TOP Makefile.MID ../libutf/Makefile.CMD ../libutf/Makefile.BOT
|
|
||||||
cat $prereq >$target
|
|
||||||
|
|
||||||
Make.%: ../libutf/Make.%
|
|
||||||
cp $prereq $target
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
Summary: Streamlined replacement for make
|
|
||||||
Name: mk
|
|
||||||
Version: 2.0
|
|
||||||
Release: 1
|
|
||||||
Group: Development/Utils
|
|
||||||
Copyright: Public Domain
|
|
||||||
Packager: Russ Cox <rsc@post.harvard.edu>
|
|
||||||
Source: http://pdos.lcs.mit.edu/~rsc/software/mk-2.0.tgz
|
|
||||||
URL: http://pdos.lcs.mit.edu/~rsc/software/#mk
|
|
||||||
Requires: libfmt libbio libregexp9 libutf
|
|
||||||
|
|
||||||
%description
|
|
||||||
Mk is a streamlined replacement for make, written for
|
|
||||||
Tenth Edition Research Unix by Andrew Hume.
|
|
||||||
|
|
||||||
http://plan9.bell-labs.com/sys/doc/mk.pdf
|
|
||||||
%prep
|
|
||||||
%setup
|
|
||||||
|
|
||||||
%build
|
|
||||||
make
|
|
||||||
|
|
||||||
%install
|
|
||||||
make install
|
|
||||||
|
|
||||||
%files
|
|
||||||
/usr/local/doc/mk.pdf
|
|
||||||
/usr/local/man/man1/mk.1
|
|
||||||
/usr/local/bin/mk
|
|
||||||
@ -1,18 +1,34 @@
|
|||||||
H=errors.h mesg.h parse.h plumb.h sam.h
|
9SRC=..
|
||||||
SRC= address.c buff.c cmd.c disk.c error.c file.c io.c\
|
include $(9SRC)/Makehdr
|
||||||
list.c mesg.c moveto.c multi.c unix.c rasp.c regexp.c\
|
|
||||||
sam.c shell.c string.c sys.c util.c xec.c plumb.c
|
|
||||||
|
|
||||||
CC=gcc
|
TARG=sam
|
||||||
PREFIX=$(HOME)
|
OFILES=sam.$O\
|
||||||
#PREFIX=/usr/local
|
address.$O\
|
||||||
CFLAGS=-I. -I$(PREFIX)/include -O -g
|
buff.$O\
|
||||||
LDFLAGS=-L$(PREFIX)/lib
|
cmd.$O\
|
||||||
LDLIBS=-l9 -lfmt -lutf
|
disk.$O\
|
||||||
|
error.$O\
|
||||||
|
file.$O\
|
||||||
|
io.$O\
|
||||||
|
list.$O\
|
||||||
|
mesg.$O\
|
||||||
|
moveto.$O\
|
||||||
|
multi.$O\
|
||||||
|
plumb.$O\
|
||||||
|
rasp.$O\
|
||||||
|
regexp.$O\
|
||||||
|
shell.$O\
|
||||||
|
string.$O\
|
||||||
|
sys.$O\
|
||||||
|
unix.$O\
|
||||||
|
util.$O\
|
||||||
|
xec.$O\
|
||||||
|
|
||||||
|
HFILES=sam.h\
|
||||||
|
errors.h\
|
||||||
|
mesg.h\
|
||||||
|
|
||||||
|
LDFLAGS+=-l9 -lfmt -lutf
|
||||||
|
|
||||||
|
include $(9SRC)/Makeone
|
||||||
|
|
||||||
all: sam
|
|
||||||
sam: $(SRC) $(H)
|
|
||||||
$(CC) -o $@ $(CFLAGS) $(SRC) $(LDFLAGS) $(LDLIBS)
|
|
||||||
clean:
|
|
||||||
rm -f *.o *~
|
|
||||||
rm -f sam
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ address(Addr *ap, Address a, int sign)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
a.r.p1 = a.r.p2 = f->_.nc;
|
a.r.p1 = a.r.p2 = f->b.nc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\'':
|
case '\'':
|
||||||
@ -52,7 +52,7 @@ address(Addr *ap, Address a, int sign)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '*':
|
case '*':
|
||||||
a.r.p1 = 0, a.r.p2 = f->_.nc;
|
a.r.p1 = 0, a.r.p2 = f->b.nc;
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
case ',':
|
case ',':
|
||||||
@ -69,7 +69,7 @@ address(Addr *ap, Address a, int sign)
|
|||||||
if(ap->next)
|
if(ap->next)
|
||||||
a2 = address(ap->next, a, 0);
|
a2 = address(ap->next, a, 0);
|
||||||
else
|
else
|
||||||
a2.f = a.f, a2.r.p1 = a2.r.p2 = f->_.nc;
|
a2.f = a.f, a2.r.p1 = a2.r.p2 = f->b.nc;
|
||||||
if(a1.f != a2.f)
|
if(a1.f != a2.f)
|
||||||
error(Eorder);
|
error(Eorder);
|
||||||
a.f = a1.f, a.r.p1 = a1.r.p1, a.r.p2 = a2.r.p2;
|
a.f = a1.f, a.r.p1 = a1.r.p1, a.r.p2 = a2.r.p2;
|
||||||
@ -101,7 +101,7 @@ nextmatch(File *f, String *r, Posn p, int sign)
|
|||||||
if(!execute(f, p, INFINITY))
|
if(!execute(f, p, INFINITY))
|
||||||
error(Esearch);
|
error(Esearch);
|
||||||
if(sel.p[0].p1==sel.p[0].p2 && sel.p[0].p1==p){
|
if(sel.p[0].p1==sel.p[0].p2 && sel.p[0].p1==p){
|
||||||
if(++p>f->_.nc)
|
if(++p>f->b.nc)
|
||||||
p = 0;
|
p = 0;
|
||||||
if(!execute(f, p, INFINITY))
|
if(!execute(f, p, INFINITY))
|
||||||
panic("address");
|
panic("address");
|
||||||
@ -111,7 +111,7 @@ nextmatch(File *f, String *r, Posn p, int sign)
|
|||||||
error(Esearch);
|
error(Esearch);
|
||||||
if(sel.p[0].p1==sel.p[0].p2 && sel.p[0].p2==p){
|
if(sel.p[0].p1==sel.p[0].p2 && sel.p[0].p2==p){
|
||||||
if(--p<0)
|
if(--p<0)
|
||||||
p = f->_.nc;
|
p = f->b.nc;
|
||||||
if(!bexecute(f, p))
|
if(!bexecute(f, p))
|
||||||
panic("address");
|
panic("address");
|
||||||
}
|
}
|
||||||
@ -156,10 +156,10 @@ filematch(File *f, String *r)
|
|||||||
/* A little dirty... */
|
/* A little dirty... */
|
||||||
if(menu == 0)
|
if(menu == 0)
|
||||||
menu = fileopen();
|
menu = fileopen();
|
||||||
bufreset(menu);
|
bufreset(&menu->b);
|
||||||
bufinsert(menu, 0, genstr.s, genstr.n);
|
bufinsert(&menu->b, 0, genstr.s, genstr.n);
|
||||||
compile(r);
|
compile(r);
|
||||||
return execute(menu, 0, menu->_.nc);
|
return execute(menu, 0, menu->b.nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address
|
Address
|
||||||
@ -171,7 +171,7 @@ charaddr(Posn l, Address addr, int sign)
|
|||||||
addr.r.p2 = addr.r.p1-=l;
|
addr.r.p2 = addr.r.p1-=l;
|
||||||
else if(sign > 0)
|
else if(sign > 0)
|
||||||
addr.r.p1 = addr.r.p2+=l;
|
addr.r.p1 = addr.r.p2+=l;
|
||||||
if(addr.r.p1<0 || addr.r.p2>addr.f->_.nc)
|
if(addr.r.p1<0 || addr.r.p2>addr.f->b.nc)
|
||||||
error(Erange);
|
error(Erange);
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
@ -203,14 +203,14 @@ lineaddr(Posn l, Address addr, int sign)
|
|||||||
n = filereadc(f, p++)=='\n';
|
n = filereadc(f, p++)=='\n';
|
||||||
}
|
}
|
||||||
while(n < l){
|
while(n < l){
|
||||||
if(p >= f->_.nc)
|
if(p >= f->b.nc)
|
||||||
error(Erange);
|
error(Erange);
|
||||||
if(filereadc(f, p++) == '\n')
|
if(filereadc(f, p++) == '\n')
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
a.r.p1 = p;
|
a.r.p1 = p;
|
||||||
}
|
}
|
||||||
while(p < f->_.nc && filereadc(f, p++)!='\n')
|
while(p < f->b.nc && filereadc(f, p++)!='\n')
|
||||||
;
|
;
|
||||||
a.r.p2 = p;
|
a.r.p2 = p;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -91,8 +91,8 @@ setcache(Buffer *b, uint q0)
|
|||||||
i = b->cbi;
|
i = b->cbi;
|
||||||
}
|
}
|
||||||
blp = &b->bl[i];
|
blp = &b->bl[i];
|
||||||
while(q+(*blp)->_.n <= q0 && q+(*blp)->_.n < b->nc){
|
while(q+(*blp)->u.n <= q0 && q+(*blp)->u.n < b->nc){
|
||||||
q += (*blp)->_.n;
|
q += (*blp)->u.n;
|
||||||
i++;
|
i++;
|
||||||
blp++;
|
blp++;
|
||||||
if(i >= b->nbl)
|
if(i >= b->nbl)
|
||||||
@ -102,8 +102,8 @@ setcache(Buffer *b, uint q0)
|
|||||||
/* remember position */
|
/* remember position */
|
||||||
b->cbi = i;
|
b->cbi = i;
|
||||||
b->cq = q;
|
b->cq = q;
|
||||||
sizecache(b, bl->_.n);
|
sizecache(b, bl->u.n);
|
||||||
b->cnc = bl->_.n;
|
b->cnc = bl->u.n;
|
||||||
/*read block*/
|
/*read block*/
|
||||||
diskread(disk, bl, b->c, b->cnc);
|
diskread(disk, bl, b->c, b->cnc);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,14 +185,14 @@ termcommand(void)
|
|||||||
{
|
{
|
||||||
Posn p;
|
Posn p;
|
||||||
|
|
||||||
for(p=cmdpt; p<cmd->_.nc; p++){
|
for(p=cmdpt; p<cmd->b.nc; p++){
|
||||||
if(terminp >= &termline[BLOCKSIZE]){
|
if(terminp >= &termline[BLOCKSIZE]){
|
||||||
cmdpt = cmd->_.nc;
|
cmdpt = cmd->b.nc;
|
||||||
error(Etoolong);
|
error(Etoolong);
|
||||||
}
|
}
|
||||||
*terminp++ = filereadc(cmd, p);
|
*terminp++ = filereadc(cmd, p);
|
||||||
}
|
}
|
||||||
cmdpt = cmd->_.nc;
|
cmdpt = cmd->b.nc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -64,20 +64,20 @@ disknewblock(Disk *d, uint n)
|
|||||||
size = ntosize(n, &i);
|
size = ntosize(n, &i);
|
||||||
b = d->free[i];
|
b = d->free[i];
|
||||||
if(b)
|
if(b)
|
||||||
d->free[i] = b->_.next;
|
d->free[i] = b->u.next;
|
||||||
else{
|
else{
|
||||||
/* allocate in chunks to reduce malloc overhead */
|
/* allocate in chunks to reduce malloc overhead */
|
||||||
if(blist == nil){
|
if(blist == nil){
|
||||||
blist = emalloc(100*sizeof(Block));
|
blist = emalloc(100*sizeof(Block));
|
||||||
for(j=0; j<100-1; j++)
|
for(j=0; j<100-1; j++)
|
||||||
blist[j]._.next = &blist[j+1];
|
blist[j].u.next = &blist[j+1];
|
||||||
}
|
}
|
||||||
b = blist;
|
b = blist;
|
||||||
blist = b->_.next;
|
blist = b->u.next;
|
||||||
b->addr = d->addr;
|
b->addr = d->addr;
|
||||||
d->addr += size;
|
d->addr += size;
|
||||||
}
|
}
|
||||||
b->_.n = n;
|
b->u.n = n;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ diskrelease(Disk *d, Block *b)
|
|||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
ntosize(b->_.n, &i);
|
ntosize(b->u.n, &i);
|
||||||
b->_.next = d->free[i];
|
b->u.next = d->free[i];
|
||||||
d->free[i] = b;
|
d->free[i] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n)
|
|||||||
Block *b;
|
Block *b;
|
||||||
|
|
||||||
b = *bp;
|
b = *bp;
|
||||||
size = ntosize(b->_.n, nil);
|
size = ntosize(b->u.n, nil);
|
||||||
nsize = ntosize(n, nil);
|
nsize = ntosize(n, nil);
|
||||||
if(size != nsize){
|
if(size != nsize){
|
||||||
diskrelease(d, b);
|
diskrelease(d, b);
|
||||||
@ -107,16 +107,16 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n)
|
|||||||
}
|
}
|
||||||
if(pwrite(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
|
if(pwrite(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
|
||||||
panic("write error to temp file");
|
panic("write error to temp file");
|
||||||
b->_.n = n;
|
b->u.n = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
diskread(Disk *d, Block *b, Rune *r, uint n)
|
diskread(Disk *d, Block *b, Rune *r, uint n)
|
||||||
{
|
{
|
||||||
if(n > b->_.n)
|
if(n > b->u.n)
|
||||||
panic("internal error: diskread");
|
panic("internal error: diskread");
|
||||||
|
|
||||||
ntosize(b->_.n, nil); /* called only for sanity check on Maxblock */
|
ntosize(b->u.n, nil); /* called only for sanity check on Maxblock */
|
||||||
if(pread(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
|
if(pread(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune))
|
||||||
panic("read error from temp file");
|
panic("read error from temp file");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ mergeextend(File *f, uint p0)
|
|||||||
|
|
||||||
mp0n = merge.p0+merge.n;
|
mp0n = merge.p0+merge.n;
|
||||||
if(mp0n != p0){
|
if(mp0n != p0){
|
||||||
bufread(f, mp0n, merge.buf+merge.nbuf, p0-mp0n);
|
bufread(&f->b, mp0n, merge.buf+merge.nbuf, p0-mp0n);
|
||||||
merge.nbuf += p0-mp0n;
|
merge.nbuf += p0-mp0n;
|
||||||
merge.n = p0-merge.p0;
|
merge.n = p0-merge.p0;
|
||||||
}
|
}
|
||||||
@ -268,11 +268,11 @@ filedeltext(File *f, Text *t)
|
|||||||
void
|
void
|
||||||
fileinsert(File *f, uint p0, Rune *s, uint ns)
|
fileinsert(File *f, uint p0, Rune *s, uint ns)
|
||||||
{
|
{
|
||||||
if(p0 > f->_.nc)
|
if(p0 > f->b.nc)
|
||||||
panic("internal error: fileinsert");
|
panic("internal error: fileinsert");
|
||||||
if(f->seq > 0)
|
if(f->seq > 0)
|
||||||
fileuninsert(f, &f->delta, p0, ns);
|
fileuninsert(f, &f->delta, p0, ns);
|
||||||
bufinsert(f, p0, s, ns);
|
bufinsert(&f->b, p0, s, ns);
|
||||||
if(ns)
|
if(ns)
|
||||||
f->mod = TRUE;
|
f->mod = TRUE;
|
||||||
}
|
}
|
||||||
@ -294,11 +294,11 @@ fileuninsert(File *f, Buffer *delta, uint p0, uint ns)
|
|||||||
void
|
void
|
||||||
filedelete(File *f, uint p0, uint p1)
|
filedelete(File *f, uint p0, uint p1)
|
||||||
{
|
{
|
||||||
if(!(p0<=p1 && p0<=f->_.nc && p1<=f->_.nc))
|
if(!(p0<=p1 && p0<=f->b.nc && p1<=f->b.nc))
|
||||||
panic("internal error: filedelete");
|
panic("internal error: filedelete");
|
||||||
if(f->seq > 0)
|
if(f->seq > 0)
|
||||||
fileundelete(f, &f->delta, p0, p1);
|
fileundelete(f, &f->delta, p0, p1);
|
||||||
bufdelete(f, p0, p1);
|
bufdelete(&f->b, p0, p1);
|
||||||
if(p1 > p0)
|
if(p1 > p0)
|
||||||
f->mod = TRUE;
|
f->mod = TRUE;
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ fileundelete(File *f, Buffer *delta, uint p0, uint p1)
|
|||||||
n = p1 - i;
|
n = p1 - i;
|
||||||
if(n > RBUFSIZE)
|
if(n > RBUFSIZE)
|
||||||
n = RBUFSIZE;
|
n = RBUFSIZE;
|
||||||
bufread(f, i, buf, n);
|
bufread(&f->b, i, buf, n);
|
||||||
bufinsert(delta, delta->nc, buf, n);
|
bufinsert(delta, delta->nc, buf, n);
|
||||||
}
|
}
|
||||||
fbuffree(buf);
|
fbuffree(buf);
|
||||||
@ -334,9 +334,9 @@ filereadc(File *f, uint q)
|
|||||||
{
|
{
|
||||||
Rune r;
|
Rune r;
|
||||||
|
|
||||||
if(q >= f->_.nc)
|
if(q >= f->b.nc)
|
||||||
return -1;
|
return -1;
|
||||||
bufread(f, q, &r, 1);
|
bufread(&f->b, q, &r, 1);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ fileload(File *f, uint p0, int fd, int *nulls)
|
|||||||
{
|
{
|
||||||
if(f->seq > 0)
|
if(f->seq > 0)
|
||||||
panic("undo in file.load unimplemented");
|
panic("undo in file.load unimplemented");
|
||||||
return bufload(f, p0, fd, nulls);
|
return bufload(&f->b, p0, fd, nulls);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -525,7 +525,7 @@ fileundo(File *f, int isundo, int canredo, uint *q0p, uint *q1p, int flag)
|
|||||||
if(canredo)
|
if(canredo)
|
||||||
fileundelete(f, epsilon, u.p0, u.p0+u.n);
|
fileundelete(f, epsilon, u.p0, u.p0+u.n);
|
||||||
f->mod = u.mod;
|
f->mod = u.mod;
|
||||||
bufdelete(f, u.p0, u.p0+u.n);
|
bufdelete(&f->b, u.p0, u.p0+u.n);
|
||||||
raspdelete(f, u.p0, u.p0+u.n, flag);
|
raspdelete(f, u.p0, u.p0+u.n, flag);
|
||||||
*q0p = u.p0;
|
*q0p = u.p0;
|
||||||
*q1p = u.p0;
|
*q1p = u.p0;
|
||||||
@ -543,7 +543,7 @@ fileundo(File *f, int isundo, int canredo, uint *q0p, uint *q1p, int flag)
|
|||||||
if(n > RBUFSIZE)
|
if(n > RBUFSIZE)
|
||||||
n = RBUFSIZE;
|
n = RBUFSIZE;
|
||||||
bufread(delta, up+i, buf, n);
|
bufread(delta, up+i, buf, n);
|
||||||
bufinsert(f, u.p0+i, buf, n);
|
bufinsert(&f->b, u.p0+i, buf, n);
|
||||||
raspinsert(f, u.p0+i, buf, n, flag);
|
raspinsert(f, u.p0+i, buf, n, flag);
|
||||||
}
|
}
|
||||||
fbuffree(buf);
|
fbuffree(buf);
|
||||||
@ -601,7 +601,7 @@ void
|
|||||||
fileclose(File *f)
|
fileclose(File *f)
|
||||||
{
|
{
|
||||||
Strclose(&f->name);
|
Strclose(&f->name);
|
||||||
bufclose(f);
|
bufclose(&f->b);
|
||||||
bufclose(&f->delta);
|
bufclose(&f->delta);
|
||||||
bufclose(&f->epsilon);
|
bufclose(&f->epsilon);
|
||||||
if(f->rasp)
|
if(f->rasp)
|
||||||
|
|||||||
@ -53,7 +53,7 @@ writef(File *f)
|
|||||||
error(Eappend);
|
error(Eappend);
|
||||||
n = writeio(f);
|
n = writeio(f);
|
||||||
if(f->name.s[0]==0 || samename){
|
if(f->name.s[0]==0 || samename){
|
||||||
if(addr.r.p1==0 && addr.r.p2==f->_.nc)
|
if(addr.r.p1==0 && addr.r.p2==f->b.nc)
|
||||||
f->cleanseq = f->seq;
|
f->cleanseq = f->seq;
|
||||||
state(f, f->cleanseq==f->seq? Clean : Dirty);
|
state(f, f->cleanseq==f->seq? Clean : Dirty);
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ readio(File *f, int *nulls, int setdate, int toterm)
|
|||||||
*nulls = FALSE;
|
*nulls = FALSE;
|
||||||
b = 0;
|
b = 0;
|
||||||
if(f->unread){
|
if(f->unread){
|
||||||
nt = bufload(f, 0, io, nulls);
|
nt = bufload(&f->b, 0, io, nulls);
|
||||||
if(toterm)
|
if(toterm)
|
||||||
raspload(f);
|
raspload(f);
|
||||||
}else
|
}else
|
||||||
@ -149,7 +149,7 @@ writeio(File *f)
|
|||||||
n = BLOCKSIZE;
|
n = BLOCKSIZE;
|
||||||
else
|
else
|
||||||
n = addr.r.p2-p;
|
n = addr.r.p2-p;
|
||||||
bufread(f, p, genbuf, n);
|
bufread(&f->b, p, genbuf, n);
|
||||||
c = Strtoc(tmprstr(genbuf, n));
|
c = Strtoc(tmprstr(genbuf, n));
|
||||||
m = strlen(c);
|
m = strlen(c);
|
||||||
if(Write(io, c, m) != m){
|
if(Write(io, c, m) != m){
|
||||||
@ -188,8 +188,7 @@ bootterm(char *machine, char **argv, char **end)
|
|||||||
argv[0] = "samterm";
|
argv[0] = "samterm";
|
||||||
*end = 0;
|
*end = 0;
|
||||||
exec(samterm, argv);
|
exec(samterm, argv);
|
||||||
fprint(2, "can't exec: ");
|
fprint(2, "can't exec %s: %r\n", samterm);
|
||||||
perror(samterm);
|
|
||||||
_exits("damn");
|
_exits("damn");
|
||||||
}
|
}
|
||||||
if(pipe(ph2t)==-1 || pipe(pt2h)==-1)
|
if(pipe(ph2t)==-1 || pipe(pt2h)==-1)
|
||||||
|
|||||||
@ -101,7 +101,7 @@ journaln(int out, long n)
|
|||||||
int
|
int
|
||||||
rcvchar(void){
|
rcvchar(void){
|
||||||
static uchar buf[64];
|
static uchar buf[64];
|
||||||
static i, nleft = 0;
|
static int i, nleft = 0;
|
||||||
|
|
||||||
if(nleft <= 0){
|
if(nleft <= 0){
|
||||||
nleft = read(0, (char *)buf, sizeof buf);
|
nleft = read(0, (char *)buf, sizeof buf);
|
||||||
@ -116,9 +116,9 @@ rcvchar(void){
|
|||||||
int
|
int
|
||||||
rcv(void){
|
rcv(void){
|
||||||
int c;
|
int c;
|
||||||
static state = 0;
|
static int state = 0;
|
||||||
static count = 0;
|
static int count = 0;
|
||||||
static i = 0;
|
static int i = 0;
|
||||||
|
|
||||||
while((c=rcvchar()) != -1)
|
while((c=rcvchar()) != -1)
|
||||||
switch(state){
|
switch(state){
|
||||||
@ -235,17 +235,17 @@ inmesg(Tmesg type)
|
|||||||
journaln(0, p1-p0);
|
journaln(0, p1-p0);
|
||||||
if(f->unread)
|
if(f->unread)
|
||||||
panic("Trequest: unread");
|
panic("Trequest: unread");
|
||||||
if(p1>f->_.nc)
|
if(p1>f->b.nc)
|
||||||
p1 = f->_.nc;
|
p1 = f->b.nc;
|
||||||
if(p0>f->_.nc) /* can happen e.g. scrolling during command */
|
if(p0>f->b.nc) /* can happen e.g. scrolling during command */
|
||||||
p0 = f->_.nc;
|
p0 = f->b.nc;
|
||||||
if(p0 == p1){
|
if(p0 == p1){
|
||||||
i = 0;
|
i = 0;
|
||||||
r.p1 = r.p2 = p0;
|
r.p1 = r.p2 = p0;
|
||||||
}else{
|
}else{
|
||||||
r = rdata(f->rasp, p0, p1-p0);
|
r = rdata(f->rasp, p0, p1-p0);
|
||||||
i = r.p2-r.p1;
|
i = r.p2-r.p1;
|
||||||
bufread(f, r.p1, buf, i);
|
bufread(&f->b, r.p1, buf, i);
|
||||||
}
|
}
|
||||||
buf[i]=0;
|
buf[i]=0;
|
||||||
outTslS(Hdata, f->tag, r.p1, tmprstr(buf, i+1));
|
outTslS(Hdata, f->tag, r.p1, tmprstr(buf, i+1));
|
||||||
@ -271,9 +271,9 @@ inmesg(Tmesg type)
|
|||||||
if(f->unread)
|
if(f->unread)
|
||||||
load(f);
|
load(f);
|
||||||
else{
|
else{
|
||||||
if(f->_.nc>0){
|
if(f->b.nc>0){
|
||||||
rgrow(f->rasp, 0L, f->_.nc);
|
rgrow(f->rasp, 0L, f->b.nc);
|
||||||
outTsll(Hgrow, f->tag, 0L, f->_.nc);
|
outTsll(Hgrow, f->tag, 0L, f->b.nc);
|
||||||
}
|
}
|
||||||
outTs(Hcheck0, f->tag);
|
outTs(Hcheck0, f->tag);
|
||||||
moveto(f, f->dot.r);
|
moveto(f, f->dot.r);
|
||||||
@ -302,7 +302,7 @@ inmesg(Tmesg type)
|
|||||||
loginsert(f, p0, str->s, str->n);
|
loginsert(f, p0, str->s, str->n);
|
||||||
if(fileupdate(f, FALSE, FALSE))
|
if(fileupdate(f, FALSE, FALSE))
|
||||||
seq++;
|
seq++;
|
||||||
if(f==cmd && p0==f->_.nc-i && i>0 && str->s[i-1]=='\n'){
|
if(f==cmd && p0==f->b.nc-i && i>0 && str->s[i-1]=='\n'){
|
||||||
freetmpstr(str);
|
freetmpstr(str);
|
||||||
termlocked++;
|
termlocked++;
|
||||||
termcommand();
|
termcommand();
|
||||||
@ -370,7 +370,7 @@ inmesg(Tmesg type)
|
|||||||
journaln(0, i);
|
journaln(0, i);
|
||||||
f = whichfile(i);
|
f = whichfile(i);
|
||||||
addr.r.p1 = 0;
|
addr.r.p1 = 0;
|
||||||
addr.r.p2 = f->_.nc;
|
addr.r.p2 = f->b.nc;
|
||||||
if(f->name.s[0] == 0)
|
if(f->name.s[0] == 0)
|
||||||
error(Enoname);
|
error(Enoname);
|
||||||
Strduplstr(&genstr, &f->name);
|
Strduplstr(&genstr, &f->name);
|
||||||
@ -427,9 +427,9 @@ inmesg(Tmesg type)
|
|||||||
outTl(Hsnarflen, genstr.n);
|
outTl(Hsnarflen, genstr.n);
|
||||||
if(genstr.s[genstr.n-1] != '\n')
|
if(genstr.s[genstr.n-1] != '\n')
|
||||||
Straddc(&genstr, '\n');
|
Straddc(&genstr, '\n');
|
||||||
loginsert(cmd, cmd->_.nc, genstr.s, genstr.n);
|
loginsert(cmd, cmd->b.nc, genstr.s, genstr.n);
|
||||||
fileupdate(cmd, FALSE, TRUE);
|
fileupdate(cmd, FALSE, TRUE);
|
||||||
cmd->dot.r.p1 = cmd->dot.r.p2 = cmd->_.nc;
|
cmd->dot.r.p1 = cmd->dot.r.p2 = cmd->b.nc;
|
||||||
telldot(cmd);
|
telldot(cmd);
|
||||||
termcommand();
|
termcommand();
|
||||||
break;
|
break;
|
||||||
@ -522,7 +522,7 @@ inmesg(Tmesg type)
|
|||||||
p = p0;
|
p = p0;
|
||||||
while(p0>0 && (i=filereadc(f, p0 - 1))!=' ' && i!='\t' && i!='\n')
|
while(p0>0 && (i=filereadc(f, p0 - 1))!=' ' && i!='\t' && i!='\n')
|
||||||
p0--;
|
p0--;
|
||||||
while(p1<f->_.nc && (i=filereadc(f, p1))!=' ' && i!='\t' && i!='\n')
|
while(p1<f->b.nc && (i=filereadc(f, p1))!=' ' && i!='\t' && i!='\n')
|
||||||
p1++;
|
p1++;
|
||||||
sprint(cbuf, "click=%ld", p-p0);
|
sprint(cbuf, "click=%ld", p-p0);
|
||||||
pm->attr = plumbunpackattr(cbuf);
|
pm->attr = plumbunpackattr(cbuf);
|
||||||
@ -559,13 +559,13 @@ snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
|
|||||||
return;
|
return;
|
||||||
bufreset(buf);
|
bufreset(buf);
|
||||||
/* Stage through genbuf to avoid compaction problems (vestigial) */
|
/* Stage through genbuf to avoid compaction problems (vestigial) */
|
||||||
if(p2 > f->_.nc){
|
if(p2 > f->b.nc){
|
||||||
fprint(2, "bad snarf addr p1=%ld p2=%ld f->_.nc=%d\n", p1, p2, f->_.nc); /*ZZZ should never happen, can remove */
|
fprint(2, "bad snarf addr p1=%ld p2=%ld f->b.nc=%d\n", p1, p2, f->b.nc); /*ZZZ should never happen, can remove */
|
||||||
p2 = f->_.nc;
|
p2 = f->b.nc;
|
||||||
}
|
}
|
||||||
for(l=p1; l<p2; l+=i){
|
for(l=p1; l<p2; l+=i){
|
||||||
i = p2-l>BLOCKSIZE? BLOCKSIZE : p2-l;
|
i = p2-l>BLOCKSIZE? BLOCKSIZE : p2-l;
|
||||||
bufread(f, l, genbuf, i);
|
bufread(&f->b, l, genbuf, i);
|
||||||
bufinsert(buf, buf->nc, tmprstr(genbuf, i)->s, i);
|
bufinsert(buf, buf->nc, tmprstr(genbuf, i)->s, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -609,7 +609,7 @@ setgenstr(File *f, Posn p0, Posn p1)
|
|||||||
if(p1-p0 >= TBLOCKSIZE)
|
if(p1-p0 >= TBLOCKSIZE)
|
||||||
error(Etoolong);
|
error(Etoolong);
|
||||||
Strinsure(&genstr, p1-p0);
|
Strinsure(&genstr, p1-p0);
|
||||||
bufread(f, p0, genbuf, p1-p0);
|
bufread(&f->b, p0, genbuf, p1-p0);
|
||||||
memmove(genstr.s, genbuf, RUNESIZE*(p1-p0));
|
memmove(genstr.s, genbuf, RUNESIZE*(p1-p0));
|
||||||
genstr.n = p1-p0;
|
genstr.n = p1-p0;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
</$objtype/mkfile
|
|
||||||
|
|
||||||
TARG=sam
|
|
||||||
OFILES=sam.$O\
|
|
||||||
address.$O\
|
|
||||||
buff.$O\
|
|
||||||
cmd.$O\
|
|
||||||
disk.$O\
|
|
||||||
error.$O\
|
|
||||||
file.$O\
|
|
||||||
io.$O\
|
|
||||||
list.$O\
|
|
||||||
mesg.$O\
|
|
||||||
moveto.$O\
|
|
||||||
multi.$O\
|
|
||||||
plan9.$O\
|
|
||||||
rasp.$O\
|
|
||||||
regexp.$O\
|
|
||||||
shell.$O\
|
|
||||||
string.$O\
|
|
||||||
sys.$O\
|
|
||||||
util.$O\
|
|
||||||
xec.$O\
|
|
||||||
|
|
||||||
HFILES=sam.h\
|
|
||||||
errors.h\
|
|
||||||
mesg.h\
|
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
|
||||||
</sys/src/cmd/mkone
|
|
||||||
|
|
||||||
address.$O cmd.$O parse.$O xec.$O unix.$O: parse.h
|
|
||||||
|
|
||||||
safeinstall: $O.out
|
|
||||||
mv $BIN/$TARG $BIN/o$TARG
|
|
||||||
cp $prereq $BIN/$TARG
|
|
||||||
|
|
||||||
safeinstallall:V:
|
|
||||||
for (objtype in $CPUS)
|
|
||||||
mk safeinstall
|
|
||||||
@ -39,8 +39,8 @@ lookorigin(File *f, Posn p0, Posn ls)
|
|||||||
int nl, nc, c;
|
int nl, nc, c;
|
||||||
Posn p, oldp0;
|
Posn p, oldp0;
|
||||||
|
|
||||||
if(p0 > f->_.nc)
|
if(p0 > f->b.nc)
|
||||||
p0 = f->_.nc;
|
p0 = f->b.nc;
|
||||||
oldp0 = p0;
|
oldp0 = p0;
|
||||||
p = p0;
|
p = p0;
|
||||||
for(nl=nc=c=0; c!=-1 && nl<ls && nc<ls*CHARSHIFT; nc++)
|
for(nl=nc=c=0; c!=-1 && nl<ls && nc<ls*CHARSHIFT; nc++)
|
||||||
@ -85,7 +85,7 @@ clickmatch(File *f, int cl, int cr, int dir, Posn *p)
|
|||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
if(dir > 0){
|
if(dir > 0){
|
||||||
if(*p >= f->_.nc)
|
if(*p >= f->b.nc)
|
||||||
break;
|
break;
|
||||||
c = filereadc(f, (*p)++);
|
c = filereadc(f, (*p)++);
|
||||||
}else{
|
}else{
|
||||||
@ -126,7 +126,7 @@ doubleclick(File *f, Posn p1)
|
|||||||
Rune *r, *l;
|
Rune *r, *l;
|
||||||
Posn p;
|
Posn p;
|
||||||
|
|
||||||
if(p1 > f->_.nc)
|
if(p1 > f->b.nc)
|
||||||
return;
|
return;
|
||||||
f->dot.r.p1 = f->dot.r.p2 = p1;
|
f->dot.r.p1 = f->dot.r.p2 = p1;
|
||||||
for(i=0; left[i]; i++){
|
for(i=0; left[i]; i++){
|
||||||
@ -147,7 +147,7 @@ doubleclick(File *f, Posn p1)
|
|||||||
}
|
}
|
||||||
/* try right match */
|
/* try right match */
|
||||||
p = p1;
|
p = p1;
|
||||||
if(p1 == f->_.nc)
|
if(p1 == f->b.nc)
|
||||||
c = '\n';
|
c = '\n';
|
||||||
else
|
else
|
||||||
c = filereadc(f, p);
|
c = filereadc(f, p);
|
||||||
@ -156,14 +156,14 @@ doubleclick(File *f, Posn p1)
|
|||||||
f->dot.r.p1 = p;
|
f->dot.r.p1 = p;
|
||||||
if(c!='\n' || p!=0 || filereadc(f, 0)=='\n')
|
if(c!='\n' || p!=0 || filereadc(f, 0)=='\n')
|
||||||
f->dot.r.p1++;
|
f->dot.r.p1++;
|
||||||
f->dot.r.p2 = p1+(p1<f->_.nc && c=='\n');
|
f->dot.r.p2 = p1+(p1<f->b.nc && c=='\n');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* try filling out word to right */
|
/* try filling out word to right */
|
||||||
p = p1;
|
p = p1;
|
||||||
while(p < f->_.nc && alnum(filereadc(f, p++)))
|
while(p < f->b.nc && alnum(filereadc(f, p++)))
|
||||||
f->dot.r.p2++;
|
f->dot.r.p2++;
|
||||||
/* try filling out word to left */
|
/* try filling out word to left */
|
||||||
p = p1;
|
p = p1;
|
||||||
|
|||||||
@ -35,10 +35,10 @@ raspload(File *f)
|
|||||||
{
|
{
|
||||||
if(f->rasp == nil)
|
if(f->rasp == nil)
|
||||||
return;
|
return;
|
||||||
grown = f->_.nc;
|
grown = f->b.nc;
|
||||||
growpos = 0;
|
growpos = 0;
|
||||||
if(f->_.nc)
|
if(f->b.nc)
|
||||||
rgrow(f->rasp, 0, f->_.nc);
|
rgrow(f->rasp, 0, f->b.nc);
|
||||||
raspdone(f, 1);
|
raspdone(f, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +55,14 @@ raspstart(File *f)
|
|||||||
void
|
void
|
||||||
raspdone(File *f, int toterm)
|
raspdone(File *f, int toterm)
|
||||||
{
|
{
|
||||||
if(f->dot.r.p1 > f->_.nc)
|
if(f->dot.r.p1 > f->b.nc)
|
||||||
f->dot.r.p1 = f->_.nc;
|
f->dot.r.p1 = f->b.nc;
|
||||||
if(f->dot.r.p2 > f->_.nc)
|
if(f->dot.r.p2 > f->b.nc)
|
||||||
f->dot.r.p2 = f->_.nc;
|
f->dot.r.p2 = f->b.nc;
|
||||||
if(f->mark.p1 > f->_.nc)
|
if(f->mark.p1 > f->b.nc)
|
||||||
f->mark.p1 = f->_.nc;
|
f->mark.p1 = f->b.nc;
|
||||||
if(f->mark.p2 > f->_.nc)
|
if(f->mark.p2 > f->b.nc)
|
||||||
f->mark.p2 = f->_.nc;
|
f->mark.p2 = f->b.nc;
|
||||||
if(f->rasp == nil)
|
if(f->rasp == nil)
|
||||||
return;
|
return;
|
||||||
if(grown)
|
if(grown)
|
||||||
|
|||||||
@ -700,7 +700,7 @@ bexecute(File *f, Posn startp)
|
|||||||
case 3:
|
case 3:
|
||||||
goto Return;
|
goto Return;
|
||||||
list[0][0].inst = list[1][0].inst = 0;
|
list[0][0].inst = list[1][0].inst = 0;
|
||||||
p = f->_.nc;
|
p = f->b.nc;
|
||||||
goto doloop;
|
goto doloop;
|
||||||
default:
|
default:
|
||||||
goto Return;
|
goto Return;
|
||||||
@ -758,7 +758,7 @@ bexecute(File *f, Posn startp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EOL:
|
case EOL:
|
||||||
if(p==f->_.nc || filereadc(f, p)=='\n')
|
if(p==f->b.nc || filereadc(f, p)=='\n')
|
||||||
goto Step;
|
goto Step;
|
||||||
break;
|
break;
|
||||||
case CCLASS:
|
case CCLASS:
|
||||||
|
|||||||
BIN
src/cmd/sam/sam
BIN
src/cmd/sam/sam
Binary file not shown.
@ -148,7 +148,7 @@ rescue(void)
|
|||||||
io = -1;
|
io = -1;
|
||||||
for(i=0; i<file.nused; i++){
|
for(i=0; i<file.nused; i++){
|
||||||
f = file.filepptr[i];
|
f = file.filepptr[i];
|
||||||
if(f==cmd || f->_.nc==0 || !fileisdirty(f))
|
if(f==cmd || f->b.nc==0 || !fileisdirty(f))
|
||||||
continue;
|
continue;
|
||||||
if(io == -1){
|
if(io == -1){
|
||||||
sprint(buf, "%s/sam.save", home);
|
sprint(buf, "%s/sam.save", home);
|
||||||
@ -164,7 +164,7 @@ rescue(void)
|
|||||||
}else
|
}else
|
||||||
sprint(buf, "nameless.%d", nblank++);
|
sprint(buf, "nameless.%d", nblank++);
|
||||||
fprint(io, "#!%s '%s' $* <<'---%s'\n", SAMSAVECMD, buf, buf);
|
fprint(io, "#!%s '%s' $* <<'---%s'\n", SAMSAVECMD, buf, buf);
|
||||||
addr.r.p1 = 0, addr.r.p2 = f->_.nc;
|
addr.r.p1 = 0, addr.r.p2 = f->b.nc;
|
||||||
writeio(f);
|
writeio(f);
|
||||||
fprint(io, "\n---%s\n", (char *)buf);
|
fprint(io, "\n---%s\n", (char *)buf);
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ cmdupdate(void)
|
|||||||
{
|
{
|
||||||
if(cmd && cmd->seq!=0){
|
if(cmd && cmd->seq!=0){
|
||||||
fileupdate(cmd, FALSE, downloaded);
|
fileupdate(cmd, FALSE, downloaded);
|
||||||
cmd->dot.r.p1 = cmd->dot.r.p2 = cmd->_.nc;
|
cmd->dot.r.p1 = cmd->dot.r.p2 = cmd->b.nc;
|
||||||
telldot(cmd);
|
telldot(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,9 +354,9 @@ edit(File *f, int cmd)
|
|||||||
if(cmd == 'r')
|
if(cmd == 'r')
|
||||||
logdelete(f, addr.r.p1, addr.r.p2);
|
logdelete(f, addr.r.p1, addr.r.p2);
|
||||||
if(cmd=='e' || cmd=='I'){
|
if(cmd=='e' || cmd=='I'){
|
||||||
logdelete(f, (Posn)0, f->_.nc);
|
logdelete(f, (Posn)0, f->b.nc);
|
||||||
addr.r.p2 = f->_.nc;
|
addr.r.p2 = f->b.nc;
|
||||||
}else if(f->_.nc!=0 || (f->name.s[0] && Strcmp(&genstr, &f->name)!=0))
|
}else if(f->b.nc!=0 || (f->name.s[0] && Strcmp(&genstr, &f->name)!=0))
|
||||||
empty = FALSE;
|
empty = FALSE;
|
||||||
if((io = open(genc, OREAD))<0) {
|
if((io = open(genc, OREAD))<0) {
|
||||||
if (curfile && curfile->unread)
|
if (curfile && curfile->unread)
|
||||||
@ -485,17 +485,17 @@ readcmd(String *s)
|
|||||||
fileclose(flist);
|
fileclose(flist);
|
||||||
flist = fileopen();
|
flist = fileopen();
|
||||||
|
|
||||||
addr.r.p1 = 0, addr.r.p2 = flist->_.nc;
|
addr.r.p1 = 0, addr.r.p2 = flist->b.nc;
|
||||||
retcode = plan9(flist, '<', s, FALSE);
|
retcode = plan9(flist, '<', s, FALSE);
|
||||||
fileupdate(flist, FALSE, FALSE);
|
fileupdate(flist, FALSE, FALSE);
|
||||||
flist->seq = 0;
|
flist->seq = 0;
|
||||||
if (flist->_.nc > BLOCKSIZE)
|
if (flist->b.nc > BLOCKSIZE)
|
||||||
error(Etoolong);
|
error(Etoolong);
|
||||||
Strzero(&genstr);
|
Strzero(&genstr);
|
||||||
Strinsure(&genstr, flist->_.nc);
|
Strinsure(&genstr, flist->b.nc);
|
||||||
bufread(flist, (Posn)0, genbuf, flist->_.nc);
|
bufread(&flist->b, (Posn)0, genbuf, flist->b.nc);
|
||||||
memmove(genstr.s, genbuf, flist->_.nc*RUNESIZE);
|
memmove(genstr.s, genbuf, flist->b.nc*RUNESIZE);
|
||||||
genstr.n = flist->_.nc;
|
genstr.n = flist->b.nc;
|
||||||
Straddc(&genstr, '\0');
|
Straddc(&genstr, '\0');
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
@ -673,7 +673,7 @@ copy(File *f, Address addr2)
|
|||||||
ni = addr.r.p2-p;
|
ni = addr.r.p2-p;
|
||||||
if(ni > BLOCKSIZE)
|
if(ni > BLOCKSIZE)
|
||||||
ni = BLOCKSIZE;
|
ni = BLOCKSIZE;
|
||||||
bufread(f, p, genbuf, ni);
|
bufread(&f->b, p, genbuf, ni);
|
||||||
loginsert(addr2.f, addr2.r.p2, tmprstr(genbuf, ni)->s, ni);
|
loginsert(addr2.f, addr2.r.p2, tmprstr(genbuf, ni)->s, ni);
|
||||||
}
|
}
|
||||||
addr2.f->ndot.r.p2 = addr2.r.p2+(f->dot.r.p2-f->dot.r.p1);
|
addr2.f->ndot.r.p2 = addr2.r.p2+(f->dot.r.p2-f->dot.r.p1);
|
||||||
|
|||||||
@ -110,11 +110,10 @@ enum
|
|||||||
struct Block
|
struct Block
|
||||||
{
|
{
|
||||||
uint addr; /* disk address in bytes */
|
uint addr; /* disk address in bytes */
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
uint n; /* number of used runes in block */
|
uint n; /* number of used runes in block */
|
||||||
Block *next; /* pointer to next in free list */
|
Block *next; /* pointer to next in free list */
|
||||||
} _;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Disk
|
struct Disk
|
||||||
@ -151,7 +150,7 @@ void bufreset(Buffer*);
|
|||||||
|
|
||||||
struct File
|
struct File
|
||||||
{
|
{
|
||||||
Buffer _; /* the data */
|
Buffer b; /* the data */
|
||||||
Buffer delta; /* transcript of changes */
|
Buffer delta; /* transcript of changes */
|
||||||
Buffer epsilon; /* inversion of delta for redo */
|
Buffer epsilon; /* inversion of delta for redo */
|
||||||
String name; /* name of associated file */
|
String name; /* name of associated file */
|
||||||
|
|||||||
@ -231,7 +231,7 @@ s_cmd(File *f, Cmd *cp)
|
|||||||
j = c-'0';
|
j = c-'0';
|
||||||
if(sel.p[j].p2-sel.p[j].p1>BLOCKSIZE)
|
if(sel.p[j].p2-sel.p[j].p1>BLOCKSIZE)
|
||||||
error(Elongtag);
|
error(Elongtag);
|
||||||
bufread(f, sel.p[j].p1, genbuf, sel.p[j].p2-sel.p[j].p1);
|
bufread(&f->b, sel.p[j].p1, genbuf, sel.p[j].p2-sel.p[j].p1);
|
||||||
Strinsert(&genstr, tmprstr(genbuf, (sel.p[j].p2-sel.p[j].p1)), genstr.n);
|
Strinsert(&genstr, tmprstr(genbuf, (sel.p[j].p2-sel.p[j].p1)), genstr.n);
|
||||||
}else
|
}else
|
||||||
Straddc(&genstr, c);
|
Straddc(&genstr, c);
|
||||||
@ -240,7 +240,7 @@ s_cmd(File *f, Cmd *cp)
|
|||||||
else{
|
else{
|
||||||
if(sel.p[0].p2-sel.p[0].p1>BLOCKSIZE)
|
if(sel.p[0].p2-sel.p[0].p1>BLOCKSIZE)
|
||||||
error(Elongrhs);
|
error(Elongrhs);
|
||||||
bufread(f, sel.p[0].p1, genbuf, sel.p[0].p2-sel.p[0].p1);
|
bufread(&f->b, sel.p[0].p1, genbuf, sel.p[0].p2-sel.p[0].p1);
|
||||||
Strinsert(&genstr,
|
Strinsert(&genstr,
|
||||||
tmprstr(genbuf, (int)(sel.p[0].p2-sel.p[0].p1)),
|
tmprstr(genbuf, (int)(sel.p[0].p2-sel.p[0].p1)),
|
||||||
genstr.n);
|
genstr.n);
|
||||||
@ -390,15 +390,15 @@ display(File *f)
|
|||||||
|
|
||||||
p1 = addr.r.p1;
|
p1 = addr.r.p1;
|
||||||
p2 = addr.r.p2;
|
p2 = addr.r.p2;
|
||||||
if(p2 > f->_.nc){
|
if(p2 > f->b.nc){
|
||||||
fprint(2, "bad display addr p1=%ld p2=%ld f->_.nc=%d\n", p1, p2, f->_.nc); /*ZZZ should never happen, can remove */
|
fprint(2, "bad display addr p1=%ld p2=%ld f->b.nc=%d\n", p1, p2, f->b.nc); /*ZZZ should never happen, can remove */
|
||||||
p2 = f->_.nc;
|
p2 = f->b.nc;
|
||||||
}
|
}
|
||||||
while(p1 < p2){
|
while(p1 < p2){
|
||||||
np = p2-p1;
|
np = p2-p1;
|
||||||
if(np>BLOCKSIZE-1)
|
if(np>BLOCKSIZE-1)
|
||||||
np = BLOCKSIZE-1;
|
np = BLOCKSIZE-1;
|
||||||
bufread(f, p1, genbuf, np);
|
bufread(&f->b, p1, genbuf, np);
|
||||||
genbuf[np] = 0;
|
genbuf[np] = 0;
|
||||||
c = Strtoc(tmprstr(genbuf, np+1));
|
c = Strtoc(tmprstr(genbuf, np+1));
|
||||||
if(downloaded)
|
if(downloaded)
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS=-O -c -Ae -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
include Make.SunOS-sun4u-$(CC)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I. -O
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,22 +1,5 @@
|
|||||||
|
9SRC=..
|
||||||
# this works in gnu make
|
include $(9SRC)/Makehdr
|
||||||
SYSNAME:=${shell uname}
|
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
|
||||||
|
|
||||||
# this works in bsd make
|
|
||||||
SYSNAME!=uname
|
|
||||||
OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|
||||||
|
|
||||||
# the gnu rules will mess up bsd but not vice versa,
|
|
||||||
# hence the gnu rules come first.
|
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
|
||||||
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
NUKEFILES=
|
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
TARG=samterm
|
TARG=samterm
|
||||||
OFILES=\
|
OFILES=\
|
||||||
@ -33,62 +16,12 @@ OFILES=\
|
|||||||
HFILES=\
|
HFILES=\
|
||||||
samterm.h\
|
samterm.h\
|
||||||
flayer.h\
|
flayer.h\
|
||||||
$(PREFIX)/include/frame.h\
|
../sam/sam.h\
|
||||||
|
../sam/mesg.h\
|
||||||
|
$(9SRC)/include/frame.h\
|
||||||
|
$(9SRC)/include/draw.h\
|
||||||
|
|
||||||
all: $(TARG)
|
CFLAGS+=-I../sam
|
||||||
|
LDFLAGS+=-lframe -ldraw -lthread -l9 -lregexp9 -lbio -lfmt -lutf -L$(X11)/lib -lX11 -lm
|
||||||
|
|
||||||
install:
|
include ../Makeone
|
||||||
install -c -m 0755 samterm $(PREFIX)/bin/samterm
|
|
||||||
|
|
||||||
|
|
||||||
$(TARG): $(OFILES)
|
|
||||||
$(CC) -o $(TARG) $(OFILES) -L$(PREFIX)/lib -lframe -ldraw -lthread -l9 -lregexp9 -lbio -lfmt -lutf -L/usr/X11R6/lib -lX11 -lm -ldraw
|
|
||||||
|
|
||||||
|
|
||||||
.c.$O:
|
|
||||||
$(CC) $(CFLAGS) -I/usr/X11R6/include -I../sam -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
%.$O: %.c
|
|
||||||
$(CC) $(CFLAGS) -I/usr/X11R6/include -I../sam -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
|
|
||||||
$(OFILES): $(HFILES)
|
|
||||||
|
|
||||||
tgz:
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
mkdir $(NAME)-$(VERSION)
|
|
||||||
cp Makefile Make.* README LICENSE NOTICE *.[ch137] rpm.spec bundle.ports $(TGZFILES) $(NAME)-$(VERSION)
|
|
||||||
tar cf - $(NAME)-$(VERSION) | gzip >$(NAME)-$(VERSION).tgz
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OFILES) $(LIB)
|
|
||||||
|
|
||||||
nuke:
|
|
||||||
rm -f $(OFILES) *.tgz *.rpm $(NUKEFILES)
|
|
||||||
|
|
||||||
rpm:
|
|
||||||
make tgz
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/src/RPM/SOURCES
|
|
||||||
rpm -ba rpm.spec
|
|
||||||
cp /usr/src/RPM/SRPMS/$(NAME)-$(VERSION)-1.src.rpm .
|
|
||||||
cp /usr/src/RPM/RPMS/i586/$(NAME)-$(VERSION)-1.i586.rpm .
|
|
||||||
scp *.rpm rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
PORTDIR=/usr/ports/$(PORTPLACE)
|
|
||||||
|
|
||||||
ports:
|
|
||||||
make tgz
|
|
||||||
rm -rf $(PORTDIR)
|
|
||||||
mkdir $(PORTDIR)
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/ports/distfiles
|
|
||||||
cat bundle.ports | (cd $(PORTDIR) && awk '$$1=="---" && $$3=="---" { ofile=$$2; next} {if(ofile) print >ofile}')
|
|
||||||
(cd $(PORTDIR); make makesum)
|
|
||||||
(cd $(PORTDIR); make)
|
|
||||||
(cd $(PORTDIR); /usr/local/bin/portlint)
|
|
||||||
rm -rf $(PORTDIR)/work
|
|
||||||
shar `find $(PORTDIR)` > ports.shar
|
|
||||||
(cd $(PORTDIR); tar cf - *) | gzip >$(NAME)-$(VERSION)-ports.tgz
|
|
||||||
scp *.tgz rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
.phony: all clean nuke install tgz rpm ports
|
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
TARG=samterm
|
|
||||||
OFILES=\
|
|
||||||
main.$O\
|
|
||||||
icons.$O\
|
|
||||||
menu.$O\
|
|
||||||
mesg.$O\
|
|
||||||
rasp.$O\
|
|
||||||
scroll.$O\
|
|
||||||
flayer.$O\
|
|
||||||
io.$O\
|
|
||||||
plan9.$O\
|
|
||||||
|
|
||||||
HFILES=\
|
|
||||||
samterm.h\
|
|
||||||
flayer.h\
|
|
||||||
$(PREFIX)/include/frame.h\
|
|
||||||
|
|
||||||
all: $(TARG)
|
|
||||||
|
|
||||||
install:
|
|
||||||
install -c -m 0755 samterm $(PREFIX)/bin/samterm
|
|
||||||
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
all:V: Makefile Make.FreeBSD-386 Make.Linux-386 Make.HP-UX-9000 Make.OSF1-alpha \
|
|
||||||
Make.SunOS-sun4u Make.SunOS-sun4u-cc Make.SunOS-sun4u-gcc \
|
|
||||||
Make.NetBSD-386 Make.Darwin-PowerMacintosh
|
|
||||||
|
|
||||||
Makefile:D: ../libutf/Makefile.TOP Makefile.MID ../libutf/Makefile.CMD ../libutf/Makefile.BOT
|
|
||||||
cat $prereq >$target
|
|
||||||
|
|
||||||
Make.%: ../libutf/Make.%
|
|
||||||
cp $prereq $target
|
|
||||||
Binary file not shown.
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS=-O -c -Ae -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
include Make.SunOS-sun4u-$(CC)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I. -O
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,27 +1,7 @@
|
|||||||
|
9SRC=..
|
||||||
# this works in gnu make
|
include $(9SRC)/Makehdr
|
||||||
SYSNAME:=${shell uname}
|
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
|
||||||
|
|
||||||
# this works in bsd make
|
|
||||||
SYSNAME!=uname
|
|
||||||
OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|
||||||
|
|
||||||
# the gnu rules will mess up bsd but not vice versa,
|
|
||||||
# hence the gnu rules come first.
|
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
|
||||||
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
NUKEFILES=
|
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
LIB=lib9.a
|
LIB=lib9.a
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/lib9
|
|
||||||
NAME=lib9
|
|
||||||
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
_exits.$O\
|
_exits.$O\
|
||||||
@ -53,68 +33,5 @@ OFILES=\
|
|||||||
HFILES=\
|
HFILES=\
|
||||||
lib9.h\
|
lib9.h\
|
||||||
|
|
||||||
all: $(LIB)
|
include $(9SRC)/Makesyslib
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man3 || mkdir $(PREFIX)/man/man3
|
|
||||||
# install -m 0644 lib9.3 $(PREFIX)/man/man3/lib9.3
|
|
||||||
install -m 0644 lib9.h $(PREFIX)/include/lib9.h
|
|
||||||
install -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
|
|
||||||
test: $(LIB) test.$O
|
|
||||||
$(CC) -o test test.$O $(LIB) -L$(PREFIX)/lib -lfmt -lutf
|
|
||||||
|
|
||||||
testfork: $(LIB) testfork.$O
|
|
||||||
$(CC) -o testfork testfork.$O $(LIB) -L$(PREFIX)/lib -lfmt -lutf
|
|
||||||
|
|
||||||
$(LIB): $(OFILES)
|
|
||||||
$(AR) $(ARFLAGS) $(LIB) $(OFILES)
|
|
||||||
|
|
||||||
NUKEFILES+=$(LIB)
|
|
||||||
.c.$O:
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
%.$O: %.c
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
|
|
||||||
$(OFILES): $(HFILES)
|
|
||||||
|
|
||||||
tgz:
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
mkdir $(NAME)-$(VERSION)
|
|
||||||
cp Makefile Make.* README LICENSE NOTICE *.[ch137] rpm.spec bundle.ports $(TGZFILES) $(NAME)-$(VERSION)
|
|
||||||
tar cf - $(NAME)-$(VERSION) | gzip >$(NAME)-$(VERSION).tgz
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OFILES) $(LIB)
|
|
||||||
|
|
||||||
nuke:
|
|
||||||
rm -f $(OFILES) *.tgz *.rpm $(NUKEFILES)
|
|
||||||
|
|
||||||
rpm:
|
|
||||||
make tgz
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/src/RPM/SOURCES
|
|
||||||
rpm -ba rpm.spec
|
|
||||||
cp /usr/src/RPM/SRPMS/$(NAME)-$(VERSION)-1.src.rpm .
|
|
||||||
cp /usr/src/RPM/RPMS/i586/$(NAME)-$(VERSION)-1.i586.rpm .
|
|
||||||
scp *.rpm rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
PORTDIR=/usr/ports/$(PORTPLACE)
|
|
||||||
|
|
||||||
ports:
|
|
||||||
make tgz
|
|
||||||
rm -rf $(PORTDIR)
|
|
||||||
mkdir $(PORTDIR)
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/ports/distfiles
|
|
||||||
cat bundle.ports | (cd $(PORTDIR) && awk '$$1=="---" && $$3=="---" { ofile=$$2; next} {if(ofile) print >ofile}')
|
|
||||||
(cd $(PORTDIR); make makesum)
|
|
||||||
(cd $(PORTDIR); make)
|
|
||||||
(cd $(PORTDIR); /usr/local/bin/portlint)
|
|
||||||
rm -rf $(PORTDIR)/work
|
|
||||||
shar `find $(PORTDIR)` > ports.shar
|
|
||||||
(cd $(PORTDIR); tar cf - *) | gzip >$(NAME)-$(VERSION)-ports.tgz
|
|
||||||
scp *.tgz rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
.phony: all clean nuke install tgz rpm ports
|
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
LIB=lib9.a
|
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/lib9
|
|
||||||
NAME=lib9
|
|
||||||
|
|
||||||
OFILES=\
|
|
||||||
_exits.$O\
|
|
||||||
argv0.$O\
|
|
||||||
await.$O\
|
|
||||||
encodefmt.$O\
|
|
||||||
errstr.$O\
|
|
||||||
exits.$O\
|
|
||||||
ffork-$(SYSNAME).$O\
|
|
||||||
getcallerpc-$(OBJTYPE).$O\
|
|
||||||
getfields.$O\
|
|
||||||
lock.$O\
|
|
||||||
malloctag.$O\
|
|
||||||
mallocz.$O\
|
|
||||||
nrand.$O\
|
|
||||||
qlock.$O\
|
|
||||||
readn.$O\
|
|
||||||
rendez.$O\
|
|
||||||
strecpy.$O\
|
|
||||||
sysfatal.$O\
|
|
||||||
tas-$(OBJTYPE).$O\
|
|
||||||
tokenize.$O\
|
|
||||||
u16.$O\
|
|
||||||
u32.$O\
|
|
||||||
u64.$O\
|
|
||||||
wait.$O\
|
|
||||||
werrstr.$O\
|
|
||||||
|
|
||||||
HFILES=\
|
|
||||||
lib9.h\
|
|
||||||
|
|
||||||
all: $(LIB)
|
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man3 || mkdir $(PREFIX)/man/man3
|
|
||||||
# install -m 0644 lib9.3 $(PREFIX)/man/man3/lib9.3
|
|
||||||
install -m 0644 lib9.h $(PREFIX)/include/lib9.h
|
|
||||||
install -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
|
|
||||||
test: $(LIB) test.$O
|
|
||||||
$(CC) -o test test.$O $(LIB) -L$(PREFIX)/lib -lfmt -lutf
|
|
||||||
|
|
||||||
testfork: $(LIB) testfork.$O
|
|
||||||
$(CC) -o testfork testfork.$O $(LIB) -L$(PREFIX)/lib -lfmt -lutf
|
|
||||||
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<../libutf/mkfile
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS=-O -c -Ae -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
include Make.SunOS-sun4u-$(CC)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I. -O
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,27 +1,7 @@
|
|||||||
|
9SRC=..
|
||||||
# this works in gnu make
|
include $(9SRC)/Makehdr
|
||||||
SYSNAME:=${shell uname}
|
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
|
||||||
|
|
||||||
# this works in bsd make
|
|
||||||
SYSNAME!=uname
|
|
||||||
OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|
||||||
|
|
||||||
# the gnu rules will mess up bsd but not vice versa,
|
|
||||||
# hence the gnu rules come first.
|
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
|
||||||
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
NUKEFILES=
|
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
LIB=libbio.a
|
LIB=libbio.a
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/libbio
|
|
||||||
NAME=libbio
|
|
||||||
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
bbuffered.$O\
|
bbuffered.$O\
|
||||||
@ -44,65 +24,8 @@ OFILES=\
|
|||||||
HFILES=\
|
HFILES=\
|
||||||
bio.h\
|
bio.h\
|
||||||
|
|
||||||
all: $(LIB)
|
include $(9SRC)/Makesyslib
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man3 || mkdir $(PREFIX)/man/man3
|
|
||||||
install -m 0644 bio.3 $(PREFIX)/man/man3/bio.3
|
|
||||||
install -m 0644 bio.h $(PREFIX)/include
|
|
||||||
install -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
|
|
||||||
bcat: bcat.$O $(LIB)
|
bcat: bcat.$O $(LIB)
|
||||||
$(CC) -o bcat bcat.$O $(LIB) -L/usr/local/lib -lfmt -lutf
|
$(CC) -o bcat bcat.$O -L$(9SRC)/lib -lbio -lfmt -lutf
|
||||||
|
|
||||||
$(LIB): $(OFILES)
|
|
||||||
$(AR) $(ARFLAGS) $(LIB) $(OFILES)
|
|
||||||
|
|
||||||
NUKEFILES+=$(LIB)
|
|
||||||
.c.$O:
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
%.$O: %.c
|
|
||||||
$(CC) $(CFLAGS) -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
|
|
||||||
$(OFILES): $(HFILES)
|
|
||||||
|
|
||||||
tgz:
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
mkdir $(NAME)-$(VERSION)
|
|
||||||
cp Makefile Make.* README LICENSE NOTICE *.[ch137] rpm.spec bundle.ports $(TGZFILES) $(NAME)-$(VERSION)
|
|
||||||
tar cf - $(NAME)-$(VERSION) | gzip >$(NAME)-$(VERSION).tgz
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OFILES) $(LIB)
|
|
||||||
|
|
||||||
nuke:
|
|
||||||
rm -f $(OFILES) *.tgz *.rpm $(NUKEFILES)
|
|
||||||
|
|
||||||
rpm:
|
|
||||||
make tgz
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/src/RPM/SOURCES
|
|
||||||
rpm -ba rpm.spec
|
|
||||||
cp /usr/src/RPM/SRPMS/$(NAME)-$(VERSION)-1.src.rpm .
|
|
||||||
cp /usr/src/RPM/RPMS/i586/$(NAME)-$(VERSION)-1.i586.rpm .
|
|
||||||
scp *.rpm rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
PORTDIR=/usr/ports/$(PORTPLACE)
|
|
||||||
|
|
||||||
ports:
|
|
||||||
make tgz
|
|
||||||
rm -rf $(PORTDIR)
|
|
||||||
mkdir $(PORTDIR)
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/ports/distfiles
|
|
||||||
cat bundle.ports | (cd $(PORTDIR) && awk '$$1=="---" && $$3=="---" { ofile=$$2; next} {if(ofile) print >ofile}')
|
|
||||||
(cd $(PORTDIR); make makesum)
|
|
||||||
(cd $(PORTDIR); make)
|
|
||||||
(cd $(PORTDIR); /usr/local/bin/portlint)
|
|
||||||
rm -rf $(PORTDIR)/work
|
|
||||||
shar `find $(PORTDIR)` > ports.shar
|
|
||||||
(cd $(PORTDIR); tar cf - *) | gzip >$(NAME)-$(VERSION)-ports.tgz
|
|
||||||
scp *.tgz rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
.phony: all clean nuke install tgz rpm ports
|
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
LIB=libbio.a
|
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/libbio
|
|
||||||
NAME=libbio
|
|
||||||
|
|
||||||
OFILES=\
|
|
||||||
bbuffered.$O\
|
|
||||||
bfildes.$O\
|
|
||||||
bflush.$O\
|
|
||||||
bgetc.$O\
|
|
||||||
bgetd.$O\
|
|
||||||
binit.$O\
|
|
||||||
boffset.$O\
|
|
||||||
bprint.$O\
|
|
||||||
bputc.$O\
|
|
||||||
brdline.$O\
|
|
||||||
brdstr.$O\
|
|
||||||
bread.$O\
|
|
||||||
bseek.$O\
|
|
||||||
bwrite.$O\
|
|
||||||
bgetrune.$O\
|
|
||||||
bputrune.$O\
|
|
||||||
|
|
||||||
HFILES=\
|
|
||||||
bio.h\
|
|
||||||
|
|
||||||
all: $(LIB)
|
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
test -d $(PREFIX)/man/man3 || mkdir $(PREFIX)/man/man3
|
|
||||||
install -m 0644 bio.3 $(PREFIX)/man/man3/bio.3
|
|
||||||
install -m 0644 bio.h $(PREFIX)/include
|
|
||||||
install -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
|
|
||||||
bcat: bcat.$O $(LIB)
|
|
||||||
$(CC) -o bcat bcat.$O $(LIB) -L/usr/local/lib -lfmt -lutf
|
|
||||||
|
|
||||||
336
src/libbio/bio.3
336
src/libbio/bio.3
@ -1,336 +0,0 @@
|
|||||||
.TH BIO 3
|
|
||||||
.SH NAME
|
|
||||||
Bopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetd, Bungetc, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered \- buffered input/output
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.ta \w'Biobuf* 'u
|
|
||||||
.B #include <fmt.h>
|
|
||||||
.B #include <bio.h>
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
Biobuf* Bopen(char *file, int mode)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Binit(Biobuf *bp, int fd, int mode)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bterm(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bprint(Biobuf *bp, char *format, ...)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bvprint(Biobuf *bp, char *format, va_list arglist);
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
void* Brdline(Biobuf *bp, int delim)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
char* Brdstr(Biobuf *bp, int delim, int nulldelim)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Blinelen(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
off_t Boffset(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bfildes(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bgetc(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
long Bgetrune(Biobufhdr *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bgetd(Biobuf *bp, double *d)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bungetc(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bungetrune(Biobufhdr *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
off_t Bseek(Biobuf *bp, off_t n, int type)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bputc(Biobuf *bp, int c)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bputrune(Biobufhdr *bp, long c)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
long Bread(Biobuf *bp, void *addr, long nbytes)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
long Bwrite(Biobuf *bp, void *addr, long nbytes)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bflush(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int Bbuffered(Biobuf *bp)
|
|
||||||
.PP
|
|
||||||
.SH DESCRIPTION
|
|
||||||
These routines implement fast buffered I/O.
|
|
||||||
I/O on different file descriptors is independent.
|
|
||||||
.PP
|
|
||||||
.I Bopen
|
|
||||||
opens
|
|
||||||
.I file
|
|
||||||
for mode
|
|
||||||
.B O_RDONLY
|
|
||||||
or creates for mode
|
|
||||||
.BR O_WRONLY .
|
|
||||||
It calls
|
|
||||||
.IR malloc (3)
|
|
||||||
to allocate a buffer.
|
|
||||||
.PP
|
|
||||||
.I Binit
|
|
||||||
initializes a buffer
|
|
||||||
with the open file descriptor passed in
|
|
||||||
by the user.
|
|
||||||
.PP
|
|
||||||
Arguments
|
|
||||||
of types pointer to Biobuf and pointer to Biobuf
|
|
||||||
can be used interchangeably in the following routines.
|
|
||||||
.PP
|
|
||||||
.IR Bopen ,
|
|
||||||
.IR Binit ,
|
|
||||||
or
|
|
||||||
.I Binits
|
|
||||||
should be called before any of the
|
|
||||||
other routines on that buffer.
|
|
||||||
.I Bfildes
|
|
||||||
returns the integer file descriptor of the associated open file.
|
|
||||||
.PP
|
|
||||||
.I Bterm
|
|
||||||
flushes the buffer for
|
|
||||||
.IR bp .
|
|
||||||
If the buffer was allocated by
|
|
||||||
.IR Bopen ,
|
|
||||||
the buffer is
|
|
||||||
.I freed
|
|
||||||
and the file is closed.
|
|
||||||
.PP
|
|
||||||
.I Brdline
|
|
||||||
reads a string from the file associated with
|
|
||||||
.I bp
|
|
||||||
up to and including the first
|
|
||||||
.I delim
|
|
||||||
character.
|
|
||||||
The delimiter character at the end of the line is
|
|
||||||
not altered.
|
|
||||||
.I Brdline
|
|
||||||
returns a pointer to the start of the line or
|
|
||||||
.L 0
|
|
||||||
on end-of-file or read error.
|
|
||||||
.I Blinelen
|
|
||||||
returns the length (including the delimiter)
|
|
||||||
of the most recent string returned by
|
|
||||||
.IR Brdline .
|
|
||||||
.PP
|
|
||||||
.I Brdstr
|
|
||||||
returns a
|
|
||||||
.IR malloc (3)-allocated
|
|
||||||
buffer containing the next line of input delimited by
|
|
||||||
.IR delim ,
|
|
||||||
terminated by a NUL (0) byte.
|
|
||||||
Unlike
|
|
||||||
.IR Brdline ,
|
|
||||||
which returns when its buffer is full even if no delimiter has been found,
|
|
||||||
.I Brdstr
|
|
||||||
will return an arbitrarily long line in a single call.
|
|
||||||
If
|
|
||||||
.I nulldelim
|
|
||||||
is set, the terminal delimiter will be overwritten with a NUL.
|
|
||||||
After a successful call to
|
|
||||||
.IR Brdstr ,
|
|
||||||
the return value of
|
|
||||||
.I Blinelen
|
|
||||||
will be the length of the returned buffer, excluding the NUL.
|
|
||||||
.PP
|
|
||||||
.I Bgetc
|
|
||||||
returns the next byte from
|
|
||||||
.IR bp ,
|
|
||||||
or a negative value
|
|
||||||
at end of file.
|
|
||||||
.I Bungetc
|
|
||||||
may be called immediately after
|
|
||||||
.I Bgetc
|
|
||||||
to allow the same byte to be reread.
|
|
||||||
.PP
|
|
||||||
.I Bgetrune
|
|
||||||
calls
|
|
||||||
.I Bgetc
|
|
||||||
to read the bytes of the next
|
|
||||||
.SM UTF
|
|
||||||
sequence in the input stream and returns the value of the rune
|
|
||||||
represented by the sequence.
|
|
||||||
It returns a negative value
|
|
||||||
at end of file.
|
|
||||||
.I Bungetrune
|
|
||||||
may be called immediately after
|
|
||||||
.I Bgetrune
|
|
||||||
to allow the same
|
|
||||||
.SM UTF
|
|
||||||
sequence to be reread as either bytes or a rune.
|
|
||||||
.I Bungetc
|
|
||||||
and
|
|
||||||
.I Bungetrune
|
|
||||||
may back up a maximum of five bytes.
|
|
||||||
.PP
|
|
||||||
.I Bgetd
|
|
||||||
uses
|
|
||||||
.I fmtcharstod
|
|
||||||
(undocumented)
|
|
||||||
and
|
|
||||||
.I Bgetc
|
|
||||||
to read the formatted
|
|
||||||
floating-point number in the input stream,
|
|
||||||
skipping initial blanks and tabs.
|
|
||||||
The value is stored in
|
|
||||||
.BR *d.
|
|
||||||
.PP
|
|
||||||
.I Bread
|
|
||||||
reads
|
|
||||||
.I nbytes
|
|
||||||
of data from
|
|
||||||
.I bp
|
|
||||||
into memory starting at
|
|
||||||
.IR addr .
|
|
||||||
The number of bytes read is returned on success
|
|
||||||
and a negative value is returned if a read error occurred.
|
|
||||||
.PP
|
|
||||||
.I Bseek
|
|
||||||
applies
|
|
||||||
.IR lseek (2)
|
|
||||||
to
|
|
||||||
.IR bp .
|
|
||||||
It returns the new file offset.
|
|
||||||
.I Boffset
|
|
||||||
returns the file offset of the next character to be processed.
|
|
||||||
.PP
|
|
||||||
.I Bputc
|
|
||||||
outputs the low order 8 bits of
|
|
||||||
.I c
|
|
||||||
on
|
|
||||||
.IR bp .
|
|
||||||
If this causes a
|
|
||||||
.IR write
|
|
||||||
to occur and there is an error,
|
|
||||||
a negative value is returned.
|
|
||||||
Otherwise, a zero is returned.
|
|
||||||
.PP
|
|
||||||
.I Bputrune
|
|
||||||
calls
|
|
||||||
.I Bputc
|
|
||||||
to output the low order
|
|
||||||
16 bits of
|
|
||||||
.I c
|
|
||||||
as a rune
|
|
||||||
in
|
|
||||||
.SM UTF
|
|
||||||
format
|
|
||||||
on the output stream.
|
|
||||||
.PP
|
|
||||||
.I Bprint
|
|
||||||
is a buffered interface to
|
|
||||||
.IR print (2).
|
|
||||||
If this causes a
|
|
||||||
.IR write
|
|
||||||
to occur and there is an error,
|
|
||||||
a negative value
|
|
||||||
.RB ( Beof )
|
|
||||||
is returned.
|
|
||||||
Otherwise, the number of bytes output is returned.
|
|
||||||
.I Bvprint
|
|
||||||
does the same except it takes as argument a
|
|
||||||
.B va_list
|
|
||||||
parameter, so it can be called within a variadic function.
|
|
||||||
.PP
|
|
||||||
.I Bwrite
|
|
||||||
outputs
|
|
||||||
.I nbytes
|
|
||||||
of data starting at
|
|
||||||
.I addr
|
|
||||||
to
|
|
||||||
.IR bp .
|
|
||||||
If this causes a
|
|
||||||
.IR write
|
|
||||||
to occur and there is an error,
|
|
||||||
a negative value is returned.
|
|
||||||
Otherwise, the number of bytes written is returned.
|
|
||||||
.PP
|
|
||||||
.I Bflush
|
|
||||||
causes any buffered output associated with
|
|
||||||
.I bp
|
|
||||||
to be written.
|
|
||||||
The return is as for
|
|
||||||
.IR Bputc .
|
|
||||||
.I Bflush
|
|
||||||
is called on
|
|
||||||
exit for every buffer still open
|
|
||||||
for writing.
|
|
||||||
.PP
|
|
||||||
.I Bbuffered
|
|
||||||
returns the number of bytes in the buffer.
|
|
||||||
When reading, this is the number of bytes still available from the last
|
|
||||||
read on the file; when writing, it is the number of bytes ready to be
|
|
||||||
written.
|
|
||||||
.PP
|
|
||||||
This library uses
|
|
||||||
.IR fmt (3)
|
|
||||||
for diagnostic messages about internal errors,
|
|
||||||
as well as for the implementation of
|
|
||||||
.I Bprint
|
|
||||||
and
|
|
||||||
.IR Bvprint .
|
|
||||||
It uses
|
|
||||||
.IR utf (3)
|
|
||||||
for the implementation of
|
|
||||||
.I Bgetrune
|
|
||||||
and
|
|
||||||
.IR Bputrune .
|
|
||||||
.SH SEE ALSO
|
|
||||||
.IR atexit (3).
|
|
||||||
.IR open (2),
|
|
||||||
.IR print (3),
|
|
||||||
.IR utf (7)
|
|
||||||
.SH DIAGNOSTICS
|
|
||||||
.I Bio
|
|
||||||
routines that return integers yield
|
|
||||||
.B Beof
|
|
||||||
if
|
|
||||||
.I bp
|
|
||||||
is not the descriptor of an open file.
|
|
||||||
.I Bopen
|
|
||||||
returns zero if the file cannot be opened in the given mode.
|
|
||||||
.SH HISTORY
|
|
||||||
The
|
|
||||||
.IR bio (3)
|
|
||||||
library originally appeared in Plan 9.
|
|
||||||
This is a port of the Plan 9 bio library.
|
|
||||||
.SH BUGS
|
|
||||||
.I Brdline
|
|
||||||
returns an error on strings longer than the buffer associated
|
|
||||||
with the file
|
|
||||||
and also if the end-of-file is encountered
|
|
||||||
before a delimiter.
|
|
||||||
.I Blinelen
|
|
||||||
will tell how many characters are available
|
|
||||||
in these cases.
|
|
||||||
In the case of a true end-of-file,
|
|
||||||
.I Blinelen
|
|
||||||
will return zero.
|
|
||||||
At the cost of allocating a buffer,
|
|
||||||
.I Brdstr
|
|
||||||
sidesteps these issues.
|
|
||||||
.PP
|
|
||||||
The data returned by
|
|
||||||
.I Brdline
|
|
||||||
may be overwritten by calls to any other
|
|
||||||
.I bio
|
|
||||||
routine on the same
|
|
||||||
.IR bp.
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
#ifndef _BIOH_
|
|
||||||
#define _BIOH_ 1
|
|
||||||
|
|
||||||
#include <sys/types.h> /* for off_t */
|
|
||||||
#include <fcntl.h> /* for O_RDONLY, O_WRONLY */
|
|
||||||
|
|
||||||
typedef struct Biobuf Biobuf;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
Bsize = 8*1024,
|
|
||||||
Bungetsize = 4, /* space for ungetc */
|
|
||||||
Bmagic = 0x314159,
|
|
||||||
Beof = -1,
|
|
||||||
Bbad = -2,
|
|
||||||
|
|
||||||
Binactive = 0, /* states */
|
|
||||||
Bractive,
|
|
||||||
Bwactive,
|
|
||||||
Bracteof,
|
|
||||||
|
|
||||||
Bend
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Biobuf
|
|
||||||
{
|
|
||||||
int icount; /* neg num of bytes at eob */
|
|
||||||
int ocount; /* num of bytes at bob */
|
|
||||||
int rdline; /* num of bytes after rdline */
|
|
||||||
int runesize; /* num of bytes of last getrune */
|
|
||||||
int state; /* r/w/inactive */
|
|
||||||
int fid; /* open file */
|
|
||||||
int flag; /* magic if malloc'ed */
|
|
||||||
off_t offset; /* offset of buffer in file */
|
|
||||||
int bsize; /* size of buffer */
|
|
||||||
unsigned char* bbuf; /* pointer to beginning of buffer */
|
|
||||||
unsigned char* ebuf; /* pointer to end of buffer */
|
|
||||||
unsigned char* gbuf; /* pointer to good data in buf */
|
|
||||||
unsigned char b[Bungetsize+Bsize];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define BGETC(bp)\
|
|
||||||
((bp)->icount?(bp)->bbuf[(bp)->bsize+(bp)->icount++]:Bgetc((bp)))
|
|
||||||
#define BPUTC(bp,c)\
|
|
||||||
((bp)->ocount?(bp)->bbuf[(bp)->bsize+(bp)->ocount++]=(c),0:Bputc((bp),(c)))
|
|
||||||
#define BOFFSET(bp)\
|
|
||||||
(((bp)->state==Bractive)?\
|
|
||||||
(bp)->offset + (bp)->icount:\
|
|
||||||
(((bp)->state==Bwactive)?\
|
|
||||||
(bp)->offset + ((bp)->bsize + (bp)->ocount):\
|
|
||||||
-1))
|
|
||||||
#define BLINELEN(bp)\
|
|
||||||
(bp)->rdline
|
|
||||||
#define BFILDES(bp)\
|
|
||||||
(bp)->fid
|
|
||||||
|
|
||||||
int Bbuffered(Biobuf*);
|
|
||||||
int Bfildes(Biobuf*);
|
|
||||||
int Bflush(Biobuf*);
|
|
||||||
int Bgetc(Biobuf*);
|
|
||||||
int Bgetd(Biobuf*, double*);
|
|
||||||
int Binit(Biobuf*, int, int);
|
|
||||||
int Binits(Biobuf*, int, int, unsigned char*, int);
|
|
||||||
int Blinelen(Biobuf*);
|
|
||||||
off_t Boffset(Biobuf*);
|
|
||||||
Biobuf* Bopen(char*, int);
|
|
||||||
int Bprint(Biobuf*, char*, ...);
|
|
||||||
int Bputc(Biobuf*, int);
|
|
||||||
void* Brdline(Biobuf*, int);
|
|
||||||
long Bread(Biobuf*, void*, long);
|
|
||||||
off_t Bseek(Biobuf*, off_t, int);
|
|
||||||
int Bterm(Biobuf*);
|
|
||||||
int Bungetc(Biobuf*);
|
|
||||||
long Bwrite(Biobuf*, void*, long);
|
|
||||||
char* Brdstr(Biobuf*, int, int);
|
|
||||||
long Bgetrune(Biobuf*);
|
|
||||||
int Bputrune(Biobuf*, long);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
--- Makefile ---
|
|
||||||
# New ports collection makefile for: libbio
|
|
||||||
# Date Created: 11 Feb 2003
|
|
||||||
# Whom: rsc
|
|
||||||
#
|
|
||||||
# THIS LINE NEEDS REPLACING. IT'S HERE TO GET BY PORTLINT
|
|
||||||
# $FreeBSD: ports/devel/libbio/Makefile,v 1.1 2003/02/12 00:51:22 rsc Exp $
|
|
||||||
|
|
||||||
PORTNAME= libbio
|
|
||||||
PORTVERSION= 2.0
|
|
||||||
CATEGORIES= devel
|
|
||||||
MASTER_SITES= http://pdos.lcs.mit.edu/~rsc/software/
|
|
||||||
EXTRACT_SUFX= .tgz
|
|
||||||
|
|
||||||
MAINTAINER= rsc@post.harvard.edu
|
|
||||||
|
|
||||||
DEPENDS= ${PORTSDIR}/devel/libfmt ${PORTSDIR}/devel/libutf
|
|
||||||
|
|
||||||
MAN3= bio.3
|
|
||||||
USE_REINPLACE= yes
|
|
||||||
|
|
||||||
.include <bsd.port.pre.mk>
|
|
||||||
|
|
||||||
post-patch:
|
|
||||||
${REINPLACE_CMD} -e 's,$$(PREFIX),${PREFIX},g' ${WRKSRC}/Makefile
|
|
||||||
|
|
||||||
.include <bsd.port.post.mk>
|
|
||||||
--- pkg-comment ---
|
|
||||||
Simple buffered I/O library from Plan 9
|
|
||||||
--- pkg-descr ---
|
|
||||||
Libbio is a port of Plan 9's formatted I/O library.
|
|
||||||
It provides most of the same functionality as stdio or sfio,
|
|
||||||
but with a simpler interface and smaller footprint.
|
|
||||||
|
|
||||||
WWW: http://pdos.lcs.mit.edu/~rsc/software/#libbio
|
|
||||||
http://plan9.bell-labs.com/magic/man2html/2/bio
|
|
||||||
|
|
||||||
Russ Cox
|
|
||||||
rsc@post.harvard.edu
|
|
||||||
--- pkg-plist ---
|
|
||||||
lib/libbio.a
|
|
||||||
include/bio.h
|
|
||||||
--- /dev/null ---
|
|
||||||
This is just a way to make sure blank lines don't
|
|
||||||
creep into pkg-plist.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
<../libutf/mkfile
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
Summary: Simple buffered I/O library from Plan 9
|
|
||||||
Name: libbio
|
|
||||||
Version: 2.0
|
|
||||||
Release: 1
|
|
||||||
Group: Development/C
|
|
||||||
Copyright: LGPL
|
|
||||||
Packager: Russ Cox <rsc@post.harvard.edu>
|
|
||||||
Source: http://pdos.lcs.mit.edu/~rsc/software/libbio-2.0.tgz
|
|
||||||
URL: http://pdos.lcs.mit.edu/~rsc/software/#libbio
|
|
||||||
Requires: libfmt libutf
|
|
||||||
|
|
||||||
%description
|
|
||||||
Libbio is a port of Plan 9's formatted I/O library.
|
|
||||||
It provides most of the same functionality as stdio or sfio,
|
|
||||||
but with a simpler interface and smaller footprint.
|
|
||||||
|
|
||||||
http://plan9.bell-labs.com/magic/man2html/2/bio
|
|
||||||
%prep
|
|
||||||
%setup
|
|
||||||
|
|
||||||
%build
|
|
||||||
make
|
|
||||||
|
|
||||||
%install
|
|
||||||
make install
|
|
||||||
|
|
||||||
%files
|
|
||||||
/usr/local/include/bio.h
|
|
||||||
/usr/local/lib/libbio.a
|
|
||||||
/usr/local/man/man3/bio.3
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS=-O -c -Ae -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
include Make.SunOS-sun4u-$(CC)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I. -O
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,30 +1,8 @@
|
|||||||
|
9SRC=..
|
||||||
# this works in gnu make
|
include $(9SRC)/Makehdr
|
||||||
SYSNAME:=${shell uname}
|
|
||||||
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
|
|
||||||
|
|
||||||
# this works in bsd make
|
|
||||||
SYSNAME!=uname
|
|
||||||
OBJTYPE!=uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'
|
|
||||||
|
|
||||||
# the gnu rules will mess up bsd but not vice versa,
|
|
||||||
# hence the gnu rules come first.
|
|
||||||
|
|
||||||
include Make.$(SYSNAME)-$(OBJTYPE)
|
|
||||||
|
|
||||||
PREFIX=/usr/local
|
|
||||||
|
|
||||||
NUKEFILES=
|
|
||||||
|
|
||||||
TGZFILES=
|
|
||||||
|
|
||||||
LIB=libdraw.a
|
LIB=libdraw.a
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/libdraw
|
|
||||||
NAME=libdraw
|
|
||||||
|
|
||||||
# keyboard.$O\
|
|
||||||
# newwindow.$O\
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
alloc.$O\
|
alloc.$O\
|
||||||
allocimagemix.$O\
|
allocimagemix.$O\
|
||||||
@ -125,70 +103,20 @@ OFILES=\
|
|||||||
unix.$O\
|
unix.$O\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
draw.h\
|
$(9SRC)/include/draw.h\
|
||||||
memdraw.h
|
$(9SRC)/include/memdraw.h\
|
||||||
|
$(9SRC)/include/memlayer.h\
|
||||||
|
$(9SRC)/include/event.h\
|
||||||
|
$(9SRC)/include/cursor.h\
|
||||||
|
$(9SRC)/include/mouse.h\
|
||||||
|
$(9SRC)/include/keyboard.h\
|
||||||
|
x11-inc.h\
|
||||||
|
x11-memdraw.h\
|
||||||
|
|
||||||
all: $(LIB)
|
CFLAGS+=-I$(X11)/include
|
||||||
|
|
||||||
install: $(LIB)
|
include $(9SRC)/Makesyslib
|
||||||
install -c -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
install -c -m 0644 draw.h $(PREFIX)/include/draw.h
|
|
||||||
install -c -m 0644 event.h $(PREFIX)/include/event.h
|
|
||||||
install -c -m 0644 cursor.h $(PREFIX)/include/cursor.h
|
|
||||||
install -c -m 0644 mouse.h $(PREFIX)/include/mouse.h
|
|
||||||
install -c -m 0644 keyboard.h $(PREFIX)/include/keyboard.h
|
|
||||||
|
|
||||||
test: test.o $(LIB)
|
test: test.o $(LIB)
|
||||||
gcc -o test test.o $(LIB) -L$(PREFIX)/lib -l9 -lfmt -lutf -L/usr/X11R6/lib -lX11 -lm
|
gcc -o test test.o -L$(9SRC) -ldraw -l9 -lfmt -lutf -L$(X11)/lib -lX11 -lm
|
||||||
|
|
||||||
$(LIB): $(OFILES)
|
|
||||||
$(AR) $(ARFLAGS) $(LIB) $(OFILES)
|
|
||||||
|
|
||||||
NUKEFILES+=$(LIB)
|
|
||||||
.c.$O:
|
|
||||||
$(CC) $(CFLAGS) -I/usr/X11R6/include -I../sam -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
%.$O: %.c
|
|
||||||
$(CC) $(CFLAGS) -I/usr/X11R6/include -I../sam -I$(PREFIX)/include $*.c
|
|
||||||
|
|
||||||
|
|
||||||
$(OFILES): $(HFILES)
|
|
||||||
|
|
||||||
tgz:
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
mkdir $(NAME)-$(VERSION)
|
|
||||||
cp Makefile Make.* README LICENSE NOTICE *.[ch137] rpm.spec bundle.ports $(TGZFILES) $(NAME)-$(VERSION)
|
|
||||||
tar cf - $(NAME)-$(VERSION) | gzip >$(NAME)-$(VERSION).tgz
|
|
||||||
rm -rf $(NAME)-$(VERSION)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OFILES) $(LIB)
|
|
||||||
|
|
||||||
nuke:
|
|
||||||
rm -f $(OFILES) *.tgz *.rpm $(NUKEFILES)
|
|
||||||
|
|
||||||
rpm:
|
|
||||||
make tgz
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/src/RPM/SOURCES
|
|
||||||
rpm -ba rpm.spec
|
|
||||||
cp /usr/src/RPM/SRPMS/$(NAME)-$(VERSION)-1.src.rpm .
|
|
||||||
cp /usr/src/RPM/RPMS/i586/$(NAME)-$(VERSION)-1.i586.rpm .
|
|
||||||
scp *.rpm rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
PORTDIR=/usr/ports/$(PORTPLACE)
|
|
||||||
|
|
||||||
ports:
|
|
||||||
make tgz
|
|
||||||
rm -rf $(PORTDIR)
|
|
||||||
mkdir $(PORTDIR)
|
|
||||||
cp $(NAME)-$(VERSION).tgz /usr/ports/distfiles
|
|
||||||
cat bundle.ports | (cd $(PORTDIR) && awk '$$1=="---" && $$3=="---" { ofile=$$2; next} {if(ofile) print >ofile}')
|
|
||||||
(cd $(PORTDIR); make makesum)
|
|
||||||
(cd $(PORTDIR); make)
|
|
||||||
(cd $(PORTDIR); /usr/local/bin/portlint)
|
|
||||||
rm -rf $(PORTDIR)/work
|
|
||||||
shar `find $(PORTDIR)` > ports.shar
|
|
||||||
(cd $(PORTDIR); tar cf - *) | gzip >$(NAME)-$(VERSION)-ports.tgz
|
|
||||||
scp *.tgz rsc@amsterdam.lcs.mit.edu:public_html/software
|
|
||||||
|
|
||||||
.phony: all clean nuke install tgz rpm ports
|
|
||||||
|
|||||||
@ -1,123 +0,0 @@
|
|||||||
LIB=libdraw.a
|
|
||||||
VERSION=2.0
|
|
||||||
PORTPLACE=devel/libdraw
|
|
||||||
NAME=libdraw
|
|
||||||
|
|
||||||
# keyboard.$O\
|
|
||||||
# newwindow.$O\
|
|
||||||
OFILES=\
|
|
||||||
alloc.$O\
|
|
||||||
allocimagemix.$O\
|
|
||||||
arith.$O\
|
|
||||||
bezier.$O\
|
|
||||||
border.$O\
|
|
||||||
buildfont.$O\
|
|
||||||
bytesperline.$O\
|
|
||||||
chan.$O\
|
|
||||||
cloadimage.$O\
|
|
||||||
computil.$O\
|
|
||||||
creadimage.$O\
|
|
||||||
debug.$O\
|
|
||||||
defont.$O\
|
|
||||||
draw.$O\
|
|
||||||
drawrepl.$O\
|
|
||||||
egetrect.$O\
|
|
||||||
ellipse.$O\
|
|
||||||
emenuhit.$O\
|
|
||||||
font.$O\
|
|
||||||
freesubfont.$O\
|
|
||||||
getdefont.$O\
|
|
||||||
getrect.$O\
|
|
||||||
getsubfont.$O\
|
|
||||||
icossin.$O\
|
|
||||||
icossin2.$O\
|
|
||||||
init.$O\
|
|
||||||
line.$O\
|
|
||||||
loadimage.$O\
|
|
||||||
menuhit.$O\
|
|
||||||
mkfont.$O\
|
|
||||||
openfont.$O\
|
|
||||||
poly.$O\
|
|
||||||
readcolmap.$O\
|
|
||||||
readimage.$O\
|
|
||||||
readsubfont.$O\
|
|
||||||
rectclip.$O\
|
|
||||||
replclipr.$O\
|
|
||||||
rgb.$O\
|
|
||||||
string.$O\
|
|
||||||
stringbg.$O\
|
|
||||||
stringsubfont.$O\
|
|
||||||
stringwidth.$O\
|
|
||||||
subfont.$O\
|
|
||||||
subfontcache.$O\
|
|
||||||
subfontname.$O\
|
|
||||||
unloadimage.$O\
|
|
||||||
window.$O\
|
|
||||||
writecolmap.$O\
|
|
||||||
writeimage.$O\
|
|
||||||
writesubfont.$O\
|
|
||||||
md-alloc.$O\
|
|
||||||
md-arc.$O\
|
|
||||||
md-cload.$O\
|
|
||||||
md-cmap.$O\
|
|
||||||
md-cread.$O\
|
|
||||||
md-defont.$O\
|
|
||||||
md-draw.$O\
|
|
||||||
md-ellipse.$O\
|
|
||||||
md-fillpoly.$O\
|
|
||||||
md-hwdraw.$O\
|
|
||||||
md-iprint.$O\
|
|
||||||
md-line.$O\
|
|
||||||
md-load.$O\
|
|
||||||
md-openmemsubfont.$O\
|
|
||||||
md-poly.$O\
|
|
||||||
md-read.$O\
|
|
||||||
md-string.$O\
|
|
||||||
md-subfont.$O\
|
|
||||||
md-unload.$O\
|
|
||||||
md-write.$O\
|
|
||||||
ml-draw.$O\
|
|
||||||
ml-lalloc.$O\
|
|
||||||
ml-layerop.$O\
|
|
||||||
ml-ldelete.$O\
|
|
||||||
ml-lhide.$O\
|
|
||||||
ml-line.$O\
|
|
||||||
ml-load.$O\
|
|
||||||
ml-lorigin.$O\
|
|
||||||
ml-lsetrefresh.$O\
|
|
||||||
ml-ltofront.$O\
|
|
||||||
ml-ltorear.$O\
|
|
||||||
ml-unload.$O\
|
|
||||||
x11-alloc.$O\
|
|
||||||
x11-cload.$O\
|
|
||||||
x11-draw.$O\
|
|
||||||
x11-event.$O\
|
|
||||||
x11-fill.$O\
|
|
||||||
x11-get.$O\
|
|
||||||
x11-init.$O\
|
|
||||||
x11-itrans.$O\
|
|
||||||
x11-keyboard.$O\
|
|
||||||
x11-load.$O\
|
|
||||||
x11-mouse.$O\
|
|
||||||
x11-pixelbits.$O\
|
|
||||||
x11-unload.$O\
|
|
||||||
devdraw.$O\
|
|
||||||
unix.$O\
|
|
||||||
|
|
||||||
HFILES=\
|
|
||||||
draw.h\
|
|
||||||
memdraw.h
|
|
||||||
|
|
||||||
all: $(LIB)
|
|
||||||
|
|
||||||
install: $(LIB)
|
|
||||||
install -c -m 0644 $(LIB) $(PREFIX)/lib/$(LIB)
|
|
||||||
install -c -m 0644 draw.h $(PREFIX)/include/draw.h
|
|
||||||
install -c -m 0644 event.h $(PREFIX)/include/event.h
|
|
||||||
install -c -m 0644 cursor.h $(PREFIX)/include/cursor.h
|
|
||||||
install -c -m 0644 mouse.h $(PREFIX)/include/mouse.h
|
|
||||||
install -c -m 0644 keyboard.h $(PREFIX)/include/keyboard.h
|
|
||||||
|
|
||||||
test: test.o $(LIB)
|
|
||||||
gcc -o test test.o $(LIB) -L$(PREFIX)/lib -l9 -lfmt -lutf -L/usr/X11R6/lib -lX11 -lm
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
typedef struct Cursor Cursor;
|
|
||||||
struct Cursor
|
|
||||||
{
|
|
||||||
Point offset;
|
|
||||||
uchar clr[2*16];
|
|
||||||
uchar set[2*16];
|
|
||||||
};
|
|
||||||
@ -1,520 +0,0 @@
|
|||||||
typedef struct Cachefont Cachefont;
|
|
||||||
typedef struct Cacheinfo Cacheinfo;
|
|
||||||
typedef struct Cachesubf Cachesubf;
|
|
||||||
typedef struct Display Display;
|
|
||||||
typedef struct Font Font;
|
|
||||||
typedef struct Fontchar Fontchar;
|
|
||||||
typedef struct Image Image;
|
|
||||||
typedef struct Mouse Mouse;
|
|
||||||
typedef struct Point Point;
|
|
||||||
typedef struct Rectangle Rectangle;
|
|
||||||
typedef struct RGB RGB;
|
|
||||||
typedef struct Screen Screen;
|
|
||||||
typedef struct Subfont Subfont;
|
|
||||||
|
|
||||||
extern int Rfmt(Fmt*);
|
|
||||||
extern int Pfmt(Fmt*);
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
DOpaque = 0xFFFFFFFF,
|
|
||||||
DTransparent = 0x00000000, /* only useful for allocimage, memfillcolor */
|
|
||||||
DBlack = 0x000000FF,
|
|
||||||
DWhite = 0xFFFFFFFF,
|
|
||||||
DRed = 0xFF0000FF,
|
|
||||||
DGreen = 0x00FF00FF,
|
|
||||||
DBlue = 0x0000FFFF,
|
|
||||||
DCyan = 0x00FFFFFF,
|
|
||||||
DMagenta = 0xFF00FFFF,
|
|
||||||
DYellow = 0xFFFF00FF,
|
|
||||||
DPaleyellow = 0xFFFFAAFF,
|
|
||||||
DDarkyellow = 0xEEEE9EFF,
|
|
||||||
DDarkgreen = 0x448844FF,
|
|
||||||
DPalegreen = 0xAAFFAAFF,
|
|
||||||
DMedgreen = 0x88CC88FF,
|
|
||||||
DDarkblue = 0x000055FF,
|
|
||||||
DPalebluegreen= 0xAAFFFFFF,
|
|
||||||
DPaleblue = 0x0000BBFF,
|
|
||||||
DBluegreen = 0x008888FF,
|
|
||||||
DGreygreen = 0x55AAAAFF,
|
|
||||||
DPalegreygreen = 0x9EEEEEFF,
|
|
||||||
DYellowgreen = 0x99994CFF,
|
|
||||||
DMedblue = 0x000099FF,
|
|
||||||
DGreyblue = 0x005DBBFF,
|
|
||||||
DPalegreyblue = 0x4993DDFF,
|
|
||||||
DPurpleblue = 0x8888CCFF,
|
|
||||||
|
|
||||||
DNotacolor = 0xFFFFFF00,
|
|
||||||
DNofill = DNotacolor,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
Displaybufsize = 8000,
|
|
||||||
ICOSSCALE = 1024,
|
|
||||||
Borderwidth = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* refresh methods */
|
|
||||||
Refbackup = 0,
|
|
||||||
Refnone = 1,
|
|
||||||
Refmesg = 2
|
|
||||||
};
|
|
||||||
#define NOREFRESH ((void*)-1)
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* line ends */
|
|
||||||
Endsquare = 0,
|
|
||||||
Enddisc = 1,
|
|
||||||
Endarrow = 2,
|
|
||||||
Endmask = 0x1F
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ARROW(a, b, c) (Endarrow|((a)<<5)|((b)<<14)|((c)<<23))
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
/* Porter-Duff compositing operators */
|
|
||||||
Clear = 0,
|
|
||||||
|
|
||||||
SinD = 8,
|
|
||||||
DinS = 4,
|
|
||||||
SoutD = 2,
|
|
||||||
DoutS = 1,
|
|
||||||
|
|
||||||
S = SinD|SoutD,
|
|
||||||
SoverD = SinD|SoutD|DoutS,
|
|
||||||
SatopD = SinD|DoutS,
|
|
||||||
SxorD = SoutD|DoutS,
|
|
||||||
|
|
||||||
D = DinS|DoutS,
|
|
||||||
DoverS = DinS|DoutS|SoutD,
|
|
||||||
DatopS = DinS|SoutD,
|
|
||||||
DxorS = DoutS|SoutD, /* == SxorD */
|
|
||||||
|
|
||||||
Ncomp = 12,
|
|
||||||
} Drawop;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* image channel descriptors
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
CRed = 0,
|
|
||||||
CGreen,
|
|
||||||
CBlue,
|
|
||||||
CGrey,
|
|
||||||
CAlpha,
|
|
||||||
CMap,
|
|
||||||
CIgnore,
|
|
||||||
NChan,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define __DC(type, nbits) ((((type)&15)<<4)|((nbits)&15))
|
|
||||||
#define CHAN1(a,b) __DC(a,b)
|
|
||||||
#define CHAN2(a,b,c,d) (CHAN1((a),(b))<<8|__DC((c),(d)))
|
|
||||||
#define CHAN3(a,b,c,d,e,f) (CHAN2((a),(b),(c),(d))<<8|__DC((e),(f)))
|
|
||||||
#define CHAN4(a,b,c,d,e,f,g,h) (CHAN3((a),(b),(c),(d),(e),(f))<<8|__DC((g),(h)))
|
|
||||||
|
|
||||||
#define NBITS(c) ((c)&15)
|
|
||||||
#define TYPE(c) (((c)>>4)&15)
|
|
||||||
|
|
||||||
enum {
|
|
||||||
GREY1 = CHAN1(CGrey, 1),
|
|
||||||
GREY2 = CHAN1(CGrey, 2),
|
|
||||||
GREY4 = CHAN1(CGrey, 4),
|
|
||||||
GREY8 = CHAN1(CGrey, 8),
|
|
||||||
CMAP8 = CHAN1(CMap, 8),
|
|
||||||
RGB15 = CHAN4(CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5),
|
|
||||||
RGB16 = CHAN3(CRed, 5, CGreen, 6, CBlue, 5),
|
|
||||||
RGB24 = CHAN3(CRed, 8, CGreen, 8, CBlue, 8),
|
|
||||||
BGR24 = CHAN3(CBlue, 8, CGreen, 8, CRed, 8),
|
|
||||||
RGBA32 = CHAN4(CRed, 8, CGreen, 8, CBlue, 8, CAlpha, 8),
|
|
||||||
ARGB32 = CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8), /* stupid VGAs */
|
|
||||||
XRGB32 = CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
|
|
||||||
XBGR32 = CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
|
|
||||||
};
|
|
||||||
|
|
||||||
extern char* chantostr(char*, u32int);
|
|
||||||
extern u32int strtochan(char*);
|
|
||||||
extern int chantodepth(u32int);
|
|
||||||
|
|
||||||
struct Point
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Rectangle
|
|
||||||
{
|
|
||||||
Point min;
|
|
||||||
Point max;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (*Reffn)(Image*, Rectangle, void*);
|
|
||||||
|
|
||||||
struct Screen
|
|
||||||
{
|
|
||||||
Display *display; /* display holding data */
|
|
||||||
int id; /* id of system-held Screen */
|
|
||||||
Image *image; /* unused; for reference only */
|
|
||||||
Image *fill; /* color to paint behind windows */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Display
|
|
||||||
{
|
|
||||||
QLock qlock;
|
|
||||||
int locking; /*program is using lockdisplay */
|
|
||||||
int dirno;
|
|
||||||
int imageid;
|
|
||||||
int local;
|
|
||||||
void (*error)(Display*, char*);
|
|
||||||
char *devdir;
|
|
||||||
char *windir;
|
|
||||||
char oldlabel[64];
|
|
||||||
u32int dataqid;
|
|
||||||
Image *image;
|
|
||||||
Image *white;
|
|
||||||
Image *black;
|
|
||||||
Image *opaque;
|
|
||||||
Image *transparent;
|
|
||||||
uchar *buf;
|
|
||||||
int bufsize;
|
|
||||||
uchar *bufp;
|
|
||||||
uchar *obuf;
|
|
||||||
int obufsize;
|
|
||||||
uchar *obufp;
|
|
||||||
Font *defaultfont;
|
|
||||||
Subfont *defaultsubfont;
|
|
||||||
Image *windows;
|
|
||||||
Image *screenimage;
|
|
||||||
int _isnewdisplay;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Image
|
|
||||||
{
|
|
||||||
Display *display; /* display holding data */
|
|
||||||
int id; /* id of system-held Image */
|
|
||||||
Rectangle r; /* rectangle in data area, local coords */
|
|
||||||
Rectangle clipr; /* clipping region */
|
|
||||||
int depth; /* number of bits per pixel */
|
|
||||||
u32int chan;
|
|
||||||
int repl; /* flag: data replicates to tile clipr */
|
|
||||||
Screen *screen; /* 0 if not a window */
|
|
||||||
Image *next; /* next in list of windows */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RGB
|
|
||||||
{
|
|
||||||
u32int red;
|
|
||||||
u32int green;
|
|
||||||
u32int blue;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Subfonts
|
|
||||||
*
|
|
||||||
* given char c, Subfont *f, Fontchar *i, and Point p, one says
|
|
||||||
* i = f->info+c;
|
|
||||||
* draw(b, Rect(p.x+i->left, p.y+i->top,
|
|
||||||
* p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
|
|
||||||
* color, f->bits, Pt(i->x, i->top));
|
|
||||||
* p.x += i->width;
|
|
||||||
* to draw characters in the specified color (itself an Image) in Image b.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct Fontchar
|
|
||||||
{
|
|
||||||
int x; /* left edge of bits */
|
|
||||||
uchar top; /* first non-zero scan-line */
|
|
||||||
uchar bottom; /* last non-zero scan-line + 1 */
|
|
||||||
char left; /* offset of baseline */
|
|
||||||
uchar width; /* width of baseline */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Subfont
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
short n; /* number of chars in font */
|
|
||||||
uchar height; /* height of image */
|
|
||||||
char ascent; /* top of image to baseline */
|
|
||||||
Fontchar *info; /* n+1 character descriptors */
|
|
||||||
Image *bits; /* of font */
|
|
||||||
int ref;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* starting values */
|
|
||||||
LOG2NFCACHE = 6,
|
|
||||||
NFCACHE = (1<<LOG2NFCACHE), /* #chars cached */
|
|
||||||
NFLOOK = 5, /* #chars to scan in cache */
|
|
||||||
NFSUBF = 2, /* #subfonts to cache */
|
|
||||||
/* max value */
|
|
||||||
MAXFCACHE = 1024+NFLOOK, /* upper limit */
|
|
||||||
MAXSUBF = 50, /* generous upper limit */
|
|
||||||
/* deltas */
|
|
||||||
DSUBF = 4,
|
|
||||||
/* expiry ages */
|
|
||||||
SUBFAGE = 10000,
|
|
||||||
CACHEAGE = 10000
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Cachefont
|
|
||||||
{
|
|
||||||
Rune min; /* lowest rune value to be taken from subfont */
|
|
||||||
Rune max; /* highest rune value+1 to be taken from subfont */
|
|
||||||
int offset; /* position in subfont of character at min */
|
|
||||||
char *name; /* stored in font */
|
|
||||||
char *subfontname; /* to access subfont */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Cacheinfo
|
|
||||||
{
|
|
||||||
ushort x; /* left edge of bits */
|
|
||||||
uchar width; /* width of baseline */
|
|
||||||
schar left; /* offset of baseline */
|
|
||||||
Rune value; /* value of character at this slot in cache */
|
|
||||||
ushort age;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Cachesubf
|
|
||||||
{
|
|
||||||
u32int age; /* for replacement */
|
|
||||||
Cachefont *cf; /* font info that owns us */
|
|
||||||
Subfont *f; /* attached subfont */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Font
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
Display *display;
|
|
||||||
short height; /* max height of image, interline spacing */
|
|
||||||
short ascent; /* top of image to baseline */
|
|
||||||
short width; /* widest so far; used in caching only */
|
|
||||||
short nsub; /* number of subfonts */
|
|
||||||
u32int age; /* increasing counter; used for LRU */
|
|
||||||
int maxdepth; /* maximum depth of all loaded subfonts */
|
|
||||||
int ncache; /* size of cache */
|
|
||||||
int nsubf; /* size of subfont list */
|
|
||||||
Cacheinfo *cache;
|
|
||||||
Cachesubf *subf;
|
|
||||||
Cachefont **sub; /* as read from file */
|
|
||||||
Image *cacheimage;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define Dx(r) ((r).max.x-(r).min.x)
|
|
||||||
#define Dy(r) ((r).max.y-(r).min.y)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Image management
|
|
||||||
*/
|
|
||||||
extern Image* _allocimage(Image*, Display*, Rectangle, u32int, int, u32int, int, int);
|
|
||||||
extern Image* allocimage(Display*, Rectangle, u32int, int, u32int);
|
|
||||||
extern uchar* bufimage(Display*, int);
|
|
||||||
extern int bytesperline(Rectangle, int);
|
|
||||||
extern void closedisplay(Display*);
|
|
||||||
extern void drawerror(Display*, char*);
|
|
||||||
extern int flushimage(Display*, int);
|
|
||||||
extern int freeimage(Image*);
|
|
||||||
extern int _freeimage1(Image*);
|
|
||||||
extern int geninitdraw(char*, void(*)(Display*, char*), char*, char*, char*, int);
|
|
||||||
extern int initdraw(void(*)(Display*, char*), char*, char*);
|
|
||||||
extern int newwindow(char*);
|
|
||||||
extern int loadimage(Image*, Rectangle, uchar*, int);
|
|
||||||
extern int cloadimage(Image*, Rectangle, uchar*, int);
|
|
||||||
extern int getwindow(Display*, int);
|
|
||||||
extern int gengetwindow(Display*, char*, Image**, Screen**, int);
|
|
||||||
extern Image* readimage(Display*, int, int);
|
|
||||||
extern Image* creadimage(Display*, int, int);
|
|
||||||
extern int unloadimage(Image*, Rectangle, uchar*, int);
|
|
||||||
extern int wordsperline(Rectangle, int);
|
|
||||||
extern int writeimage(int, Image*, int);
|
|
||||||
extern Image* namedimage(Display*, char*);
|
|
||||||
extern int nameimage(Image*, char*, int);
|
|
||||||
extern Image* allocimagemix(Display*, u32int, u32int);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Colors
|
|
||||||
*/
|
|
||||||
extern void readcolmap(Display*, RGB*);
|
|
||||||
extern void writecolmap(Display*, RGB*);
|
|
||||||
extern u32int setalpha(u32int, uchar);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Windows
|
|
||||||
*/
|
|
||||||
extern Screen* allocscreen(Image*, Image*, int);
|
|
||||||
extern Image* _allocwindow(Image*, Screen*, Rectangle, int, u32int);
|
|
||||||
extern Image* allocwindow(Screen*, Rectangle, int, u32int);
|
|
||||||
extern void bottomnwindows(Image**, int);
|
|
||||||
extern void bottomwindow(Image*);
|
|
||||||
extern int freescreen(Screen*);
|
|
||||||
extern Screen* publicscreen(Display*, int, u32int);
|
|
||||||
extern void topnwindows(Image**, int);
|
|
||||||
extern void topwindow(Image*);
|
|
||||||
extern int originwindow(Image*, Point, Point);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Geometry
|
|
||||||
*/
|
|
||||||
extern Point Pt(int, int);
|
|
||||||
extern Rectangle Rect(int, int, int, int);
|
|
||||||
extern Rectangle Rpt(Point, Point);
|
|
||||||
extern Point addpt(Point, Point);
|
|
||||||
extern Point subpt(Point, Point);
|
|
||||||
extern Point divpt(Point, int);
|
|
||||||
extern Point mulpt(Point, int);
|
|
||||||
extern int eqpt(Point, Point);
|
|
||||||
extern int eqrect(Rectangle, Rectangle);
|
|
||||||
extern Rectangle insetrect(Rectangle, int);
|
|
||||||
extern Rectangle rectaddpt(Rectangle, Point);
|
|
||||||
extern Rectangle rectsubpt(Rectangle, Point);
|
|
||||||
extern Rectangle canonrect(Rectangle);
|
|
||||||
extern int rectXrect(Rectangle, Rectangle);
|
|
||||||
extern int rectinrect(Rectangle, Rectangle);
|
|
||||||
extern void combinerect(Rectangle*, Rectangle);
|
|
||||||
extern int rectclip(Rectangle*, Rectangle);
|
|
||||||
extern int ptinrect(Point, Rectangle);
|
|
||||||
extern void replclipr(Image*, int, Rectangle);
|
|
||||||
extern int drawreplxy(int, int, int); /* used to be drawsetxy */
|
|
||||||
extern Point drawrepl(Rectangle, Point);
|
|
||||||
extern int rgb2cmap(int, int, int);
|
|
||||||
extern int cmap2rgb(int);
|
|
||||||
extern int cmap2rgba(int);
|
|
||||||
extern void icossin(int, int*, int*);
|
|
||||||
extern void icossin2(int, int, int*, int*);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Graphics
|
|
||||||
*/
|
|
||||||
extern void draw(Image*, Rectangle, Image*, Image*, Point);
|
|
||||||
extern void drawop(Image*, Rectangle, Image*, Image*, Point, Drawop);
|
|
||||||
extern void gendraw(Image*, Rectangle, Image*, Point, Image*, Point);
|
|
||||||
extern void gendrawop(Image*, Rectangle, Image*, Point, Image*, Point, Drawop);
|
|
||||||
extern void line(Image*, Point, Point, int, int, int, Image*, Point);
|
|
||||||
extern void lineop(Image*, Point, Point, int, int, int, Image*, Point, Drawop);
|
|
||||||
extern void poly(Image*, Point*, int, int, int, int, Image*, Point);
|
|
||||||
extern void polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
|
|
||||||
extern void fillpoly(Image*, Point*, int, int, Image*, Point);
|
|
||||||
extern void fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);
|
|
||||||
extern Point string(Image*, Point, Image*, Point, Font*, char*);
|
|
||||||
extern Point stringop(Image*, Point, Image*, Point, Font*, char*, Drawop);
|
|
||||||
extern Point stringn(Image*, Point, Image*, Point, Font*, char*, int);
|
|
||||||
extern Point stringnop(Image*, Point, Image*, Point, Font*, char*, int, Drawop);
|
|
||||||
extern Point runestring(Image*, Point, Image*, Point, Font*, Rune*);
|
|
||||||
extern Point runestringop(Image*, Point, Image*, Point, Font*, Rune*, Drawop);
|
|
||||||
extern Point runestringn(Image*, Point, Image*, Point, Font*, Rune*, int);
|
|
||||||
extern Point runestringnop(Image*, Point, Image*, Point, Font*, Rune*, int, Drawop);
|
|
||||||
extern Point stringbg(Image*, Point, Image*, Point, Font*, char*, Image*, Point);
|
|
||||||
extern Point stringbgop(Image*, Point, Image*, Point, Font*, char*, Image*, Point, Drawop);
|
|
||||||
extern Point stringnbg(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point);
|
|
||||||
extern Point stringnbgop(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point, Drawop);
|
|
||||||
extern Point runestringbg(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point);
|
|
||||||
extern Point runestringbgop(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point, Drawop);
|
|
||||||
extern Point runestringnbg(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point);
|
|
||||||
extern Point runestringnbgop(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point, Drawop);
|
|
||||||
extern Point _string(Image*, Point, Image*, Point, Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
|
|
||||||
extern Point stringsubfont(Image*, Point, Image*, Subfont*, char*);
|
|
||||||
extern int bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
|
|
||||||
extern int bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
|
|
||||||
extern int bezspline(Image*, Point*, int, int, int, int, Image*, Point);
|
|
||||||
extern int bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
|
|
||||||
extern int bezsplinepts(Point*, int, Point**);
|
|
||||||
extern int fillbezier(Image*, Point, Point, Point, Point, int, Image*, Point);
|
|
||||||
extern int fillbezierop(Image*, Point, Point, Point, Point, int, Image*, Point, Drawop);
|
|
||||||
extern int fillbezspline(Image*, Point*, int, int, Image*, Point);
|
|
||||||
extern int fillbezsplineop(Image*, Point*, int, int, Image*, Point, Drawop);
|
|
||||||
extern void ellipse(Image*, Point, int, int, int, Image*, Point);
|
|
||||||
extern void ellipseop(Image*, Point, int, int, int, Image*, Point, Drawop);
|
|
||||||
extern void fillellipse(Image*, Point, int, int, Image*, Point);
|
|
||||||
extern void fillellipseop(Image*, Point, int, int, Image*, Point, Drawop);
|
|
||||||
extern void arc(Image*, Point, int, int, int, Image*, Point, int, int);
|
|
||||||
extern void arcop(Image*, Point, int, int, int, Image*, Point, int, int, Drawop);
|
|
||||||
extern void fillarc(Image*, Point, int, int, Image*, Point, int, int);
|
|
||||||
extern void fillarcop(Image*, Point, int, int, Image*, Point, int, int, Drawop);
|
|
||||||
extern void border(Image*, Rectangle, int, Image*, Point);
|
|
||||||
extern void borderop(Image*, Rectangle, int, Image*, Point, Drawop);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Font management
|
|
||||||
*/
|
|
||||||
extern Font* openfont(Display*, char*);
|
|
||||||
extern Font* buildfont(Display*, char*, char*);
|
|
||||||
extern void freefont(Font*);
|
|
||||||
extern Font* mkfont(Subfont*, Rune);
|
|
||||||
extern int cachechars(Font*, char**, Rune**, ushort*, int, int*, char**);
|
|
||||||
extern void agefont(Font*);
|
|
||||||
extern Subfont* allocsubfont(char*, int, int, int, Fontchar*, Image*);
|
|
||||||
extern Subfont* lookupsubfont(Display*, char*);
|
|
||||||
extern void installsubfont(char*, Subfont*);
|
|
||||||
extern void uninstallsubfont(Subfont*);
|
|
||||||
extern void freesubfont(Subfont*);
|
|
||||||
extern Subfont* readsubfont(Display*, char*, int, int);
|
|
||||||
extern Subfont* readsubfonti(Display*, char*, int, Image*, int);
|
|
||||||
extern int writesubfont(int, Subfont*);
|
|
||||||
extern void _unpackinfo(Fontchar*, uchar*, int);
|
|
||||||
extern Point stringsize(Font*, char*);
|
|
||||||
extern int stringwidth(Font*, char*);
|
|
||||||
extern int stringnwidth(Font*, char*, int);
|
|
||||||
extern Point runestringsize(Font*, Rune*);
|
|
||||||
extern int runestringwidth(Font*, Rune*);
|
|
||||||
extern int runestringnwidth(Font*, Rune*, int);
|
|
||||||
extern Point strsubfontwidth(Subfont*, char*);
|
|
||||||
extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**);
|
|
||||||
extern char* subfontname(char*, char*, int);
|
|
||||||
extern Subfont* _getsubfont(Display*, char*);
|
|
||||||
extern Subfont* getdefont(Display*);
|
|
||||||
extern void lockdisplay(Display*);
|
|
||||||
extern void unlockdisplay(Display*);
|
|
||||||
extern int drawlsetrefresh(u32int, int, void*, void*);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Predefined
|
|
||||||
*/
|
|
||||||
extern uchar defontdata[];
|
|
||||||
extern int sizeofdefont;
|
|
||||||
extern Point ZP;
|
|
||||||
extern Rectangle ZR;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set up by initdraw()
|
|
||||||
*/
|
|
||||||
extern Display *display;
|
|
||||||
extern Font *font;
|
|
||||||
extern Image *screen;
|
|
||||||
extern Screen *_screen;
|
|
||||||
extern int _cursorfd;
|
|
||||||
extern int _drawdebug; /* set to 1 to see errors from flushimage */
|
|
||||||
extern void _setdrawop(Display*, Drawop);
|
|
||||||
extern Display *_initdisplay(void(*)(Display*,char*), char*);
|
|
||||||
|
|
||||||
#define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
|
|
||||||
#define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
|
|
||||||
#define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
|
|
||||||
#define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compressed image file parameters and helper routines
|
|
||||||
*/
|
|
||||||
#define NMATCH 3 /* shortest match possible */
|
|
||||||
#define NRUN (NMATCH+31) /* longest match possible */
|
|
||||||
#define NMEM 1024 /* window size */
|
|
||||||
#define NDUMP 128 /* maximum length of dump */
|
|
||||||
#define NCBLOCK 6000 /* size of compressed blocks */
|
|
||||||
extern void _twiddlecompressed(uchar*, int);
|
|
||||||
extern int _compblocksize(Rectangle, int);
|
|
||||||
|
|
||||||
/* XXX backwards helps; should go */
|
|
||||||
extern int log2[];
|
|
||||||
extern u32int drawld2chan[];
|
|
||||||
extern void drawsetdebug(int);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Port magic.
|
|
||||||
*/
|
|
||||||
int _drawmsgread(Display*, void*, int);
|
|
||||||
int _drawmsgwrite(Display*, void*, int);
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
typedef struct Event Event;
|
|
||||||
typedef struct Menu Menu;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
Emouse = 1,
|
|
||||||
Ekeyboard = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MAXSLAVE = 32,
|
|
||||||
EMAXMSG = 128+8192, /* size of 9p header+data */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Mouse
|
|
||||||
{
|
|
||||||
int buttons; /* bit array: LMR=124 */
|
|
||||||
Point xy;
|
|
||||||
ulong msec;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Event
|
|
||||||
{
|
|
||||||
int kbdc;
|
|
||||||
Mouse mouse;
|
|
||||||
int n; /* number of characters in message */
|
|
||||||
void *v; /* data unpacked by general event-handling function */
|
|
||||||
uchar data[EMAXMSG]; /* message from an arbitrary file descriptor */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Menu
|
|
||||||
{
|
|
||||||
char **item;
|
|
||||||
char *(*gen)(int);
|
|
||||||
int lasthit;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Events
|
|
||||||
*/
|
|
||||||
extern void einit(ulong);
|
|
||||||
extern ulong estart(ulong, int, int);
|
|
||||||
extern ulong estartfn(ulong, int, int, int (*fn)(int, Event*, uchar*, int));
|
|
||||||
extern ulong etimer(ulong, int);
|
|
||||||
extern ulong event(Event*);
|
|
||||||
extern ulong eread(ulong, Event*);
|
|
||||||
extern Mouse emouse(void);
|
|
||||||
extern int ekbd(void);
|
|
||||||
extern int ecanread(ulong);
|
|
||||||
extern int ecanmouse(void);
|
|
||||||
extern int ecankbd(void);
|
|
||||||
extern void eresized(int); /* supplied by user */
|
|
||||||
extern int emenuhit(int, Mouse*, Menu*);
|
|
||||||
extern int eatomouse(Mouse*, char*, int);
|
|
||||||
extern Rectangle getrect(int, Mouse*);
|
|
||||||
struct Cursor;
|
|
||||||
extern void esetcursor(struct Cursor*);
|
|
||||||
extern void emoveto(Point);
|
|
||||||
extern Rectangle egetrect(int, Mouse*);
|
|
||||||
extern void edrawgetrect(Rectangle, int);
|
|
||||||
extern int ereadmouse(Mouse*);
|
|
||||||
extern int eatomouse(Mouse*, char*, int);
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
typedef struct Keyboardctl Keyboardctl;
|
|
||||||
|
|
||||||
struct Keyboardctl
|
|
||||||
{
|
|
||||||
struct Channel *c; /* chan(Rune)[20] */
|
|
||||||
|
|
||||||
char *file;
|
|
||||||
int consfd; /* to cons file */
|
|
||||||
int ctlfd; /* to ctl file */
|
|
||||||
int pid; /* of slave proc */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern Keyboardctl* initkeyboard(char*);
|
|
||||||
extern int ctlkeyboard(Keyboardctl*, char*);
|
|
||||||
extern void closekeyboard(Keyboardctl*);
|
|
||||||
|
|
||||||
enum {
|
|
||||||
KF= 0xF000, /* Rune: beginning of private Unicode space */
|
|
||||||
/* KF|1, KF|2, ..., KF|0xC is F1, F2, ..., F12 */
|
|
||||||
Khome= KF|0x0D,
|
|
||||||
Kup= KF|0x0E,
|
|
||||||
Kpgup= KF|0x0F,
|
|
||||||
Kprint= KF|0x10,
|
|
||||||
Kleft= KF|0x11,
|
|
||||||
Kright= KF|0x12,
|
|
||||||
Kdown= 0x80,
|
|
||||||
Kview= 0x80,
|
|
||||||
Kpgdown= KF|0x13,
|
|
||||||
Kins= KF|0x14,
|
|
||||||
Kend= '\r', /* [sic] */
|
|
||||||
|
|
||||||
Kalt= KF|0x15,
|
|
||||||
Kshift= KF|0x16,
|
|
||||||
Kctl= KF|0x17,
|
|
||||||
};
|
|
||||||
@ -1,209 +0,0 @@
|
|||||||
typedef struct Memimage Memimage;
|
|
||||||
typedef struct Memdata Memdata;
|
|
||||||
typedef struct Memsubfont Memsubfont;
|
|
||||||
typedef struct Memlayer Memlayer;
|
|
||||||
typedef struct Memcmap Memcmap;
|
|
||||||
typedef struct Memdrawparam Memdrawparam;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Memdata is allocated from main pool, but .data from the image pool.
|
|
||||||
* Memdata is allocated separately to permit patching its pointer after
|
|
||||||
* compaction when windows share the image data.
|
|
||||||
* The first word of data is a back pointer to the Memdata, to find
|
|
||||||
* The word to patch.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct Memdata
|
|
||||||
{
|
|
||||||
u32int *base; /* allocated data pointer */
|
|
||||||
uchar *bdata; /* pointer to first byte of actual data; word-aligned */
|
|
||||||
int ref; /* number of Memimages using this data */
|
|
||||||
void* imref;
|
|
||||||
int allocd; /* is this malloc'd? */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
Frepl = 1<<0, /* is replicated */
|
|
||||||
Fsimple = 1<<1, /* is 1x1 */
|
|
||||||
Fgrey = 1<<2, /* is grey */
|
|
||||||
Falpha = 1<<3, /* has explicit alpha */
|
|
||||||
Fcmap = 1<<4, /* has cmap channel */
|
|
||||||
Fbytes = 1<<5, /* has only 8-bit channels */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Memimage
|
|
||||||
{
|
|
||||||
Rectangle r; /* rectangle in data area, local coords */
|
|
||||||
Rectangle clipr; /* clipping region */
|
|
||||||
int depth; /* number of bits of storage per pixel */
|
|
||||||
int nchan; /* number of channels */
|
|
||||||
u32int chan; /* channel descriptions */
|
|
||||||
Memcmap *cmap;
|
|
||||||
|
|
||||||
Memdata *data; /* pointer to data; shared by windows in this image */
|
|
||||||
int zero; /* data->bdata+zero==&byte containing (0,0) */
|
|
||||||
u32int width; /* width in words of a single scan line */
|
|
||||||
Memlayer *layer; /* nil if not a layer*/
|
|
||||||
u32int flags;
|
|
||||||
void *X;
|
|
||||||
|
|
||||||
int shift[NChan];
|
|
||||||
int mask[NChan];
|
|
||||||
int nbits[NChan];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Memcmap
|
|
||||||
{
|
|
||||||
uchar cmap2rgb[3*256];
|
|
||||||
uchar rgb2cmap[16*16*16];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Subfonts
|
|
||||||
*
|
|
||||||
* given char c, Subfont *f, Fontchar *i, and Point p, one says
|
|
||||||
* i = f->info+c;
|
|
||||||
* draw(b, Rect(p.x+i->left, p.y+i->top,
|
|
||||||
* p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
|
|
||||||
* color, f->bits, Pt(i->x, i->top));
|
|
||||||
* p.x += i->width;
|
|
||||||
* to draw characters in the specified color (itself a Memimage) in Memimage b.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct Memsubfont
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
short n; /* number of chars in font */
|
|
||||||
uchar height; /* height of bitmap */
|
|
||||||
char ascent; /* top of bitmap to baseline */
|
|
||||||
Fontchar *info; /* n+1 character descriptors */
|
|
||||||
Memimage *bits; /* of font */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encapsulated parameters and information for sub-draw routines.
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
Simplesrc=1<<0,
|
|
||||||
Simplemask=1<<1,
|
|
||||||
Replsrc=1<<2,
|
|
||||||
Replmask=1<<3,
|
|
||||||
Fullmask=1<<4,
|
|
||||||
};
|
|
||||||
struct Memdrawparam
|
|
||||||
{
|
|
||||||
Memimage *dst;
|
|
||||||
Rectangle r;
|
|
||||||
Memimage *src;
|
|
||||||
Rectangle sr;
|
|
||||||
Memimage *mask;
|
|
||||||
Rectangle mr;
|
|
||||||
int op;
|
|
||||||
|
|
||||||
u32int state;
|
|
||||||
u32int mval; /* if Simplemask, the mask pixel in mask format */
|
|
||||||
u32int mrgba; /* mval in rgba */
|
|
||||||
u32int sval; /* if Simplesrc, the source pixel in src format */
|
|
||||||
u32int srgba; /* sval in rgba */
|
|
||||||
u32int sdval; /* sval in dst format */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Memimage management
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern Memimage* allocmemimage(Rectangle, u32int);
|
|
||||||
extern Memimage* allocmemimaged(Rectangle, u32int, Memdata*, void*);
|
|
||||||
extern Memimage* readmemimage(int);
|
|
||||||
extern Memimage* creadmemimage(int);
|
|
||||||
extern int writememimage(int, Memimage*);
|
|
||||||
extern void freememimage(Memimage*);
|
|
||||||
extern int loadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern int cloadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern int unloadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern u32int* wordaddr(Memimage*, Point);
|
|
||||||
extern uchar* byteaddr(Memimage*, Point);
|
|
||||||
extern int drawclip(Memimage*, Rectangle*, Memimage*, Point*,
|
|
||||||
Memimage*, Point*, Rectangle*, Rectangle*);
|
|
||||||
extern void memfillcolor(Memimage*, u32int);
|
|
||||||
extern int memsetchan(Memimage*, u32int);
|
|
||||||
extern u32int pixelbits(Memimage*, Point);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Graphics
|
|
||||||
*/
|
|
||||||
extern void memdraw(Memimage*, Rectangle, Memimage*, Point,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void memline(Memimage*, Point, Point, int, int, int,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void mempoly(Memimage*, Point*, int, int, int, int,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void memfillpoly(Memimage*, Point*, int, int,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void _memfillpolysc(Memimage*, Point*, int, int,
|
|
||||||
Memimage*, Point, int, int, int, int);
|
|
||||||
extern void memimagedraw(Memimage*, Rectangle, Memimage*, Point,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern int hwdraw(Memdrawparam*);
|
|
||||||
extern void memimageline(Memimage*, Point, Point, int, int, int,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void _memimageline(Memimage*, Point, Point, int, int, int,
|
|
||||||
Memimage*, Point, Rectangle, int);
|
|
||||||
extern Point memimagestring(Memimage*, Point, Memimage*, Point,
|
|
||||||
Memsubfont*, char*);
|
|
||||||
extern void memellipse(Memimage*, Point, int, int, int,
|
|
||||||
Memimage*, Point, int);
|
|
||||||
extern void memarc(Memimage*, Point, int, int, int, Memimage*,
|
|
||||||
Point, int, int, int);
|
|
||||||
extern Rectangle memlinebbox(Point, Point, int, int, int);
|
|
||||||
extern int memlineendsize(int);
|
|
||||||
extern void _memmkcmap(void);
|
|
||||||
extern void memimageinit(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Subfont management
|
|
||||||
*/
|
|
||||||
extern Memsubfont* allocmemsubfont(char*, int, int, int, Fontchar*, Memimage*);
|
|
||||||
extern Memsubfont* openmemsubfont(char*);
|
|
||||||
extern void freememsubfont(Memsubfont*);
|
|
||||||
extern Point memsubfontwidth(Memsubfont*, char*);
|
|
||||||
extern Memsubfont* getmemdefont(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Predefined
|
|
||||||
*/
|
|
||||||
extern Memimage* memwhite;
|
|
||||||
extern Memimage* memblack;
|
|
||||||
extern Memimage* memopaque;
|
|
||||||
extern Memimage* memtransparent;
|
|
||||||
extern Memcmap* memdefcmap;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Kernel interface
|
|
||||||
*/
|
|
||||||
void memimagemove(void*, void*);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Kernel cruft
|
|
||||||
*/
|
|
||||||
extern void rdb(void);
|
|
||||||
extern int iprint(char*, ...);
|
|
||||||
extern int drawdebug;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For other implementations, like x11.
|
|
||||||
*/
|
|
||||||
extern void _memfillcolor(Memimage*, u32int);
|
|
||||||
extern Memimage* _allocmemimage(Rectangle, u32int);
|
|
||||||
extern int _cloadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern int _loadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern void _freememimage(Memimage*);
|
|
||||||
extern u32int _rgbatoimg(Memimage*, u32int);
|
|
||||||
extern u32int _imgtorgba(Memimage*, u32int);
|
|
||||||
extern u32int _pixelbits(Memimage*, Point);
|
|
||||||
extern int _unloadmemimage(Memimage*, Rectangle, uchar*, int);
|
|
||||||
extern Memdrawparam* _memimagedrawsetup(Memimage*,
|
|
||||||
Rectangle, Memimage*, Point, Memimage*,
|
|
||||||
Point, int);
|
|
||||||
extern void _memimagedraw(Memdrawparam*);
|
|
||||||
extern void _drawreplacescreenimage(Memimage*);
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
typedef struct Memscreen Memscreen;
|
|
||||||
typedef void (*Refreshfn)(Memimage*, Rectangle, void*);
|
|
||||||
|
|
||||||
struct Memscreen
|
|
||||||
{
|
|
||||||
Memimage *frontmost; /* frontmost layer on screen */
|
|
||||||
Memimage *rearmost; /* rearmost layer on screen */
|
|
||||||
Memimage *image; /* upon which all layers are drawn */
|
|
||||||
Memimage *fill; /* if non-zero, picture to use when repainting */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Memlayer
|
|
||||||
{
|
|
||||||
Rectangle screenr; /* true position of layer on screen */
|
|
||||||
Point delta; /* add delta to go from image coords to screen */
|
|
||||||
Memscreen *screen; /* screen this layer belongs to */
|
|
||||||
Memimage *front; /* window in front of this one */
|
|
||||||
Memimage *rear; /* window behind this one*/
|
|
||||||
int clear; /* layer is fully visible */
|
|
||||||
Memimage *save; /* save area for obscured parts */
|
|
||||||
Refreshfn refreshfn; /* function to call to refresh obscured parts if save==nil */
|
|
||||||
void *refreshptr; /* argument to refreshfn */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These functions accept local coordinates
|
|
||||||
*/
|
|
||||||
int memload(Memimage*, Rectangle, uchar*, int, int);
|
|
||||||
int memunload(Memimage*, Rectangle, uchar*, int);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All these functions accept screen coordinates, not local ones.
|
|
||||||
*/
|
|
||||||
void _memlayerop(void (*fn)(Memimage*, Rectangle, Rectangle, void*, int), Memimage*, Rectangle, Rectangle, void*);
|
|
||||||
Memimage* memlalloc(Memscreen*, Rectangle, Refreshfn, void*, u32int);
|
|
||||||
void memldelete(Memimage*);
|
|
||||||
void memlfree(Memimage*);
|
|
||||||
void memltofront(Memimage*);
|
|
||||||
void memltofrontn(Memimage**, int);
|
|
||||||
void _memltofrontfill(Memimage*, int);
|
|
||||||
void memltorear(Memimage*);
|
|
||||||
void memltorearn(Memimage**, int);
|
|
||||||
int memlsetrefresh(Memimage*, Refreshfn, void*);
|
|
||||||
void memlhide(Memimage*, Rectangle);
|
|
||||||
void memlexpose(Memimage*, Rectangle);
|
|
||||||
void _memlsetclear(Memscreen*);
|
|
||||||
int memlorigin(Memimage*, Point, Point);
|
|
||||||
void memlnorefresh(Memimage*, Rectangle, void*);
|
|
||||||
@ -1 +0,0 @@
|
|||||||
<../libutf/mkfile
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
typedef struct Menu Menu;
|
|
||||||
typedef struct Mousectl Mousectl;
|
|
||||||
|
|
||||||
struct Mouse
|
|
||||||
{
|
|
||||||
int buttons; /* bit array: LMR=124 */
|
|
||||||
Point xy;
|
|
||||||
ulong msec;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Mousectl
|
|
||||||
{
|
|
||||||
Mouse m;
|
|
||||||
struct Channel *c; /* chan(Mouse) */
|
|
||||||
struct Channel *resizec; /* chan(int)[2] */
|
|
||||||
/* buffered in case client is waiting for a mouse action before handling resize */
|
|
||||||
|
|
||||||
char *file;
|
|
||||||
int mfd; /* to mouse file */
|
|
||||||
int cfd; /* to cursor file */
|
|
||||||
int pid; /* of slave proc */
|
|
||||||
Display *display;
|
|
||||||
/*Image* image; / * of associated window/display */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Menu
|
|
||||||
{
|
|
||||||
char **item;
|
|
||||||
char *(*gen)(int);
|
|
||||||
int lasthit;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mouse
|
|
||||||
*/
|
|
||||||
extern Mousectl* initmouse(char*, Image*);
|
|
||||||
extern void moveto(Mousectl*, Point);
|
|
||||||
extern int readmouse(Mousectl*);
|
|
||||||
extern void closemouse(Mousectl*);
|
|
||||||
struct Cursor;
|
|
||||||
extern void setcursor(Mousectl*, struct Cursor*);
|
|
||||||
extern void drawgetrect(Rectangle, int);
|
|
||||||
extern Rectangle getrect(int, Mousectl*);
|
|
||||||
extern int menuhit(int, Mousectl*, Menu*, Screen*);
|
|
||||||
BIN
src/libdraw/test
BIN
src/libdraw/test
Binary file not shown.
@ -1,6 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include -pg
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS=-O -c -Ae -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -DNEEDLL
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
CC=gcc
|
|
||||||
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I$(PREFIX)/include
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O # default, can be overriden by Make.$(SYSNAME)
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
CC=cc
|
|
||||||
CFLAGS+=-g -c -I.
|
|
||||||
O=o
|
|
||||||
AR=ar
|
|
||||||
ARFLAGS=rvc
|
|
||||||
NAN=nan64.$O
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
include Make.SunOS-sun4u-$(CC)
|
|
||||||
NAN=nan64.$O
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user