[Coco] Undocumented NitrOS9 system call (Boisy?)
Bill Pierce
ooogalapasooo at aol.com
Thu Nov 5 05:24:01 EST 2015
Thanks Barry, I'll look it over.
Bill Pierce
"Charlie stole the handle, and the train it won't stop going, no way to slow down!" - Ian Anderson - Jethro Tull
My Music from the Tandy/Radio Shack Color Computer 2 & 3
https://sites.google.com/site/dabarnstudio/
Co-Contributor, Co-Editor for CocoPedia
http://www.cocopedia.com/wiki/index.php/Main_Page
Global Moderator for TRS-80/Tandy Color Computer Forums
http://www.tandycoco.com/forum/
E-Mail: ooogalapasooo at aol.com
-----Original Message-----
From: Barry Nelson <barry.nelson at amobiledevice.com>
To: coco <coco at maltedmedia.com>
Sent: Thu, Nov 5, 2015 4:22 am
Subject: Re: [Coco] Undocumented NitrOS9 system call (Boisy?)
In some old C code for a dir command I have I found this function I was using to
read the file attributes. The variable inp is a pointer to a file handle to the
device that is left open until the program exits. The character string dir is
the directory being read. Once inp is open, multiple calls can be made to get_fd
to get file descriptors on that device. The variable s->dir_addr is the LSN of
the file descriptor from the directory entry.
int inp;
char indev[8];
char *dir;
struct fildesc ifdes;
struct dirent *s;
get_dev(dir,
indev);
if ((inp = open(indev, READ)) == -1) {
write(STDERR, "Error
reading input device.\n", 28);
exit(errno);
}
get_fd(inp,
&ifdes, s->dir_addr);
/*
** seek to 'pos' on device 'pn' and read
** 'fildes'
bytes into 'buf'
*/
get_fd(pn, buf, pos)
int pn;
struct fildesc *buf;
char
*pos;
{
l3seek(pn, pos);
if ((read(pn, buf, sizeof(struct fildesc))) ==
-1) {
write(STDERR, "Error reading file desc.\n", 25);
exit(errno);
}
}
/*
** seek to the LSN specified by the 3 char string
'pos'
*/
l3seek(pn, pos)
int pn;
char *pos;
{
long lpos;
int j;
register char *p = &lpos;
for (j = 3; j ; j--)
*p++ = *pos++;
*p = 0;
lseek(pn, lpos, 0);
}
/*
** return in 'buf' the device name
where
** file 's' resides.
*/
get_dev(s, buf)
char *s, *buf;
{
char
temp[32];
int pn;
if ((pn = open(s, DIR + READ + flag)) == -1)
return(-1);
lgetstat(pn, SS_DEVNM, temp, 0, 0);
*buf++ = '/';
strhcpy(buf, temp);
strcat(buf, "@");
close(pn);
}
/*
** local
getstat
** r_a = path number r_b = code
** r_x = parameter r_y =
parameter r_u = parameter
*/
lgetstat(r_a, r_b, r_x, r_y, r_u)
char
r_a, r_b;
int r_x, r_y, r_u;
{
struct registers reg;
reg.rg_a = r_a;
reg.rg_b = r_b;
reg.rg_x = r_x;
reg.rg_y = r_y;
reg.rg_u = r_u;
if (_os9(I_GETSTT, ®) == -1)
exit(reg.rg_b);
return(reg.rg_x);
}
--
Coco mailing
list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco
mailing list