~ubuntu-branches/ubuntu/karmic/x11-xserver-utils/karmic

« back to all changes in this revision

Viewing changes to xtrap/xtrapstats.c

  • Committer: Bazaar Package Importer
  • Author(s): Brice Goglin, Julien Cristau, Brice Goglin
  • Date: 2007-08-17 09:58:34 UTC
  • Revision ID: james.westby@ubuntu.com-20070817095834-ywge2nyzj1s3rqnd
Tags: 7.3+1
[ Julien Cristau ]
* iceauth 1.0.2.
  + removes blank line in the manpage (closes: #25285).
* xmodmap 1.0.3.
  + manpage updated to state that -pm is the default (closes: #236198)
* xgamma 1.0.2.
  + the manpage now explains how to print the gamma value more clearly
    (closes: #296021).
* xsetroot 1.0.2.
* xrdb 1.0.4.
  + fixes manpage typo (closes: #276286).
* Add upstream URL to debian/copyright, and update it from xgamma's COPYING
  file.

[ Brice Goglin ]
* Add menu entries for xrefresh and xvidtune.
* sessreg 1.0.3.
* xset 1.0.3.
* Add myself to Uploaders, and remove Branden with his permission.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/xtrap/xtrapstats.c,v 1.1tsi Exp $ */
 
2
/*
 
3
 * @DEC_COPYRIGHT@
 
4
 */
 
5
/*
 
6
 * HISTORY
 
7
 * Log: xtrapstats.c,v $
 
8
 * Revision 1.1.4.2  1993/12/14  12:37:41  Kenneth_Miller
 
9
 *      ANSI-standardize code and turn client build on
 
10
 *      [1993/12/09  20:16:19  Kenneth_Miller]
 
11
 *
 
12
 * Revision 1.1.2.2  1992/04/27  13:52:12  Leela_Obilichetti
 
13
 *      initial load of xtrap clients - from silver BL6 pool
 
14
 *      [92/04/27  13:49:48  Leela_Obilichetti]
 
15
 * 
 
16
 * EndLog$
 
17
 */
 
18
/*****************************************************************************
 
19
Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993 by Digital Equipment Corp., 
 
20
Maynard, MA
 
21
 
 
22
Permission to use, copy, modify, and distribute this software and its 
 
23
documentation for any purpose and without fee is hereby granted, 
 
24
provided that the above copyright notice appear in all copies and that
 
25
both that copyright notice and this permission notice appear in 
 
26
supporting documentation, and that the name of Digital not be
 
27
used in advertising or publicity pertaining to distribution of the
 
28
software without specific, written prior permission.  
 
29
 
 
30
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
31
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
32
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
33
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
34
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
35
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
36
SOFTWARE.
 
37
 
 
38
*****************************************************************************/
 
39
/*
 
40
 *
 
41
 *  CONTRIBUTORS:
 
42
 *
 
43
 *      Dick Annicchiarico
 
44
 *      Robert Chesler
 
45
 *      Dan Coutu
 
46
 *      Gene Durso
 
47
 *      Marc Evans
 
48
 *      Alan Jamison
 
49
 *      Mark Henry
 
50
 *      Ken Miller
 
51
 *
 
52
 */
 
53
#include <stdio.h>
 
54
#include <stdlib.h>
 
55
#include <X11/extensions/xtraplib.h>
 
56
#include <X11/extensions/xtraplibp.h>
 
57
#include <ctype.h>
 
58
 
 
59
int
 
60
main(int argc, char *argv[])
 
61
{
 
62
    XETrapGetAvailRep     ret_avail;
 
63
    XETrapGetStatsRep     ret_stats;
 
64
    Widget  appW;
 
65
    XtAppContext app;
 
66
    char *tmp = NULL;
 
67
    XETC    *tc;
 
68
    Display *dpy;
 
69
    Bool done;
 
70
    char    buffer[10];
 
71
    ReqFlags   requests;
 
72
    EventFlags events;
 
73
    int i;
 
74
 
 
75
    /* Connect to Server */
 
76
    appW = XtAppInitialize(&app,"XTrap",NULL,(Cardinal)0L,
 
77
        (int *)&argc, (String *)argv, (String *)NULL,(ArgList)&tmp,
 
78
        (Cardinal)NULL);
 
79
    dpy = XtDisplay(appW);
 
80
#ifdef DEBUG
 
81
    XSynchronize(dpy, True);
 
82
#endif
 
83
    printf("Display:  %s \n", DisplayString(dpy));
 
84
    if ((tc = XECreateTC(dpy,0L, NULL)) == False)
 
85
    {
 
86
        fprintf(stderr,"%s: could not initialize extension\n",argv[0]);
 
87
        exit(1L);
 
88
    }
 
89
 
 
90
    (void)XEGetAvailableRequest(tc,&ret_avail);
 
91
    if (BitIsFalse(ret_avail.valid, XETrapStatistics))
 
92
    {
 
93
        printf("\nStatistics not available from '%s'.\n",
 
94
            DisplayString(dpy));
 
95
        exit(1L);
 
96
    }
 
97
    XETrapSetStatistics(tc, True);
 
98
    for (i=0; i<256L; i++)
 
99
    {
 
100
        BitTrue(requests, i);
 
101
    }
 
102
    XETrapSetRequests(tc, True, requests);
 
103
    for (i=KeyPress; i<=MotionNotify; i++)
 
104
    {
 
105
        BitTrue(events, i);
 
106
    }
 
107
    XETrapSetEvents(tc, True, events);
 
108
    done = False;
 
109
    while(done == False)
 
110
    {
 
111
        fprintf(stderr,"Stats Command (Zero, Quit, [Show])? ");
 
112
        fgets(buffer, sizeof(buffer), stdin);
 
113
        switch(toupper(buffer[0]))
 
114
        {
 
115
            case '\n':  /* Default command */
 
116
            case 'S':   /* Request fresh counters & display */
 
117
                (void)XEGetStatisticsRequest(tc,&ret_stats);
 
118
                (void)XEPrintStatistics(stdout,&ret_stats,tc);
 
119
                break;
 
120
            case 'Z':  /* Zero out counters */
 
121
                XETrapSetStatistics(tc, False);
 
122
                break;
 
123
            case 'Q':
 
124
                done = True;
 
125
                break;
 
126
            default:
 
127
                printf("Invalid command, reenter!\n");
 
128
                break;
 
129
        }
 
130
    }
 
131
    (void)XEFreeTC(tc);
 
132
    (void)XCloseDisplay(dpy);
 
133
    exit(0L);
 
134
}