2
/*****************************************************************************
3
Copyright 1987, 1988, 1989, 1990, 1991, 1992 by Digital Equipment Corp.,
6
Permission to use, copy, modify, and distribute this software and its
7
documentation for any purpose and without fee is hereby granted,
8
provided that the above copyright notice appear in all copies and that
9
both that copyright notice and this permission notice appear in
10
supporting documentation, and that the name of Digital not be
11
used in advertising or publicity pertaining to distribution of the
12
software without specific, written prior permission.
14
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22
*****************************************************************************/
40
#include <descrip.h> /* Character string descriptors */
41
#include <dvidef.h> /* GETDVI item codes */
42
#include <devdef.h> /* device independent codes */
43
#include <iodef.h> /* I/O function codes */
44
#include <psldef.h> /* PSL definitions */
45
#include <ssdef.h> /* System service codes */
46
#include <stsdef.h> /* System status masks and codes */
47
#include <ttdef.h> /* Terminal specific I/O defs */
48
#include <tt2def.h> /* Terminal specific I/O defs */
49
#define CTRL_USER_MODE 3
55
#define $CheckStatus(status)\
56
if (!(status & 1)) return(status);
58
/* Allocate a quadword aligned VMS descriptor.
59
* NOTE: This supersedes the $DESCRIPTOR macro in DESCRIP.H.
60
* The only difference is the _align(QUADWORD) term.
62
#define $DESCRIPTOR_Q(name, string)\
63
struct dsc$descriptor_s _align (QUADWORD) name = \
64
{ sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
66
/*---------------------*
68
*---------------------*/
70
static $DESCRIPTOR_Q (sys_input, "SYS$INPUT:");
73
comm_chan, /* Communication channel */
74
comm_iosb[4]; /* I/O status block */
76
static struct getdvi_itmlst_struct
77
{ /* $GETDVI item list */
85
} _align (LONGWORD) getdvi_itmlst = { sizeof(int),
89
static unsigned int dvi_characteristics,return_length;
91
static struct exit_handler_blk
94
void (*exit_routine)();
95
unsigned char arg_cnt;
96
unsigned char null_byte;
97
unsigned short null_word;
98
unsigned int cond_value;
99
} _align (LONGWORD) exit_block;
101
static unsigned int vms_condition;
107
#include <X11/extensions/xtraplib.h>
108
#include <X11/extensions/xtraplibp.h>
110
#include "XEKeybCtrl.h"
112
int XEEnableCtrlKeys(void (*rtn)(int))
115
signal(SIGINT, rtn); /* CTRL-C */
123
* Provide the addresses of the longword to receive device chars
124
* and the return length of the information.
126
getdvi_itmlst.bufadr = &dvi_characteristics;
127
getdvi_itmlst.retadr = &return_length;
129
status = SYS$GETDVIW (0, 0, &sys_input, &getdvi_itmlst, 0, 0, 0, 0);
130
$CheckStatus(status);
133
/* If we have a terminal device, enable control-c and control-y */
134
if (dvi_characteristics & DEV$M_TRM)
136
/* Assign a channel to the communication device. */
137
status = SYS$ASSIGN ( &sys_input, /* Device name */
138
&comm_chan, /* Channel returned */
140
$CheckStatus(status);
142
status = XEEnableCtrlC(rtn);
143
$CheckStatus(status);
145
status = XEEnableCtrlY(rtn);
146
$CheckStatus(status);
154
int XEClearCtrlKeys(void)
157
signal(SIGINT, SIG_DFL); /* CTRL-C */
162
if (dvi_characteristics & DEV$M_TRM)
164
status = SYS$DASSGN(comm_chan);
165
$CheckStatus(status);
171
int XEEnableCtrlC(void (*rtn)(int))
174
signal(SIGINT, rtn); /* CTRL-C */
179
status = SYS$QIOW ( 0, /* Now set the characteristics */
180
comm_chan, /* Channel */
181
IO$_SETMODE|IO$M_CTRLCAST, /* Set ctrl_c */
182
comm_iosb, /* iosb address */
184
rtn, 0, /* AST routine and param */
185
CTRL_USER_MODE, 0, 0, 0 );
186
$CheckStatus(status);
193
int XEEnableCtrlY(void (*rtn)(int))
196
signal(SIGQUIT,rtn); /* CTRL-backslash */
201
status = SYS$QIOW ( 0, /* Set characteristics */
202
comm_chan, /* Channel */
203
IO$_SETMODE|IO$M_CTRLYAST, /* Set ctrl_y */
204
comm_iosb, /* iosb address */
206
rtn, 0, /* AST routine and param */
207
CTRL_USER_MODE, 0, 0, 0 );
208
$CheckStatus(status);
215
int XEDeclExitHndlr(void (*rtn)(int))
218
return(1); /* no real way for U*IX to do this */
223
* The Exit handler routine must accept one argument.
224
* This argument will be the condition that signaled the
227
exit_block.exit_routine = rtn;
228
exit_block.arg_cnt = 1; /* The condition code is the first argument */
229
exit_block.cond_value = &vms_condition; /* Address of condition value written by VMS */
231
status = SYS$DCLEXH (&exit_block); /* Set up the condition handler */
232
$CheckStatus(status);