21 #include "addr_hash.h"
22 #include "serv_hash.h"
25 #include "sorted_list.h"
27 #include "screenfilter.h"
29 #define HOSTNAME_LENGTH 256
31 #define HISTORY_DIVISIONS 3
35 #define HELP_MESSAGE \
36 "Host display: General:\n"\
37 " n - toggle DNS host resolution P - pause display\n"\
38 " s - toggle show source host h - toggle this help display\n"\
39 " d - toggle show destination host b - toggle bar graph display\n"\
40 " t - cycle line display mode B - cycle bar graph average\n"\
41 " T - toggle cumulative line totals\n"\
42 "Port display: j/k - scroll display\n"\
43 " N - toggle service resolution f - edit filter code\n"\
44 " S - toggle show source port l - set screen filter\n"\
45 " D - toggle show destination port L - lin/log scales\n"\
46 " p - toggle port display ! - shell command\n"\
49 " 1/2/3 - sort by 1st/2nd/3rd column\n"\
50 " < - sort by source name\n"\
51 " > - sort by dest name\n"\
52 " o - freeze current order\n"\
54 "iftop, version " IFTOP_VERSION
57 /* 2, 10 and 40 seconds */
58 int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
60 #define UNIT_DIVISIONS 4
61 char* unit_bits[UNIT_DIVISIONS] = { "b", "kb", "Mb", "Gb"};
62 char* unit_bytes[UNIT_DIVISIONS] = { "B", "kB", "MB", "GB"};
64 typedef struct host_pair_line_tag {
66 double long total_recv;
67 double long total_sent;
68 double long recv[HISTORY_DIVISIONS];
69 double long sent[HISTORY_DIVISIONS];
73 extern hash_type* history;
74 extern int history_pos;
75 extern int history_len;
77 extern options_t options ;
81 hash_type* screen_hash;
82 hash_type* service_hash;
83 sorted_list_type screen_list;
84 host_pair_line totals;
85 int peaksent, peakrecv, peaktotal;
87 #define HELP_MSG_SIZE 80
89 int persistenthelp = 0;
91 char helpmsg[HELP_MSG_SIZE];
92 int dontshowdisplay = 0;
95 * Compare two screen lines based on bandwidth. Start comparing from the
98 int screen_line_bandwidth_compare(host_pair_line* aa, host_pair_line* bb, int start_div) {
100 switch(options.linedisplay) {
101 case OPTION_LINEDISPLAY_ONE_LINE_SENT:
102 for(i = start_div; i < HISTORY_DIVISIONS; i++) {
103 if(aa->sent[i] != bb->sent[i]) {
104 return(aa->sent[i] < bb->sent[i]);
108 case OPTION_LINEDISPLAY_ONE_LINE_RECV:
109 for(i = start_div; i < HISTORY_DIVISIONS; i++) {
110 if(aa->recv[i] != bb->recv[i]) {
111 return(aa->recv[i] < bb->recv[i]);
115 case OPTION_LINEDISPLAY_TWO_LINE:
116 case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
117 /* fallback to the combined sent+recv that also act as fallback for sent/recv */
120 for(i = start_div; i < HISTORY_DIVISIONS; i++) {
121 if(aa->recv[i] + aa->sent[i] != bb->recv[i] + bb->sent[i]) {
122 return(aa->recv[i] + aa->sent[i] < bb->recv[i] + bb->sent[i]);
129 * Compare two screen lines based on hostname / IP. Fall over to compare by
132 int screen_line_host_compare(void* a, void* b, host_pair_line* aa, host_pair_line* bb) {
133 char hosta[HOSTNAME_LENGTH], hostb[HOSTNAME_LENGTH];
136 /* This isn't overly efficient because we resolve again before
138 if (options.dnsresolution) {
139 resolve(aa->ap.af, a, hosta, HOSTNAME_LENGTH);
140 resolve(bb->ap.af, b, hostb, HOSTNAME_LENGTH);
143 inet_ntop(aa->ap.af, a, hosta, sizeof(hosta));
144 inet_ntop(bb->ap.af, b, hostb, sizeof(hostb));
147 r = strcmp(hosta, hostb);
150 return screen_line_bandwidth_compare(aa, bb, 2);
159 int screen_line_compare(void* a, void* b) {
160 host_pair_line* aa = (host_pair_line*)a;
161 host_pair_line* bb = (host_pair_line*)b;
162 if(options.sort == OPTION_SORT_DIV1) {
163 return screen_line_bandwidth_compare(aa, bb, 0);
165 else if(options.sort == OPTION_SORT_DIV2) {
166 return screen_line_bandwidth_compare(aa, bb, 1);
168 else if(options.sort == OPTION_SORT_DIV3) {
169 return screen_line_bandwidth_compare(aa, bb, 2);
171 else if(options.sort == OPTION_SORT_SRC) {
172 return screen_line_host_compare(&(aa->ap.src6), &(bb->ap.src6), aa, bb);
174 else if(options.sort == OPTION_SORT_DEST) {
175 return screen_line_host_compare(&(aa->ap.dst6), &(bb->ap.dst6), aa, bb);
181 void readable_size(float n, char* buf, int bsize, int ksize, int bytes) {
186 /* Convert to bits? */
192 if(n < size * 1000 || i >= UNIT_DIVISIONS - 1) {
193 snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
199 snprintf(buf, bsize, " %4.2f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
202 else if(n < size * 100) {
203 snprintf(buf, bsize, " %4.1f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
210 /* Barchart scales. */
214 { 64000, 10 }, /* 64 kbit/s */
217 { 1000000, 10 }, /* 1 Mbit/s */
220 { 1000000000, 100 } /* 1 Gbit/s */
222 static int rateidx = 0, wantbiggerrate;
224 static int get_bar_interval(float bandwidth) {
226 if(bandwidth > 100000000) {
232 static float get_max_bandwidth() {
234 if(options.max_bandwidth > 0) {
235 max = options.max_bandwidth;
238 max = scale[rateidx].max;
244 static int get_bar_length(const int rate) {
248 if (rate > scale[rateidx].max)
250 if(options.log_scale) {
251 l = log(rate) / log(get_max_bandwidth());
254 l = rate / get_max_bandwidth();
259 static void draw_bar_scale(int* y) {
262 max = get_max_bandwidth();
263 interval = get_bar_interval(max);
264 if(options.showbars) {
266 /* Draw bar graph scale on top of the window. */
269 mvhline(*y + 1, 0, 0, COLS);
272 if(options.log_scale) {
281 /* for (i = 1.25; i * 8 <= max; i *= interval) { */
285 /* This 1024 vs 1000 stuff is just plain evil */
286 readable_size(i, s, sizeof s, options.log_scale ? 1000 : 1024, options.bandwidth_in_bytes);
287 p = s + strspn(s, " ");
288 x = get_bar_length(i * 8);
289 mvaddch(*y + 1, x, ACS_BTEE);
290 if (x + strlen(p) >= COLS)
291 x = COLS - strlen(p);
294 if(options.log_scale) {
301 mvaddch(*y + 1, 0, ACS_LLCORNER);
305 mvhline(*y, 0, 0, COLS);
310 int history_length(const int d) {
311 if (history_len < history_divs[d])
312 return history_len * RESOLUTION;
314 return history_divs[d] * RESOLUTION;
317 void draw_line_total(float sent, float recv, int y, int x, option_linedisplay_t linedisplay, int bytes) {
320 switch(linedisplay) {
321 case OPTION_LINEDISPLAY_TWO_LINE:
322 draw_line_total(sent, recv, y, x, OPTION_LINEDISPLAY_ONE_LINE_SENT, bytes);
323 draw_line_total(sent, recv, y+1, x, OPTION_LINEDISPLAY_ONE_LINE_RECV, bytes);
325 case OPTION_LINEDISPLAY_ONE_LINE_SENT:
328 case OPTION_LINEDISPLAY_ONE_LINE_RECV:
331 case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
335 if(linedisplay != OPTION_LINEDISPLAY_TWO_LINE) {
336 readable_size(n, buf, 10, 1024, bytes);
341 void draw_bar(float n, int y) {
343 mvchgat(y, 0, -1, A_NORMAL, 0, NULL);
344 L = get_bar_length(8 * n);
346 mvchgat(y, 0, L + 1, A_REVERSE, 0, NULL);
349 void draw_line_totals(int y, host_pair_line* line, option_linedisplay_t linedisplay) {
351 int x = (COLS - 8 * HISTORY_DIVISIONS);
353 for(j = 0; j < HISTORY_DIVISIONS; j++) {
354 draw_line_total(line->sent[j], line->recv[j], y, x, linedisplay, options.bandwidth_in_bytes);
358 if(options.showbars) {
359 switch(linedisplay) {
360 case OPTION_LINEDISPLAY_TWO_LINE:
361 draw_bar(line->sent[options.bar_interval],y);
362 draw_bar(line->recv[options.bar_interval],y+1);
364 case OPTION_LINEDISPLAY_ONE_LINE_SENT:
365 draw_bar(line->sent[options.bar_interval],y);
367 case OPTION_LINEDISPLAY_ONE_LINE_RECV:
368 draw_bar(line->recv[options.bar_interval],y);
370 case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
371 draw_bar(line->recv[options.bar_interval] + line->sent[options.bar_interval],y);
377 void draw_totals(host_pair_line* totals) {
382 int x = (COLS - 8 * HISTORY_DIVISIONS);
384 draw_line_totals(y, totals, OPTION_LINEDISPLAY_TWO_LINE);
386 for(j = 0; j < HISTORY_DIVISIONS; j++) {
387 readable_size((totals->sent[j] + totals->recv[j]) , buf, 10, 1024, options.bandwidth_in_bytes);
393 extern history_type history_totals;
395 void screen_list_init() {
396 screen_list.compare = &screen_line_compare;
397 sorted_list_initialise(&screen_list);
400 void screen_list_clear() {
401 sorted_list_node* nn = NULL;
402 peaksent = peakrecv = peaktotal = 0;
403 while((nn = sorted_list_next_item(&screen_list, nn)) != NULL) {
406 sorted_list_destroy(&screen_list);
409 void calculate_totals() {
413 * Calculate peaks and totals
415 for(i = 0; i < HISTORY_LENGTH; i++) {
417 int ii = (HISTORY_LENGTH + history_pos - i) % HISTORY_LENGTH;
419 for(j = 0; j < HISTORY_DIVISIONS; j++) {
420 if(i < history_divs[j]) {
421 totals.recv[j] += history_totals.recv[ii];
422 totals.sent[j] += history_totals.sent[ii];
426 if(history_totals.recv[i] > peakrecv) {
427 peakrecv = history_totals.recv[i];
429 if(history_totals.sent[i] > peaksent) {
430 peaksent = history_totals.sent[i];
432 if(history_totals.recv[i] + history_totals.sent[i] > peaktotal) {
433 peaktotal = history_totals.recv[i] + history_totals.sent[i];
436 for(i = 0; i < HISTORY_DIVISIONS; i++) {
437 int t = history_length(i);
443 void make_screen_list() {
444 hash_node_type* n = NULL;
445 while(hash_next_item(screen_hash, &n) == HASH_STATUS_OK) {
446 host_pair_line* line = (host_pair_line*)n->rec;
448 for(i = 0; i < HISTORY_DIVISIONS; i++) {
449 line->recv[i] /= history_length(i);
450 line->sent[i] /= history_length(i);
453 /* Don't make a new, sorted screen list if order is frozen
455 if(!options.freezeorder) {
456 sorted_list_insert(&screen_list, line);
463 * Zeros all data in the screen hash, but does not remove items.
465 void screen_hash_clear() {
466 hash_node_type* n = NULL;
467 while(hash_next_item(screen_hash, &n) == HASH_STATUS_OK) {
468 host_pair_line* hpl = (host_pair_line*)n->rec;
469 hpl->total_recv = hpl->total_sent = 0;
470 memset(hpl->recv, 0, sizeof(hpl->recv));
471 memset(hpl->sent, 0, sizeof(hpl->sent));
475 void analyse_data() {
476 hash_node_type* n = NULL;
478 if(options.paused == 1) {
483 memset(&totals, 0, sizeof totals);
485 if(options.freezeorder) {
490 hash_delete_all(screen_hash);
493 while(hash_next_item(history, &n) == HASH_STATUS_OK) {
494 history_type* d = (history_type*)n->rec;
495 host_pair_line* screen_line;
497 host_pair_line **h_p_l_pp;
499 } u_screen_line = { &screen_line };
506 ap = *(addr_pair*)n->key;
508 /* Aggregate hosts, if required */
509 if(options.aggregate_src) {
510 memset(&ap.src6, '\0', sizeof(ap.src6));
512 if(options.aggregate_dest) {
513 memset(&ap.dst6, '\0', sizeof(ap.dst6));
516 /* Aggregate ports, if required */
517 if(options.showports == OPTION_PORTS_DEST || options.showports == OPTION_PORTS_OFF) {
520 if(options.showports == OPTION_PORTS_SRC || options.showports == OPTION_PORTS_OFF) {
523 if(options.showports == OPTION_PORTS_OFF) {
528 if(hash_find(screen_hash, &ap, u_screen_line.void_pp) == HASH_STATUS_KEY_NOT_FOUND) {
529 screen_line = xcalloc(1, sizeof *screen_line);
530 hash_insert(screen_hash, &ap, screen_line);
531 screen_line->ap = ap;
534 screen_line->total_sent += d->total_sent;
535 screen_line->total_recv += d->total_recv;
537 for(i = 0; i < HISTORY_LENGTH; i++) {
539 int ii = (HISTORY_LENGTH + history_pos - i) % HISTORY_LENGTH;
541 for(j = 0; j < HISTORY_DIVISIONS; j++) {
542 if(i < history_divs[j]) {
543 screen_line->recv[j] += d->recv[ii];
544 screen_line->sent[j] += d->sent[ii];
558 void sprint_host(char * line, int af, struct in6_addr* addr, unsigned int port, unsigned int protocol, int L) {
559 char hostname[HOSTNAME_LENGTH];
560 char service[HOSTNAME_LENGTH];
565 } u_s_name = { &s_name };
570 if(IN6_IS_ADDR_UNSPECIFIED(addr)) {
571 sprintf(hostname, " * ");
574 if (options.dnsresolution)
575 resolve(af, addr, hostname, L);
577 inet_ntop(af, addr, hostname, sizeof(hostname));
579 left = strlen(hostname);
583 skey.protocol = protocol;
584 if(options.portresolution && hash_find(service_hash, &skey, u_s_name.void_pp) == HASH_STATUS_OK) {
585 snprintf(service, HOSTNAME_LENGTH, ":%s", s_name);
588 snprintf(service, HOSTNAME_LENGTH, ":%d", port);
596 sprintf(line, "%-*s", L, hostname);
597 if(left > (L - strlen(service))) {
598 left = L - strlen(service);
603 sprintf(line + left, "%-*s", L-left, service);
609 sorted_list_node* nn = NULL;
610 char host1[HOSTNAME_LENGTH], host2[HOSTNAME_LENGTH];
618 if (!line || lcols != COLS) {
620 line = calloc(COLS + 1, 1);
624 * erase() is faster than clear(). Dunno why we switched to
625 * clear() -pdw 24/10/02
631 if(options.showhelp) {
632 mvaddstr(y,0,HELP_MESSAGE);
637 while(i < options.screen_offset && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) {
641 /* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history
642 * items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two
645 if(i == 0 || nn != NULL) {
646 while((y < LINES - 5) && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) {
650 host_pair_line* screen_line = (host_pair_line*)nn->data;
653 L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2;
654 if(options.show_totals) {
657 if(L > HOSTNAME_LENGTH) {
661 sprint_host(host1, screen_line->ap.af,
662 &(screen_line->ap.src6),
663 screen_line->ap.src_port,
664 screen_line->ap.protocol, L);
665 sprint_host(host2, screen_line->ap.af,
666 &(screen_line->ap.dst6),
667 screen_line->ap.dst_port,
668 screen_line->ap.protocol, L);
670 if(!screen_filter_match(host1) && !screen_filter_match(host2)) {
674 mvaddstr(y, x, host1);
677 switch(options.linedisplay) {
678 case OPTION_LINEDISPLAY_TWO_LINE:
679 mvaddstr(y, x, " => ");
680 mvaddstr(y+1, x, " <= ");
682 case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
683 mvaddstr(y, x, "<=> ");
685 case OPTION_LINEDISPLAY_ONE_LINE_SENT:
686 mvaddstr(y, x, " => ");
688 case OPTION_LINEDISPLAY_ONE_LINE_RECV:
689 mvaddstr(y, x, " <= ");
696 mvaddstr(y, x, host2);
698 if(options.show_totals) {
699 draw_line_total(screen_line->total_sent, screen_line->total_recv, y, COLS - 8 * (HISTORY_DIVISIONS + 1), options.linedisplay, 1);
702 draw_line_totals(y, screen_line, options.linedisplay);
705 if(options.linedisplay == OPTION_LINEDISPLAY_TWO_LINE) {
718 mvhline(y-1, 0, 0, COLS);
720 mvaddstr(y, 0, "TX: ");
721 mvaddstr(y+1, 0, "RX: ");
722 mvaddstr(y+2, 0, "TOTAL: ");
724 /* Cummulative totals */
725 mvaddstr(y, 16, "cum: ");
727 readable_size(history_totals.total_sent, line, 10, 1024, 1);
728 mvaddstr(y, 22, line);
730 readable_size(history_totals.total_recv, line, 10, 1024, 1);
731 mvaddstr(y+1, 22, line);
733 readable_size(history_totals.total_recv + history_totals.total_sent, line, 10, 1024, 1);
734 mvaddstr(y+2, 22, line);
737 mvaddstr(y, 32, "peak: ");
739 readable_size(peaksent / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
740 mvaddstr(y, 39, line);
742 readable_size(peakrecv / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
743 mvaddstr(y+1, 39, line);
745 readable_size(peaktotal / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
746 mvaddstr(y+2, 39, line);
748 mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 8, "rates:");
750 draw_totals(&totals);
755 mvaddstr(0, 1, helpmsg);
756 mvaddstr(0, 1 + strlen(helpmsg), " ");
757 mvchgat(0, 0, strlen(helpmsg) + 2, A_REVERSE, 0, NULL);
759 move(LINES - 1, COLS - 1);
763 /* Bar chart auto scale */
764 if (wantbiggerrate && options.max_bandwidth == 0) {
770 void ui_tick(int print) {
774 else if(showhelphint && (time(NULL) - helptimer > HELP_TIME) && !persistenthelp) {
780 void ui_curses_init() {
781 (void) initscr(); /* initialize the curses library */
782 keypad(stdscr, TRUE); /* enable keyboard mapping */
783 (void) nonl(); /* tell curses not to do NL->CR/NL on output */
784 (void) cbreak(); /* take input chars one at a time, no wait for \n */
785 (void) noecho(); /* don't echo input */
789 void showhelp(const char * s) {
790 strncpy(helpmsg, s, HELP_MSG_SIZE);
792 helptimer = time(NULL);
804 screen_hash = addr_hash_create();
806 service_hash = serv_hash_create();
807 serv_hash_initialise(service_hash);
809 snprintf(msg,20,"Listening on %s",options.interface);
816 void showportstatus() {
817 if(options.showports == OPTION_PORTS_ON) {
818 showhelp("Port display ON");
820 else if(options.showports == OPTION_PORTS_OFF) {
821 showhelp("Port display OFF");
823 else if(options.showports == OPTION_PORTS_DEST) {
824 showhelp("Port display DEST");
826 else if(options.showports == OPTION_PORTS_SRC) {
827 showhelp("Port display SOURCE");
834 char *edline(int linenum, const char *prompt, const char *initial);
836 char *set_filter_code(const char *filter);
838 extern sig_atomic_t foad;
849 if(options.dnsresolution) {
850 options.dnsresolution = 0;
851 showhelp("DNS resolution off");
854 options.dnsresolution = 1;
855 showhelp("DNS resolution on");
861 if(options.portresolution) {
862 options.portresolution = 0;
863 showhelp("Port resolution off");
866 options.portresolution = 1;
867 showhelp("Port resolution on");
874 options.showhelp = !options.showhelp;
879 if(options.showbars) {
880 options.showbars = 0;
881 showhelp("Bars off");
884 options.showbars = 1;
891 options.bar_interval = (options.bar_interval + 1) % 3;
892 if(options.bar_interval == 0) {
893 showhelp("Bars show 2s average");
895 else if(options.bar_interval == 1) {
896 showhelp("Bars show 10s average");
899 showhelp("Bars show 40s average");
904 if(options.aggregate_src) {
905 options.aggregate_src = 0;
906 showhelp("Show source host");
909 options.aggregate_src = 1;
910 showhelp("Hide source host");
914 if(options.aggregate_dest) {
915 options.aggregate_dest = 0;
916 showhelp("Show dest host");
919 options.aggregate_dest = 1;
920 showhelp("Hide dest host");
924 /* Show source ports */
925 if(options.showports == OPTION_PORTS_OFF) {
926 options.showports = OPTION_PORTS_SRC;
928 else if(options.showports == OPTION_PORTS_DEST) {
929 options.showports = OPTION_PORTS_ON;
931 else if(options.showports == OPTION_PORTS_ON) {
932 options.showports = OPTION_PORTS_DEST;
935 options.showports = OPTION_PORTS_OFF;
940 /* Show dest ports */
941 if(options.showports == OPTION_PORTS_OFF) {
942 options.showports = OPTION_PORTS_DEST;
944 else if(options.showports == OPTION_PORTS_SRC) {
945 options.showports = OPTION_PORTS_ON;
947 else if(options.showports == OPTION_PORTS_ON) {
948 options.showports = OPTION_PORTS_SRC;
951 options.showports = OPTION_PORTS_OFF;
957 (options.showports == OPTION_PORTS_OFF)
961 // Don't tick here, otherwise we get a bogus display
966 showhelp("Display unpaused");
970 showhelp("Display paused");
975 if(options.freezeorder) {
976 options.freezeorder = 0;
977 showhelp("Order unfrozen");
980 options.freezeorder = 1;
981 showhelp("Order frozen");
986 options.sort = OPTION_SORT_DIV1;
987 showhelp("Sort by col 1");
990 options.sort = OPTION_SORT_DIV2;
991 showhelp("Sort by col 2");
994 options.sort = OPTION_SORT_DIV3;
995 showhelp("Sort by col 3");
998 options.sort = OPTION_SORT_SRC;
999 showhelp("Sort by source");
1002 options.sort = OPTION_SORT_DEST;
1003 showhelp("Sort by dest");
1006 options.screen_offset++;
1010 if(options.screen_offset > 0) {
1011 options.screen_offset--;
1016 options.linedisplay = (options.linedisplay + 1) % 4;
1017 switch(options.linedisplay) {
1018 case OPTION_LINEDISPLAY_TWO_LINE:
1019 showhelp("Two lines per host");
1021 case OPTION_LINEDISPLAY_ONE_LINE_SENT:
1022 showhelp("Sent traffic only");
1024 case OPTION_LINEDISPLAY_ONE_LINE_RECV:
1025 showhelp("Received traffic only");
1027 case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
1028 showhelp("One line per host");
1035 dontshowdisplay = 1;
1036 if ((s = edline(0, "Net filter", options.filtercode))) {
1038 if (s[strspn(s, " \t")] == 0) {
1039 /* Empty filter; set to NULL. */
1043 if (!(m = set_filter_code(s))) {
1044 xfree(options.filtercode);
1045 options.filtercode = s;
1046 /* -lpcap will write junk to stderr; we do our best to
1048 move(COLS - 1, LINES - 1);
1050 showhelp("Installed new filter");
1056 dontshowdisplay = 0;
1063 dontshowdisplay = 1;
1064 if ((s = edline(0, "Screen filter", options.screenfilter))) {
1065 if(!screen_filter_set(s)) {
1066 showhelp("Invalid regexp");
1069 dontshowdisplay = 0;
1072 showhelp("Sorry, screen filters not supported on this platform")
1077 #ifdef ALLOW_SUBSHELL
1079 dontshowdisplay = 1;
1080 if ((s = edline(0, "Command", "")) && s[strspn(s, " \t")]) {
1087 if (i == -1 || (i == 127 && errno != 0)) {
1088 fprintf(stderr, "system: %s: %s\n", s, strerror(errno));
1090 } else if (i != 0) {
1092 fprintf(stderr, "%s: exited with code %d\n", s, WEXITSTATUS(i));
1093 else if (WIFSIGNALED(i))
1094 fprintf(stderr, "%s: killed by signal %d\n", s, WTERMSIG(i));
1099 fprintf(stderr, "Press any key....");
1100 while (getch() == ERR);
1105 dontshowdisplay = 0;
1107 showhelp("Sorry, subshells have been disabled.");
1112 options.show_totals = !options.show_totals;
1113 if(options.show_totals) {
1114 showhelp("Show cumulative totals");
1117 showhelp("Hide cumulative totals");
1122 options.log_scale = !options.log_scale;
1123 showhelp(options.log_scale ? "Logarithmic scale" : "Linear scale");
1133 showhelp("Press H or ? for help");