[comp.sys.amiga.tech] Getting a file handle for a non-cli window

rminnich@udel.EDU (Ron Minnich) (05/04/88)

1) WHy do i want to do this?
   Cause all the io, in lattice and manx, is in terms of file handles.
   I just don't LIKE the console.device nonsense. Every program i 
have seen does it a little differently. This seems silly. 
   Which brings me to the thing i don't want to ask:
      Anybody out there disassembled newcli yet?
   After all, newcli, or maybe the con: driver, does what i want 
to do! OR maybe there is a library function to do it? 
Like i say, i would rather not know, but, lacking any REASONABLE
alternative ...
-- 
ron (rminnich@udel.edu)

cmcmanis%pepper@Sun.COM (Chuck McManis) (05/04/88)

In article <2370@louie.udel.EDU> rminnich@udel.EDU (Ron Minnich) writes:
>1) WHy do i want to do this?
>   Cause all the io, in lattice and manx, is in terms of file handles.
>   I just don't LIKE the console.device nonsense.
>ron (rminnich@udel.edu)

Ron has been sending these out for a bit and while I thought the answer
was fairly clear I suspect it is not. The 'simple' answer is to put a 
window pointer into the startup message of the console device when starting
it, and then jamming that value into a file handle at the appropriate place.

Basically, there are three things we are dealing with here :

CON:	       - can be opened and accessed with read(3), and write(3), 
		 as well as the stdio library. Limited to opening windows on 
		 the WORKBENCH screen.
console.device - can be opened with the AmigaDOS Open(2) call and accessed
	         with SendIO(2) and DoIO(2), etc. Normally limited to the
		 WORKBENCH but some tricks can be used (described in AmigaMail)
		 to make it open on a different screen.
Window	       - Can be opened with OpenWindow() and written to using the Text()
		 call. This is what vt100 does, the extremely patient person
	 	 could possibly turn the VT100 program into a library routine
		 for opening 'terminal' windows.

The problem with the solution above is the 'jamming' part. There is no 
officially sanctioned way to create a filehandle out of an open file
descriptor. About the only think I can think of would be to open a 
CON: window, using the ACTION_INFO packet get a pointer to the ConUnit
structure, put in the parameters from your opened console.device, and 
then send it an esc-c to get it to re-sync. Not pretty and not easy
either. (Nor is it likely to work in future versions of the OS). 

My real suggestion is to put some wrappers around the calls to the console
device to make them more usable, or rethink the problem.

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

rminnich@udel.EDU (Ron Minnich) (05/05/88)

In article <51947@sun.uucp> cmcmanis@sun.UUCP (Chuck McManis) writes:
>In article <2370@louie.udel.EDU> rminnich@udel.EDU (Ron Minnich) writes:
>>1) WHy do i want to do this?
>>   Cause all the io, in lattice and manx, is in terms of file handles.
>Ron has been sending these out for a bit and while I thought the answer
>was fairly clear I suspect it is not. 
   Yup, that is my problem. There are three or four ways to get 
a half-assed solution, most of them very unsatisfying and 
version-dependent. I have looked at the Process, ConUnit, etc. structures
and folks, this is a REAL mess. So far no one has proposed
a general solution that uses standard ADOS/Rom Kernel stuff- it all
involves some pretty bizarre trickery. The worst part is that 
it seems to me you ought to WANT to do this!File Handles are the
standard io mechanism for both lattice and manx now. Ergo, i think,
you want file handles to windows.
   I am looking at a solution that involves using ConMan; i will 
let you know what i find.
ron
-- 
ron (rminnich@udel.edu)

peter@sugar.UUCP (Peter da Silva) (05/05/88)

In article <51947@sun.uucp>, cmcmanis%pepper@Sun.COM (Chuck McManis) writes:
> console.device - can be opened with the AmigaDOS Open(2) call and accessed
                                                   ^^^^^^^ ???????

Don't you mean OpenDevice?

By the way, the code fragment on page 279 of the AW version of RKM:L&D is
of interest:

OpenConsole(writerequest,readrequest,window)
struct IOStdReq *writerequest;
struct IOStdReq *readrequest;
struct Window *window;
{
	int error;

	writerequest->io_Data = (APTR)window;
	writerequest->io_Length = sizeof(*window);
	error = OpenDevice("console.device", 0, writerequest, 0);
	readrequest->io_Device = writerequest->io_Device;
	readrequest->io_Unit = writerequest->io_Unit;
	return error;
}
-- 
-- Peter da Silva      `-_-'      ...!hoptoad!academ!uhnix1!sugar!peter
-- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter
-- Disclaimer: These aren't mere opinions, these are *values*.

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (05/06/88)

In article <51947@sun.uucp> cmcmanis@sun.UUCP (Chuck McManis) writes:
>console.device - can be opened with the AmigaDOS Open(2) call and accessed
>	         with SendIO(2) and DoIO(2), etc. Normally limited to the
>		 WORKBENCH but some tricks can be used (described in AmigaMail)
>		 to make it open on a different screen.

	Say what, Chuck?

	CON: is the DOS domain goodie, and console.device is the Exec domain
goodie.  CON: is opened with Open() and console.device is opened with
OpenDevice().

	The console.device can be attached to any window on any screen.
This is explained quite well in the AutoDocs.

	Or am I missing some underlying Deep Meaning you were trying to
impart?

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape  ihnp4!pacbell -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

cmcmanis%pepper@Sun.COM (Chuck McManis) (05/07/88)

In article <5887@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
->In article <51947@sun.uucp> FumbleFingers writes:
->>console.device - can be opened with the AmigaDOS Open(2) call and accessed
->>	         with SendIO(2) and DoIO(2), etc. Normally limited to the
->>		 WORKBENCH but some tricks can be used (described in AmigaMail)
->>		 to make it open on a different screen.
->
->	Say what, Chuck?

I would like to say it was all planned and that I was just checking to 
see if anyone was reading, unfortunately this particular passage required
some "name expansion" on the part of the reader. Yes, I meant OpenDevice()
and not Open(). The DoIO and SendIO should have given it away :-)


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.