Article View: comp.sys.amiga.tech
Article #5036More Questions About Using raw/cooked
From: Mark Millard
Date: Mon, 27 Aug 1990 17:51
Date: Mon, 27 Aug 1990 17:51
73 lines
2594 bytes
2594 bytes
I have a few questions concerning the usage of Chuck McManis's "raw"
and "cooked" utilities (recently re-posted).
I was wondering if it is possible to combine the raw mode with
waiting for signals on stdin's message port. I modified Chuck's
testraw program to do the following:
void main()
{
struct FileHandle *stdin_fh;
struct UFB *stdin_ufb;
struct MsgPort *readport;
ULONG signals,readsig;
/* get message port for stdin */
stdin_ufb = (struct UFB *) chkufb(fileno(stdin));
stdin_fh = (struct FileHandle *) (stdin_ufb->ufbfh);
readport = ((struct FileHandle *) (BADDR(stdin_fh)))->fh_Type;
/* set stdin to CBREAK mode */
if (raw(stdin) != 0) perror("raw");
/* gather and dispatch input */
readsig = 1 << readport->mp_SigBit;
signals = Wait(readsig);
if (signals & readsig) {
/* read input here */
}
/* reset stdin back to normal */
if (cooked(stdin) != 0) perror("raw");
}
What happens is that "Wait" never returns. Is the signal valid in raw
mode? If I replace the "gather and dispatch input" segment with
infh = Input();
ok = WaitForChar(infh,1000000);
if (ok)
read(fileno(stdin),buffer,1);
It seems to work fine. However, this is not what I want since eventually
I want to wait for input from other sources (i.e. intuition windows).
How can I do this? Is there something similar to UNIX's "select()"
mechanism which somebody can help me with?
My second question concerns Chuck's testraw program and using "fputc()"
or "putc()". I modified his while loop to be
while ((c = fgetc(win)) != 'Q') {
i = (i + 1) % 25;
if (i == 0 ) fputc('\n',win);
fputc(c,win);
}
"fputc" put it somewhere, but not in the console device. The same was
true with "putc". Has anybody else tried this?
Thanks for any help you can provide.
Mark Millard
Microware Systems Corp.
email: sun!mcrware!markm
phone: (515)-294-1929
Technical Details
Message-ID:
<2545@mcrware.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcrware!markmShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcrware!markm From: markm@mcrware.UUCP (Mark Millard) Newsgroups: comp.sys.amiga.tech Subject: More Questions About Using raw/cooked Message-ID: <2545@mcrware.UUCP> Date: 27 Aug 90 17:51:41 GMT Reply-To: markm@mcrware.UUCP (Mark Millard) Organization: Microware Systems Corp., Des Moines, Iowa Lines: 73