2
mtr -- a network diagnostic tool
3
Copyright (C) 1997 Matt Kimball
5
split.c -- raw output (for inclusion in KDE Network Utilities or others
7
Copyright (C) 1998 Bertrand Leconte <B.Leconte@mail.dotcom.fr>
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29
#include <sys/types.h>
40
#include <sys/types.h>
43
/* Use the curses variant */
45
#if defined(HAVE_NCURSES_H)
47
#elif defined(HAVE_NCURSES_CURSES_H)
48
# include <ncurses/curses.h>
49
#elif defined(HAVE_CURSES_H)
52
# error No curses header file available
58
extern char *Hostname;
62
/* There is 256 hops max in the IP header (coded with a byte) */
63
#define MAX_LINE_COUNT 256
64
#define MAX_LINE_SIZE 256
66
char Lines[MAX_LINE_COUNT][MAX_LINE_SIZE];
73
void split_redraw(void)
79
char newLine[MAX_LINE_SIZE];
83
fprintf(stderr, "split_redraw()\n");
87
* If there is less lines than last time, we delete them
91
for (i=LineCount; i>max; i--) {
97
* For each line, we compute the new one and we compare it to the old one
99
for(at = 0; at < max; at++) {
102
if( addrcmp( (void *) addr, (void *) &unspec_addr, af ) != 0 ) {
103
name = dns_lookup(addr);
105
/* May be we should test name's length */
106
sprintf(newLine, "%s %d %d %d %d %d %d", name,
108
net_returned(at), net_xmit(at),
109
net_best(at) /1000, net_avg(at)/1000,
112
sprintf(newLine, "%s %d %d %d %d %d %d",
115
net_returned(at), net_xmit(at),
116
net_best(at) /1000, net_avg(at)/1000,
120
sprintf(newLine, "???");
123
if (strcmp(newLine, Lines[at]) == 0) {
124
/* The same, so do nothing */
126
printf("SAME LINE\n");
129
printf("%d %s\n", at+1, newLine);
131
strcpy(Lines[at], newLine);
132
if (LineCount < (at+1)) {
140
void split_open(void)
144
printf("split_open()\n");
147
for (i=0; i<MAX_LINE_COUNT; i++) {
148
strcpy(Lines[i], "???");
153
void split_close(void)
156
printf("split_close()\n");
161
int split_keyaction(void)
169
FD_SET (0, &readfds);
173
if (select (1, &readfds, NULL, NULL, &tv) > 0) {
182
printf("split_keyaction()\n");
184
if(tolower(c) == 'q')
188
if(tolower(c) == 'r')