Article View: comp.sys.amiga.tech
Article #1604Re: fork() (not forkv()!) on Amiga?
From: Richard Addison
Date: Wed, 11 Oct 1989 04:11
Date: Wed, 11 Oct 1989 04:11
87 lines
3294 bytes
3294 bytes
In article <13920001@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
>My appologies if this has been discussed before; our site just began
>subscribing to comp.sys.amiga* yesterday. If it has been discussed,
>could someone mail the thread to me?
>
>I have two questions. One concerns tasks, the other conserns the
>console device. I have lattice 5.02, if that matters.
...
>Question 2: (maybe easier!)
>
>I'm trying to put the console device in a RAW mode, such that I can
>read single characters from it without waiting for a newline. I can
>turn off buffering in Lattice, but it still waits for a newline.
>I know that in Manx there is an stty() call; is there anything like that
>in Lattice? I know I can read characters via IntuiMessage events, but
>it's important that I do it through the console device. I can't find
>anything about this in the Lattice manuals, other than the function
>to turn off buffering.
...
> - steve (koren@hpfela)
I can handle that one. In fact I had to a few years back. Should
still work:
#/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
#Human archive. Cut here and figure it out yourself. :-)
#\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/* For those of you who like prototypes: */
extern void SetConMode(long);
/* Includes needed for SetConMode: */
#include <exec/types.h>
#include <exec/exec.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdlib.h>
#include <stdio.h>
/* SetConMode
*
* This routine sets the console input mode to raw (for single character
* input) or to cooked (passed through line editor, default). Notice that
* this requires AmigaDos version 1.2 or higher.
*/
void SetConMode(mode)
long mode; /* -1: raw, 0: cooked */
{
register struct Process *proc;
register struct MsgPort *mp;
register struct StandardPacket *spkt;
proc = (struct Process *) FindTask(NULL);
if (proc->pr_ConsoleTask)
{
if (mp = CreatePort(NULL,0))
{
if (spkt = (struct StandardPacket *)
AllocMem(sizeof(struct StandardPacket),MEMF_CLEAR|MEMF_PUBLIC))
{
spkt->sp_Msg.mn_Node.ln_Name = (char *) &spkt->sp_Pkt;
spkt->sp_Pkt.dp_Link = &spkt->sp_Msg;
spkt->sp_Pkt.dp_Port = mp;
spkt->sp_Pkt.dp_Type = ACTION_SCREEN_MODE;
spkt->sp_Pkt.dp_Arg1 = mode;
spkt->sp_Pkt.dp_Arg2 = (long) proc;
PutMsg((struct MsgPort *) proc->pr_ConsoleTask,&spkt->sp_Msg);
WaitPort(mp);
(void) GetMsg(mp);
FreeMem((char *) spkt,sizeof(struct StandardPacket));
}
DeletePort(mp);
}
}
}
/* Richard Addison, said the C program AUTHORatively. */
Technical Details
Message-ID:
<20434@usc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!usc!pollux.usc.edu!addisonReferences:
<13920001@hpfelg.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!usc!pollux.usc.edu!addison From: addison@pollux.usc.edu (Richard Addison) Newsgroups: comp.sys.amiga.tech Subject: Re: fork() (not forkv()!) on Amiga? Summary: An answer to (2) Keywords: raw cooked Message-ID: <20434@usc.edu> Date: 11 Oct 89 04:11:58 GMT References: <13920001@hpfelg.HP.COM> Sender: news@usc.edu Reply-To: addison@pollux.usc.edu (Richard Addison) Organization: University of Southern California, Los Angeles, CA Lines: 87