int main(int argc, char **argv) { FILE *file; Hubyte mac[6]; mac[0] = 0x00; mac[1] = 0xE0; mac[2] = 0x18; mac[3] = 0xE4; mac[4] = 0xB2; mac[5] = 0x74; eth_init( mac ); setup_ncurses(); num_packets = 0; num_bytes = 0; res_total = 0; res_number = 0; res_max = 0; res_min = 0; file = open_file( argv[1] ); log_data( file ); close_ncurses(); eth_destroy(); return 0; }
void log_mesg(int log_level, int log_exit, int log_stderr, int debug, const char *fmt, ...) { va_list args; extern cmd_opt opt; char tmp_str[512]; if (log_level > debug && (!log_exit || opt.force)) return; va_start(args, fmt); vsnprintf(tmp_str, sizeof(tmp_str), fmt, args); va_end(args); if (opt.ncurses) { #ifdef HAVE_LIBNCURSESW setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); if ((log_stderr) && (log_level <= debug)) { if (log_exit) wattron(log_win, A_STANDOUT); wprintw(log_win, tmp_str); if (log_exit) { wattroff(log_win, A_STANDOUT); sleep(3); } wrefresh(log_win); log_y_line++; } #endif } else { /// write log to stderr if log_stderr is true if ((log_stderr == 1) && (log_level <= debug)) fprintf(stderr, "%s", tmp_str); } /// write log to logfile if debug is true if (log_level <= debug) fprintf(msg, "%s", tmp_str); /// clear message fflush(msg); /// exit if lexit true if ((!opt.force) && log_exit) { close_ncurses(); fprintf(stderr, "Partclone fail, please check %s !\n", opt.logfile); exit(1); } }
/// open progress interface extern int open_pui(int pui, unsigned long res){ int tui = 0; if (pui == NCURSES){ tui = open_ncurses(); if (tui == 0){ close_ncurses(); } } else if (pui == DIALOG){ tui = 1; } PUI = pui; RES = res; return tui; }
/// close progress interface extern void close_pui(int pui){ if (pui == NCURSES){ close_ncurses(); } }