
GVG$TT_CHAR                                                     30-MAR-1989 15:53:57    VAX C      V2.2-015                 Page 1
V1.0                                                            30-MAR-1989 15:48:53    GVG$TT_CHAR.C;1 (1)



    1        	 
    2        	/*
    3        	 *	This routine sets the VMS terminal characteristics for strictly
    4        	 *	VMS functions for a terminal already under ioctl control.
    5        	 */
    6        	 
    7        	# include	<errno.h>
   50        	# include	<iodef.h>
  435        	# include	<ssdef.h>
  844        	# include	"sys_struct.h"
  884        	# include	<ttdef.h>
 1023        	# include	<tt2def.h>
 1089        	# include	"vmstermio.h"	/* Only structures defined. */
 1383        	# define	bool	char
 1384        	# define	reg	register
 1385        	 
 1386        	globalref struct vms_term_data		*vms_term_data_head;
 1387        	 
 1388        	# define	BITS(flag,mask)			(index->vmstermio->char_buff.flag & mask)
 1389        	# define	BTEST(flag,mask)		(BITS(flag,mask) == mask)
 1390        	# define	SETBITS(flag,mask)		(index->vmstermio->char_buff.flag |= mask)
 1391        	# define	RESETBITS(flag,mask)		(index->vmstermio->char_buff.flag &= ~mask)
 1392        	 
 1393        	/*
 1394        	 *	This routine returns TRUE if a terminal characteristic is set.
 1395        	 */
 1396        	 
 1397        	int
 1398        	vms_has_tt_char (fildes, tt_char, second)
 1399        		int	fildes;		/* File descriptor to check it on. */
 1400        		int	tt_char;	/* Which characteristic to check. */
 1401        		bool	second;		/* TRUE to use second word of characteristics buffer. */
 1402        	{
 1403    1   		struct vms_term_data	*index;				/* Index into VMS terminal data block. */
 1404    1   	 
 1405    1   	 
 1406    1   			/* Get the structure for this particular file descriptor. */
 1407    1   		for (index=vms_term_data_head;  index;  index=index->next)
 1408    1   		{	if (index->fildes == fildes)
 1409    2   				break;
 1410    2   		}
 1411    1   		if (!index)
 1412    1   			return 0;
 1413    1   	 
 1414    1   			/* Check the bit. */
 1415    1   		if (!second)
 1416    1   			return (BTEST (term_char, tt_char));
 1417    1   		else
 1418    1   			return (BTEST (term_char2, tt_char));
 1419    1   	}
 1420        	 
 1421        	 
 1422        	/*
 1423        	 *	This routine sets a terminal characteristic.
 1424        	 */

GVG$TT_CHAR                                                     30-MAR-1989 15:53:57    VAX C      V2.2-015                 Page 2
V1.0                                                            30-MAR-1989 15:48:53    GVG$TT_CHAR.C;1 (1)

 1425        	 
 1426        	int
 1427        	vms_set_tt_char (fildes, tt_char, second)
 1428        		int	fildes;		/* File descriptor to set it on. */
 1429        		int	tt_char;	/* Which characteristic to set. */
 1430        		bool	second;		/* TRUE to use second word of characteristics buffer. */
 1431        	{
 1432    1   		struct vms_term_data	*index;			/* Index into VMS terminal data block. */
 1433    1   	 	unsigned short int	func=0;			/* QIO function code and modifiers. */
 1434    1   		unsigned short int	chan;
 1435    1   		unsigned int		p1=0, p2=0, p3=0;	/* QIO funciton dependent parameters. */
 1436    1   		struct iosb_struct	iosb;			/* I/O status block for call to QIO. */
 1437    1   		bool			changes;		/* TRUE if VMS term. characteristics have changed. */
 1438    1   	 
 1439    1   	 
 1440    1   			/* Get the structure for this particular file descriptor. */
 1441    1   		for (index=vms_term_data_head;  index;  index=index->next)
 1442    1   		{	if (index->fildes == fildes)
 1443    2   				break;
 1444    2   		}
 1445    1   		if (!index)
 1446    1   			return 0;
 1447    1   	 
 1448    1   	 
 1449    1   			/* Set the bit(s). */
 1450    1   		if (!second)
 1451    1   			SETBITS (term_char, tt_char);
 1452    1   		else
 1453    1   			SETBITS (term_char2, tt_char);
 1454    1   	 
 1455    1   		func = IO$_SETMODE;			/* Set current terminal characteristics. */
 1456    1   		chan = index->vmstermio->chan;		/* Channel for this particular QIO. */
 1457    1   		p1 = &(index->vmstermio->char_buff);	/* Address of characteristics buffer. */
 1458    1   		p2 = 12;				/* Length of characteristics buffer. */
 1459    1   		p3 = index->vmstermio->baud;		/* The (possibly new) baud rate. */
 1460    1   		if ((vaxc$errno = sys$qiow (0, chan, func, &iosb, 0, 0, p1, p2, p3, 0, 0, 0)) != SS$_NORMAL)
 1461    1   		{	errno = EVMSERR;
 1462    2   			return (FALSE);
 1463    2   		}
 1464    1   		if ((vaxc$errno = iosb.cond) != SS$_NORMAL)
 1465    1   		{	errno = EVMSERR;
 1466    2   			return (FALSE);
 1467    2   		}
 1468    1   	 
 1469    1   			/* Return success. */
 1470    1   		return (TRUE);
 1471    1   	}
 1472        	 
 1473        	 
 1474        	/*
 1475        	 *	This routine resets a terminal characteristic.
 1476        	 */
 1477        	 
 1478        	int
 1479        	vms_reset_tt_char (fildes, tt_char, second)
 1480        		int	fildes;		/* File descriptor to reset it on. */
 1481        		int	tt_char;	/* Which characteristic to reset. */

