2019-01-10 11:44:47 +11:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2019-01-11 00:07:56 +11:00
|
|
|
#include <string.h>
|
2019-01-17 23:54:27 +11:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
2019-01-10 11:44:47 +11:00
|
|
|
#include <getopt.h>
|
|
|
|
#include <ncurses.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ecran.h"
|
|
|
|
|
2019-01-31 02:44:43 +11:00
|
|
|
extern int verbosity;
|
2019-01-10 11:44:47 +11:00
|
|
|
|
2019-05-14 02:48:58 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
int kbhit(void)
|
|
|
|
{
|
|
|
|
int r, ch;
|
|
|
|
|
|
|
|
nodelay(stdscr, TRUE);
|
|
|
|
noecho();
|
|
|
|
|
|
|
|
// check for input
|
|
|
|
ch = getch();
|
|
|
|
if( ch == ERR) { // no input
|
|
|
|
r = FALSE;
|
|
|
|
}
|
|
|
|
else { // input
|
|
|
|
r = TRUE;
|
|
|
|
ungetch(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore block and echo
|
|
|
|
echo();
|
|
|
|
nodelay(stdscr, FALSE);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2019-01-10 11:44:47 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
2019-05-15 00:18:03 +11:00
|
|
|
int aff_message(char *txt)
|
2019-01-23 01:24:49 +11:00
|
|
|
{
|
2019-01-27 22:12:49 +11:00
|
|
|
static int pass = 0;
|
|
|
|
|
2019-01-31 02:44:43 +11:00
|
|
|
#if TRACE
|
2019-01-30 09:25:59 +11:00
|
|
|
fprintf(stderr, "%s [%s]\n", __func__, txt);
|
2019-01-31 02:44:43 +11:00
|
|
|
#endif
|
2019-01-30 09:25:59 +11:00
|
|
|
|
2019-01-23 01:24:49 +11:00
|
|
|
standout();
|
2019-02-05 22:16:27 +11:00
|
|
|
mvhline(LINES-1, 0, ' ', COLS);
|
2019-01-27 22:12:49 +11:00
|
|
|
mvaddch(LINES-1, 0, "\\|/-"[(pass++)%4]);
|
2019-01-24 11:20:39 +11:00
|
|
|
mvaddstr(LINES-1, 2, txt);
|
2019-01-23 01:24:49 +11:00
|
|
|
standend();
|
|
|
|
refresh();
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-10 11:44:47 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
void barre_inverse(char c, int ligne)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
standout();
|
|
|
|
for (foo=0; foo<COLS; foo++)
|
|
|
|
mvaddch(ligne, foo, c);
|
|
|
|
standend();
|
|
|
|
/* refresh(); */
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
2019-01-31 02:44:43 +11:00
|
|
|
/* make display on the standard screen (stdscr) */
|
2019-01-11 00:07:56 +11:00
|
|
|
int fond_ecran(char *title)
|
2019-01-10 11:44:47 +11:00
|
|
|
{
|
2019-01-27 22:12:49 +11:00
|
|
|
char *tp;
|
|
|
|
struct utsname utsn;
|
|
|
|
int foo;
|
|
|
|
char buffer[200];
|
2019-01-10 11:44:47 +11:00
|
|
|
|
2019-01-31 02:44:43 +11:00
|
|
|
tp = " DD2 Monitoring by tTh 2019 ";
|
2019-01-11 00:07:56 +11:00
|
|
|
if (NULL != title) tp = title;
|
|
|
|
|
2019-01-13 02:26:15 +11:00
|
|
|
barre_inverse(' ', 0);
|
2019-01-10 11:44:47 +11:00
|
|
|
standout();
|
2019-01-11 00:07:56 +11:00
|
|
|
mvaddstr(0, 2, tp);
|
2019-01-27 22:12:49 +11:00
|
|
|
|
|
|
|
if (verbosity) {
|
2019-01-31 02:44:43 +11:00
|
|
|
sprintf(buffer, " ecr: %dx%d ", COLS, LINES);
|
|
|
|
fprintf(stderr, "%s ==> %s\n", __func__, buffer);
|
2019-01-27 22:12:49 +11:00
|
|
|
foo = strlen(buffer);
|
|
|
|
mvaddstr(0, COLS-2-foo, buffer);
|
|
|
|
}
|
2019-01-17 23:54:27 +11:00
|
|
|
|
|
|
|
/* get and display hostname */
|
|
|
|
foo = uname(&utsn);
|
|
|
|
if ( !foo ) {
|
|
|
|
mvaddstr(0, 2+strlen(tp), "on");
|
|
|
|
mvaddstr(0, 5+strlen(tp), utsn.nodename);
|
|
|
|
}
|
|
|
|
|
2019-01-10 11:44:47 +11:00
|
|
|
standend();
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|