Browse Source

Make the curses interface optional with a new --text-only -T option.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
e21e923648
  1. 22
      main.c
  2. 4
      util.c

22
main.c

@ -147,15 +147,20 @@ static int opt_n_threads; @@ -147,15 +147,20 @@ static int opt_n_threads;
static int mining_threads;
static int num_processors;
static int scan_intensity;
static bool use_curses = true;
static char *rpc_url;
static char *rpc_userpass;
static char *rpc_user, *rpc_pass;
struct thr_info *thr_info;
static int work_thr_id;
int longpoll_thr_id;
static int stage_thr_id;
static int watchdog_thr_id;
struct work_restart *work_restart = NULL;
static pthread_mutex_t hash_lock;
static pthread_mutex_t qd_lock;
static pthread_mutex_t stgd_lock;
@ -361,6 +366,9 @@ static struct opt_table opt_config_table[] = { @@ -361,6 +366,9 @@ static struct opt_table opt_config_table[] = {
opt_set_bool, &use_syslog,
"Use system log for output messages (default: standard error)"),
#endif
OPT_WITHOUT_ARG("--text-only|-T",
opt_set_invbool, &use_curses,
"Disable ncurses formatted screen output"),
OPT_WITH_ARG("--url|-o",
set_url, opt_show_charp, &rpc_url,
"URL for bitcoin JSON-RPC server"),
@ -603,14 +611,13 @@ static void print_status(int thr_id) @@ -603,14 +611,13 @@ static void print_status(int thr_id)
void log_curses(const char *f, va_list ap)
{
if (!curses_active)
vprintf(f, ap);
else {
if (curses_active) {
pthread_mutex_lock(&curses_lock);
vw_printw(logwin, f, ap);
wrefresh(logwin);
pthread_mutex_unlock(&curses_lock);
}
} else
vprintf(f, ap);
}
static bool submit_fail = false;
@ -1096,7 +1103,10 @@ static void hashmeter(int thr_id, struct timeval *diff, @@ -1096,7 +1103,10 @@ static void hashmeter(int thr_id, struct timeval *diff,
sprintf(statusline, "[(%ds):%.1f (avg):%.1f Mh/s] [Q:%d A:%d R:%d HW:%d E:%.0f%% U:%.2f/m]",
opt_log_interval, rolling_local / local_secs, total_mhashes_done / total_secs,
getwork_requested, accepted, rejected, hw_errors, efficiency, utility);
print_status(thr_id);
if (!curses_active) {
printf("%s \r", statusline);
fflush(stdout);
} else
applog(LOG_INFO, "%s", statusline);
local_mhashes_done = 0;
@ -2293,7 +2303,7 @@ int main (int argc, char *argv[]) @@ -2293,7 +2303,7 @@ int main (int argc, char *argv[])
pthread_mutex_unlock(&hash_lock);
/* Set up the ncurses interface */
if (!opt_quiet) {
if (!opt_quiet && use_curses) {
mainwin = initscr();
getmaxyx(mainwin, y, x);
statuswin = newwin(logstart, x, 0, 0);

4
util.c

@ -79,9 +79,9 @@ void vapplog(int prio, const char *fmt, va_list ap) @@ -79,9 +79,9 @@ void vapplog(int prio, const char *fmt, va_list ap)
localtime_r(&tv.tv_sec, &tm);
len = 40 + strlen(fmt) + 2;
len = 40 + strlen(fmt) + 22;
f = alloca(len);
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s\n",
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s \n",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,

Loading…
Cancel
Save