summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:24 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:24 +0000
commit721055e48fa8964d8895f551292dc845a5724c36 (patch)
treed9d8ccc8ab5a56f81a5ae722ee286ec801285d52
Initial revisionXORG-STABLE
-rw-r--r--XEKeybCtrl.c236
-rw-r--r--XEKeybCtrl.h8
-rw-r--r--chparse.c408
-rw-r--r--chparse.h10
-rw-r--r--xtrap.man216
-rw-r--r--xtrapchar.c733
-rw-r--r--xtrapin.c272
-rw-r--r--xtrapinfo.c88
-rw-r--r--xtrapout.c287
-rw-r--r--xtrapproto.c110
-rw-r--r--xtrapreset.c85
-rw-r--r--xtrapstats.c134
12 files changed, 2587 insertions, 0 deletions
diff --git a/XEKeybCtrl.c b/XEKeybCtrl.c
new file mode 100644
index 0000000..1c851b2
--- /dev/null
+++ b/XEKeybCtrl.c
@@ -0,0 +1,236 @@
+/* $XFree86: xc/programs/xtrap/XEKeybCtrl.c,v 1.1 2001/11/02 23:29:34 dawes Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#ifndef vms
+#include <signal.h>
+#else
+#include <descrip.h> /* Character string descriptors */
+#include <dvidef.h> /* GETDVI item codes */
+#include <devdef.h> /* device independent codes */
+#include <iodef.h> /* I/O function codes */
+#include <psldef.h> /* PSL definitions */
+#include <ssdef.h> /* System service codes */
+#include <stsdef.h> /* System status masks and codes */
+#include <ttdef.h> /* Terminal specific I/O defs */
+#include <tt2def.h> /* Terminal specific I/O defs */
+#define CTRL_USER_MODE 3
+
+/*----------*
+ * Macros *
+ *----------*/
+
+#define $CheckStatus(status)\
+ if (!(status & 1)) return(status);
+
+ /* Allocate a quadword aligned VMS descriptor.
+ * NOTE: This supersedes the $DESCRIPTOR macro in DESCRIP.H.
+ * The only difference is the _align(QUADWORD) term.
+ */
+#define $DESCRIPTOR_Q(name, string)\
+ struct dsc$descriptor_s _align (QUADWORD) name = \
+ { sizeof(string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
+
+/*---------------------*
+ * Data Declarations *
+ *---------------------*/
+
+static $DESCRIPTOR_Q (sys_input, "SYS$INPUT:");
+
+static unsigned short
+ comm_chan, /* Communication channel */
+ comm_iosb[4]; /* I/O status block */
+
+static struct getdvi_itmlst_struct
+ { /* $GETDVI item list */
+ unsigned short int
+ buflen,
+ item_code;
+ unsigned int
+ bufadr,
+ retadr,
+ eol;
+ } _align (LONGWORD) getdvi_itmlst = { sizeof(int),
+ DVI$_DEVCHAR,
+ 0,0,0 };
+
+static unsigned int dvi_characteristics,return_length;
+
+static struct exit_handler_blk
+ {
+ unsigned int flink;
+ void (*exit_routine)();
+ unsigned char arg_cnt;
+ unsigned char null_byte;
+ unsigned short null_word;
+ unsigned int cond_value;
+ } _align (LONGWORD) exit_block;
+
+static unsigned int vms_condition;
+
+#endif /* vms */
+
+
+
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+#include "XEKeybCtrl.h"
+
+int XEEnableCtrlKeys(void (*rtn)(int))
+{
+#ifndef vms
+ signal(SIGINT, rtn); /* CTRL-C */
+ return(1L);
+
+#else /* vms */
+
+ int status;
+
+ /*
+ * Provide the addresses of the longword to receive device chars
+ * and the return length of the information.
+ */
+ getdvi_itmlst.bufadr = &dvi_characteristics;
+ getdvi_itmlst.retadr = &return_length;
+
+ status = SYS$GETDVIW (0, 0, &sys_input, &getdvi_itmlst, 0, 0, 0, 0);
+ $CheckStatus(status);
+
+
+ /* If we have a terminal device, enable control-c and control-y */
+ if (dvi_characteristics & DEV$M_TRM)
+ {
+ /* Assign a channel to the communication device. */
+ status = SYS$ASSIGN ( &sys_input, /* Device name */
+ &comm_chan, /* Channel returned */
+ 0, 0 );
+ $CheckStatus(status);
+
+ status = XEEnableCtrlC(rtn);
+ $CheckStatus(status);
+
+ status = XEEnableCtrlY(rtn);
+ $CheckStatus(status);
+ }
+ return (SS$_NORMAL);
+
+#endif /* vms */
+}
+
+
+int XEClearCtrlKeys(void)
+{
+#ifndef vms
+ signal(SIGINT, SIG_DFL); /* CTRL-C */
+ return(1L);
+#else /* vms */
+ int status;
+
+ if (dvi_characteristics & DEV$M_TRM)
+ {
+ status = SYS$DASSGN(comm_chan);
+ $CheckStatus(status);
+ }
+ return (SS$_NORMAL);
+#endif /* vms */
+}
+
+int XEEnableCtrlC(void (*rtn)(int))
+{
+#ifndef vms
+ signal(SIGINT, rtn); /* CTRL-C */
+ return(1);
+#else
+ int status;
+
+ status = SYS$QIOW ( 0, /* Now set the characteristics */
+ comm_chan, /* Channel */
+ IO$_SETMODE|IO$M_CTRLCAST, /* Set ctrl_c */
+ comm_iosb, /* iosb address */
+ 0, 0, /* */
+ rtn, 0, /* AST routine and param */
+ CTRL_USER_MODE, 0, 0, 0 );
+ $CheckStatus(status);
+
+ return (SS$_NORMAL);
+#endif /* vms */
+}
+
+
+int XEEnableCtrlY(void (*rtn)(int))
+{
+#ifndef vms
+ signal(SIGQUIT,rtn); /* CTRL-backslash */
+ return(1);
+#else /* vms */
+ int status;
+
+ status = SYS$QIOW ( 0, /* Set characteristics */
+ comm_chan, /* Channel */
+ IO$_SETMODE|IO$M_CTRLYAST, /* Set ctrl_y */
+ comm_iosb, /* iosb address */
+ 0, 0, /* */
+ rtn, 0, /* AST routine and param */
+ CTRL_USER_MODE, 0, 0, 0 );
+ $CheckStatus(status);
+
+ return (SS$_NORMAL);
+#endif /* vms */
+}
+
+
+int XEDeclExitHndlr(void (*rtn)(int))
+{
+#ifndef vms
+ return(1); /* no real way for U*IX to do this */
+#else /* vms */
+ int status;
+
+ /*
+ * The Exit handler routine must accept one argument.
+ * This argument will be the condition that signaled the
+ * the exit handler.
+ */
+ exit_block.exit_routine = rtn;
+ exit_block.arg_cnt = 1; /* The condition code is the first argument */
+ exit_block.cond_value = &vms_condition; /* Address of condition value written by VMS */
+
+ status = SYS$DCLEXH (&exit_block); /* Set up the condition handler */
+ $CheckStatus(status);
+
+ return (SS$_NORMAL);
+#endif /* vms */
+}
diff --git a/XEKeybCtrl.h b/XEKeybCtrl.h
new file mode 100644
index 0000000..d0362c4
--- /dev/null
+++ b/XEKeybCtrl.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/programs/xtrap/XEKeybCtrl.h,v 1.1 2001/11/02 23:29:34 dawes Exp $ */
+
+extern int XEEnableCtrlKeys(void(*rtn)(int));
+extern int XEEnableCtrlC(void (*rtn)(int));
+extern int XEEnableCtrlY(void (*rtn)(int));
+extern int XEClearCtrlKeys(void);
+extern int XEDeclExitHndlr(void (*rtn)(int));
+
diff --git a/chparse.c b/chparse.c
new file mode 100644
index 0000000..3375f8c
--- /dev/null
+++ b/chparse.c
@@ -0,0 +1,408 @@
+/* $XFree86: xc/programs/xtrap/chparse.c,v 1.3 2002/09/18 17:11:57 tsi Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+**++
+** FACILITY: chparse - ASCII ESC & CSI parser
+**
+** MODULE DESCRIPTION:
+**
+** This module accepts single character I/O from
+** stdin and returns a parsed character or sequence
+** of characters. This is to be used in conjunction
+** with passing data from dragon-speak to XTrap.
+**
+** AUTHORS:
+**
+** Roy Lomicka (revised by Martin Minow & later Kenneth B. Miller)
+**
+** CREATION DATE: March 26, 1991
+**
+** DESIGN ISSUES:
+**
+** The algorithm is rather obscure. However, it was decided
+** that it should be left in its original condition since it
+** closely depicts the state transition diagram for ASCII
+** sequences (about the only good thing goto's are for;) .
+** The old-fashioned bracketing and tabbing schemed were
+** also preserved for posterity.
+**
+**--
+*/
+
+#include <stdio.h>
+#include <ctype.h>
+#ifdef vms
+#include <ssdef.h>
+#include <stsdef.h>
+#include <iodef.h>
+#include <descrip.h>
+#else
+#include <sys/types.h>
+#include <sys/time.h>
+#endif
+#include <string.h>
+#include <unistd.h>
+#include "chparse.h"
+
+#ifdef __QNX__
+#include <sys/select.h>
+#endif
+
+#ifndef VERBOSE
+#define VERBOSE 0
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+#define EOS '\0'
+#define ERROR (-1)
+#define TIMEOUT (-2)
+#define NPARAM 8
+#define NINTER 8
+#define BUFFLEN 10 /* Size of typeahead buffer */
+#ifndef EXIT_SUCCESS
+#ifdef vms
+#define EXIT_SUCCESS (SS$_NORMAL | STS$M_INHIB_MSG)
+#define EXIT_FAILURE (SS$_ABORT)
+#else
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+#endif
+#endif
+
+#define NUL 0x00
+#define CAN 0x18
+#define SUB 0x1A
+#define ESC 0x1B
+#define DEL 0x7F
+#define SS3 0x8f
+#define DCS 0x90
+#define CSI 0x9B
+#define ST 0x9C
+#define OSC 0x9D
+#define PM 0x9E
+#define APC 0x9F
+
+static int kbinr(int max_delay);
+
+/*
+ * Escape sequence parser, obscure but useful.
+ */
+int chparse(
+int max_delay,
+int rest_delay,
+int *state, /* Parser state (n.z. if incomplete) */
+int *private, /* Sequence private char, 'X' if error */
+int param[], /* numeric param, starting at param[1] */
+int *nparam, /* Number of parameters */
+int inter[], /* intermediate char, starting at [1] */
+int *ninter, /* Number of intermediates */
+int *final) /* Sequence terminator */
+{
+ int present[NPARAM]; /* TRUE if param[i] is not defaulted */
+ register int c;
+ register int i;
+
+ if (*state == 0)
+ *private = 0;
+label1: c = kbinr(max_delay);
+#if 0
+ printf("c %02x, *state %02x, *nparam %d\n", c, *state, *nparam);
+#endif
+ max_delay = rest_delay;
+label2: switch (c) {
+ case NUL:
+ case DEL:
+ goto label5;
+ case ESC:
+ case CSI:
+ case SS3:
+ case DCS:
+ case OSC:
+ case PM:
+ case APC:
+ *state = c;
+ *private = 0;
+ for (i = 0; i < NPARAM; i++)
+ param[i] = present[i] = 0;
+ for (i = 0; i < NINTER; i++)
+ inter[i] = EOS;
+ *nparam = *ninter = 0;
+ goto label1;
+ }
+ if (*state == 0)
+ goto label5;
+ if ((c >= 0x80 && c < 0xA0)
+ || c == TIMEOUT
+ || c == ERROR
+ || c == CAN
+ || c == SUB) {
+ *state = 0;
+ goto label5;
+ }
+ if (c < 0x20) /* Doesn't stop seq. */
+ goto label5;
+ if (c <= 0x2F) {
+ if (*ninter < 7)
+ inter[++*ninter] = c;
+ goto label1;
+ }
+ if (*state == ESC) {
+ if (*ninter == 0
+ && (c & 0x3F) < 0x20) {
+ c = (c & 0x3F) + 0x80;
+ goto label2;
+ }
+ goto label4;
+ }
+ if (c >= 0x40)
+ goto label3;
+ else if (c >= 0x3C) { /* Private introducer */
+ if (*nparam != 0)
+ *private = 'X';
+ else {
+ *private = c;
+ *nparam = 1;
+ }
+ goto label1;
+ }
+ if (*nparam == 0)
+ *nparam = 1;
+ if (*ninter != 0) {
+ *ninter = 0;
+ *private = 'X';
+ }
+ if (c == ';') {
+ if (*nparam >= (NPARAM - 1))
+ *private = 'X';
+ else {
+ ++*nparam;
+ }
+ goto label1;
+ }
+ if (c > '9') {
+ *private = 'X';
+ goto label1;
+ }
+ present[*nparam] = 1;
+ param[*nparam] = (param[*nparam] * 10) + (c - '0');
+ goto label1;
+label3: if (*nparam == 0)
+ *nparam = 1;
+label4: *final = c;
+ c = *state;
+ *state = 0;
+label5: return (c);
+}
+
+void dumpsequence(
+int state,
+int c,
+int private, /* Sequence private char, 'X' if error */
+int param[], /* numeric param, starting at param[1] */
+int nparam, /* Number of parameters */
+int inter[], /* intermediate char, starting at [1] */
+int ninter, /* Number of intermediates */
+int final, /* Sequence terminator */
+short *column) /* column display count */
+{
+ register int i;
+
+ if (isascii(c) && isprint(c)) {
+ *column +=2;
+ if (*column >= 79) {
+ printf("\n");
+ *column = 2;
+ }
+ printf("%c ", c);
+ }
+ else if (private == 'X') {
+ *column += strlen("bad sequence ");
+ if (*column >= 79) {
+ printf("\n");
+ *column = strlen("bad sequence ");
+ }
+ printf("bad sequence ");
+ }
+ else if (state != NUL) {
+ *column += 32;
+ if (*column >= 79) {
+ printf("\n");
+ *column = 32;
+ }
+ printf("incomplete sequence (type <%02x>) ", state);
+ }
+ else {
+ *column += 5; /* update total chars printed */
+ if (*column >= 79) {
+ printf("\n");
+ *column = 6;
+ }
+ switch (c) {
+ case ESC: printf("<ESC>"); break;
+ case DCS: printf("<DCS>"); break;
+ case CSI: printf("<CSI>"); break;
+ case SS3: printf("<SS3>"); break;
+ default: printf("<%02x>", c & 0xFF);
+ }
+ if (c == ESC || c == DCS || c == CSI || c == SS3) {
+ *column += 1 + nparam*2 + ninter + 1; /* total chars printed */
+ if (*column >= 79) {
+ printf("\n");
+ *column = 1 + nparam*2 + ninter + 1;
+ }
+ if (private != NUL && private != 'X')
+ printf("%c", private);
+ for (i = 1; i <= nparam; i++)
+ printf("%s%d", (i > 1) ? "," : " ", param[i]);
+ for (i = 1; i <= ninter; i++)
+ printf("%c", inter[i]);
+ printf("%c", final);
+ }
+ (*column)++;
+ if (*column >= 79) {
+ printf("\n");
+ *column = 1;
+ }
+ printf(" ");
+ }
+}
+
+#ifdef vms
+/*
+ * Read a character from the terminal (with selectable timeout)
+ */
+
+int
+kbinr(timeout)
+int timeout; /* In seconds, 0 == immediately */
+/*
+ * Get one byte without echoing, if available. Returns
+ * ERROR Something is dwrong
+ * TIMEOUT Nothing read within limit.
+ * Note:
+ * timeout = 0 return immediately if nothing is present
+ * timeout = 1 Indeterminate, do not use
+ * timeout = 2 Wait at least one second.
+ */
+{
+ register int incount;
+ static char buffer[BUFFLEN];
+ static char *bufptr = buffer;
+ static char *bufend = buffer;
+
+ if (bufptr >= bufend) {
+ bufptr = bufend = buffer;
+ incount = vmsread(buffer, BUFFLEN, 0);
+ if (incount == TIMEOUT)
+ incount = vmsread(buffer, 1, timeout);
+ if (incount <= 0)
+ return (incount);
+ bufend = &buffer[incount];
+ }
+ return (*bufptr++ & 0xFF);
+}
+
+static int tt_channel; /* Gets channel number */
+typedef struct {
+ short int status;
+ short int term_offset;
+ short int terminator;
+ short int term_size;
+} IOSTAB;
+
+int
+vmsread(buffer, size, timeout)
+char *buffer;
+int size;
+int timeout;
+{
+ register int status;
+ IOSTAB iostab;
+ static $DESCRIPTOR(tt_device, "SYS$COMMAND");
+ static long termset[2] = { 0, 0 }; /* No terminator */
+ static short opened = FALSE; /* TRUE when opened */
+
+ if (!opened) {
+ status = sys$assign(&tt_device, &tt_channel, 0, 0);
+ if (status != SS$_NORMAL)
+ lib$stop(status);
+ opened = TRUE;
+ }
+ status = sys$qiow(
+ 0, /* Event flag */
+ tt_channel, /* Input channel */
+ IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR | IO$M_TIMED,
+ /* Read, no echo, no translate */
+ &iostab, /* I/O status block */
+ NULL, /* AST block (none) */
+ 0, /* AST parameter */
+ buffer, /* P1 - input buffer */
+ size, /* P2 - buffer length */
+ timeout, /* P3 - timeout */
+ &termset, /* P4 - terminator set */
+ NULL, /* P5 - ignored (prompt buffer) */
+ 0 /* P6 - ignored (prompt size) */
+ );
+ if (status == SS$_TIMEOUT)
+ return (TIMEOUT);
+ else if (status != SS$_NORMAL)
+ return (ERROR);
+ else {
+ if ((status = iostab.term_offset + iostab.term_size) > 0)
+ return (status);
+ return (TIMEOUT);
+ }
+}
+#else
+static int
+kbinr(int max_delay)
+{
+ auto int fdmask;
+ struct timeval timeout;
+ int count;
+ static unsigned char buffer[80];
+ static unsigned char *bend;
+ static unsigned char *bptr;
+
+ if (bptr >= bend) {
+ fdmask = 1 << fileno(stdin);
+ timeout.tv_usec = 0;
+ timeout.tv_sec = max_delay;
+ count = select(fileno(stdin) + 1, (fd_set *)&fdmask, NULL, NULL, &timeout);
+ if (count < 0)
+ return (ERROR);
+ else if (count == 0)
+ return (TIMEOUT);
+ if (count >= sizeof buffer)
+ count = sizeof buffer;
+ count = read(fileno(stdin), buffer, count);
+ if (count <= 0)
+ return (ERROR);
+ bptr = buffer;
+ bend = buffer + count;
+ }
+ return (*bptr++);
+}
+#endif
diff --git a/chparse.h b/chparse.h
new file mode 100644
index 0000000..933846d
--- /dev/null
+++ b/chparse.h
@@ -0,0 +1,10 @@
+/* $XFree86: xc/programs/xtrap/chparse.h,v 1.1 2001/11/02 23:29:34 dawes Exp $ */
+
+extern int chparse(int max_delay, int rest_delay, int *state, int *private,
+ int param[], int *nparam, int inter[], int *ninter,
+ int *final);
+extern void dumpsequence(int state, int c, int private, int param[],
+ int nparam, int inter[], int ninter, int final,
+ short *column);
+
+
diff --git a/xtrap.man b/xtrap.man
new file mode 100644
index 0000000..de2f0c6
--- /dev/null
+++ b/xtrap.man
@@ -0,0 +1,216 @@
+.\" $XFree86: xc/programs/xtrap/xtrap.man,v 1.2 2001/11/03 18:51:04 dawes Exp $
+.TH xtrap 1
+.SH NAME
+xtrapreset, xtrapinfo, xtrapstats, xtrapout, xtrapin, xtrapchar, xtrapproto
+- XTrap sample clients
+.SH SYNTAX
+.NXR "XTrap X Server Extension Sample Clients"
+.B xtrapreset
+[
+.B \-d[isplay]
+.I display
+]
+.\".ll -8
+.LP
+.B xtrapinfo
+[
+.B \-d[isplay]
+.I display
+]
+.\".ll -8
+.LP
+.B xtrapstats
+[
+.B \-d[isplay]
+.I display
+]
+.\".ll -8
+.LP
+.B xtrapout
+[
+.B \-f
+.I script
+] [
+.B \-e
+] [
+.B \-d[isplay]
+.I display
+] [
+.B \-v
+]
+.\".ll -8
+.LP
+.B xtrapin
+[
+.B \-f
+.I script
+] [
+.B \-d[isplay]
+.I display
+]
+.\".ll -8
+.LP
+.B xtrapchar
+[
+.B \-v
+] [
+.B \-d[isplay]
+.I display
+]
+.LP
+.B xtrapproto
+[
+.B \-d[isplay]
+.I display
+]
+.SH DESCRIPTION
+.LP
+These commands are
+.B "SAMPLE CLIENTS"
+provided with the XTrap X Server Extension
+Sources, Version 3.3.
+XTrap is an X Server
+extension which facilitates the capturing of server protocol and synthesizing
+core input events.
+Information on how to obtain these sources can be
+found in the SOURCES section below.
+.LP
+The
+.B xtrapreset
+command
+is the simplest XTrap client in that it merely performs an XQueryExtension()
+against XTrap. The name "reset" is historical. The
+.I display
+argument is parsed by the X Toolkit and specifies the display where XTrap is
+to be loaded; see X(1).
+.LP
+.B xtrapinfo
+displays general configuration information as a result of an GetAvailable
+XTrap request to the specified server. It is simply designed to test the
+request/response mechanism of the XTrap extension and client library as
+well as display the configuration information that it finds.
+.LP
+.B xtrapstats
+tests the event and request vectoring of the server extension by configuring
+XTrap to collect usage statistics on all core input events and requests. It
+has a primitive command-line interface for showing the counters, zeroing
+out the counters, and quitting the program.
+.LP
+.B xtrapout
+tests the output transport from the XTrap extension to the XTrap client
+library.
+As an aside, since xtrapout has the capability of "recording" events and
+requests it receives,
+.B xtrapout
+is ideal for providing input to test
+.B xtrapin.
+Since events are the only concern for the input transport, the \-e flag can
+be specified to indicate that all input events (and only events) should be
+recorded by
+.B xtrapout.
+.I script
+is specified primarily for non-U*IX machines which don't support I/O
+re-direction easily.
+The \-v flag is used to force recording of all requests and input events.
+.LP
+.B xtrapin
+is used to test the input transport to the XTrap server extension. As stated
+earler, it's input can be provided by
+.B xtrapout
+using the \-e qualifer. While it's primary function is for testing XTrap
+and serving as an example for XTrap functionality, it can reasonably used as
+a primitive "playback" client for X sessions.
+.LP
+.B xtrapchar
+parses ANSI character sequences including application program sequences to
+synthesize input events to X Window servers using the XTrap server extension.
+The intent of this program is to serve as a sample implementation for
+interfacing character-based alternative input sources into X servers (e.g.
+voice recognition systems). Another application might be "remote keyboards".
+The -v flag causes the program to display XTrap configuration information
+and echo's characters processed to stdout. If present, this must be the
+first argument.
+.LP
+Note:
+.B xtrapchar
+has only been used with Digital Workstations using the
+LK201 compatible keyboard. Though reasonable effort was done to maintain
+portability, no claims are made as to the current level of portability to
+non-DEC servers for this program.
+.LP
+The
+.B xtrapproto
+command
+is a regression test designed to test the basic XTrap protocol between a
+client and server. If a given implementation is suspect, the results of
+this test should be sent to an XTrap implementor and/or developer.
+.SH OPTIONS
+.PP
+.TP 4
+.B "-d[isplay] \fIdisplay\fP"
+Specifies the server to record from or playback to; see
+.PN X(1).
+.PP
+.TP 4
+.B "-e"
+Record only (and all) events. Should be used when creating input for
+.PN xtrapin.
+.PP
+.TP 4
+.B "-f \fIscript\fP"
+The pathname of the script to be recorded / played back.
+.PP
+.TP 4
+.B "-v"
+Verbose mode.
+.LP
+.SH DIAGNOSTICS
+.LP
+.B "X Toolkit Error: Can't load DEC-XTRAP extension"
+.PP
+The XTrap X server extension has not been linked into the specified X
+server.
+.SH SOURCES
+.LP
+.EX
+Sources have been posted on UseNet systems via anonymous ftp.
+They are:
+East Coast (USA): export@lcs.mit.edu:contrib/XTrap_v32*.tar.Z
+West Coast (USA): gatekeeper@pa.dec.com:X11/contrib/XTrap_v32*.tar.Z
+
+.SH IMPORTANT NOTE
+.LP
+.EX
+Digital participated in the X Consortium's xtest working group which
+chose to evolve XTrap functionality into a new extension for X11/R6
+known as the RECORD extension (XTrap input synthesis functionality is
+currently covered by the XTEST extension). It is strongly suggested
+that users of XTrap technology begin developing against RECORD/XTEST
+as it is the intention of the X Consortium to drive these two extensions
+in the standards process for providing the protocol capturing/synthesis
+functionality. Some members of the xtest working group are actively
+researching migration issues between XTrap and RECORD. If you'd like
+to contribute, please participate! Contact your local X Consortium Rep
+for details on how to be added to the xtest mailing list.
+
+If you encounter problems, have questions, etc. with XTrap, please contact
+via mail, phone, etc. at:
+
+ Ken Miller
+ miller@zk3.dec.com
+ (VOICE) 603-881-6221
+ (FAX) 603 881-2257
+
+or paper mail at:
+
+ Digital Equipment Corp.
+ Ken Miller @ ZKO3-3/Y25
+ 110 Spitbrook Rd.
+ Nashua, NH 03062
+
+Naturally email is preferred and will get the fastest response.
+.EE
+.SH SEE ALSO
+X(1)
+.NXE "X"
+
diff --git a/xtrapchar.c b/xtrapchar.c
new file mode 100644
index 0000000..3f632d6
--- /dev/null
+++ b/xtrapchar.c
@@ -0,0 +1,733 @@
+/* $XFree86: xc/programs/xtrap/xtrapchar.c,v 1.3 2001/12/12 00:43:50 dawes Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapchar.c,v $
+ * Revision 1.1.2.2 1993/12/14 12:37:15 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:15:33 Kenneth_Miller]
+ *
+ * EndLog$
+ */
+#if !defined(lint) && 0
+static char *rcsid = "@(#)RCSfile: xtrapchar.c,v $ Revision: 1.1.2.2 $ (DEC) Date: 1993/12/14 12:37:15 $";
+#endif
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+#define ProgName "xtrapchar"
+/*
+**++
+** FACILITY: xtrapchar - Converts ANSI character sequences to X.
+**
+** MODULE DESCRIPTION:
+**
+** Parses ANSI character sequences including application program
+** sequences to synthesize input events to X Window servers
+** using the XTrap server extension. Additionally, this main
+** module is designed to be used with the voice
+** recognition systems which will allow voice input into X Servers.
+**
+** AUTHORS:
+**
+** Kenneth B. Miller
+**
+** CREATION DATE: March 23, 1991
+**
+** DESIGN ISSUES:
+**
+** Accepts non-buffered Ascii characters as input and
+** performs a table look-up to determine what the corresponding
+** X actions are to be performed.
+**
+** Uses chparse() which was contributed to DECUS C by Roy
+** Lomicka and later revised by Martin Minow and myself.
+** Also, getopt() is used to parse the command
+** line arguments prior to calling XtAppInitialize().
+** Currently only the -v argument is supported to indicate
+** echoing of characters received for debugging
+** purposes.
+**
+**
+** CAVEAT:
+**
+** This program has *only* been used with Digital Workstations
+** using the LK201 compatible keyboard. Though reasonable
+** effort was done to maintain portability, no claims are made
+** as to the current level of portability to non-DEC servers
+** for this program.
+**--
+*/
+#include <unistd.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#include <X11/keysym.h>
+
+#include "chparse.h"
+
+#ifndef vaxc
+#define globalref extern
+#endif
+ /* Special private indicators */
+#define BPRESS '!'
+#define BRELEASE '"'
+#define BCLICK '#'
+#define APRESS '$'
+#define ARELEASE '%'
+#define CPRESS '('
+#define CRELEASE ')'
+#define SPRESS '+'
+#define SRELEASE '-'
+#define DPRIVATE '='
+#define MNOTIFY '>'
+#define RMNOTIFY '?'
+
+#define NPARAM 8
+#define NINTER 8
+#define NUL 0x00
+#define CAN 0x18
+#define SUB 0x1A
+#define ESC 0x1B
+#define DEL 0x7F
+#define SS3 0x8f
+#define DCS 0x90
+#define CSI 0x9B
+#define ST 0x9C
+#define OSC 0x9D
+#define PM 0x9E
+#define APC 0x9F
+
+static BOOL verbose_flag = FALSE;
+static INT16 column = 0;
+static int state = NUL; /* Parser state (n.z. if incomplete) */
+static Window root;
+static BOOL passive_shift; /* Cap's assumed? */
+static BOOL passive_ctrl; /* Control key assumed? */
+static BOOL shift; /* Cap's on? */
+static BOOL ctrl; /* Control key? */
+static BOOL alt; /* Alt key? */
+KeyCode alt_code;
+KeyCode ctrl_code;
+KeyCode shift_code;
+
+
+
+#define _AdjustCol(length) \
+ if ((column += length) >= 79) \
+ { \
+ printf("\n"); \
+ column = length; \
+ }
+
+static void KeyClick(XETC *tc, KeyCode keycode)
+{
+ if (passive_ctrl && !ctrl)
+ {
+ XESimulateXEventRequest(tc, KeyPress, ctrl_code, 0, 0, 0);
+ }
+ if (passive_shift && !shift)
+ {
+ XESimulateXEventRequest(tc, KeyPress, shift_code, 0, 0, 0);
+ }
+ XESimulateXEventRequest(tc, KeyPress, keycode, 0, 0, 0);
+ XESimulateXEventRequest(tc, KeyRelease, keycode, 0, 0, 0);
+ if (passive_shift && !shift)
+ {
+ XESimulateXEventRequest(tc, KeyRelease, shift_code, 0, 0, 0);
+ }
+ if (passive_ctrl && !ctrl)
+ {
+ XESimulateXEventRequest(tc, KeyRelease, ctrl_code, 0, 0, 0);
+ }
+ passive_ctrl = passive_shift = FALSE; /* Action's been completed */
+}
+
+
+/*
+**
+** FORWARD DECLARATIONS
+**
+*/
+static int get_csi_key ( XETC *tc , int private , int param [],
+ int nparam , int inter [], int ninter , int final );
+static int get_ss3_key ( XETC *tc , int private , int param [],
+ int nparam , int inter [], int ninter , int final );
+static void send_special ( XETC *tc , int private , int param [],
+ int nparam , int inter [], int ninter , int final );
+static KeyCode get_typical_char ( XETC *tc , CARD32 keysym);
+static KeyCode get_keycode ( XETC *tc , KeySym keysym);
+
+
+int
+main(int argc, char *argv[])
+{
+ Widget appW;
+ Display *dpy;
+ XETrapGetCurRep ret_cur;
+ XETC *tc;
+ XtAppContext app;
+ char *tmp = NULL;
+ INT16 ch;
+ INT16 i;
+ KeyCode keycode;
+ /* ESC & CSI Parsing variables */
+ int max_delay = 3;
+ int rest_delay = 2;
+ int private; /* Sequence private char, 'X' if error */
+ int param[NPARAM]; /* numeric param, starting at param[1] */
+ int nparam; /* Number of parameters */
+ int inter[NINTER]; /* intermediate char, starting at [1] */
+ int ninter; /* Number of intermediates */
+ int final; /* Sequence terminator */
+ int *popterr;
+#ifndef vms
+ popterr = &opterr;
+#else
+ popterr = XEgetopterr();
+#endif
+ *popterr = 0; /* don't complain about -d for display */
+ while ((ch = getopt(argc, argv, "d:v")) != EOF)
+ {
+ switch(ch)
+ {
+ case 'v':
+ verbose_flag = TRUE;
+ break;
+ case 'd': /* -display, let's let the toolkit parse it */
+ break;
+ default:
+ break;
+ }
+ }
+ appW = XtAppInitialize(&app,"XTrap",(XrmOptionDescList)NULL,(Cardinal)0L,
+ (int *)&argc, (String *)argv, NULL,(ArgList)&tmp,
+ (Cardinal)0);
+
+ dpy = XtDisplay(appW);
+ if (verbose_flag)
+ {
+ printf("Display: %s \n", DisplayString(dpy));
+ }
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize XTrap extension\n", ProgName);
+ exit (1L);
+ }
+ root = RootWindow(dpy,DefaultScreen(dpy));
+ (void)XEStartTrapRequest(tc);
+ alt_code = XKeysymToKeycode(tc->dpy,XK_Alt_L);
+ ctrl_code = XKeysymToKeycode(tc->dpy,XK_Control_L);
+ shift_code = XKeysymToKeycode(tc->dpy,XK_Shift_L);
+
+
+
+ if (verbose_flag)
+ {
+ (void)XEGetCurrentRequest(tc,&ret_cur);
+ XEPrintCurrent(stderr,&ret_cur);
+ }
+
+ column = 0; /* if displaying char's, don't go beyond 80 columns */
+
+ while ((ch = chparse(max_delay, rest_delay, &state, &private, param,
+ &nparam, inter, &ninter, &final)) != -1)
+ {
+ if (ch == -2)
+ {
+ continue; /* timeout condition */
+ }
+ if ((!ferror(stdin)) && (!feof(stdin)) && (state == 0))
+ { /* we got something */
+ switch(ch)
+ {
+ case CSI: /* Control Sequence */
+ keycode = get_csi_key(tc, private, param, nparam, inter,
+ ninter, final);
+ if (keycode)
+ KeyClick(tc, keycode);
+ break;
+ case SS3: /* Keypad stuff */
+ keycode = get_ss3_key(tc, private, param, nparam, inter,
+ ninter, final);
+ if (keycode)
+ KeyClick(tc, keycode);
+ break;
+ case APC: /* Application Cmd (Button's, Press, Release) */
+ send_special(tc, private, param, nparam, inter, ninter,
+ final);
+ break;
+ case ESC: /* Escape Sequence */
+ /* send ESCAPE */
+ if (!(keycode = XKeysymToKeycode(tc->dpy,XK_Escape)))
+ { /* must be an LK201 keyboard */
+ BOOL orig_ctrl = ctrl;
+ /*
+ * the following is kind of strange. We need to
+ * have ctrl TRUE for get_typical_char() to
+ * report the verbose message correctly. We
+ * can't use passive_ctrl cause it resets it.
+ * Then, for KeyClick(), ctrl has to be FALSE
+ * and passive_ctrl has to be TRUE in order for
+ * us to get the desired <CTRL>[ to simulate
+ * an escape key. Once it's all done, we need
+ * to return ctrl to whatever it was and clear
+ * the passive_ctrl.
+ */
+ ctrl = TRUE; /* for get_typical_char */
+ keycode = get_typical_char(tc, (CARD32)'[');
+ ctrl = FALSE; /* for KeyClick */
+ passive_ctrl = TRUE; /* for KeyClick */
+ KeyClick(tc, keycode);
+ passive_ctrl = FALSE; /* to continue */
+ ctrl = orig_ctrl; /* to continue */
+ }
+ else
+ {
+ KeyClick(tc, keycode);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<ESC>"));
+ printf("<ESC>");
+ }
+ }
+ /* send private (if valid) */
+ if (private != NUL && private != 'X' &&
+ (keycode = get_typical_char(tc, (CARD32)private)))
+ KeyClick(tc, keycode);
+ /* send addt'l parameters, if any */
+ for (i = 1; i <= nparam; i++)
+ if ((keycode = get_typical_char(tc, (CARD32)param[i])))
+ KeyClick(tc, keycode);
+ /* send intermediate's, if any */
+ for (i = 1; i <= ninter; i++)
+ if ((keycode = get_typical_char(tc, (CARD32)inter[i])))
+ KeyClick(tc, keycode);
+ /* send final character */
+ if ((keycode = get_typical_char(tc, (CARD32)final)))
+ KeyClick(tc, keycode);
+ break;
+
+ case DCS: /* We don't deal with these */
+ case OSC:
+ case PM:
+ if (verbose_flag)
+ {
+ printf("Ignoring the following: ");
+ dumpsequence(state, ch, private, param, nparam,
+ inter, ninter, final, &column);
+ }
+ break;
+ default: /* typical character */
+ keycode = get_typical_char(tc, (CARD32)ch);
+ if (keycode)
+ KeyClick(tc, keycode);
+ break;
+ }
+ }
+ else
+ { /* error? */
+ if (ferror(stdin) || state != 0)
+ {
+ perror("Error occurred parsing input characters!\n");
+ }
+ break;
+ }
+ }
+ /* Clean things up */
+ XEFreeTC(tc);
+ (void)XCloseDisplay(dpy);
+
+ exit(0L);
+}
+
+static int get_csi_key(tc, private, param, nparam, inter, ninter, final)
+ XETC *tc;
+ int private;
+ int param[], nparam;
+ int inter[], ninter;
+ int final;
+{
+ KeySym keysym = 0;
+ switch(param[1])
+ {
+ case 0:
+ switch ((char )final)
+ {
+ case 'A': keysym = XK_Up; break;
+ case 'B': keysym = XK_Down; break;
+ case 'C': keysym = XK_Right; break;
+ case 'D': keysym = XK_Left; break;
+ default:
+ dumpsequence(state, CSI, private, param, nparam,
+ inter, ninter, final, &column);
+ break;
+ }
+ break;
+ case 1: keysym = XK_Find; break;
+ case 2: keysym = XK_Insert; break;
+#ifdef DXK_Remove
+ case 3: keysym = DXK_Remove; break;
+#endif
+ case 4: keysym = XK_Select; break;
+ case 5: keysym = XK_Prior; break;
+ case 6: keysym = XK_Next; break;
+ case 17: keysym = XK_F6; break;
+ case 18: keysym = XK_F7; break;
+ case 19: keysym = XK_F8; break;
+ case 20: keysym = XK_F9; break;
+ case 21: keysym = XK_F10; break;
+ case 23: keysym = XK_F11; break;
+ case 24: keysym = XK_F12; break;
+ case 25: keysym = XK_F13; break;
+ case 26: keysym = XK_F14; break;
+ case 28: keysym = XK_Help; break;
+ case 29: keysym = XK_Menu; break;
+ case 31: keysym = XK_F17; break;
+ case 32: keysym = XK_F18; break;
+ case 33: keysym = XK_F19; break;
+ case 34: keysym = XK_F20; break;
+ default:
+ dumpsequence(state, CSI, private, param, nparam,
+ inter, ninter, final, &column);
+ }
+
+ return(get_keycode(tc, keysym));
+}
+
+ /*
+ * XTrap special sequences:
+ * ButtonPress: <APC>=!X (where 'X' is 'A', 'B', or 'C'
+ * for MB1, MB2, MB3 respectively)
+ * ButtonRelease: <APC>="X (where 'X' is 'A', 'B', or 'C'
+ * for MB1, MB2, MB3 respectively)
+ * ButtonClick: <APC>=#X (where 'X' is 'A', 'B', or 'C'
+ * for MB1, MB2, MB3 respectively)
+ * AltPress: <APC>=$~
+ * AltRelease: <APC>=%~
+ * CtrlPress: <APC>=(~
+ * CtrlRelease: <APC>=)~
+ * ShiftPress: <APC>=+~
+ * ShiftRelease: <APC>=-~
+ * MotionNotify: <APC>>;X;Y~ (where 'X' is the X coord and 'Y'
+ * is the Y coord of the desired
+ * pointer position)
+ * Relative MotionNotify:
+ * <APC>?;X;Y~ (where 'X' is the X coord and 'Y'
+ * is the Y coord of the desired
+ * pointer position)
+ *
+ */
+static void send_special(tc, private, param, nparam, inter, ninter, final)
+ XETC *tc;
+ int private;
+ int param[], nparam;
+ int inter[], ninter;
+ int final;
+{
+ switch(private)
+ {
+ case DPRIVATE: /* default APC */
+ if (ninter != 1)
+ { /* Not my sequence */
+ dumpsequence(state, APC, private, param, nparam,
+ inter, ninter, final, &column);
+ return;
+ }
+ else
+ {
+ switch(inter[1])
+ {
+ Window rid, wid;
+ int x, y, wx, wy;
+ unsigned int sm;
+ CARD8 detail;
+
+ case BPRESS:
+ detail = (final - 'A' + 1);
+ if ((Bool)XQueryPointer(tc->dpy,root,&rid,&wid,&x,
+ &y,&wx,&wy,&sm) == False)
+ {
+ fprintf(stderr, "\nPointer's not on screen 0!\n");
+ }
+ else
+ {
+ XESimulateXEventRequest(tc, ButtonPress, detail,
+ x, y, 0);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<MB%d-Press> ")-1);
+ printf("<MB%d-Press> ", detail);
+ }
+ }
+ break;
+ case BRELEASE:
+ detail = (final - 'A' + 1);
+ if ((Bool)XQueryPointer(tc->dpy,root,&rid,&wid,&x,
+ &y,&wx,&wy,&sm) == False)
+ {
+ fprintf(stderr, "\nPointer's not on screen 0!\n");
+ }
+ else
+ {
+ XESimulateXEventRequest(tc, ButtonRelease, detail,
+ x,y,0);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<MB%d-Release> ")-1);
+ printf("<MB%d-Release> ", detail);
+ }
+ }
+ break;
+ case BCLICK:
+ detail = (final - 'A' + 1);
+ if (XQueryPointer(tc->dpy,root,&rid,&wid,&x,&y,
+ &wx,&wy,&sm)
+ == False)
+ {
+ fprintf(stderr, "\nPointer's not on screen 0!\n");
+ }
+ else
+ {
+ XESimulateXEventRequest(tc,ButtonPress,
+ detail,x,y,0);
+ XESimulateXEventRequest(tc,ButtonRelease,
+ detail,x,y,0);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<MB%d> ")-1);
+ printf("<MB%d> ", detail);
+ }
+ }
+ break;
+ case APRESS:
+ alt = TRUE;
+ XESimulateXEventRequest(tc,KeyPress,alt_code,0,0,0);
+ break;
+ case ARELEASE:
+ alt = FALSE;
+ XESimulateXEventRequest(tc,KeyRelease,alt_code,0,0,0);
+ break;
+ case SPRESS:
+ shift = TRUE;
+ XESimulateXEventRequest(tc,KeyPress,shift_code,0,0,0);
+ break;
+ case SRELEASE:
+ shift = FALSE;
+ XESimulateXEventRequest(tc,KeyRelease,shift_code,
+ 0,0,0);
+ break;
+ case CPRESS:
+ ctrl = TRUE;
+ XESimulateXEventRequest(tc,KeyPress,ctrl_code,0,0,0);
+ break;
+ case CRELEASE:
+ ctrl = FALSE;
+ XESimulateXEventRequest(tc,KeyRelease,ctrl_code,0,0,0);
+ break;
+ default:
+ fprintf(stderr, "\nInvalid Sequence!\n");
+ dumpsequence(state, APC, private, param, nparam,
+ inter, ninter, final, &column);
+ }
+ }
+ break;
+ case MNOTIFY:
+ if (nparam != 3)
+ { /* Not my sequence */
+ dumpsequence(state, APC, private, param, nparam,
+ inter, ninter, final, &column);
+ return;
+ }
+ else
+ {
+ int x, y;
+
+ x = param[2];
+ y = param[3];
+ XESimulateXEventRequest(tc,MotionNotify,0,x,y,0);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<M %d,%d> ")+3);
+ printf("<M %d,%d> ",x,y);
+ }
+ }
+ break;
+ case RMNOTIFY:
+ if (nparam != 3)
+ { /* Not my sequence */
+ dumpsequence(state, APC, private, param, nparam,
+ inter, ninter, final, &column);
+ return;
+ }
+ else
+ {
+ Window rid, wid;
+ int x, y, wx, wy;
+ unsigned int sm;
+
+ if (XQueryPointer(tc->dpy,root,&rid,&wid,&x,&y,&wx,&wy,&sm)
+ == False)
+ {
+ fprintf(stderr, "\nPointer's not on screen 0!\n");
+ }
+ else
+ { /* We're ready to go */
+ x += param[2];
+ y += param[3];
+ XESimulateXEventRequest(tc,MotionNotify,0,x,y,0);
+ if (verbose_flag)
+ {
+ _AdjustCol(strlen("<RM ddd+sddd,dddd+sdddd> "));
+ printf("<RM %d+%d,%d+%d> ",x-param[2],param[3],
+ y-param[3],param[3]);
+ }
+ }
+ break;
+ default:
+ dumpsequence(state, APC, private, param, nparam,
+ inter, ninter, final, &column);
+ break;
+ }
+ }
+}
+
+static int get_ss3_key(tc, private, param, nparam, inter, ninter, final)
+ XETC *tc;
+ int private;
+ int param[], nparam;
+ int inter[], ninter;
+ int final;
+{
+ KeySym keysym = 0;
+ switch(param[1])
+ {
+ case 0:
+ switch ((char )final)
+ {
+ case 'A': keysym = XK_Up; break;
+ case 'B': keysym = XK_Down; break;
+ case 'C': keysym = XK_Right; break;
+ case 'D': keysym = XK_Left; break;
+ case 'p': keysym = XK_KP_0; break;
+ case 'q': keysym = XK_KP_1; break;
+ case 'r': keysym = XK_KP_2; break;
+ case 's': keysym = XK_KP_3; break;
+ case 't': keysym = XK_KP_4; break;
+ case 'u': keysym = XK_KP_5; break;
+ case 'v': keysym = XK_KP_6; break;
+ case 'w': keysym = XK_KP_7; break;
+ case 'x': keysym = XK_KP_8; break;
+ case 'y': keysym = XK_KP_9; break;
+ case 'm': keysym = XK_KP_Subtract; break;
+ case 'l': keysym = XK_KP_Separator; break;
+ case 'n': keysym = XK_KP_Decimal; break;
+ case 'M': keysym = XK_KP_Enter; break;
+ case 'P': keysym = XK_KP_F1; break;
+ case 'Q': keysym = XK_KP_F2; break;
+ case 'R': keysym = XK_KP_F3; break;
+ case 'S': keysym = XK_KP_F4; break;
+ default:
+ dumpsequence(state, SS3, private, param, nparam,
+ inter, ninter, final, &column);
+ break;
+ }
+ break;
+ }
+
+ return(get_keycode(tc, keysym));
+}
+
+static KeyCode get_typical_char(tc, keysym)
+ XETC *tc;
+ CARD32 keysym;
+{
+ if (iscntrl(keysym))
+ {
+ switch(keysym)
+ {
+ case 0x09: keysym = XK_Tab; break;
+ case 0x0d: keysym = XK_Return; break;
+ case 0x7f: keysym = XK_Delete; break;
+ case ESC: keysym = XK_Escape; break;
+ }
+ }
+ passive_shift = (keysym >= XK_A && keysym <= XK_Z) ? TRUE : FALSE;
+ switch(keysym)
+ { /* Special case shift's */
+ case '!': case '"': case '@': case '#': case '$':
+ case '%': case '^': case '&': case '*': case '(':
+ case ')': case '_': case '+': case '{': case '}':
+ case '|': case ':': case '>': case '?': case '~':
+ passive_shift = TRUE;
+ }
+
+ if (keysym >= 1 && keysym <= 26)
+ {
+ passive_ctrl = TRUE;
+ keysym += 'a' - 1;
+ }
+ else
+ {
+ passive_ctrl = FALSE;
+ }
+
+ return(get_keycode(tc, keysym));
+}
+
+static KeyCode get_keycode(XETC *tc, KeySym keysym)
+{
+ char *keystr = (char *)XKeysymToString(keysym);
+ KeyCode keycode;
+
+ keystr = (keystr == NULL) ? "unknown" : keystr;
+ if (verbose_flag)
+ {
+ if (shift || passive_shift)
+ {
+ _AdjustCol(strlen("<SHIFT>"));
+ printf("<SHIFT>");
+ }
+ if (alt)
+ {
+ _AdjustCol(strlen("<ALT>"));
+ printf("<ALT>");
+ }
+ if (ctrl || passive_ctrl)
+ {
+ _AdjustCol(strlen("<CTRL>"));
+ printf("<CTRL>");
+ }
+ _AdjustCol(strlen(keystr)+1);
+ printf("%s ", keystr);
+ }
+ if (!(keycode = XKeysymToKeycode(tc->dpy,keysym)))
+ {
+ fprintf(stderr,"\n[%s ('%%0x%04x') returns bad Keycode, ignored]\n",
+ keystr, (unsigned int)keysym);
+ column = 0;
+ }
+
+ return(keycode);
+}
diff --git a/xtrapin.c b/xtrapin.c
new file mode 100644
index 0000000..4b826c2
--- /dev/null
+++ b/xtrapin.c
@@ -0,0 +1,272 @@
+/* $XFree86: xc/programs/xtrap/xtrapin.c,v 1.2 2001/12/12 00:43:50 dawes Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapin.c,v $
+ * Revision 1.1.4.2 1993/12/14 12:37:20 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:15:45 Kenneth_Miller]
+ *
+ * Revision 1.1.2.2 1992/04/27 13:51:39 Leela_Obilichetti
+ * Initial load of xtrap clients - from silver BL6
+ * [92/04/27 13:49:16 Leela_Obilichetti]
+ *
+ * EndLog$
+ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#define ProgName "xtrapin"
+/*
+**++
+** FACILITY: xtrapin - Sample client to test input to XTrap extension
+**
+** MODULE DESCRIPTION:
+**
+** This is the main module for a sample/test client
+** for the XTrap X11 Server Extension. It accepts
+** a script file and a transport method as input
+** in addition to the standard X arguments (-d, etc.).
+** If no script file is provided, stdin is the default
+** and can be piped from the companion "xtrapout"
+** client (normally used with the -e argument which
+** sends all core input events to stdout).
+**
+**
+** AUTHORS:
+**
+** Kenneth B. Miller
+**
+** CREATION DATE: December 15, 1990
+**
+** DESIGN ISSUES:
+**
+** See the companion "xtrapout" client.
+**
+** Also, getopt() is used to parse the command
+** line arguments prior to calling XtAppInitialize().
+** This is because DECwindows appears to remove the user-
+** defined arguments from the argv[] vector without actually
+** acting upon them.
+**
+**
+**--
+*/
+#include <stdio.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#ifndef vaxc
+#define globalref extern
+#endif
+
+static Boolean grabFlag = False;
+
+FILE *ifp;
+XrmOptionDescRec optionTable [] =
+{
+ {"-f", "*script", XrmoptionSepArg, (caddr_t) NULL},
+ {"-g", "*grabServer",XrmoptionSkipArg, (caddr_t) NULL},
+};
+
+typedef struct
+{ /* longword-align fields for arg passing */
+ Time ts;
+ int type;
+ int detail;
+ int x;
+ int y;
+ int screen; /* this will always be 0 till vectored events! */
+} file_rec;
+
+/* Forward declarations */
+static Bool found_input_rec (FILE *ifp , file_rec *rec );
+
+static Widget appW;
+static Display *dpy;
+
+
+int
+main(int argc, char *argv[])
+{
+ XETrapGetAvailRep ret_avail;
+ XETrapGetCurRep ret_cur;
+ XETC *tc;
+ XtAppContext app;
+ char *tmp = NULL;
+ INT16 ch;
+ file_rec rec;
+ Time last_time = 0L;
+ int *popterr;
+ char **poptarg;
+#ifndef vms
+ popterr = &opterr;
+ poptarg = &optarg;
+#else
+ popterr = XEgetopterr();
+ poptarg = XEgetoptarg();
+#endif
+
+ ifp = NULL;
+ *popterr = 0; /* don't complain about -d for display */
+ grabFlag = False;
+ while ((ch = getopt(argc, argv, "d:f:g")) != EOF)
+ {
+ switch(ch)
+ {
+ case 'f':
+ if ((ifp = fopen(*poptarg,"rb")) == NULL)
+ { /* can't open it */
+ fprintf(stderr,"%s: could not open output file '%s'!\n",
+ ProgName, *poptarg);
+ }
+ break;
+ case 'd': /* -display, let's let the toolkit parse it */
+ break;
+ case 'g':
+ grabFlag = True;
+ default:
+ break;
+ }
+ }
+ ifp = (ifp ? ifp : stdin);
+
+ appW = XtAppInitialize(&app,"XTrap",optionTable,(Cardinal)1L,
+ (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
+ (Cardinal)NULL);
+
+ dpy = XtDisplay(appW);
+#ifdef DEBUG
+ XSynchronize(dpy, True);
+#endif
+ printf("Display: %s \n", DisplayString(dpy));
+
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize XTrap extension\n", ProgName);
+ exit (1L);
+ }
+ (void)XEGetAvailableRequest(tc,&ret_avail);
+ XEPrintAvail(stderr,&ret_avail);
+ XEPrintTkFlags(stderr,tc);
+
+ if (grabFlag == True)
+ { /*
+ * In order to ignore GrabServer's we must configure at least one
+ * trap. Let's make it X_GrabServer. We don't have to receive
+ * a callback, though.
+ */
+ ReqFlags requests;
+ (void)memset(requests,0L,sizeof(requests));
+ BitTrue(requests, X_GrabServer);
+ XETrapSetRequests(tc, True, requests);
+ (void)XETrapSetGrabServer(tc, True);
+ }
+
+ (void)XEStartTrapRequest(tc);
+ (void)XEGetCurrentRequest(tc,&ret_cur);
+ XEPrintCurrent(stderr,&ret_cur);
+
+ /* Open up script file */
+ while (found_input_rec(ifp,&rec) == True)
+ {
+ /* if not pipe'd, delay time delta time recorded */
+ if (ifp != stdin)
+ {
+ register INT32 delta, t1, t2;
+ last_time = (last_time ? last_time : rec.ts); /* first rec */
+ rec.ts = (rec.ts ? rec.ts : last_time); /* dual monitor bug! */
+ t1 = rec.ts; t2 = last_time; /* move to signed variables */
+ delta = abs(t1 - t2); /* protect from clock roll-over */
+ msleep(delta);
+ last_time = rec.ts;
+ }
+ XESimulateXEventRequest(tc, rec.type, rec.detail, rec.x, rec.y,
+ rec.screen);
+ }
+
+ (void)XCloseDisplay(dpy);
+ exit(0L);
+}
+
+static Bool found_input_rec(FILE *ifp, file_rec *rec)
+{
+ int found = False;
+ char buff[BUFSIZ];
+ char junk[16L];
+ int match;
+ int tmp[8L];
+
+ while ((found != True) && (fgets(buff,BUFSIZ,ifp) != NULL))
+ {
+ if (!strncmp(buff, "Event:", strlen("Event:")))
+ { /* we want this record */
+ if ((match = sscanf(buff,
+ "Event: %s (%d):det=%d scr=%d (%d,%d) root=%d Msk=%d TS=%d\n",
+ junk, &(tmp[0L]), &(tmp[1L]), &(tmp[2L]), &(tmp[3L]),
+ &(tmp[4L]), &(tmp[5L]), &(tmp[6L]), &(tmp[7L]))) != 9L)
+ {
+ fprintf(stderr, "%s: Error parsing script input!\n\t'%s'\n",
+ ProgName, buff);
+ }
+ else
+ {
+ found = True;
+ /* Sun's have problems with "byte" fields passed to scanf */
+ rec->type = tmp[0L];
+ rec->detail = tmp[1L];
+ rec->screen = tmp[2L];
+ rec->x = tmp[3L];
+ rec->y = tmp[4L];
+ rec->ts = tmp[7L];
+ }
+ }
+ else if (!strncmp(buff, "Request:", strlen("Request:")))
+ { /* a valid thing to see */
+ continue;
+ }
+ else
+ { /* this stuff doesn't look like what we'd expect */
+ fprintf(stderr, "%s: Not a valid script record!\n\t'%s'\n",
+ ProgName, buff);
+ }
+ }
+
+ return(found);
+}
+
diff --git a/xtrapinfo.c b/xtrapinfo.c
new file mode 100644
index 0000000..0337e83
--- /dev/null
+++ b/xtrapinfo.c
@@ -0,0 +1,88 @@
+/* $XFree86: xc/programs/xtrap/xtrapinfo.c,v 1.2 2002/09/18 17:11:57 tsi Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapinfo.c,v $
+ * Revision 1.1.4.2 1993/12/14 12:37:24 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:15:55 Kenneth_Miller]
+ *
+ * Revision 1.1.2.2 1992/04/27 13:51:50 Leela_Obilichetti
+ * initial load of xtrap clients - from silver BL6 pool
+ * [92/04/27 13:49:24 Leela_Obilichetti]
+ *
+ * EndLog$
+ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+int
+main(int argc, char *argv[])
+{
+ static Widget appW;
+ XtAppContext app;
+ char *tmp = NULL;
+ XETrapGetAvailRep ret_avail;
+ XETC *tc;
+ Display *dpy;
+
+ /* Connect to Server */
+ appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
+ (int *)&argc, (String *)argv, (String *)NULL, (ArgList)&tmp,
+ (Cardinal)NULL);
+ dpy = XtDisplay(appW);
+#ifdef DEBUG
+ XSynchronize(dpy, True);
+#endif
+ printf("Display: %s \n", DisplayString(dpy));
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
+ exit(1L);
+ }
+
+ (void)XEGetAvailableRequest(tc,&ret_avail);
+ (void)XEPrintAvail(stdout,&ret_avail);
+
+ (void)XCloseDisplay(dpy);
+ exit(0L);
+}
diff --git a/xtrapout.c b/xtrapout.c
new file mode 100644
index 0000000..f784a99
--- /dev/null
+++ b/xtrapout.c
@@ -0,0 +1,287 @@
+/* $XFree86: xc/programs/xtrap/xtrapout.c,v 1.2 2001/12/12 00:43:50 dawes Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapout.c,v $
+ * Revision 1.1.4.2 1993/12/14 12:37:28 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:16:01 Kenneth_Miller]
+ *
+ * Revision 1.1.2.2 1992/04/27 13:51:57 Leela_Obilichetti
+ * initial load of xtrap clients - from silver BL6 pool
+ * [92/04/27 13:49:33 Leela_Obilichetti]
+ *
+ * EndLog$
+ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#define ProgName "xtrapout"
+/*
+**++
+** FACILITY: xtrapout - Sample client to test output from XTrap extension
+**
+** MODULE DESCRIPTION:
+**
+** This is the main module for a sample/test client
+** for the XTrap X11 Server Extension. It accepts
+** a script output file, a transport method,
+** and an "events mode" flag (-e) as input,
+** in addition to the standard X arguments (-d, etc.).
+** If no script file is provided, stdout is the default
+** and can be piped to the companion "xtrapin"
+** client (normally used with the -e argument which
+** sends all core input events to stdout).
+**
+**
+** AUTHORS:
+**
+** Kenneth B. Miller
+**
+** CREATION DATE: March 28, 1990
+**
+** DESIGN ISSUES:
+**
+** See the companion "xtrapin" client.
+**
+** Also, getopt() is used to parse the command
+** line arguments prior to calling XtAppInitialize().
+** This is because DECwindows appears to remove the user-
+** defined arguments from the argv[] vector without actually
+** acting upon them.
+**
+**
+**--
+*/
+
+#include <stdio.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#include <signal.h>
+#include <X11/keysym.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "XEKeybCtrl.h"
+
+#ifndef vaxc
+#define globalref extern
+#endif
+
+
+/* Forward declarations */
+static void SetGlobalDone (void );
+static void print_req_callback (XETC *tc , XETrapDatum *data ,
+ char *my_buf );
+static void print_evt_callback (XETC *tc , XETrapDatum *data ,
+ char *my_buf );
+
+
+FILE *ofp;
+Bool GlobalDone = False;
+XrmOptionDescRec optionTable [] =
+{
+ {"-f", "*script", XrmoptionSepArg, (caddr_t) NULL},
+ {"-e", "*eventFlag", XrmoptionSkipArg, (caddr_t) NULL},
+ {"-v", "*verbose", XrmoptionSkipArg, (caddr_t) NULL},
+};
+
+static void SetGlobalDone(void)
+{
+ GlobalDone = 1L;
+ fprintf(stderr,"Process Completed!\n");
+ return;
+}
+
+static void print_req_callback(XETC *tc, XETrapDatum *data, char *my_buf)
+{
+ char *req_type;
+ req_type = (data->u.req.reqType == XETrapGetExtOpcode(tc) ? "XTrap" :
+ XERequestIDToString(data->u.req.reqType,tc));
+ fprintf(ofp,"Request: %-19s (%d): length '%ld' client '%d' window=%ld\n",
+ req_type, data->u.req.reqType, (long)data->hdr.count, data->hdr.client,
+ (long)data->u.req.id);
+}
+
+static void print_evt_callback(XETC *tc, XETrapDatum *data, char *my_buf)
+{
+ static Time last_time = 0;
+ int delta;
+
+ delta = abs((int)last_time ? data->u.event.u.keyButtonPointer.time -
+ (int)last_time : (int)last_time);
+ last_time = data->u.event.u.keyButtonPointer.time;
+
+ /* The "screen" and "root" fields aren't valid until "event"
+ * vectoring becomes a reality. Currently, XTrap intercepts
+ * the core events prior to when fields other than rootX, rootY,
+ * type, detail, time, and state are filled in. This will be
+ * addressed in the next release of XTrap (3.2?).
+ */
+ fprintf(ofp,
+ "Event: %-15s (%d):det=%d scr=%d (%d,%d) root=%d Msk=%d TS=%d\n",
+ XEEventIDToString(data->u.event.u.u.type,tc), data->u.event.u.u.type,
+ data->u.event.u.u.detail, data->hdr.screen, /* Not really valid yet */
+ data->u.event.u.keyButtonPointer.rootX,
+ data->u.event.u.keyButtonPointer.rootY,
+ (int)data->u.event.u.keyButtonPointer.root, /* Not really valid yet */
+ (int)data->u.event.u.keyButtonPointer.state,
+ (int)delta);
+ fflush(ofp);
+}
+static Boolean eventFlag = False;
+static Boolean verboseFlag = False;
+static Widget appW;
+static Display *dpy;
+
+int
+main(int argc, char *argv[])
+{
+ XETrapGetAvailRep ret_avail;
+ XETrapGetCurRep ret_cur;
+ XETC *tc;
+ ReqFlags requests;
+ EventFlags events;
+ XtAppContext app;
+ char *tmp = NULL;
+ INT16 ch;
+ int *popterr;
+ char **poptarg;
+#ifndef vms
+ popterr = &opterr;
+ poptarg = &optarg;
+#else
+ popterr = XEgetopterr();
+ poptarg = XEgetoptarg();
+#endif
+
+ eventFlag = False;
+ ofp = NULL;
+ *popterr = 0; /* don't complain about -d (display) */
+ while ((ch = getopt(argc, argv, "d:evf:")) != EOF)
+ {
+ switch(ch)
+ {
+ case 'e':
+ eventFlag = True;
+ break;
+ case 'v':
+ verboseFlag = True;
+ break;
+ case 'f':
+ if ((ofp = fopen(*poptarg,"wb")) == NULL)
+ { /* can't open it */
+ fprintf(stderr,"%s: could not open output file '%s'!\n",
+ ProgName, *poptarg);
+ }
+ break;
+ case 'd': /* -display, let's let the toolkit parse it */
+ break;
+ default:
+ break;
+ }
+ }
+ ofp = (ofp ? ofp : stdout);
+
+ appW = XtAppInitialize(&app,"XTrap",optionTable,(Cardinal)2L,
+ (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
+ (Cardinal)NULL);
+
+ dpy = XtDisplay(appW);
+#ifdef DEBUG
+ XSynchronize(dpy, True);
+#endif
+ fprintf(stderr,"Display: %s \n", DisplayString(dpy));
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize XTrap extension\n",ProgName);
+ exit (1L);
+ }
+ XETrapSetTimestamps(tc,True, False);
+ (void)XEGetAvailableRequest(tc,&ret_avail);
+ XEPrintAvail(stderr,&ret_avail);
+ XEPrintTkFlags(stderr,tc);
+
+ /* Need to prime events/requests initially turning all off */
+ (void)memset(requests,0L,sizeof(requests));
+ (void)memset(events,0L,sizeof(events));
+ /* Now turn on the ones you really want */
+ (void)memset(events,0xFFL,XETrapMaxEvent);
+ if (eventFlag == False)
+ { /* doesn't want just events */
+ (void)memset(requests,0xFFL,XETrapMaxRequest);
+ /* Turn off XTrap Requests for multi-client regression tests & XLib */
+ BitFalse(requests, XETrapGetExtOpcode(tc));
+ /* Turn off noisy events */
+ BitFalse(events, MotionNotify);
+ }
+ if (verboseFlag == True)
+ { /* want's *all* requests/events */
+ (void)memset(requests,0xFFL,XETrapMaxRequest);
+ (void)memset(events,0xFFL,XETrapMaxEvent);
+ }
+ /* Tell the TC about it */
+ XETrapSetRequests(tc, True, requests);
+ XETrapSetEvents(tc, True, events);
+ XETrapSetMaxPacket(tc, True, XETrapMinPktSize); /* just get the minimum */
+
+ /* Set up callbacks for data */
+ XEAddRequestCBs(tc, requests, print_req_callback, NULL);
+ XEAddEventCBs(tc, events, print_evt_callback, NULL);
+
+ (void)XEStartTrapRequest(tc);
+ (void)XEGetCurrentRequest(tc,&ret_cur);
+ XEPrintCurrent(stderr,&ret_cur);
+
+ /* Add signal handlers so that we clean up properly */
+ _InitExceptionHandling((void_function)SetGlobalDone);
+ (void)XEEnableCtrlKeys((void_function)SetGlobalDone);
+
+ XETrapAppWhileLoop(app,tc,&GlobalDone);
+
+ /* Make sure <CTRL> key is released */
+ XESimulateXEventRequest(tc, KeyRelease,
+ XKeysymToKeycode(dpy, XK_Control_L), 0L, 0L, 0L);
+
+ /* close down everything nicely */
+ XEFreeTC(tc);
+ (void)XCloseDisplay(dpy);
+ (void)XEClearCtrlKeys();
+ _ClearExceptionHandling();
+ exit(0L);
+}
+
diff --git a/xtrapproto.c b/xtrapproto.c
new file mode 100644
index 0000000..192de78
--- /dev/null
+++ b/xtrapproto.c
@@ -0,0 +1,110 @@
+/* $XFree86: xc/programs/xtrap/xtrapproto.c,v 1.3 2002/09/18 17:11:57 tsi Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapproto.c,v $
+ * Revision 1.1.2.2 1993/12/14 12:37:32 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:16:08 Kenneth_Miller]
+ *
+ * EndLog$
+ */
+#if !defined(lint) && 0
+static char *rcsid = "@(#)RCSfile: xtrapproto.c,v $ Revision: 1.1.2.2 $ (DEC) Date: 1993/12/14 12:37:32 $";
+#endif
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ static Widget appW;
+ XtAppContext app;
+ char *tmp = NULL;
+ XETrapGetAvailRep ret_avail;
+ XETrapGetCurRep ret_cur;
+ XETrapGetStatsRep ret_stats;
+ XETrapGetVersRep ret_vers;
+ XETrapGetLastInpTimeRep ret_time;
+ XETC *tc;
+ Display *dpy;
+ Boolean status = True;
+
+ /* Connect to Server */
+ appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
+ (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
+ (Cardinal)NULL);
+ dpy = XtDisplay(appW);
+ printf("Display: %s \n", DisplayString(dpy));
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
+ exit(1L);
+ }
+ XSynchronize(dpy, True);
+ status = XEResetRequest(tc);
+ status = XEGetAvailableRequest(tc,&ret_avail);
+ XEPrintAvail(stdout,&ret_avail);
+ status = XEGetCurrentRequest(tc,&ret_cur);
+ XEPrintCurrent(stderr,&ret_cur);
+ XETrapSetStatistics(tc, True); /* trigger config and def stats */
+ status = XEFlushConfig(tc);
+ status = XEGetStatisticsRequest(tc, &ret_stats);
+ XEPrintStatistics(stdout, &ret_stats,tc);
+ status = XEStartTrapRequest(tc);
+ status = XESimulateXEventRequest(tc, MotionNotify, 0, 10L, 20L, 0L);
+ status = XEStopTrapRequest(tc);
+ if (tc->protocol == 31)
+ { /* didn't work in V3.1 */
+ printf("XEGetVersionRequest() & XEGetLastInpTimeRequest() are\n");
+ printf("broken using the V3.1 protocol!\n");
+ }
+ else
+ {
+ status = XEGetVersionRequest(tc,&ret_vers);
+ status = XEGetLastInpTimeRequest(tc, &ret_time);
+ }
+ XEFreeTC(tc);
+ (void)XCloseDisplay(dpy);
+ exit(0L);
+}
diff --git a/xtrapreset.c b/xtrapreset.c
new file mode 100644
index 0000000..1eda765
--- /dev/null
+++ b/xtrapreset.c
@@ -0,0 +1,85 @@
+/* $XFree86: xc/programs/xtrap/xtrapreset.c,v 1.2 2002/09/18 17:11:57 tsi Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapreset.c,v $
+ * Revision 1.1.4.2 1993/12/14 12:37:37 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:16:13 Kenneth_Miller]
+ *
+ * Revision 1.1.2.2 1992/04/27 13:52:06 Leela_Obilichetti
+ * initial load of xtrap clients - from silver BL6 pool
+ * [92/04/27 13:49:41 Leela_Obilichetti]
+ *
+ * EndLog$
+ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+int
+main(int argc, char *argv[])
+{
+ Widget appW;
+ XtAppContext app;
+ Display *dpy;
+ XETC *tc;
+ char *tmp = NULL;
+
+ /* Connect to Server */
+ appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
+ (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
+ (Cardinal)NULL);
+ dpy = XtDisplay(appW);
+#ifdef DEBUG
+ XSynchronize(dpy, True);
+#endif
+ printf("Resetting Display: %s \n", DisplayString(dpy));
+
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
+ exit (1L);
+ }
+ XEResetRequest(tc);
+ XCloseDisplay(dpy);
+ exit (0);
+}
diff --git a/xtrapstats.c b/xtrapstats.c
new file mode 100644
index 0000000..5dc0def
--- /dev/null
+++ b/xtrapstats.c
@@ -0,0 +1,134 @@
+/* $XFree86: xc/programs/xtrap/xtrapstats.c,v 1.2 2002/09/18 17:11:57 tsi Exp $ */
+/*
+ * @DEC_COPYRIGHT@
+ */
+/*
+ * HISTORY
+ * Log: xtrapstats.c,v $
+ * Revision 1.1.4.2 1993/12/14 12:37:41 Kenneth_Miller
+ * ANSI-standardize code and turn client build on
+ * [1993/12/09 20:16:19 Kenneth_Miller]
+ *
+ * Revision 1.1.2.2 1992/04/27 13:52:12 Leela_Obilichetti
+ * initial load of xtrap clients - from silver BL6 pool
+ * [92/04/27 13:49:48 Leela_Obilichetti]
+ *
+ * EndLog$
+ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp.,
+Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+#include <ctype.h>
+
+int
+main(int argc, char *argv[])
+{
+ XETrapGetAvailRep ret_avail;
+ XETrapGetStatsRep ret_stats;
+ Widget appW;
+ XtAppContext app;
+ char *tmp = NULL;
+ XETC *tc;
+ Display *dpy;
+ Bool done;
+ char buffer[10];
+ ReqFlags requests;
+ EventFlags events;
+ int i;
+
+ /* Connect to Server */
+ appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
+ (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
+ (Cardinal)NULL);
+ dpy = XtDisplay(appW);
+#ifdef DEBUG
+ XSynchronize(dpy, True);
+#endif
+ printf("Display: %s \n", DisplayString(dpy));
+ if ((tc = XECreateTC(dpy,0L, NULL)) == False)
+ {
+ fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
+ exit(1L);
+ }
+
+ (void)XEGetAvailableRequest(tc,&ret_avail);
+ if (BitIsFalse(ret_avail.valid, XETrapStatistics))
+ {
+ printf("\nStatistics not available from '%s'.\n",
+ DisplayString(dpy));
+ exit(1L);
+ }
+ XETrapSetStatistics(tc, True);
+ for (i=0; i<256L; i++)
+ {
+ BitTrue(requests, i);
+ }
+ XETrapSetRequests(tc, True, requests);
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ BitTrue(events, i);
+ }
+ XETrapSetEvents(tc, True, events);
+ done = False;
+ while(done == False)
+ {
+ fprintf(stderr,"Stats Command (Zero, Quit, [Show])? ");
+ fgets(buffer, sizeof(buffer), stdin);
+ switch(toupper(buffer[0]))
+ {
+ case '\n': /* Default command */
+ case 'S': /* Request fresh counters & display */
+ (void)XEGetStatisticsRequest(tc,&ret_stats);
+ (void)XEPrintStatistics(stdout,&ret_stats,tc);
+ break;
+ case 'Z': /* Zero out counters */
+ XETrapSetStatistics(tc, False);
+ break;
+ case 'Q':
+ done = True;
+ break;
+ default:
+ printf("Invalid command, reenter!\n");
+ break;
+ }
+ }
+ (void)XEFreeTC(tc);
+ (void)XCloseDisplay(dpy);
+ exit(0L);
+}