Annotation of embedaddon/mtr/display.c, revision 1.1.1.2
1.1 misho 1: /*
2: mtr -- a network diagnostic tool
3: Copyright (C) 1997,1998 Matt Kimball
4:
5: This program is free software; you can redistribute it and/or modify
6: it under the terms of the GNU General Public License version 2 as
7: published by the Free Software Foundation.
8:
9: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with this program; if not, write to the Free Software
16: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17: */
18:
1.1.1.2 ! misho 19: #include "config.h"
! 20:
1.1 misho 21: #include <stdio.h>
22: #include <stdlib.h>
23: #include <sys/types.h>
24:
25: #include "mtr.h"
26: #include "display.h"
27: #include "mtr-curses.h"
28: #include "mtr-gtk.h"
29: #include "report.h"
30: #include "select.h"
31: #include "raw.h"
32: #include "dns.h"
1.1.1.2 ! misho 33: #include "asn.h"
1.1 misho 34:
35: extern int DisplayMode;
36:
37: #ifdef NO_CURSES
38: #define mtr_curses_open()
39: #define mtr_curses_close()
40: #define mtr_curses_redraw()
41: #define mtr_curses_keyaction()
42: #define mtr_curses_clear()
43: #else
44: #include "mtr-curses.h"
45: #endif
46:
47: #ifdef NO_GTK
48: #define gtk_open()
49: #define gtk_close()
50: #define gtk_redraw()
51: #define gtk_keyaction() 0
52: #define gtk_loop() {fprintf (stderr, "No GTK support. Sorry.\n"); exit (1); }
53: #else
54: #include "mtr-gtk.h"
55: #endif
56:
57: #ifdef NO_SPLIT
58: #define split_open()
59: #define split_close()
60: #define split_redraw()
61: #define split_keyaction() 0
62: #else
63: #include "split.h"
64: #endif
65:
66: void display_detect(int *argc, char ***argv) {
67: DisplayMode = DisplayReport;
68:
69: #ifndef NO_CURSES
70: DisplayMode = DisplayCurses;
71: #endif
72:
73: #ifndef NO_GTK
74: if(gtk_detect(argc, argv)) {
75: DisplayMode = DisplayGTK;
76: }
77: #endif
78: }
79:
80:
81: void display_open(void)
82: {
83: switch(DisplayMode) {
84:
85: case DisplayReport:
86: report_open();
87: break;
88: case DisplayTXT:
89: txt_open();
90: break;
91: case DisplayXML:
92: xml_open();
93: break;
94: case DisplayCSV:
95: csv_open();
96: break;
97: case DisplayCurses:
98: mtr_curses_open();
1.1.1.2 ! misho 99: #ifdef IPINFO
1.1 misho 100: if (ipinfo_no >= 0)
101: asn_open();
102: #endif
103: break;
104: case DisplaySplit:
105: split_open();
106: break;
107: case DisplayGTK:
108: gtk_open();
109: break;
110: }
111: }
112:
113:
114: void display_close(time_t now)
115: {
116: switch(DisplayMode) {
117: case DisplayReport:
118: report_close();
119: break;
120: case DisplayTXT:
121: txt_close();
122: break;
123: case DisplayXML:
124: xml_close();
125: break;
126: case DisplayCSV:
127: csv_close(now);
128: break;
129: case DisplayCurses:
1.1.1.2 ! misho 130: #ifdef IPINFO
1.1 misho 131: if (ipinfo_no >= 0)
132: asn_close();
133: #endif
134: mtr_curses_close();
135: break;
136: case DisplaySplit:
137: split_close();
138: break;
139: case DisplayGTK:
140: gtk_close();
141: break;
142: }
143: }
144:
145:
146: void display_redraw(void)
147: {
148: switch(DisplayMode) {
149:
150: case DisplayCurses:
151: mtr_curses_redraw();
152: break;
153:
154: case DisplaySplit:
155: split_redraw();
156: break;
157:
158: case DisplayGTK:
159: gtk_redraw();
160: break;
161: }
162: }
163:
164:
165: int display_keyaction(void)
166: {
167: switch(DisplayMode) {
168: case DisplayCurses:
169: return mtr_curses_keyaction();
170:
171: case DisplaySplit:
172: return split_keyaction();
173:
174: case DisplayGTK:
175: return gtk_keyaction();
176: }
177: return 0;
178: }
179:
180:
181: void display_rawping(int host, int msec)
182: {
183: switch(DisplayMode) {
184: case DisplayReport:
185: case DisplayTXT:
186: case DisplayXML:
187: case DisplayCSV:
188: case DisplaySplit:
189: case DisplayCurses:
190: case DisplayGTK:
191: break;
192: case DisplayRaw:
193: raw_rawping (host, msec);
194: break;
195: }
196: }
197:
198:
199: void display_rawhost(int host, ip_t *ip_addr)
200: {
201: switch(DisplayMode) {
202: case DisplayReport:
203: case DisplayTXT:
204: case DisplayXML:
205: case DisplayCSV:
206: case DisplaySplit:
207: case DisplayCurses:
208: case DisplayGTK:
209: break;
210: case DisplayRaw:
211: raw_rawhost (host, ip_addr);
212: break;
213: }
214: }
215:
216:
217: void display_loop(void)
218: {
219: switch(DisplayMode) {
220: case DisplayReport:
221: case DisplayTXT:
222: case DisplayXML:
223: case DisplayCSV:
224: case DisplaySplit:
225: case DisplayCurses:
226: case DisplayRaw:
227: select_loop();
228: break;
229: case DisplayGTK:
230: gtk_loop();
231: break;
232: }
233: }
234:
235:
236: void display_clear(void)
237: {
238: switch(DisplayMode) {
239: case DisplayCurses:
240: mtr_curses_clear();
241: break;
242: case DisplayReport:
243: case DisplayTXT:
244: case DisplayXML:
245: case DisplayCSV:
246: case DisplaySplit:
247: case DisplayRaw:
248: break;
249:
250: case DisplayGTK:
251: break;
252: }
253: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>