From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 23-MAR-1993 19:46:41.09
To:	MACRO32@WKUVX1.BITNET
CC:	
Subj:	Raw mode in UCX/rlogin vs DECnet/LAT

The following program is intended to set login session to transparent
8-bit mode and read input. Whilst it appears to work OK over DECnet/LAT
session, it fails when run over UCX rlogin connection. Everything seems
fine, except CTRL/S and CTRL/Q 's are removed from the byte stream.

To use the program below, login and run it. Type some characters and notice
 the absence of any CTRL/S or CTRL/Q typed - eg. abc^Sdef^Qghi.

Can anyone offer any suggestions to how this can be resolved.

Please email replies to debbie@visionware.co.uk

#include <stdio.h>
#include <ssdef.h>
#include <ttdef.h>
#include <tt2def.h>
#include <descrip.h>
#include <iodef.h>
#include <file.h>

typedef struct {
        char class;
        char type;
        short page_width;
        int basic_chars;
        int extended_chars;
} vms_term_chars;

extern vms_term_chars term_chars;

/* Macro to convert string to descriptor */
#define strtodesc(desc,string) desc.dsc$a_pointer = string;\
                               desc.dsc$w_length = strlen(string);\
                               desc.dsc$b_dtype = DSC$K_DTYPE_T;\
                               desc.dsc$b_class = DSC$K_CLASS_S;


void DebugLog(s,a,b,c,d,e,f,g,h)
char *s;
long a,b,c,d,e,f,g,h;
{
    int fd;

    fd = open( "rawmode.log", O_RDWR | O_CREAT);

    if( fd >= 0 )
    {
        char buff[256];

        sprintf(buff, s, a, b, c, d, e, f, g, h );
        lseek( fd, 0L, 2 );
        write( fd, buff, strlen(buff) );
        close( fd );
    }
}

main ()
{
        int vmschan;
        int myval;
        int i;
        int status;
        char vmsbuff[512];
        struct dsc$descriptor trans_dsc;
        short data_block[4];
        short iostatus[4];
        int term[2];

        term[0] = 0;
        term[1] = 0;

/* Open up a channel to read from terminal */

        strtodesc(trans_dsc, "SYS$COMMAND");

        status = SYS$ASSIGN(&trans_dsc, &vmschan, 0, 0);

        if (status != SS$_NORMAL)  LIB$STOP (status);

/* Alter terminal characteristics */

        status = SYS$QIOW(0, vmschan, IO$_SENSEMODE, 0, 0, 0,
                &term_chars, 12, 0, 0, 0, 0);

        if (status != SS$_NORMAL)  LIB$STOP (status);

        term_chars.basic_chars |= TT$M_NOECHO;
        term_chars.basic_chars &= ~TT$M_TTSYNC;
        term_chars.basic_chars |= TT$M_NOBRDCST;
        term_chars.basic_chars &= ~TT$M_HOSTSYNC;
        term_chars.basic_chars &= ~TT$M_READSYNC;
/*
 * Put into 8-bit mode.
 */
        term_chars.basic_chars |= TT$M_EIGHTBIT;

        term_chars.extended_chars |= TT2$M_PASTHRU;

        status = SYS$QIOW(0, vmschan, IO$_SETMODE, 0, 0, 0,
                &term_chars, 12, 0, 0, 0, 0) ;

        if(status != SS$_NORMAL)  LIB$STOP (status);

        for (;;)
        {

/* Find out how many bytes are to be read */

                status = SYS$QIOW(0, vmschan, IO$_SENSEMODE|IO$M_TYPEAHDCNT,
                        0, 0, 0, data_block, 4*sizeof(short),
                        0, 0, 0, 0);

                if(status != SS$_NORMAL) LIB$STOP (status);

/* Read data */
                if ( data_block[0] != 0 )
                {
                status = SYS$QIOW(0, vmschan, IO$_READVBLK,
                        iostatus, 0, 0, vmsbuff, data_block[0], 0, term, 0, 0);

                if(status != SS$_NORMAL) LIB$STOP (status);

                if(iostatus[0] != SS$_NORMAL) LIB$STOP (status);

                for (i =0; i < iostatus[1]; i++)
                        DebugLog ("buff[%d] = %x\n", i, vmsbuff[i]);
                }
        }
}
