
######natbcpl/sysc/clib.c#
/*#0A**.This.is.CLIB.for.BCPL.compiled.into.native.
code#0A**#0A**.It.is.based.on.cintsys#2Ec.from.the.
BCPL.Cintcode.system.and.is#0A**.meant.to.run.on.mo
st.machines.with.a.Unix-like.C.libraries#2E#0A**#0A
**.(c).Copyright:..Martin.Richards..4.September.200
9#0A**#0A*/#0A#0A/*#0AChange.History#0A#0A04/09/09#0A
Started.to.make.changes.for.the.Vax.under.VMS#0A#0A
10/04/06#0AMade.change.to.natbcpl.to.make.rdch.read
.the.command.argument.characters.before#0Areading.f
rom.stdin,.for.compatibility.with.cintsys#2E#0A#0A2
1/04/04#0AMade.many.changes.and.improvements.sugges
ted.by.Colin.Liebenrood#0A#0A07/11/96#0ASystematic.
changes.to.allow.64.bit.implementation.on.the.ALPHA
#0A#0A23/07/96#0AFirst.implementation#0A*/#0A#0A#23
include.<stdio#2Eh>#0A#23include.<stdlib#2Eh>#0A#23
include.<signal#2Eh>#0A#23include.<string#2Eh>#0A#0A
#23if.defined(forVmsItanium).||.defined(forVmsVax)#0A
#23include.<sys/timeb#2Eh>#0A#23else#0A#23include.<
sys/timeb#2Eh>#0A#23endif#0A#0A/*.bcpl#2Eh.contains
.machine/system.dependent.#23defines..*/#0A#23inclu
de."bcpl#2Eh"#0A#0Astatic.BCPLWORD.result2;#0Astati
c.BCPLWORD.prefix;#0ABCPLWORD.rootnode[Rtn_upb+1];#0A
static.char.*parms;../*.vector.of.command-line.argu
ments.*/#0Astatic.int..parmp#3D1;./*.subscript.of.n
ext.command-line.character#2E.*/#0Astatic.int..ttyi
np;../*.#3D1.if.stdin.is.a.tty,.#3D0.otherwise.*/#0A
#0A/*.prototypes.for.forward.references.*/#0Astatic
.BCPLWORD.muldiv(BCPLWORD.a,.BCPLWORD.b,.BCPLWORD.c
);#0Astatic.char.*b2c_fname(BCPLWORD.bstr,.char.*cs
tr);#0Astatic.char.*vmsfname(char.*name,.char.*vaxn
ame);#0Astatic.char.*b2c_str(BCPLWORD.bstr,.char.*c
str);#0Astatic.BCPLWORD.c2b_str(char.*cstr,.BCPLWOR
D.bstr);#0A#0A/*.Function.normally.defined.in.graph
ics#2Ec..*/#0Aextern.BCPLWORD.sysGraphics(BCPLWORD.
*p);#0ABCPLWORD.sysGraphics(BCPLWORD.*p).{.return.0
;.}./*.Dummy.definition.*/#0A#0A#23define.Globword.
.....0x8F8F0000L#0A#23define.Gn_result2....10#0A#0A
int.badimplementation(void)#0A{.int.bad.#3D.0,.A#3D
'A';#0A..SIGNEDCHAR.c.#3D.(SIGNEDCHAR)255;#0A..if(s
izeof(BCPLWORD)!#3D(1<<B2Wsh)).{#0A.......PRINTF("S
ize.of.a.BCPL.word.is.not.%d\n",.1<<B2Wsh);#0A.....
..bad.#3D.1;#0A..}#0A..if(A!#3D65).{#0A.......PRINT
F("Character.set.is.not.ASCII\n");#0A.......bad.#3D
.1;#0A..}#0A..if.(c/-1.!#3D.1).{#0A....PRINTF("Ther
e.is.a.problem.with.SIGNEDCHAR\n");#0A....bad.#3D.1
;#0A..}#0A..return.bad;#0A}#0A#0Avoid.initfpvec(voi
d)....{.return;.}#0ABCPLWORD.newfno(FILE.*fp)...{.r
eturn.WD.fp;.}#0ABCPLWORD.freefno(BCPLWORD.fno).{.r
eturn.fno;.}#0AFILE.*findfp(BCPLWORD.fno)..{.return
.(FILE.*)fno;.}#0A#0A/*.storage.for.SIGINT.handler.
*/#0Avoid.(*old_handler)(int);#0A#0Avoid.handler(in
t.sig)#0A{.#0A..printf("SIGINT.received\n");#0A..ol
d_handler.#3D.signal(SIGINT,.old_handler);#0A..clos
e_keyb();#0A..exit(20);#0A}#0A#0Aint.main(int.argc,
.char.*argv[])#0A{.int.i;....../*.for.FOR.loops..*/
#0A#0A..if.(.badimplementation().)#0A..{.printf("Th
is.implementation.of.C.is.not.suitable\n");#0A....r
eturn.20;#0A..}#0A#0A../*.Try.to.reconstruct.the.co
mmand.line.arguments.from.argv.*/#0A..parms.#3D.(ch
ar.*)(MALLOC(256));#0A#0A..{.int.p#3D0;#0A....parms
[0].#3D.0;#0A#0A....for.(i#3D1;.i<argc;.i++).{#0A..
....char.*arg.#3D.argv[i];#0A......int.len.#3D.strl
en(arg);#0A......int.j;#0A......int.is_string.#3D.0
;./*.#3D1.if.arg.contains.",.space,.or.newline#2Ewh
ite.space.*/#0A....../*printf("clib:.getting.comman
d.line,.len#3D%d\n",.len);.*/#0A......for.(j#3D0;.j
<len;.j++)#0A........if(.arg[j]#3D#3D'"'.||.arg[j]#3D
#3D'.'.||.arg[j]#3D#3D'\n').is_string.#3D.1;#0A....
../*printf("clib:.getting.command.line,.is_string#3D
%d\n",.is_string);.*/#0A......parms[++p].#3D.'.';#0A
......if(is_string)#0A......{.parms[++p].#3D.'"';#0A
........for.(j#3D0;.j<len;.j++)#0A........{.int.ch.
#3D.arg[j];#0A..........if(ch#3D#3D'\n').{.parms[p+
+].#3D.'*';.parms[++p].#3D.'n';.}#0A..........if(ch
#3D#3D'"')..{.parms[p++].#3D.'*';.parms[++p].#3D.'"
';.}#0A#09..else.parms[++p].#3D.ch;#0A........}#0A.
.......parms[++p].#3D.'"';#0A......}.else.{#0A.....
...for.(j#3D0;.j<len;.j++).parms[++p].#3D.arg[j];#0A
......}#0A....}#0A....parms[++p].#3D.'\n';../*.Put.
a.newline.at.the.end.of.the.argument.string.*/#0A..
..parms[0].#3D.p;./*.Fill.in.the.BCPL.string.length
.*/#0A....parmp.#3D.1;..../*.Subscript.of.the.first
.character.of.the.*/#0A................../*.command
-line.argument.*/#0A#0A..../*printf("clib:.args:.le
n#3D%d\n",.parms[0]);.*/#0A..../*for(i#3D1;.i<#3Dpa
rms[0];i++).printf("parm[%d]#3D%d\n",.i,.parms[i]);
.*/#0A..../*printf("\n");.*/#0A..}#0A#0A../*..parms
.#3D.(BCPLWORD.*)(MALLOC(argc+1));.*/#0A../*parms[0
].#3D.argc.>.1.?.argc.:.0;.*/#0A../*for.(i.#3D.0;.i
.<.argc;.i++).{.*/#0A../*..BCPLWORD.v.#3D.(BCPLWORD
)(MALLOC(1+strlen(argv[i]).>>.B2Wsh)).>>.B2Wsh;.*/#0A
../*..c2b_str(argv[i],.v);.*/#0A../*..parms[1+i].#3D
.v;.*/#0A../*}.*/#0A#0A..old_handler.#3D.signal(SIG
INT,.handler);#0A..initfpvec();#0A#0A..BCPLWORD.*gl
obbase..#3D.(BCPLWORD.*)(calloc((gvecupb.+1),.1<<B2
Wsh));#0A..if(globbase#3D#3D0).#0A....{.printf("una
ble.to.allocate.space.for.globbase\n");#0A......exi
t(20);#0A....}#0A#0A..BCPLWORD.*stackbase.#3D.(BCPL
WORD.*)(calloc((stackupb+1),.1<<B2Wsh));#0A..if(sta
ckbase#3D#3D0).#0A....{.printf("unable.to.allocate.
space.for.stackbase\n");#0A......exit(20);#0A....}#0A
#0A..for(i#3D0;.i<#3DRtn_upb;.i++).rootnode[i].#3D.
0;#0A#0A..globbase[0].#3D.gvecupb;#0A#0A..for.(i#3D
1;i<#3Dgvecupb;i++).globbase[i].#3D.Globword.+.i;#0A
..globbase[Gn_rootnode].#3D.((BCPLWORD)rootnode)>>B
2Wsh;#0A#0A..for.(i#3D0;i<#3Dstackupb;i++).stackbas
e[i].#3D.0;#0A#0A../*..printf("clib:.gvecupb#3D%d.s
tackupb#3D%d\n",.gvecupb,.stackupb);.*/#0A../*.init
sections,.gvecupb.and.stackupb.are.defined.in.the.f
ile.*/#0A../*.(typically).initprog#2Ec.created.by.a
.call.of.the.command.makeinit#2E.*/#0A..initsection
s(globbase);#0A..ttyinp.#3D.init_keyb();#0A#0A../*.
Enter.BCPL.start.function:.callstart.is.defined.in.
mlib#2Es.*/#0A..BCPLWORD.res.#3D.callstart(stackbas
e,.globbase);#0A#0A..close_keyb();#0A#0A..if.(res).
printf("\nExecution.finished,.return.code.%ld\n",.(
long)res);#0A#0A..free(globbase);#0A..free(stackbas
e);#0A..free(parms);#0A#0A..return.res;#0A}#0A#0A#0A
BCPLWORD.muldiv(BCPLWORD.a,.BCPLWORD.b,.BCPLWORD.c)
#0A{.unsigned.BCPLWORD.q#3D0,.r#3D0,.qn,.rn;#0A..un
signed.BCPLWORD.ua,.ub,.uc;#0A..int.qneg#3D0,.rneg#3D
0;#0A../*..printf("muldiv:.a#3D%d.b#3D%d.c#3D%d\n",
.a,.b,.c);.*/#0A..if(c#3D#3D0).c#3D1;#0A..if(a<0).{
.qneg#3D!qneg;.rneg#3D!rneg;.ua.#3D.-a;.}#0A..else.
.............................ua.#3D..a;#0A..if(b<0)
.{.qneg#3D!qneg;.rneg#3D!rneg;.ub.#3D.-b;.}#0A..els
e..............................ub.#3D..b;#0A..if(c<
0).{.qneg#3D!qneg;.............uc.#3D.-c;.}#0A..els
e..............................uc.#3D..c;#0A..#0A..
qn.#3D.ub./.uc;#0A..rn.#3D.ub.%.uc;#0A..#0A..while(
ua)#0A..{.if(ua&1).{.q.+#3D.qn;#0A...............r.
+#3D.rn;#0A...............if(r>#3Dc).{.q++;.r.-#3D.
uc;.}#0A.............}#0A....ua.>>#3D.1;#0A....qn.<
<#3D.1;#0A....rn.<<#3D.1;#0A....if(rn>#3Duc).{qn++;
.rn.-#3D.uc;.}#0A..}#0A..result2.#3D.rneg.?.-r.:.r;
#0A..return.qneg.?.-q.:.q;#0A}#0A#0Astatic.char.chb
uf1[256],.chbuf2[256];./*.to.hold.filenames.*/#0Ast
atic.char.chbuf3[256],.chbuf4[256];./*.to.hold.file
names.*/#0A#0Aint.tracing.#3D.0;#0Aint.filetracing.
#3D.0;#0A#0Aint.relfilename(char.*name)#0A{.if(name
[0]#3D#3DFILE_SEP_CH.||#0A...../*.The.following.is.
fiddle.for.MSDOS/Windows.*/#0A.....FILE_SEP_CH#3D#3D
'\\'.&&.'A'<#3Dname[0].&&.name[0]<#3D'Z'.&&.name[1]
#3D#3D':')#0A.......return.0;./*.Absolute.file.name
s.don't.use.paths.*/#0A..return.1;.#0A}#0A#0A/*.pat
hinput.does.not.use.any.of.chbuf1,.chbuf2.or.chbuf3
#2E.*/#0AFILEPT.pathinput(char.*name,.char.*pathnam
e)#0A/*.If.pathname.is.not.null,.name.is.looked.up.
in.the.directories#0A...it.specified,.otherwise.nam
e.is.looked.up.in.the.current.directory#0A*/#0A{.FI
LEPT.fp.#3D.0;#0A#0A../*.Look.through.the.PATH.dire
ctories.if.pathname.is.given#2E.*/#0A..if.(pathname
).{#0A....char.str[256];#0A....char.*filename.#3D.&
str[0];#0A....int.itemsep.#3D.FILE_SEP_CH#3D#3D'/'.
?.':'.:.';';#0A#23if.defined(forVmsItanium).||.defi
ned(forVmsVax)#0A....itemsep.#3D.';';#0A#23endif#0A
..../*PRINTFS("pathinput:.searching.for.%s.in.path.
%s\n",.name,.pathname);.*/#0A....if.(relfilename(na
me))#0A....{.char.*path.#3D.getenv(pathname);#0A...
...if(filetracing).{#0A........PRINTFS("pathinput:.
using.%s",.pathname);#0A........PRINTFS(".#3D.%s\n"
,.path);#0A......}#0A....../*PRINTFS("pathinput:.se
arching.directories.%s\n",.path);.*/#0A....../*.Try
.prefixing.with.each.directory.in.the.path#2E.*/#0A
......while(path.&&.fp#3D#3D0)#0A......{.char.*f#3D
filename;#0A........char.*n#3Dname;#0A........while
(*path#3D#3Ditemsep).path++;#0A........if(*path#3D#3D
0).break;#0A......../*.Copy.the.directory.name.into
.filename.*/#0A........while(*path!#3D0.&&.*path!#3D
itemsep)#0A........{.char.ch.#3D.*path++;#0A.......
...if(ch#3D#3D'/'.||.ch#3D#3D'\\').ch.#3D.FILE_SEP_
CH;#0A..........*f++.#3D.ch;#0A........}#0A........
/*.Insert.a.filename.seperator.if.necessary#2E.*/#0A
........if(f[-1]!#3DFILE_SEP_CH).*f++.#3D.FILE_SEP_
CH;#0A#0A......../*.Append.the.given.file.name.*/#0A
........while(*n)#0A........{.char.ch.#3D.*n++;#0A.
.........if(ch#3D#3D'/'.||.ch#3D#3D'\\').ch.#3D.FIL
E_SEP_CH;#0A..........*f++.#3D.ch;#0A........}#0A..
......*f.#3D.0;#0A#23if.defined(forVmsItanium).||.d
efined(forVmsVax)#0A........filename.#3D.vmsfname(f
ilename,.chbuf4);#0A#23endif#0A........fp.#3D.fopen
(filename,."rb");#0A........if(filetracing)#0A.....
...{.PRINTFS("Trying:.%s.-.",.filename);#0A#09..if(
fp).{#0A............PRINTF("found\n");#0A#09..}.els
e.{#0A............PRINTF("not.found\n");#0A#09..}#0A
........}#0A......}#0A....}#0A..}.else.{#0A..../*.I
f.pathname.was.NULL,.search.the.current.directory.*
/#0A..../*PRINTFS("Searching.for.%s.in.the.current.
directory\n",.name);.*/#0A#23if.defined(forVmsItani
um).||.defined(forVmsVax)#0A....fp.#3D.fopen(vmsfna
me(name,.chbuf4),."rb");#0A#23else#0A....fp.#3D.fop
en(name,."rb");#0A#23endif#0A....if(filetracing)#0A
....{.PRINTFS("Trying:.%s.in.the.current.directory.
-.",.name);#0A......if(fp).{#0A........PRINTF("foun
d\n");#0A......}.else.{#0A........PRINTF("not.found
\n");#0A......}#0A....}#0A..}#0A#0A../*if(fp#3D#3D0
).PRINTFS("pathinput:.failed.to.find.%s.anywhere\n"
,.name);.*/#0A../*else......PRINTF("pathinput:.succ
ess\n");.*/#0A#0A..return.fp;#0A}#0A/*#0AFILE.*path
input(char.*name,.char.*pathname)#0A{.FILE.*fp.#3D.
fopen(name,."r");#0A..char.filename[1024];#0A..int.
itemsep.#3D.FILE_SEP_CH#3D#3D'/'.?.':'.:.';';#0A..i
f.(fp#3D#3D0)#0A..{.if.(pathname.&&.relfilename(nam
e))#0A....{.char.*path.#3D.getenv(pathname);#0A....
..while(path.&&.fp#3D#3D0)#0A......{.char.*f#3Dfile
name,#0A.............*n#3Dname;#0A........while(*pa
th#3D#3Ditemsep).path++;#0A........if(*path#3D#3D0)
.break;#0A........while(*path!#3D0.&&.*path!#3Ditem
sep).*f++.#3D.*path++;#0A........if(f[-1]!#3DFILE_S
EP_CH).*f++.#3D.FILE_SEP_CH;#0A........while(*n).*f
++.#3D.*n++;#0A........*f.#3D.0;#0A........fp.#3D.f
open(filename,."r");#0A......}#0A....}#0A..}#0A..re
turn.fp;#0A}#0A*/#0A#0A/*.dosys(P,.G).called.from.m
lib#2Es.in.response.to#0A**.BCPL.call.res.:#3D.sys(
n,.x,.y,.#2E#2E#2E#2E)#2E.Arguments.p.&.g.are.the#0A
**.OCODE.stack-pointer.P.and.Global.vector.pointer.
G#2E.The.arguments#0A**.to.sys().are.n.#3D.p[3],.x.
#3D.p[4].#2E#2E#2E#2E#0A**.sys(0,.r).is.trapped.in.
mlib#2Es#0A*/#0A#0ABCPLWORD.dosys(register.BCPLWORD
.*p,.register.BCPLWORD.*g)#0A{.register.BCPLWORD.i;
#0A#0A..switch((int)(p[3]))#0A..{.default:.printf("
\nBad.sys.%ld\n",.(long)p[3]);..return.p[3];#0A..#0A
..../*#0A....case.Sys_setcount:.set.count..........
.....--.done.in.cinterp#0A....case.Sys_quit:.....re
turn.from.interpreter.--.done.in.cinterp#0A#0A....c
ase.Sys_rti:......sys(Sys_rti,.regs)......--.done.i
n.cinterp..Cintpos#0A....case.Sys_saveregs:.sys(Sys
_saveregs,.regs).--.done.in.cinterp..Cintpos#0A....
case.Sys_setst:....sys(Sys_setst,.st)......--.done.
in.cinterp..Cintpos#0A....case.Sys_tracing:..//.sys
(Sys_tracing,.b)#0A......tracing.#3D.W[p+4];#0A....
..return.0;#0A....case.Sys_watch:....sys(Sys_watch,
.addr)....--.done.in.cinterp#0A#0A....case..Sys_tal
ly:.........//.sys(Sys_tally,.flag)#0A......if(W[p+
4]).{#0A........tallylim.#3D.tallyupb;#0A........fo
r(i#3D1;.i<#3Dtallylim;.i++).tallyv[i].#3D.0;#0A...
...}.else.{#0A........tallylim.#3D.0;#0A......}#0A.
.....return.0;#0A.....#0A....case.Sys_interpret:.//
.call.interpreter.(recursively)#0A....{.BCPLWORD.re
gsv.#3D.W[p+4];#0A......if(W[regsv+7]<0).return.CIN
TASM..(regsv,.W);#0A......return.interpret(regsv,.W
);#0A....}#0A....*/#0A#0A....case.Sys_sardch:#0A...
.{.BCPLWORD.ch;#0A....../*printf("parmp#3D%d.parms[
0]#3D%d\n",.parmp,.parms[0]);.*/#0A......if(parmp<#3D
parms[0]).{../*.Added.MR.10/04/06.*/#0A......../*.R
ead.the.command.arguments.(without.echo).first#2E.*
/#0A......../*printf("sardch:.parmp#3D%d.parms[0]#3D
%d\n",.parmp,.parms[0]);.*/#0A......../*printf("sar
dch:.returning.%d\n",.parms[parmp]);.*/#0A........r
eturn.parms[parmp++];#0A......}#0A......ch.#3D.Read
ch();#0A......if.(ttyinp).{../*.echo.tty.input.only
.*/#0A........if.(ch>#3D0).putchar((char)ch);#0A...
.....if(ch#3D#3D13).{.ch.#3D.10;.putchar(10);.}#0A.
.......fflush(stdout);#0A......}#0A......return.ch;
#0A....}#0A#0A....case.Sys_sawrch:#0A......if(p[4].
#3D#3D.10).putchar(13);#0A......putchar((char)p[4])
;#0A......fflush(stdout);#0A......return.0;#0A#0A..
..case.Sys_read:../*.bytesread.:#3D.sys(Sys_read,.f
p,.buf,.bytecount).*/#0A....{.FILE.*fp.#3D.findfp(p
[4]);#0A......char.*bbuf.#3D.(char.*)(p[5]<<B2Wsh);
#0A......BCPLWORD.len...#3D.p[6];#0A......len.#3D.f
read(bbuf,.(size_t)1,.(size_t)len,.fp);#0A......ret
urn.len;#0A....}#0A#0A....case.Sys_write:#0A....{.F
ILE.*fp.#3D.findfp(p[4]);#0A......char.*bbuf.#3D.(c
har.*)(p[5]<<B2Wsh);#0A......BCPLWORD.len.#3D.p[6];
#0A......len.#3D.WD.fwrite(bbuf,.(size_t)1,.(size_t
)len,.fp);#0A......fflush(fp);#0A......return.len;#0A
....}#0A#0A....case.Sys_openread:#0A....{.char.*nam
e.#3D.b2c_fname(p[4],.chbuf1);#0A......FILEPT.fp;#0A
#23if.defined(forVmsItanium).||.defined(forVmsVax)#0A
......name.#3D.vaxfname(name,.chbuf4);#0A#23endif#0A
#0A......fp.#3D.pathinput(name,....................
/*.Filename.*/#0A.....................b2c_str(p[5],
.chbuf2));../*.Environment.variable.*/#0A......if(f
p#3D#3D0).return.0L;#0A......return.newfno(fp);#0A.
...}#0A#0A....case.Sys_openwrite:#0A....{.char.*nam
e.#3D.b2c_fname(p[4],.chbuf1);#0A......FILEPT.fp;#0A
#23if.defined(forVmsItanium).||.defined(forVmsVax)#0A
......name.#3D.vaxfname(name,.chbuf4);#0A#23endif#0A
#0A......fp.#3D.fopen(name,."wb");#0A......if(fp#3D
#3D0).return.0L;#0A......return.newfno(fp);#0A....}
#0A#0A....case.Sys_openreadwrite:#0A....{.char.*nam
e.#3D.b2c_fname(p[4],.chbuf1);#0A......FILEPT.fp;#0A
#23if.defined(forVmsItanium).||.defined(forVmsVax)#0A
......name.#3D.vaxfname(name,.chbuf4);#0A#23endif#0A
#0A.......fp.#3D.fopen(name,."rb+");#0A......if(fp#3D
#3D0).fp.#3D.fopen(name,."wb+");#0A......if(fp#3D#3D
0).return.0L;#0A......return.newfno(fp);#0A....}#0A
#0A....case.Sys_close:#0A....{.BCPLWORD.res.#3D.!.f
close(findfp(p[4]));#0A......freefno(p[4]);#0A.....
.return.res;#0A....}#0A#0A....case.Sys_deletefile:#0A
....{.char.*name.#3D.b2c_fname(p[4],.chbuf1);#0A...
...FILEPT.fp;#0A#23if.defined(forVmsItanium).||.def
ined(forVmsVax)#0A......name.#3D.vaxfname(name,.chb
uf4);#0A......{./*.Append.';*'.to.name.*/#0A.......
.int.len.#3D.0;#0A........while(name[len]).len++;#0A
........name[len].#3D.';';#0A........name[len].#3D.
'*';#0A........name[len].#3D.0;#0A......}#0A#23endi
f#0A......return.!.REMOVE(name);#0A....}#0A#0A....c
ase.Sys_renamefile:#0A....{.char.*name1.#3D.b2c_fna
me(p[4],.chbuf1);#0A......char.*name2.#3D.b2c_fname
(p[5],.chbuf2);#0A......int.len.#3D.0;#0A#23if.defi
ned(forVmsItanium).||.defined(forVmsVax)#0A......na
me1.#3D.vaxfname(name1,.chbuf3);#0A......name2.#3D.
vaxfname(name2,.chbuf4);#0A......{./*.Append.';*'.t
o.name2.*/#0A........len.#3D.0;#0A........while(nam
e2[len]).len++;#0A........name2[len].#3D.';';#0A...
.....name2[len].#3D.'*';#0A........name2[len].#3D.0
;#0A......}#0A#23endif#0A......REMOVE(name2);#0A#23
if.defined(forVmsItanium).||.defined(forVmsVax)#0A.
.....name2[len].#3D.0;#0A#23endif#0A......return.!.
rename(name1,.name2);#0A....}#0A#0A....case.Sys_get
vec:#0A......return.((BCPLWORD)(malloc((1+p[4])<<B2
Wsh)))>>B2Wsh;#0A#0A....case.Sys_freevec:#0A......f
ree((void.*)(p[4]<<B2Wsh));.return.-1;#0A/*#0A....c
ase.Sys_loadseg:#0A......return.loadseg(b2c_str(p[4
],.chbuf1));#0A....case.Sys_globin:#0A......return.
globin(p[4],.g);#0A....case.Sys_unloadseg:#0A......
unloadseg(p[4]);....................return.0;#0A*/#0A
#0A....case.Sys_muldiv:#0A....{.BCPLWORD.res.#3D..m
uldiv(p[4],.p[5],.p[6]);#0A......g[Gn_result2].#3D.
result2;#0A......return.res;#0A....}#0A#0A....case.
Sys_intflag:#0A......return.intflag().?.-1L.:.0L;#0A
#0A/*#0A....case.Sys_setraster:#0A......return.setr
aster(p[4],.p[5]);#0A*/#0A#0A....case.Sys_cputime:.
/*.Return.CPU.time.in.milliseconds..*/#0A......retu
rn.muldiv(clock(),.1000,.TICKS_PER_SEC);#0A#0A....c
ase.Sys_filemodtime:./*.Return.time.of.last.modific
ation.of.file#0A.............................whose.
name.is.in.p[4]..*/#0A....{.struct.stat.buf;#0A....
..char.*name.#3D.b2c_fname(p[4],.chbuf1);#0A......F
ILEPT.fp;#0A#23if.defined(forVmsItanium).||.defined
(forVmsVax)#0A......name.#3D.vaxfname(name,.chbuf4)
;#0A#23endif#0A......if.(stat(name,.&buf)).return.0
;#0A......return.buf#2Est_mtime;#0A....}#0A#0A....c
ase.Sys_setprefix:./*.Set.the.file.prefix.string..*
/#0A......prefix.#3D.p[4];#0A......return.prefix;#0A
#0A....case.Sys_getprefix:./*.Return.the.file.prefi
x.string..*/#0A......return.prefix;#0A#0A....case.S
ys_graphics:./*.Perform.an.operation.on.the.graphic
s.window..*/#0A......return.sysGraphics(p);#0A#0A..
..case.Sys_seek:../*.res.:#3D.seek(fd,.pos)...*/#0A
....{.FILEPT.fp.#3D.findfp(p[4]);#0A......BCPLWORD.
pos.#3D.p[5];#0A......BCPLWORD.res.#3D.fseek(fp,.po
s,.SEEK_SET);#0A....../*printf("fseek.#3D>.res#3D%d
.errno#3D%d\n",.res,.errno);.*/#0A....../*g[Gn_resu
lt2].#3D.errno;.*/#0A......return.res#3D#3D0.?.-1.:
.0;./*.res#3D0.succ,.res#3D-1.error..*/#0A....}#0A#0A
....case.Sys_tell:./*.pos.:#3D.sys(Sys_tell,fd)..*/
#0A....{.FILE.*fp.#3D.findfp(p[4]);#0A......BCPLWOR
D.pos.#3D.ftell(fp);#0A....../*g[Gn_result2].#3D.er
rno;.*/#0A......return.pos;./*.>#3D0.succ,.-1#3Derr
or.*/#0A....}#0A#0A....case.Sys_waitirq:./*.Wait.fo
r.irq.*/#0A....../*#0A......pthread_mutex_lock..(..
.......&irq_mutex);#0A......pthread_cond_wait...(&i
rq_cv,.&irq_mutex);#0A......pthread_mutex_unlock(..
.......&irq_mutex);#0A......*/#0A......return.0;#0A
#0A....case.Sys_lockirq:./*.Stop.all.devices.from.m
odifying.*/#0A....................../*.packets.or.g
enerating.interrupts.*/#0A....../*#0A......pthread_
mutex_lock(&irq_mutex);#0A......*/#0A......return.0
;#0A#0A....case.Sys_unlockirq:./*.Allow.devices.to.
modify.packets.*/#0A......................../*.and.
generate.interrput.*/#0A....../*#0A......pthread_mu
tex_unlock(&irq_mutex);#0A......*/#0A......return.0
;#0A#0A.....case.Sys_devcom:./*.res.:#3D.sys(Sys_de
vcom,.com,.arg).*/#0A.......return.0;./*devcommand(
W[p+4],.W[p+5],.W[p+6]);.*/#0A#0A.....case.Sys_ftim
e:./*.return.result.of.calling.ftime.*/#0A.....{.st
ruct.timeb.tb;#0A.......BCPLWORD.*v.#3D.(BCPLWORD*)
(p[4]<<2);#0A.......ftime(&tb);#0A#0A......./*.****
************.BEWARE.************************.*/#0A.
....../*.The.date.will.OVERFLOW.on.19-Jan-2038.at.3
:14:07.*/#0A.......v[0].#3D.0;./*(BCPLWORD)(tb#2Eti
me>>32);.*/#0A.......v[1].#3D.(BCPLWORD)tb#2Etime;.
./*.Seconds.since.epoch.*/#0A.......v[2].#3D.tb#2Em
illitm;...../*.milli-seconds.*/#0A.......v[3].#3D.t
b#2Etimezone;..../*.Minutes.west.of.Greenwich.*/#0A
.......v[4].#3D.tb#2Edstflag;...../*.non.zero.#3D>.
Daylight.saving.time#0A............................
.....applies.*/#0A#0A.......daylight.#3D.1;........
../*.Fudge.for.windows.*/#0A.......daylight.#3D.0;.
........./*.Fudge.for.windows.MR.31/10/03.*/#0A....
...tzset();.............../*.Should.be.done.separat
ely.*/#0A......./*#0A.......printf("cintpos:.timezo
ne#3D%d.daylight#3D%d.%s.%s\n",#0A...............(B
CPLWORD)timezone,(BCPLWORD)daylight,.tzname[0],#0A#09
.......tzname[1]);#0A.......*/#0A.......if(((BCPLWO
RD)timezone)%3600#3D#3D0)./*.Fudge.for.windows.*/#0A
.........v[1].-#3D.(BCPLWORD)timezone;..../*.Correc
t.for.timezone.*/#0A.......if.(daylight)#0A........
.v[1].+#3D.60*60;............./*.Add.one.hour.in.DS
T.*/#0A.......v[1].+#3D.rootnode[Rtn_adjclock].*.60
;./*.Add.adjustment.*/#0A.......return.-1;#0A.....}
#0A#0A.....case.Sys_usleep:./*.usleep.for.some.micr
o-seconds.*/#0A.......return.usleep(p[4]);#0A......
........#0A.....case.Sys_filesize:../*.res.:#3D.sys
(Sys_filesize,.fd)...*/#0A.....{.FILE.*fp...#3D.fin
dfp(p[4]);#0A.......BCPLWORD.pos..#3D.ftell(fp);#0A
.......BCPLWORD.rc...#3D.fseek(fp,.0,.SEEK_END);#0A
.......BCPLWORD.size.#3D.ftell(fp);#0A.......rc..#3D
.fseek(fp,.pos,.SEEK_SET);#0A.......if.(rc).size.#3D
.-1;#0A.......return.size;./*.>#3D0.succ,.-1#3Derro
r..*/#0A.....}#0A#0A.....case.Sys_getsysval:./*.res
.:#3D.sys(Sys_getsysval,.addr).*/#0A.....{.BCPLWORD
.*addr.#3D.(BCPLWORD*)p[4];#0A.......return.*addr;#0A
.....}#0A#0A.....case.Sys_putsysval:./*.res.:#3D.sy
s(Sys_putsysval,.addr,.val).*/#0A.....{.BCPLWORD.*a
ddr.#3D.(BCPLWORD*)p[4];#0A.......*addr.#3D.p[5];#0A
.......return.0;#0A.....}#0A#0A.....case.Sys_shellc
om:./*.res.:#3D.sys(Sys_shellcom,.comstr).*/#0A....
.{.char.*comstr.#3D.(char*)(p[4]<<2);#0A.......int.
i;#0A.......char.com[256];#0A.......int.len.#3D.str
len(comstr);#0A.......for(i#3D0;.i<len;.i++).com[i]
.#3D.comstr[i+1];#0A.......com[len].#3D.0;#0A......
./*#0A.......printf("\ndosys:.calling.shell.command
.%s\n",.com);#0A.......*/#0A.......return.system(co
m);#0A.....}#0A#0A.....case.Sys_getpid:./*.res.:#3D
.sys(Sys_getpid).*/#0A.......return.getpid();#0A#0A
.....case.Sys_dumpmem:./*.sys(Sys_dumpmem,.context)
.*/#0A.......printf("\nCintpos.memory.not.dumped.to
.DUMP#2Emem\n");#0A.......return.0;#0A#0A.....case.
Sys_callnative:#0A.....{./*.Call.native.code#2E.*/#0A
.......int(*rasmfn)(void).#3D.(int(*)(void))&p[4];#0A
.......return.rasmfn();#0A.....}..............#0A#0A
.....case.135:./*.Return.system.date.and.time.in.VE
C.5.*/#0A.....{.time_t.clk.#3D.time(0);#0A.......st
ruct.tm.*now.#3D.gmtime(&clk);#0A.......BCPLWORD.*a
rg.#3D.PT(p[4].<<.B2Wsh);#0A.......arg[0].#3D.now->
tm_year+1900;#0A.......arg[1].#3D.now->tm_mon+1;#0A
.......arg[2].#3D.now->tm_mday;#0A.......arg[3].#3D
.now->tm_hour;#0A.......arg[4].#3D.now->tm_min;#0A.
......arg[5].#3D.now->tm_sec;#0A.......return.0;#0A
.....}#0A#0A.....case.136:./*.Return.current.direct
ory.in.VEC.1.+.256/bytesperword.*/#0A.....{.getcwd(
chbuf1,.256);#0A.......c2b_str(chbuf1,.p[4]);#0A...
....return.0;#0A.....}#0A#0A....case.137:#0A......r
eturn.(BCPLWORD)parms.>>.B2Wsh;#0A..}#0A}.#0A#0Acha
r.*vmsfname(char.*name,.char.*vmsname).{#0A/*#0AThi
s.function.converts.a.BCPL.filename.to.a.VMS.filena
me#0AExamples:#0A#0AName.........................VM
S.name#0A#0Aecho#2Eb.......................echo#2Eb
#0Acom/echo#2Eb...................[#2Ecom]echo#2Eb#0A
/mrich177/distribution/bcpl#2Eg/libhdr#2Eh#0A......
.......................[mrich177#2Edistribution#2Eb
cpl#2Eg]libhdr#2Eh#0Avd10$disk:/mrich177/junk#2Eb..
.vd10$disk:[mrich177]junk#2Eb#0A#2E#2E/cintcode/com
/bcplfe#2Eb.....[-#2Ecintcode#2Ecom]bcplfe#2Eb#0A*/
#0A..int.ch,.i#3D0,.j#3D0,.len#3D0,.lastslashpos#3D
-1;#0A../*.If.name.contains.a.colon,.copy.all#0A...
..characters.up.to.and.including.the.colon#2E#0A..*
/#0A..while.(1).{#0A....int.ch.#3D.name[i];#0A....i
f.(ch#3D#3D0).break;./*.No.colon.in.name.*/#0A....i
f.(ch#3D#3D':').{#0A....../*.Copy.up.to.and.includi
ng.the.colon.*/#0A......while.(len<#3Di).{.vmsname[
len].#3D.name[len];.len++;.}#0A......j.#3D.len;#0A.
.....break;#0A....}#0A....i++;#0A..}#0A../*.Find.po
sition.of.last.slash,.if.any.*/#0A..while.(1).{#0A.
...int.ch.#3D.name[j];#0A....if(ch#3D#3D0).break;#0A
....if(ch#3D#3D'/').lastslashpos.#3D.j;#0A....j++;#0A
..}#0A#0A../*.No.slashes..#3D>.nothing#0A.....Leadi
ng./...#3D>.[#0A.....Slashes.but.no.leading.slash.s
o.insert.[#2E.or.[-#0A#0A.....name.is.then.copied.c
onverting.all.slashes.except.the.leading#0A.....and
.last.ones.to.dots,.and.converting.the.last.slash.t
o.]#2E#0A..*/#0A..j.#3D.i;#0A..if(name[j]#3D#3D'/')
.{#0A..../*.if.leading.slash.but.not.the.last.conve
rt.it.to.[.*/#0A....if.(j!#3Dlastslashpos).vmsname[
len++].#3D.'[';#0A....j++;#0A..}.else.{#0A....if.(l
astslashpos>#3D0).{#0A....../*.Slashes.but.no.leadi
ng.slash,.so.insert.[#2E.or.[-..*/#0A......vmsname[
len++].#3D.'[';#0A......if(name[j]!#3D'#2E'.||.name
[j+1]!#3D'#2E').{#0A........vmsname[len++].#3D.'#2E
';#0A......}#0A....}#0A..}#0A#0A..while.(1).{#0A...
./*.Replace.last./.by.]#0A.......and.non.last./.by.
#2E#0A.......and.#2E#2E.by.-#0A....*/#0A....int.ch.
#3D.name[j];#0A....if(ch#3D#3D'#2E'.&&.name[j+1]#3D
#3D'#2E').{#0A....../*.Convert.#2E#2E.to.-.*/#0A...
...ch.#3D.'-';#0A......j++;#0A....}#0A....if(ch#3D#3D
'/').{#0A......if.(j#3D#3Dlastslashpos).ch.#3D.']';
#0A......else.................ch.#3D.'#2E';#0A....}
#0A....vmsname[len++].#3D.ch;#0A....if(ch#3D#3D0).b
reak;#0A....j++;#0A..}#0A..return.vmsname;#0A}#0A#0A
/*.b2c_fname.converts.the.BCPL.string.for.a.file.na
me.to.a.C.character#0A**.string#2E..The.character.'
/'.(or.'\').is.treated.as.a.separator.and.is#0A**.c
onverted.to.FILE_SEP_CH.('/'.for.unix,.'\'.for.MSDO
S.or.':'.for.MAC)#2E#0A**.If.prefix.is.set.and.the.
filename.is.relative,.the.prefix.is.prepended#2E#0A
*/#0Achar.*b2c_fname(BCPLWORD.bstr,.char.*.cstr)#0A
{..char.*bp.#3D.(char*)(bstr<<2);#0A...int.len;#0A.
..int.i#3D0;#0A...if.(bstr#3D#3D0).return.0;./*.No.
path.given.*/#0A...len.#3D.*bp++;#0A...if.(prefix.&
&.relfilename((char*)bstr))#0A...{./*.Prepend.the.f
ilename.with.prefix.*/#0A.....char.*pfxp.#3D.(char*
)(prefix<<2);#0A.....int.pfxlen.#3D.*pfxp++;#0A....
.while(pfxlen--)#0A.....{.char.ch.#3D.*pfxp++;#0A..
.....if(ch#3D#3D'/'.||.ch#3D#3D'\\'.||.ch#3D#3D':')
.ch.#3D.FILE_SEP_CH;#0A.......cstr[i++].#3D.ch;#0A.
....}#0A.....if.(cstr[i-1].!#3D.FILE_SEP_CH).cstr[i
++].#3D.FILE_SEP_CH;#0A...}#0A#0A...while.(len--)#0A
...{.char.ch.#3D.*bp++;#0A.....if(ch#3D#3D'/'.||.ch
#3D#3D'\\'.||.ch#3D#3D':').ch.#3D.FILE_SEP_CH;#0A..
...cstr[i++].#3D.ch;#0A...}#0A...cstr[i].#3D.0;#0A.
../*if.(prefix).printfs("filename.#3D.%s\n",.cstr);
.*/#0A.../*printfs("b2c_fname:.cstr.#3D.%s\n",.cstr
);.*/#0A...return.cstr;#0A}#0A#0A/*.b2c_str.convert
s.the.BCPL.string.for.a.file.name.to.a.C.character#0A
**.string#2E..The.character.'/'.(or.'\').is.treated
.as.a.separator.and.is#0A**.converted.to.FILE_SEP_C
H.('/'.for.unix,.'\'.for.MSDOS.or.':'.for.MAC)#0A*/
#0Achar.*b2c_str(BCPLWORD.bstr,.char.*.cstr)#0A{..c
har.*bp,.i,.len;#0A...if.(bstr#3D#3D0).return.0;#0A
...bp.#3D.(char.*)(bstr<<B2Wsh);#0A...len.#3D.*bp++
;#0A...for(i.#3D.0;.i<len;.i++)#0A...{.char.ch.#3D.
*bp++;#0A.....if(ch#3D#3D'/'.||.ch#3D#3D'\\').ch.#3D
.FILE_SEP_CH;#0A.....cstr[i].#3D.ch;#0A...}#0A...cs
tr[len].#3D.0;#0A...return.cstr;#0A}.#0A#0A/*#0A**.
c2b_str.converts.a.C.string.into.a.BCPL.string#0A*/
#0ABCPLWORD.c2b_str(char.*cstr,.BCPLWORD.bstr).{#0A
..char.*bp.#3D.(char.*)(bstr.<<.B2Wsh);#0A..int.len
.#3D.0;#0A..while.(cstr[len]).{#0A....bp[len+1].#3D
.cstr[len];#0A......++len;#0A..}#0A..bp[0].#3D.len;
#0A..return.bstr;#0A}#0A

######natbcpl/sysc/initcmpltest.c#
/*.Initialisation.file.written.by.MakeInit.version.
1#2E9..*/#0A#23include."bcpl#2Eh"#0A#0Aint.stackupb
#3D10000;#0A#0Aint.gvecupb#3D1000;#0A#0A/*.BCPL.sec
tions..*/#0Aextern.BLIB(BCPLWORD.*g);.#09/*.file.(r
un-time.library)..*/#0Aextern.cmpltest(BCPLWORD.*g)
;.#09/*.file.#2E#2E/bcplprogs/tests/cmpltest#2Eb..*
/#0Aextern.DLIB(BCPLWORD.*g);.#09/*.file.(system.de
pendent.library)..*/#0A#0Avoid.initsections(BCPLWOR
D.*g).{#0A.......BLIB(g);.#09/*.file.(run-time.libr
ary)..*/#0A.......cmpltest(g);.#09/*.file.#2E#2E/bc
plprogs/tests/cmpltest#2Eb..*/#0A.......DLIB(g);.#09
/*.file.(system.dependent.library)..*/#0A#0A.......
return;#0A}#0A

