@lsuc.uucp () (06/19/88)
I have been trying to post to comp.os.os9, but I keep
having my messages bounced, so I'll keep posting here for
now.
Anyway, this is a strange posting. You see, this is
a C library addition, but it doesn't seem to work. I don't
see anything wrong with it though, and it seems that the
Get/Put Buffer system may be flakey. So this program may
just be right as is. If you see anything wrong with it,
please let me know.
Cheers! -- Jim O.
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# ReadMe
# makefile
# gpbmap.a
# test.c
# This archive created:
# By: Jim Omura ()
cat << \SHAR_EOF > ReadMe
88/06/18
I tried to create a C library call to control mapping
and unmapping of the get/put buffers. It should work.
Funny thing is, it doesn't. If you can figure out why,
I'd sure like to know.
SHAR_EOF
cat << \SHAR_EOF > makefile
# make.test
CFILES = test.c
AFILES = gpbmap.a
LIB = -l=/dd/lib/cgfx.l -l=/dd/lib/clib.l -l=/dd/lib/sys.l
CFLAGS = -r
test: test.r gpbmap.r
rlink /dd/lib/cstart.r test.r gpbmap.r $(LIB) -o=/dd/cmds/test
test.r: test.c
cc1 test.c $(CFLAGS)
gpbmap.r: gpbmap.a
cc1 gpbmap.a $(CFLAGS)
SHAR_EOF
cat << \SHAR_EOF > gpbmap.a
psect gpbmap_c,0,0,0,0,0
nam gpbmap_c
* */* gpbmap.c */
* *
* */* 1988 By Jim Omura
* * * Public Domain
* * */
* *
* *int
* *gpbmap(path,group,buffer,action)
* *int path;
* *int group;
* *int buffer;
* *int action;
* * /* Returns -1 on error */
* *{
ttl gpbmap
gpbmap:
pshs u
ldd #_1
lbsr _stkcheck
* * path = path;
* ldd 4,s
* std 4,s
* * group = group;
* ldd 6,s
* std 6,s
* * buffer = buffer;
* ldd 8,s
* std 8,s
* * action = action;
* ldd 10,s
* std 10,s
* /* Fast Load X register */
lda 7,s /* Group */
ldb 9,s /* Buffer */
exg d,x /* copy it to X */
lda 5,s /* Path */
ldb #$84 /* SetStt option */
ldy 10,s /* Action */
os9 $8e /* I$SetStt */
bcs errexit
exg x,d /* Put pointer in D */
bra cleanexit
errexit
ldd #-1
cleanexit
* * return();
puls u,pc
* *}
_1 equ -64
* *
endsect
SHAR_EOF
cat << \SHAR_EOF > test.c
/* test.c */
/* tests gpbmap(path,group,buffer,action) */
#include <stdio.h>
char mkwin[] = { /* Make Dev Window */
0x1b,0x20,8,0,0,40,24,15,0,0 /* 10 char */
};
char select[] = {
0x1b,0x21
};
char mkbuf[] = {
0x1b,0x29,5,1,0,0x20 /* 6 char. Buffer = 32 bytes */
};
char gpld[] = {
0x1b,0x2b,5,1,2,0,8,0,1,0,8 /* 11 bytes */
};
char messg[] = { /* 8 Bytes */
'H','i',' ','T','h','e','r','e'
};
char kilbuf[] = {
0x1b,0x2a,5,0 /* 4 bytes */
};
char dwend[] = {
0x1b,0x24
};
main()
{
char *buffer;
int path;
path = open("/w",3);
write(path,mkwin,10);
write(path,select,2);
write(path,mkbuf,6);
write(path,gpld,11);
write(path,messg,8);
buffer = gpbmap(path,5,1,1);
if(buffer = -1)
{
fprintf(stderr,"Error\n");
}
else
{
write(2,buffer,8); /* Write it to STDERR */
}
gpbmap(path,5,1,0); /* Unmap */
for(;;)
{
if(_gs_rdy(path) > 0);
{
break;
}
}
write(path,kilbuf,4);
/* write(path,dwend,2); /* Not Nec. */
close(path);
}
SHAR_EOF
# End of shell archive
exit 0
--
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
ihnp4!utzoo!lsuc!jimomura
Byte Information eXchange: jimomura