"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mt.c" between
multitail-6.2.1.tgz and multitail-6.4.tgz

About: multitail lets you view one or multiple files like the original tail program.

mt.c  (multitail-6.2.1.tgz):mt.c  (multitail-6.4.tgz)
skipping to change at line 450 skipping to change at line 450
int draw_tab(NEWWIN *win) int draw_tab(NEWWIN *win)
{ {
if (tab_width) if (tab_width)
{ {
int curx = getcurx(win -> win), loop; int curx = getcurx(win -> win), loop;
int move = (((curx / tab_width) + 1) * tab_width) - curx; int move = (((curx / tab_width) + 1) * tab_width) - curx;
for(loop=0; loop<move; loop++) for(loop=0; loop<move; loop++)
waddch(win -> win, ' '); waddch(win -> win, ' ');
return move;
} }
return 0; return 1;
} }
char find_highlight_matches(regmatch_t *matches, char use_regex, int offset) char find_highlight_matches(regmatch_t *matches, char use_regex, int offset)
{ {
int match_offset; int match_offset;
for(match_offset=0; match_offset<MAX_N_RE_MATCHES; match_offset++) for(match_offset=0; match_offset<MAX_N_RE_MATCHES; match_offset++)
{ {
char matching; char matching;
skipping to change at line 1392 skipping to change at line 1390
get_now_ts(statusline_ts_format, timestamp, sizeof(timestamp)); get_now_ts(statusline_ts_format, timestamp, sizeof(timestamp));
help_str_offset = 4 + strlen(USE_IF_SET(cur -> win_title, fname)) ; /* 4: '%02d] '!! (window nr.) */ help_str_offset = 4 + strlen(USE_IF_SET(cur -> win_title, fname)) ; /* 4: '%02d] '!! (window nr.) */
statusline_len = help_str_offset + strlen(timestamp) + 1; /* 4: ' %02d] '!! (window nr.) */ statusline_len = help_str_offset + strlen(timestamp) + 1; /* 4: ' %02d] '!! (window nr.) */
if (win_nr == terminal_main_index) if (win_nr == terminal_main_index)
wprintw(status -> win, ", press <CTRL>+<a>, <d> to exit") ; wprintw(status -> win, ", press <CTRL>+<a>, <d> to exit") ;
else if (mail) else if (mail)
wprintw(status -> win, " You've got mail!"); wprintw(status -> win, " You've got mail!");
dx = getcurx(status -> win); if (win_width >= (statusline_len + 13))
if (dx >= (statusline_len + 13))
{ {
if (cur -> paused) if (cur -> paused)
{ {
color_on(status, find_colorpair(COLOR_YELLOW, -1, 0)); color_on(status, find_colorpair(COLOR_YELLOW, -1, 0));
mvwprintw(status -> win, 0, dx - 10, " Paused " ); mvwprintw(status -> win, 0, win_width - 10, " Pa used ");
color_off(status, find_colorpair(COLOR_YELLOW, -1 , 0)); color_off(status, find_colorpair(COLOR_YELLOW, -1 , 0));
} }
else if (cur -> wt == WT_COMMAND) else if (cur -> wt == WT_COMMAND)
{ {
int vmsize = get_vmsize(cur -> pid); int vmsize = get_vmsize(cur -> pid);
total_info_len = statusline_len + 12; total_info_len = statusline_len + 12;
if (vmsize != -1 && dx >= (statusline_len + 30)) if (vmsize != -1 && win_width >= (statusline_len + 30))
{ {
int str_x = dx - strlen(timestamp) - 30; int str_x = win_width - strlen(timestamp) - 30;
char *vmsize_str = amount_to_str(vmsize); char *vmsize_str = amount_to_str(vmsize);
mvwprintw(status -> win, 0, str_x, "%6s ( VMsize) %5d (PID) - %s", vmsize_str, cur -> pid, timestamp); mvwprintw(status -> win, 0, str_x, "%6s ( VMsize) %5d (PID) - %s", vmsize_str, cur -> pid, timestamp);
myfree(vmsize_str); myfree(vmsize_str);
total_info_len = statusline_len + 30; total_info_len = statusline_len + 30;
} }
else else
{ {
if (cur -> last_exit_rc != 0) if (cur -> last_exit_rc != 0)
{ {
mvwprintw(status -> win, 0, dx - strlen(timestamp) - 26, "Last rc: %d, %5d (PID) - %s", WEXITSTATUS(cur -> last_e xit_rc), cur -> pid, timestamp); mvwprintw(status -> win, 0, win_w idth - strlen(timestamp) - 26, "Last rc: %d, %5d (PID) - %s", WEXITSTATUS(cur -> last_exit_rc), cur -> pid, timestamp);
} }
else else
mvwprintw(status -> win, 0, dx - strlen(timestamp) - 12, "%5d (PID) - %s", cur -> pid, timestamp); mvwprintw(status -> win, 0, win_w idth - strlen(timestamp) - 12, "%5d (PID) - %s", cur -> pid, timestamp);
} }
} }
else if (fsize == -1) else if (fsize == -1)
{ {
if (cur -> wt == WT_STDIN || cur -> wt == WT_SOCK ET) if (cur -> wt == WT_STDIN || cur -> wt == WT_SOCK ET)
mvwprintw(status -> win, 0, dx - strlen(t imestamp), "%s", timestamp); mvwprintw(status -> win, 0, win_width - s trlen(timestamp), "%s", timestamp);
else else
{ {
mvwprintw(status -> win, 0, dx - strlen(t imestamp) - 6, "??? - %s", timestamp); mvwprintw(status -> win, 0, win_width - s trlen(timestamp) - 6, "??? - %s", timestamp);
total_info_len = statusline_len + 6; total_info_len = statusline_len + 6;
} }
} }
else else
{ {
int cur_len = 0; int cur_len = 0;
if (fsize < cur -> last_size) if (fsize < cur -> last_size)
add_markerline(win_nr, cur, MARKER_MSG, " file got truncated"); add_markerline(win_nr, cur, MARKER_MSG, " file got truncated");
cur -> last_size = fsize; cur -> last_size = fsize;
if (afs) if (afs)
{ {
char *filesize = amount_to_str(fsize); char *filesize = amount_to_str(fsize);
cur_len = 3 + strlen(filesize); cur_len = 3 + strlen(filesize);
mvwprintw(status -> win, 0, dx - (strlen( timestamp) + cur_len), "%s - %s", filesize, timestamp); mvwprintw(status -> win, 0, win_width - ( strlen(timestamp) + cur_len), "%s - %s", filesize, timestamp);
myfree(filesize); myfree(filesize);
} }
else else
{ {
cur_len = 13; cur_len = 13;
/* is this trick still neccessary as I mo ved from off_t to off64_t? */ /* is this trick still neccessary as I mo ved from off_t to off64_t? */
#if 0 #if 0
/* this trick is because on MacOS X 'off_ t' is specified as a 64 bit integer */ /* this trick is because on MacOS X 'off_ t' is specified as a 64 bit integer */
#endif #endif
if (sizeof(off64_t) == 8) if (sizeof(off64_t) == 8)
mvwprintw(status -> win, 0, dx - (strlen(timestamp) + cur_len), "%10lld - %s", fsize, timestamp); mvwprintw(status -> win, 0, win_w idth - (strlen(timestamp) + cur_len), "%10lld - %s", fsize, timestamp);
else else
mvwprintw(status -> win, 0, dx - (strlen(timestamp) + cur_len), "%10ld - %s", fsize, timestamp); mvwprintw(status -> win, 0, win_w idth - (strlen(timestamp) + cur_len), "%10ld - %s", fsize, timestamp);
} }
total_info_len = statusline_len + cur_len; total_info_len = statusline_len + cur_len;
} }
} }
if (show_f1) if (show_f1)
{ {
if (use_colors) color_on(status, find_colorpair(COLOR_YEL LOW, -1, 0)); if (use_colors) color_on(status, find_colorpair(COLOR_YEL LOW, -1, 0));
if (dx >= (total_info_len + 32)) if (win_width >= (total_info_len + 32))
mvwprintw(status -> win, 0, help_str_offset, " *P ress F1/<CTRL>+<h> for help* "); mvwprintw(status -> win, 0, help_str_offset, " *P ress F1/<CTRL>+<h> for help* ");
else if (dx >= (total_info_len + 21)) else if (win_width >= (total_info_len + 21))
mvwprintw(status -> win, 0, help_str_offset, " F1 /<CTRL>+<h>: help "); mvwprintw(status -> win, 0, help_str_offset, " F1 /<CTRL>+<h>: help ");
else if (dx >= (total_info_len + 13)) else if (win_width >= (total_info_len + 13))
mvwprintw(status -> win, 0, help_str_offset, " F1 /^h: help "); mvwprintw(status -> win, 0, help_str_offset, " F1 /^h: help ");
if (use_colors) color_off(status, find_colorpair(COLOR_YE LLOW, -1, 0)); if (use_colors) color_off(status, find_colorpair(COLOR_YE LLOW, -1, 0));
} }
myattr_off(status, attrs); myattr_off(status, attrs);
update_panels(); update_panels();
} }
} }
skipping to change at line 2013 skipping to change at line 2010
void do_restart_window(proginfo *cur) void do_restart_window(proginfo *cur)
{ {
/* stop process */ /* stop process */
stop_process(cur -> pid); stop_process(cur -> pid);
/* close pipes */ /* close pipes */
myclose(cur -> fd); myclose(cur -> fd);
myclose(cur -> wfd); myclose(cur -> wfd);
/* re-start tail */ /* re-start tail */
cur -> restart.first = 1;
if (start_proc(cur, 1) == -1) if (start_proc(cur, 1) == -1)
error_exit(FALSE, FALSE, "Failed to start process %s.\n", cur -> filename); error_exit(FALSE, FALSE, "Failed to start process %s.\n", cur -> filename);
} }
char * key_to_keybinding(char what) char * key_to_keybinding(char what)
{ {
static char buffer[3]; static char buffer[3];
buffer[1] = buffer[2] = 0x00; buffer[1] = buffer[2] = 0x00;
skipping to change at line 3365 skipping to change at line 3363
host, host[0] ?" ":"", host, host[0] ?" ":"",
facility, facility[0] ?" ":"", facility, facility[0] ?" ":"",
severity, severity[0] ?" ":"", severity, severity[0] ?" ":"",
recv_buffer); recv_buffer);
myfree(recv_buffer); myfree(recv_buffer);
return nbytes; return nbytes;
} }
void get_markerline_sleep(double *const s, char *have_any)
{
int loop = 0;
dtime_t now = get_ts();
*have_any = 0;
for(loop=0; loop<nfd; loop++)
{
proginfo *cur = &pi[loop];
do
{
if (cur -> mark_interval)
{
double t_until_next = cur -> statistics.lastevent
+ cur -> mark_interval - now;
*have_any = 1;
if (t_until_next <= 0)
{
*s = 0;
return;
}
*s = min(*s, t_until_next);
}
cur = cur -> next;
}
while(cur);
}
}
int wait_for_keypress(int what_help, double max_wait, NEWWIN *popup, char cursor _shift) int wait_for_keypress(int what_help, double max_wait, NEWWIN *popup, char cursor _shift)
{ {
int c = -1; int c = -1;
dtime_t max_wait_start = get_ts(); dtime_t max_wait_start = get_ts();
for(;;) for(;;)
{ {
int deleted_entry_in_array = -1; int deleted_entry_in_array = -1;
int last_fd = 0, rc, loop; int last_fd = 0, rc, loop;
fd_set rfds; fd_set rfds;
struct timeval tv; struct timeval tv;
dtime_t now = get_ts(); dtime_t now = get_ts();
proginfo *last_changed_window = NULL; proginfo *last_changed_window = NULL;
char prev_mail_status = mail; char prev_mail_status = mail;
static double lastupdate = 0; static double lastupdate = 0;
double sleep = 32767.0; double sleep = 32767.0;
char any_markers = 0;
/* need to check any paths? */ /* need to check any paths? */
if (check_paths()) if (check_paths())
set_do_refresh(2); set_do_refresh(2);
sleep = min(sleep, check_for_mail > 0 ? max((msf_last_check + check_for_mail) - now, 0) : 32767); sleep = min(sleep, check_for_mail > 0 ? max((msf_last_check + check_for_mail) - now, 0) : 32767);
sleep = min(sleep, heartbeat_interval > 0 ? max((heartbeat_t + he artbeat_interval) - now, 0) : 32767); sleep = min(sleep, heartbeat_interval > 0 ? max((heartbeat_t + he artbeat_interval) - now, 0) : 32767);
sleep = min(sleep, max_wait > 0.0 ? max((max_wait_start + max_wait) - now, 0) : 32767); sleep = min(sleep, max_wait > 0.0 ? max((max_wait_start + max_wait) - now, 0) : 32767);
get_markerline_sleep(&sleep, &any_markers);
for(loop=0; loop<n_cdg; loop++) for(loop=0; loop<n_cdg; loop++)
sleep = min(sleep, max((cdg[loop].last_check + cdg[loop]. check_interval) - now, 0)); sleep = min(sleep, max((cdg[loop].last_check + cdg[loop]. check_interval) - now, 0));
if (sleep < 32767.0) if (sleep < 32767.0)
{ {
if (sleep < 0.01) if (sleep < 0.01)
sleep = 0.01; sleep = 0.01;
tv.tv_sec = sleep; tv.tv_sec = sleep;
tv.tv_usec = (sleep - (double)tv.tv_sec) * 1000000; tv.tv_usec = (sleep - (double)tv.tv_sec) * 1000000;
skipping to change at line 3492 skipping to change at line 3527
if (max_wait != 0.0 && now - max_wait_start >= max_wait) if (max_wait != 0.0 && now - max_wait_start >= max_wait)
break; break;
if (got_sigusr1) if (got_sigusr1)
{ {
got_sigusr1 = 0; got_sigusr1 = 0;
sigusr1_restart_tails(); sigusr1_restart_tails();
} }
if (any_markers)
{
for(loop=0; loop<nfd; loop++)
{
proginfo *cur = &pi[loop];
if (cur -> paused || cur -> closed)
continue;
do
{
if (cur -> mark_interval && now - cur ->
statistics.lastevent >= cur -> mark_interval)
{
if (cur -> statistics.lastevent)
{
add_markerline(loop, cur,
MARKER_IDLE, NULL);
if (get_do_refresh() == 0
)
set_do_refresh(1)
;
}
cur -> statistics.lastevent = now
;
}
cur = cur -> next;
}
while(cur);
}
}
if (rc > 0) if (rc > 0)
{ {
/* any key pressed? */ /* any key pressed? */
if (FD_ISSET(0, &rfds)) if (FD_ISSET(0, &rfds))
{ {
mail = 0; mail = 0;
c = process_global_keys(what_help, popup, cursor_ shift); c = process_global_keys(what_help, popup, cursor_ shift);
if (c != -1) if (c != -1)
break; break;
skipping to change at line 3598 skipping to change at line 3663
deleted_entry_in_array = close_wi ndow(loop, cur, MY_TRUE); deleted_entry_in_array = close_wi ndow(loop, cur, MY_TRUE);
if (deleted_entry_in_array >= 0) if (deleted_entry_in_array >= 0)
{ {
set_do_refresh(2); set_do_refresh(2);
goto closed_window; goto closed_window;
} }
} }
if (cur -> mark_interval)
{
if (now - cur -> statistics.laste
vent >= cur -> mark_interval)
{
add_markerline(loop, cur,
MARKER_IDLE, NULL);
if (get_do_refresh() == 0
)
set_do_refresh(1)
;
cur -> statistics.lasteve
nt = now;
}
}
cur = cur -> next; cur = cur -> next;
} }
while(cur); while(cur);
if (deleted_entry_in_array > 0) if (deleted_entry_in_array > 0)
break; break;
} }
} }
/* see if any processes have died (processes started /* see if any processes have died (processes started
 End of changes. 22 change blocks. 
36 lines changed or deleted 89 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS