xtrapproto.c revision 99435119
1/* $XFree86: xc/programs/xtrap/xtrapproto.c,v 1.3tsi Exp $ */
2/*
3 * @DEC_COPYRIGHT@
4 */
5/*
6 * HISTORY
7 * Log: xtrapproto.c,v $
8 * Revision 1.1.2.2  1993/12/14  12:37:32  Kenneth_Miller
9 * 	ANSI-standardize code and turn client build on
10 * 	[1993/12/09  20:16:08  Kenneth_Miller]
11 *
12 * EndLog$
13 */
14#if !defined(lint) && 0
15static char *rcsid = "@(#)RCSfile: xtrapproto.c,v $ Revision: 1.1.2.2 $ (DEC) Date: 1993/12/14 12:37:32 $";
16#endif
17/*****************************************************************************
18Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp.,
19Maynard, MA
20
21Permission to use, copy, modify, and distribute this software and its
22documentation for any purpose and without fee is hereby granted,
23provided that the above copyright notice appear in all copies and that
24both that copyright notice and this permission notice appear in
25supporting documentation, and that the name of Digital not be
26used in advertising or publicity pertaining to distribution of the
27software without specific, written prior permission.
28
29DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
30ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
31DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
32ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
33WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
34ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
35SOFTWARE.
36
37*****************************************************************************/
38/*
39 *
40 *  CONTRIBUTORS:
41 *
42 *      Dick Annicchiarico
43 *      Robert Chesler
44 *      Dan Coutu
45 *      Gene Durso
46 *      Marc Evans
47 *      Alan Jamison
48 *      Mark Henry
49 *      Ken Miller
50 *
51 */
52#include <stdio.h>
53#include <stdlib.h>
54#include <X11/extensions/xtraplib.h>
55#include <X11/extensions/xtraplibp.h>
56
57
58int
59main(int argc, char *argv[])
60{
61    static Widget appW;
62    XtAppContext app;
63    char *tmp = NULL;
64    XETrapGetAvailRep     ret_avail;
65    XETrapGetCurRep       ret_cur;
66    XETrapGetStatsRep     ret_stats;
67    XETrapGetVersRep      ret_vers;
68    XETrapGetLastInpTimeRep ret_time;
69    XETC    *tc;
70    Display *dpy;
71
72    /* Connect to Server */
73    appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
74        (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
75        0);
76    dpy = XtDisplay(appW);
77    printf("Display:  %s \n", DisplayString(dpy));
78    if ((tc = XECreateTC(dpy,0L, NULL)) == NULL)
79    {
80        fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
81        exit(1L);
82    }
83    XSynchronize(dpy, True);
84    XEResetRequest(tc);
85    XEGetAvailableRequest(tc,&ret_avail);
86    XEPrintAvail(stdout,&ret_avail);
87    XEGetCurrentRequest(tc,&ret_cur);
88    XEPrintCurrent(stderr,&ret_cur);
89    XETrapSetStatistics(tc, True);  /* trigger config and def stats */
90    XEFlushConfig(tc);
91    XEGetStatisticsRequest(tc, &ret_stats);
92    XEPrintStatistics(stdout, &ret_stats,tc);
93    XEStartTrapRequest(tc);
94    XESimulateXEventRequest(tc, MotionNotify, 0, 10L, 20L, 0L);
95    XEStopTrapRequest(tc);
96    if (tc->protocol == 31)
97    {   /* didn't work in V3.1 */
98        printf("XEGetVersionRequest() & XEGetLastInpTimeRequest() are\n");
99        printf("broken using the V3.1 protocol!\n");
100    }
101    else
102    {
103        XEGetVersionRequest(tc,&ret_vers);
104        XEGetLastInpTimeRequest(tc, &ret_time);
105    }
106    XEFreeTC(tc);
107    (void)XCloseDisplay(dpy);
108    exit(0L);
109}
110