hadden@SRC.Honeywell.COM (George D. Hadden) (10/31/89)
i'm doing some work with midi files in xlisp and have run into a
problem. it appears that (read_byte foo), where foo is
an open file, thinks that it has reached end of file when it sees a
control-z. questions:
1) am i using the right function for reading binary data?
2) is there a workaround?
any help would be greatly appreciated. thanks.
the following code appears to be relevant:
****************************************************************
from xlftab.c:
{ "INT-CHAR", S, xintchar }, /* 244 */
{ "READ-BYTE", S, xrdbyte }, /* 245 */
{ "WRITE-BYTE", S, xwrbyte }, /* 246 */
****************************************************************
from xlfio.c:
/* xrdbyte - read a byte from a file */
LVAL xrdbyte()
{
LVAL fptr;
int ch;
/* get file pointer */
fptr = (moreargs() ? xlgetfile() : getvalue(s_stdin));
xllastarg();
/* get character and check for eof */
return ((ch = xlgetc(fptr)) == EOF ? NIL : cvfixnum((FIXTYPE)ch));
}
****************************************************************
from xlio.c:
/* xlgetc - get a character from a file or stream */
int xlgetc(fptr)
LVAL fptr;
{
LVAL lptr,cptr;
FILE *fp;
int ch;
/* check for input from nil */
if (fptr == NIL)
ch = EOF;
/* otherwise, check for input from a stream */
else if (ustreamp(fptr)) {
if ((lptr = gethead(fptr)) == NIL)
ch = EOF;
else {
if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr))
xlfail("bad stream");
sethead(fptr,lptr = cdr(lptr));
if (lptr == NIL)
settail(fptr,NIL);
ch = getchcode(cptr);
}
}
/* otherwise, check for a buffered character */
else if (ch = getsavech(fptr))
setsavech(fptr,'\0');
/* otherwise, check for terminal input or file input */
else {
fp = getfile(fptr);
if (fp == stdin || fp == stderr)
ch = ostgetc();
else
ch = osagetc(fp);
}
/* return the character */
return (ch);
}
****************************************************************
-geo
---
George D. Hadden, Honeywell Systems and Research Center
Where "Research" is our middle name!
PHONE: (612)782-7769 ARPA: hadden@src.honeywell.com
MAIL: 3660 Technology Drive MN65-2100, Minneapolis, MN 55418
UUCP: {umn-cs, ems, bthpyd}!srcsip!hadden