use a cell that actually exists
[arla.git] / rx / rx_dumptrace.c
blob4ec43ee9346ec17493c8200c284029a67d9fe50b
1 /*
2 ****************************************************************************
3 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
4 * *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, *
7 * provided that the above copyright notice appear in all copies and *
8 * that both that copyright notice and this permission notice appear in *
9 * supporting documentation, and that the name of IBM not be used in *
10 * advertising or publicity pertaining to distribution of the software *
11 * without specific, written prior permission. *
12 * *
13 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
14 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
15 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
16 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
17 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
18 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 ****************************************************************************
22 #define RXDEBUG 1 /* XXX fix abi */
24 #include "rx_locl.h"
26 RCSID("$Id$");
28 int
29 main(int argc, char **argv)
31 struct rx_trace ip;
32 int error = 0;
33 int fd;
35 setlinebuf(stdout);
36 argv++;
37 argc--;
38 while (argc && **argv == '-') {
39 if (strcmp(*argv, "-trace") == 0) {
40 strlcpy(rxi_tracename, *(++argv), sizeof(rxi_tracename));
41 argc--;
42 } else {
43 error++;
44 break;
46 argv++, argc--;
48 if (error || argc != 0) {
49 printf("usage: dumptrace [-trace pathname]");
50 exit(1);
52 fd = open(rxi_tracename, O_RDONLY);
53 if (fd < 0) {
54 perror("");
55 exit(errno);
57 while (read(fd, &ip, sizeof(struct rx_trace))) {
58 printf("%9u ", (unsigned)ip.now);
59 switch (ip.event) {
60 case RX_CALL_END:
61 putchar('E');
62 break;
63 case RX_CALL_START:
64 putchar('S');
65 break;
66 case RX_CALL_ARRIVAL:
67 putchar('A');
68 break;
69 case RX_TRACE_DROP:
70 putchar('D');
71 break;
72 default:
73 putchar('U');
74 break;
76 printf(" %3u %7u %7u %lx.%x\n",
77 (unsigned)ip.qlen,
78 (unsigned)ip.servicetime,
79 (unsigned)ip.waittime,
80 ip.cid,
81 ip.call);
83 return 0;