######natbcpl/sysc/kblib.c#
/*.this.module.defines.the.machine.dependent.keyboa
rd.interface#0A#0A...int.Readch(void).....returns.t
he.ASCII.code.for.the.next.key.pressed#0A..........
..............without.echo#2E#0A...int.init_keyb(vo
id)..initialises.the.keyboard.interface#2E#0A...int
.close_keyb(void).restores.the.keyboard.to.its.orig
inal.state#2E#0A...int.intflag(void)....returns.1.i
f.interrupt.key.combination.pressed#2E#0A#0AFollowi
ng.Colin.Liebenrood's.suggestion.(for.LINUX),#0A#0A
...init_keyb.return.1.is.stdin.is.a.tty,.0.otherwis
e#0Aand#0A...Readch().return.endstreamch.if.the.std
in.is.exhausted.or.^D.read#2E#0A*/#0A#0A#23include.
<stdio#2Eh>#0A#23include.<stdlib#2Eh>#0A#0A/*.bcpl#2E
h.contains.machine/system.dependent.#23defines..*/#0A
#23include."bcpl#2Eh"#0A#0A#23if.defined(forMIPS).|
|.defined(forSUN4).||.defined(forALPHA)#0A#23includ
e.<sys/ioctl#2Eh>#0A#23include.<sgtty#2Eh>#0A#0Aint
.init_keyb(void)#0A{.struct.sgttyb.ttyb;#0A#0A..ioc
tl(0,.TIOCGETP,.&ttyb);#0A..ttyb#2Esg_flags.#3D.CBR
EAK+EVENP+ODDP+CRMOD;#0A..ioctl(0,.TIOCSETP,.&ttyb)
;#0A..return.0;#0A}#0A#0Aint.close_keyb(void)#0A{.s
truct.sgttyb.ttyb;#0A..ioctl(0,.TIOCGETP,.&ttyb);#0A
..ttyb#2Esg_flags.#3D.ECHO+EVENP+ODDP+CRMOD;#0A..io
ctl(0,.TIOCSETP,.&ttyb);#0A..return.0;#0A}#0A#0Aint
.Readch(void)#0A{.return.getchar();#0A}#0A#0Aint.in
tflag(void)#0A{.return.0;#0A}#0A#23endif#0A#0A#23if
.defined(forLINUX).||.defined(forSPARC)#0A#23includ
e.<unistd#2Eh>#0A#23include.<stdio#2Eh>#0A#23includ
e.<stdlib#2Eh>#0A#23include.<termios#2Eh>#0A#0A/*.U
se.this.variable.to.remember.original.terminal.attr
ibutes#2E..*/#0A.....#0Astruct.termios.saved_attrib
utes;#0A.....#0Avoid#0Areset_input_mode.(void)#0A{#0A
..tcsetattr.(STDIN_FILENO,.TCSANOW,.&saved_attribut
es);#0A}#0A.....#0Avoid#0Aset_input_mode.(void)#0A{
#0A..struct.termios.tattr;#0A#0A..if.(!isatty(STDIN
_FILENO)).return;..#0A...#0A../*.Save.the.terminal.
attributes.so.we.can.restore.them.later#2E..*/#0A..
tcgetattr.(STDIN_FILENO,.&saved_attributes);#0A..at
exit.(reset_input_mode);#0A#0A../*.Set.the.funny.te
rminal.modes#2E..*/#0A..tcgetattr.(STDIN_FILENO,.&t
attr);#0A..tattr#2Ec_lflag.&#3D.~(ICANON|ECHO);./*.
Clear.ICANON.and.ECHO#2E...*/#0A..tattr#2Ec_cc[VMIN
].#3D.1;#0A..tattr#2Ec_cc[VTIME].#3D.0;#0A..tcsetat
tr.(STDIN_FILENO,.TCSAFLUSH,.&tattr);#0A}#0A.....#0A
int.Readch()#0A{.char.ch;#0A..if.(.read(STDIN_FILEN
O,.&ch,.1).)#0A....return.ch#3D#3D0x04.?.-1.:.ch;#0A
.#0A..return.-1;.//.endstreamch#0A}#0A#0Aint.init_k
eyb(void)#0A{.#0A..if.(.isatty(STDIN_FILENO).).{#0A
....set_input_mode();#0A....return.1;#0A..}#0A..ret
urn.0;#0A}#0A#0A#0Aint.close_keyb(void)#0A{.return.
0;#0A}#0A#0Aint.intflag(void)#0A{.return.0;#0A}#0A#23
endif#0A#0A#23ifdef.forMAC#0A#23include.<console#2E
h>#0A#0Aint.Readch(void)#0A{.int.ch.#3D.EOF;#0A..wh
ile.(ch#3D#3DEOF).ch.#3D.getchar();./*.horrible!!!!
.*/#0A..return.ch;#0A}#0A#0Aint.init_keyb(void)#0A{
.console_options#2Etitle.#3D."\pBCPL.Cintcode";#0A.
.console_options#2Epause_atexit.#3D.0;#0A..cshow(st
din);#0A..csetmode(C_RAW,.stdin);#0A..return.0;#0A}
#0A#0Aint.close_keyb()#0A{.return.0;#0A}#0A#0Aint.i
ntflag(void)#0A{.long.theKeys[4];#0A..GetKeys(theKe
ys);#0A..return.theKeys[1]#3D#3D0x8005;../*.Command
-Option-Shift.depressed..*/#0A}#0A#23endif#0A#0A#23
ifdef.forMSDOS#0Aextern.int.getch(void);#0A#0Aint.R
eadch()#0A{.return.getch();#0A}#0A#0Aint.init_keyb(
void)#0A{.return.0;#0A}#0A#0Aint.close_keyb(void)#0A
{.return.0;#0A}#0A#0Aint.intflag(void)#0A{.return.0
;#0A}#0A#23endif#0A#0A#23ifdef.forOS2#0A#23include.
<conio#2Eh>#0A#0Aint.Readch(void)#0A{.int.ch.#3D.ge
tch();#0A..return.ch;#0A}#0A#0Aint.init_keyb(void)#0A
{.return.0;#0A}#0A#0Aint.close_keyb(void)#0A{.retur
n.0;#0A}#0A#0Aint.intflag(void)#0A{.return.0;#0A}#0A
#23endif#0A#0A#0A

######+#