GVG$TT_CHAR                                                     30-MAR-1989 15:53:57    VAX C      V2.2-015                 Page 3
V1.0                                                            30-MAR-1989 15:48:53    GVG$TT_CHAR.C;1 (1)

 1482        		bool	second;		/* TRUE to use second word of characteristics buffer. */
 1483        	{
 1484    1   		struct vms_term_data	*index;			/* Index into VMS terminal data block. */
 1485    1   	 	unsigned short int	func=0;			/* QIO function code and modifiers. */
 1486    1   		unsigned short int	chan;
 1487    1   		unsigned int		p1=0, p2=0, p3=0;	/* QIO funciton dependent parameters. */
 1488    1   		struct iosb_struct	iosb;			/* I/O status block for call to QIO. */
 1489    1   		bool			changes;		/* TRUE if VMS term. characteristics have changed. */
 1490    1   	 
 1491    1   	 
 1492    1   			/* Get the structure for this particular file descriptor. */
 1493    1   		for (index=vms_term_data_head;  index;  index=index->next)
 1494    1   		{	if (index->fildes == fildes)
 1495    2   				break;
 1496    2   		}
 1497    1   		if (!index)
 1498    1   			return 0;
 1499    1   	 
 1500    1   	 
 1501    1   			/* Reset the bit(s). */
 1502    1   		if (!second)
 1503    1   			RESETBITS (term_char, tt_char);
 1504    1   		else
 1505    1   			RESETBITS (term_char2, tt_char);
 1506    1   	 
 1507    1   		func = IO$_SETMODE;			/* Set current terminal characteristics. */
 1508    1   		chan = index->vmstermio->chan;		/* Channel for this particular QIO. */
 1509    1   		p1 = &(index->vmstermio->char_buff);	/* Address of characteristics buffer. */
 1510    1   		p2 = 12;				/* Length of characteristics buffer. */
 1511    1   		p3 = index->vmstermio->baud;		/* The (possibly new) baud rate. */
 1512    1   		if ((vaxc$errno = sys$qiow (0, chan, func, &iosb, 0, 0, p1, p2, p3, 0, 0, 0)) != SS$_NORMAL)
 1513    1   		{	errno = EVMSERR;
 1514    2   			return (FALSE);
 1515    2   		}
 1516    1   		if ((vaxc$errno = iosb.cond) != SS$_NORMAL)
 1517    1   		{	errno = EVMSERR;
 1518    2   			return (FALSE);
 1519    2   		}
 1520    1   	 
 1521    1   			/* Return success. */
 1522    1   		return (TRUE);
 1523    1   	}

 
 
Command Line
------------
 
CC/LIST GVG$TT_CHAR.C+VMS_TT_CHAR.C

