[comp.std.c] How to read terminal reports from a C program, Help !

francis@hslrswi.UUCP (Francis Demierre) (03/01/90)

Hi Netland !

I was trying today to write a routine that would query the status of a printer
connected to a vt320 terminal.

To get a printer status report, an escape sequence is to be sent to the terminal
( ^[[?12n as far as I remember). The terminal will then generate a reply 
escape sequence such as ^[[?10n (Printer not connected).

My question is:

Under UNIX from a C program, how do you read the reply from the terminal ?
(as far as I could experiment, the reply comes back on stdin...)

Let's say I send the query with somwething like 'puts("\033[?12n");', how
do I read the answer of the terminal. I would also like to use a similar
method to read the terminal setting (VT100, VT220 or VT320 mode) and
the function keys content. What is the magic ?

Thank you in anticipation !
(answers preferably by Email as this is probably a "green horns" question ;-) )

BTW: I need a portable code that would run on RT AIX, PS2 AIX, XENIX and
     ULTRIX if it is possible.

-------------------------------------------------------------------------------
Francis Demierre       UUCP: ...!mcvax!cernvax!hslrswi!francis
                       Unix mail: francis@hslrswi.UUCP
-------------------------------------------------------------------------------

francis@hslrswi.UUCP (Francis Demierre) (03/02/90)

Sorry to have posted this question on this group !
That was obviously not the right one.
Francis.