add menu support to lcdproc client (currently hidden behind #ifdef LCDPROC_MENUS) -
patch provided by Andrew Foss
This commit is contained in:
+15
-5
@@ -71,14 +71,24 @@ battery_status(int status)
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
battery_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
battery_screen (int rep, int display)
|
battery_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = TRUE;
|
|
||||||
int acstat = 0, battstat = 0, percent = 0;
|
int acstat = 0, battstat = 0, percent = 0;
|
||||||
int gauge_wid = lcd_wid - 2;
|
int gauge_wid = lcd_wid - 2;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
if (first == TRUE) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add B\n");
|
sock_send_string (sock, "screen_add B\n");
|
||||||
sprintf (buffer, "screen_set B -name {APM stats: %s}\n", get_hostname());
|
sprintf (buffer, "screen_set B -name {APM stats: %s}\n", get_hostname());
|
||||||
@@ -111,10 +121,10 @@ battery_screen (int rep, int display)
|
|||||||
sprintf(buffer, "widget_set B title {%s: %s: %s}\n",
|
sprintf(buffer, "widget_set B title {%s: %s: %s}\n",
|
||||||
(acstat == LCDP_AC_ON && battstat == LCDP_BATT_ABSENT) ? "AC" : "Batt",
|
(acstat == LCDP_AC_ON && battstat == LCDP_BATT_ABSENT) ? "AC" : "Batt",
|
||||||
tmp, get_hostname());
|
tmp, get_hostname());
|
||||||
if(display)
|
if (display)
|
||||||
sock_send_string (sock, buffer);
|
sock_send_string (sock, buffer);
|
||||||
|
|
||||||
if(lcd_hgt >= 4) { // 4-line version of the screen
|
if (lcd_hgt >= 4) { // 4-line version of the screen
|
||||||
sprintf(buffer, "widget_set B one 1 2 {AC: %s}\n", ac_status(acstat));
|
sprintf(buffer, "widget_set B one 1 2 {AC: %s}\n", ac_status(acstat));
|
||||||
if (display)
|
if (display)
|
||||||
sock_send_string (sock, buffer);
|
sock_send_string (sock, buffer);
|
||||||
@@ -125,7 +135,7 @@ battery_screen (int rep, int display)
|
|||||||
|
|
||||||
if (percent > 0) {
|
if (percent > 0) {
|
||||||
sprintf(buffer, "widget_set B gauge 2 4 %d\n", (percent * gauge_wid * lcd_cellwid) / 100);
|
sprintf(buffer, "widget_set B gauge 2 4 %d\n", (percent * gauge_wid * lcd_cellwid) / 100);
|
||||||
if(display)
|
if (display)
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef BATT_H
|
#ifndef BATT_H
|
||||||
#define BATT_H
|
#define BATT_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int battery_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int battery_screen (int rep, int display);
|
int battery_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+60
-10
@@ -96,21 +96,31 @@ static char *shortmonths[] = {
|
|||||||
//+--------------------+
|
//+--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
time_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
time_screen (int rep, int display)
|
time_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
char now[20];
|
char now[20];
|
||||||
char day[16], month[16];
|
char day[16], month[16];
|
||||||
int xoffs;
|
int xoffs;
|
||||||
int days, hour, min, sec;
|
int days, hour, min, sec;
|
||||||
static int first = 1;
|
|
||||||
static int heartbeat = 0;
|
static int heartbeat = 0;
|
||||||
static char colon[] = {':', ' '};
|
static char colon[] = {':', ' '};
|
||||||
time_t thetime;
|
time_t thetime;
|
||||||
struct tm *rtime;
|
struct tm *rtime;
|
||||||
double uptime, idle;
|
double uptime, idle;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add T\n");
|
sock_send_string (sock, "screen_add T\n");
|
||||||
sprintf (buffer, "screen_set T -name {Time Screen: %s}\n", get_hostname());
|
sprintf (buffer, "screen_set T -name {Time Screen: %s}\n", get_hostname());
|
||||||
@@ -212,19 +222,29 @@ time_screen (int rep, int display)
|
|||||||
//+--------------------+
|
//+--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
clock_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
clock_screen (int rep, int display)
|
clock_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
char now[20];
|
char now[20];
|
||||||
char day[16], month[16];
|
char day[16], month[16];
|
||||||
int xoffs;
|
int xoffs;
|
||||||
static int first = 1;
|
|
||||||
static int heartbeat = 0;
|
static int heartbeat = 0;
|
||||||
static char colon[] = {':', ' '};
|
static char colon[] = {':', ' '};
|
||||||
time_t thetime;
|
time_t thetime;
|
||||||
struct tm *rtime;
|
struct tm *rtime;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add O\n");
|
sock_send_string (sock, "screen_add O\n");
|
||||||
sprintf (buffer, "screen_set O -name {Old Clock Screen: %s}\n", get_hostname());
|
sprintf (buffer, "screen_set O -name {Old Clock Screen: %s}\n", get_hostname());
|
||||||
@@ -306,17 +326,27 @@ clock_screen (int rep, int display)
|
|||||||
//+--------------------+
|
//+--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
uptime_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
uptime_screen (int rep, int display)
|
uptime_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int xoffs;
|
int xoffs;
|
||||||
int days, hour, min, sec;
|
int days, hour, min, sec;
|
||||||
double uptime, idle;
|
double uptime, idle;
|
||||||
static int first = 1;
|
|
||||||
static int heartbeat = 0;
|
static int heartbeat = 0;
|
||||||
static char colon[] = {':', ' '};
|
static char colon[] = {':', ' '};
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add U\n");
|
sock_send_string (sock, "screen_add U\n");
|
||||||
sprintf (buffer, "screen_set U -name {Uptime Screen: %s}\n", get_hostname());
|
sprintf (buffer, "screen_set U -name {Uptime Screen: %s}\n", get_hostname());
|
||||||
@@ -383,9 +413,12 @@ uptime_screen (int rep, int display)
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
big_clock_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
big_clock_screen (int rep, int display)
|
big_clock_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
|
||||||
time_t thetime;
|
time_t thetime;
|
||||||
struct tm *rtime;
|
struct tm *rtime;
|
||||||
int pos[] = { 1, 4, 8, 11, 15, 18 };
|
int pos[] = { 1, 4, 8, 11, 15, 18 };
|
||||||
@@ -399,9 +432,16 @@ big_clock_screen (int rep, int display)
|
|||||||
|
|
||||||
// toggle colon display
|
// toggle colon display
|
||||||
heartbeat ^= 1;
|
heartbeat ^= 1;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add K\n");
|
sock_send_string (sock, "screen_add K\n");
|
||||||
sock_send_string (sock, "screen_set K -name {Big Clock Screen} -heartbeat off\n");
|
sock_send_string (sock, "screen_set K -name {Big Clock Screen} -heartbeat off\n");
|
||||||
@@ -460,15 +500,25 @@ big_clock_screen (int rep, int display)
|
|||||||
//+--------------------+
|
//+--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
essential_clock_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
essential_clock_screen (int rep, int display)
|
essential_clock_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
|
||||||
struct tm *rtime;
|
struct tm *rtime;
|
||||||
struct timeval ttime;
|
struct timeval ttime;
|
||||||
static char colon[] = {':', ' '};
|
static char colon[] = {':', ' '};
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string (sock, "screen_add E\n");
|
sock_send_string (sock, "screen_add E\n");
|
||||||
sock_send_string (sock, "screen_set E -name {Essential Clock Screen} -heartbeat off\n");
|
sock_send_string (sock, "screen_set E -name {Essential Clock Screen} -heartbeat off\n");
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
#ifndef CHRONO_H
|
#ifndef CHRONO_H
|
||||||
#define CHRONO_H
|
#define CHRONO_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int clock_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int uptime_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int time_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int big_clock_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int essential_clock_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int clock_screen (int rep, int display);
|
int clock_screen (int rep, int display);
|
||||||
int uptime_screen (int rep, int display);
|
int uptime_screen (int rep, int display);
|
||||||
int time_screen (int rep, int display);
|
int time_screen (int rep, int display);
|
||||||
int big_clock_screen (int rep, int display);
|
int big_clock_screen (int rep, int display);
|
||||||
int essential_clock_screen (int rep, int display);
|
int essential_clock_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+32
-12
@@ -29,11 +29,14 @@
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
cpu_screen(int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
cpu_screen(int rep, int display)
|
cpu_screen(int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#undef CPU_BUF_SIZE
|
#undef CPU_BUF_SIZE
|
||||||
#define CPU_BUF_SIZE 4
|
#define CPU_BUF_SIZE 4
|
||||||
static int first = TRUE;
|
|
||||||
static double cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
static double cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
||||||
static int gauge_wid = 0;
|
static int gauge_wid = 0;
|
||||||
static int usni_wid = 0;
|
static int usni_wid = 0;
|
||||||
@@ -41,9 +44,16 @@ cpu_screen(int rep, int display)
|
|||||||
int i, j, n;
|
int i, j, n;
|
||||||
double value;
|
double value;
|
||||||
load_type load;
|
load_type load;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string(sock, "screen_add C\n");
|
sock_send_string(sock, "screen_add C\n");
|
||||||
sprintf(buffer, "screen_set C -name {CPU Use: %s}\n", get_hostname());
|
sprintf(buffer, "screen_set C -name {CPU Use: %s}\n", get_hostname());
|
||||||
@@ -121,27 +131,27 @@ cpu_screen(int rep, int display)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
// Only clear on first display...
|
// Only clear on first display...
|
||||||
if(!rep){
|
if (!rep) {
|
||||||
// Make all the same, if this is the first time...
|
// Make all the same, if this is the first time...
|
||||||
for(i=0; i<CPU_BUF_SIZE-1; i++)
|
for (i=0; i < CPU_BUF_SIZE-1; i++)
|
||||||
for(j=0; j<5; j++)
|
for (j=0; j < 5; j++)
|
||||||
cpu[i][j] = cpu[CPU_BUF_SIZE-1][j];
|
cpu[i][j] = cpu[CPU_BUF_SIZE-1][j];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Average values for final result
|
// Average values for final result
|
||||||
for(i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
for(j = 0; j < CPU_BUF_SIZE; j++)
|
for (j = 0; j < CPU_BUF_SIZE; j++)
|
||||||
value += cpu[j][i];
|
value += cpu[j][i];
|
||||||
value /= CPU_BUF_SIZE;
|
value /= CPU_BUF_SIZE;
|
||||||
cpu[CPU_BUF_SIZE][i] = value;
|
cpu[CPU_BUF_SIZE][i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!display)
|
if (!display)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
if(lcd_hgt >= 4) { // 4-line display
|
if (lcd_hgt >= 4) { // 4-line display
|
||||||
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
sprintf_percent(tmp, cpu[CPU_BUF_SIZE][4]);
|
||||||
sprintf(buffer, "widget_set C title {CPU %5s: %s}\n", tmp, get_hostname());
|
sprintf(buffer, "widget_set C title {CPU %5s: %s}\n", tmp, get_hostname());
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
@@ -208,11 +218,14 @@ cpu_screen(int rep, int display)
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
cpu_graph_screen(int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
cpu_graph_screen(int rep, int display)
|
cpu_graph_screen(int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#undef CPU_BUF_SIZE
|
#undef CPU_BUF_SIZE
|
||||||
#define CPU_BUF_SIZE 2
|
#define CPU_BUF_SIZE 2
|
||||||
static int first = TRUE;
|
|
||||||
static double cpu[CPU_BUF_SIZE];
|
static double cpu[CPU_BUF_SIZE];
|
||||||
static int cpu_past[LCD_MAX_WIDTH];
|
static int cpu_past[LCD_MAX_WIDTH];
|
||||||
static int gauge_hgt = 0;
|
static int gauge_hgt = 0;
|
||||||
@@ -220,15 +233,22 @@ cpu_graph_screen(int rep, int display)
|
|||||||
int i, n = 0;
|
int i, n = 0;
|
||||||
double value ;
|
double value ;
|
||||||
load_type load;
|
load_type load;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
||||||
|
|
||||||
sock_send_string(sock, "screen_add G\n");
|
sock_send_string(sock, "screen_add G\n");
|
||||||
sprintf(buffer, "screen_set G -name {CPU Graph: %s}\n", get_hostname());
|
sprintf(buffer, "screen_set G -name {CPU Graph: %s}\n", get_hostname());
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
if(lcd_hgt >= 4) {
|
if (lcd_hgt >= 4) {
|
||||||
sock_send_string(sock, "widget_add G title title\n");
|
sock_send_string(sock, "widget_add G title title\n");
|
||||||
sprintf(buffer, "widget_set G title {CPU: %s}\n", get_hostname());
|
sprintf(buffer, "widget_set G title {CPU: %s}\n", get_hostname());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#ifndef CPU_H
|
#ifndef CPU_H
|
||||||
#define CPU_H
|
#define CPU_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int cpu_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int cpu_graph_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int cpu_screen (int rep, int display);
|
int cpu_screen (int rep, int display);
|
||||||
int cpu_graph_screen (int rep, int display);
|
int cpu_graph_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,21 +65,31 @@ static char *numnames[MAX_CPUS] = { "one", "two", "three", "four", "five", "six"
|
|||||||
// CPU screen shows info about percentage of the CPU being used
|
// CPU screen shows info about percentage of the CPU being used
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
cpu_smp_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
cpu_smp_screen (int rep, int display)
|
cpu_smp_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#undef CPU_BUF_SIZE
|
#undef CPU_BUF_SIZE
|
||||||
#define CPU_BUF_SIZE 4
|
#define CPU_BUF_SIZE 4
|
||||||
int i, j, n, z;
|
int i, j, n, z;
|
||||||
static int first = 1;
|
|
||||||
float value;
|
float value;
|
||||||
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
||||||
load_type load[MAX_CPUS];
|
load_type load[MAX_CPUS];
|
||||||
int numprocs;
|
int numprocs;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char *graphsize;
|
char *graphsize;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
machine_get_smpload (load, &numprocs);
|
machine_get_smpload (load, &numprocs);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef CPU_SMP_H
|
#ifndef CPU_SMP_H
|
||||||
#define CPU_SMP_H
|
#define CPU_SMP_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int cpu_smp_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int cpu_smp_screen (int rep, int display);
|
int cpu_smp_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+12
-2
@@ -32,7 +32,11 @@
|
|||||||
//
|
//
|
||||||
// TODO: Disk screen! Requires virtual pages in the server, though...
|
// TODO: Disk screen! Requires virtual pages in the server, though...
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
disk_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
disk_screen (int rep, int display)
|
disk_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static mounts_type mnt[256];
|
static mounts_type mnt[256];
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
@@ -45,15 +49,21 @@ disk_screen (int rep, int display)
|
|||||||
} table[256];
|
} table[256];
|
||||||
int i;
|
int i;
|
||||||
static int num_disks = 0;
|
static int num_disks = 0;
|
||||||
static int first = 1; // First line to display, sort of.
|
|
||||||
static int dev_wid = 6;
|
static int dev_wid = 6;
|
||||||
static int gauge_wid = 6;
|
static int gauge_wid = 6;
|
||||||
|
|
||||||
#define huge long long int
|
#define huge long long int
|
||||||
huge size;
|
huge size;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
dev_wid = (lcd_wid >= 20) ? (lcd_wid - 8) / 2 : (lcd_wid / 2) - 1;
|
dev_wid = (lcd_wid >= 20) ? (lcd_wid - 8) / 2 : (lcd_wid / 2) - 1;
|
||||||
gauge_wid = (lcd_wid >= 20) ? (lcd_wid - dev_wid - 10) : (lcd_wid - dev_wid - 3);
|
gauge_wid = (lcd_wid >= 20) ? (lcd_wid - dev_wid - 10) : (lcd_wid - dev_wid - 3);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef DISK_H
|
#ifndef DISK_H
|
||||||
#define DISK_H
|
#define DISK_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int disk_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int disk_screen (int rep, int display);
|
int disk_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+13
-3
@@ -26,17 +26,27 @@
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
xload_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
xload_screen (int rep, int display)
|
xload_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
|
||||||
static int gauge_hgt = 0;
|
static int gauge_hgt = 0;
|
||||||
static double loads[LCD_MAX_WIDTH];
|
static double loads[LCD_MAX_WIDTH];
|
||||||
int loadtop, i;
|
int loadtop, i;
|
||||||
double loadmax = 0, factor;
|
double loadmax = 0, factor;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
if (first) { // Only the first time this is ever called...
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
first = 0;
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
first = FALSE;
|
||||||
|
#endif
|
||||||
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
||||||
memset (loads, '\0', sizeof (double) * LCD_MAX_WIDTH);
|
memset (loads, '\0', sizeof (double) * LCD_MAX_WIDTH);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
#define LOAD_MIN 0.5
|
#define LOAD_MIN 0.5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int xload_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int xload_screen (int rep, int display);
|
int xload_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ int machine_init()
|
|||||||
lcdproc_port = mach_host_self();
|
lcdproc_port = mach_host_self();
|
||||||
host_page_size(lcdproc_port, &pagesize);
|
host_page_size(lcdproc_port, &pagesize);
|
||||||
|
|
||||||
while(pagesize > 1)
|
while (pagesize > 1)
|
||||||
{
|
{
|
||||||
pageshift++;
|
pageshift++;
|
||||||
pagesize >>= 1;
|
pagesize >>= 1;
|
||||||
@@ -108,10 +108,10 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
|
|
||||||
if (CFArrayGetCount(sources) == 0) return(FALSE);
|
if (CFArrayGetCount(sources) == 0) return(FALSE);
|
||||||
|
|
||||||
for(i = 0; i < CFArrayGetCount(sources); i++)
|
for (i = 0; i < CFArrayGetCount(sources); i++)
|
||||||
{
|
{
|
||||||
pSource = IOPSGetPowerSourceDescription(blob, CFArrayGetValueAtIndex(sources, i));
|
pSource = IOPSGetPowerSourceDescription(blob, CFArrayGetValueAtIndex(sources, i));
|
||||||
if(!pSource) break;
|
if (!pSource) break;
|
||||||
|
|
||||||
psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSNameKey));
|
psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSNameKey));
|
||||||
|
|
||||||
@@ -179,14 +179,14 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
int statcnt, fscnt, i;
|
int statcnt, fscnt, i;
|
||||||
|
|
||||||
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
||||||
if(fscnt == 0)
|
if (fscnt == 0)
|
||||||
{
|
{
|
||||||
perror("getmntinfo");
|
perror("getmntinfo");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
for(statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
for (statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
||||||
{
|
{
|
||||||
if( strcmp(pp->f_fstypename, "procfs")
|
if ( strcmp(pp->f_fstypename, "procfs")
|
||||||
&& strcmp(pp->f_fstypename, "kernfs")
|
&& strcmp(pp->f_fstypename, "kernfs")
|
||||||
&& strcmp(pp->f_fstypename, "linprocfs")
|
&& strcmp(pp->f_fstypename, "linprocfs")
|
||||||
#ifndef STAT_NFS
|
#ifndef STAT_NFS
|
||||||
@@ -202,7 +202,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
||||||
|
|
||||||
fs[statcnt].blocks = pp->f_blocks;
|
fs[statcnt].blocks = pp->f_blocks;
|
||||||
if(fs[statcnt].blocks > 0)
|
if (fs[statcnt].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[statcnt].bsize = pp->f_bsize;
|
fs[statcnt].bsize = pp->f_bsize;
|
||||||
fs[statcnt].bfree = pp->f_bfree;
|
fs[statcnt].bfree = pp->f_bfree;
|
||||||
@@ -240,7 +240,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
load.idle = (unsigned long) (load_info.cpu_ticks[CPU_STATE_IDLE]);
|
load.idle = (unsigned long) (load_info.cpu_ticks[CPU_STATE_IDLE]);
|
||||||
load.total = load.user + load.nice + load.system + load.idle;
|
load.total = load.user + load.nice + load.system + load.idle;
|
||||||
|
|
||||||
if(load.total != last_load.total)
|
if (load.total != last_load.total)
|
||||||
{
|
{
|
||||||
curr_load->user = load.user - last_load.user;
|
curr_load->user = load.user - last_load.user;
|
||||||
curr_load->nice = load.nice - last_load.nice;
|
curr_load->nice = load.nice - last_load.nice;
|
||||||
@@ -263,7 +263,7 @@ int machine_get_loadavg(double *load)
|
|||||||
{
|
{
|
||||||
double loadavg[1];
|
double loadavg[1];
|
||||||
|
|
||||||
if(getloadavg(loadavg, 1) == -1)
|
if (getloadavg(loadavg, 1) == -1)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*load = loadavg[0];
|
*load = loadavg[0];
|
||||||
@@ -296,7 +296,7 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
result[1].total = 0;
|
result[1].total = 0;
|
||||||
result[1].free = 0;
|
result[1].free = 0;
|
||||||
|
|
||||||
if(swapmode(&total_pages, &free_pages) != -1)
|
if (swapmode(&total_pages, &free_pages) != -1)
|
||||||
{
|
{
|
||||||
result[1].total = total_pages;
|
result[1].total = total_pages;
|
||||||
result[1].free = free_pages;
|
result[1].free = free_pages;
|
||||||
@@ -324,7 +324,7 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < nproc; i++)
|
for (i = 0; i < nproc; i++)
|
||||||
{
|
{
|
||||||
if (host_processor_set_priv(lcdproc_port, psets[i], &pset))
|
if (host_processor_set_priv(lcdproc_port, psets[i], &pset))
|
||||||
{
|
{
|
||||||
@@ -333,7 +333,7 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
perror("mem_top_malloc");
|
perror("mem_top_malloc");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -350,19 +350,19 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
load_type curr_load;
|
load_type curr_load;
|
||||||
|
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
if(sysctlbyname("hw.ncpu", &num, &size, NULL, 0) < 0)
|
if (sysctlbyname("hw.ncpu", &num, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl hw.ncpu");
|
perror("sysctl hw.ncpu");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*numcpus = num;
|
*numcpus = num;
|
||||||
num = num > 8 ? 8 : num;
|
num = num > 8 ? 8 : num;
|
||||||
/* Don't know how to get per-cpu-load values */
|
/* Don't know how to get per-cpu-load values */
|
||||||
for(i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
result[i] = curr_load;
|
result[i] = curr_load;
|
||||||
}
|
}
|
||||||
@@ -383,12 +383,12 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
size = sizeof(boottime);
|
size = sizeof(boottime);
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
if(sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
|
if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
|
||||||
boottime.tv_sec != 0)
|
boottime.tv_sec != 0)
|
||||||
|
|
||||||
*up = (double)(now - boottime.tv_sec);
|
*up = (double)(now - boottime.tv_sec);
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
*idle = 100.;
|
*idle = 100.;
|
||||||
else
|
else
|
||||||
*idle = 100.*curr_load.idle/curr_load.total;
|
*idle = 100.*curr_load.idle/curr_load.total;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ int machine_init()
|
|||||||
/* get the page size with "getpagesize" and calculate pageshift from it */
|
/* get the page size with "getpagesize" and calculate pageshift from it */
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
pageshift = 0;
|
pageshift = 0;
|
||||||
while(pagesize > 1)
|
while (pagesize > 1)
|
||||||
{
|
{
|
||||||
pageshift++;
|
pageshift++;
|
||||||
pagesize >>= 1;
|
pagesize >>= 1;
|
||||||
@@ -89,13 +89,13 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
*battflag = LCDP_BATT_ABSENT;
|
*battflag = LCDP_BATT_ABSENT;
|
||||||
*percent = 100;
|
*percent = 100;
|
||||||
|
|
||||||
if((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
if ((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
||||||
{
|
{
|
||||||
perror("get_battstat_open");
|
perror("get_battstat_open");
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ioctl(apmd, APMIO_GETINFO, &aip) == -1)
|
if (ioctl(apmd, APMIO_GETINFO, &aip) == -1)
|
||||||
{
|
{
|
||||||
perror("get_battstat_ioctl");
|
perror("get_battstat_ioctl");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -134,7 +134,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*percent = aip.ai_batt_life;
|
*percent = aip.ai_batt_life;
|
||||||
if(*percent == 255)
|
if (*percent == 255)
|
||||||
*percent = -1;
|
*percent = -1;
|
||||||
|
|
||||||
close(apmd);
|
close(apmd);
|
||||||
@@ -149,14 +149,14 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
int statcnt, fscnt, i;
|
int statcnt, fscnt, i;
|
||||||
|
|
||||||
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
||||||
if(fscnt == 0)
|
if (fscnt == 0)
|
||||||
{
|
{
|
||||||
perror("getmntinfo");
|
perror("getmntinfo");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
for(statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
for (statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
||||||
{
|
{
|
||||||
if( strcmp(pp->f_fstypename, "procfs")
|
if ( strcmp(pp->f_fstypename, "procfs")
|
||||||
&& strcmp(pp->f_fstypename, "kernfs")
|
&& strcmp(pp->f_fstypename, "kernfs")
|
||||||
&& strcmp(pp->f_fstypename, "linprocfs")
|
&& strcmp(pp->f_fstypename, "linprocfs")
|
||||||
#ifndef STAT_NFS
|
#ifndef STAT_NFS
|
||||||
@@ -172,7 +172,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
||||||
|
|
||||||
fs[statcnt].blocks = pp->f_blocks;
|
fs[statcnt].blocks = pp->f_blocks;
|
||||||
if(fs[statcnt].blocks > 0)
|
if (fs[statcnt].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[statcnt].bsize = pp->f_bsize;
|
fs[statcnt].bsize = pp->f_bsize;
|
||||||
fs[statcnt].bfree = pp->f_bfree;
|
fs[statcnt].bfree = pp->f_bfree;
|
||||||
@@ -197,7 +197,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
size = sizeof(cp_time);
|
size = sizeof(cp_time);
|
||||||
if(sysctlbyname("kern.cp_time", cp_time, &size, NULL, 0) < 0)
|
if (sysctlbyname("kern.cp_time", cp_time, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.cp_time failed");
|
perror("sysctl kern.cp_time failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -209,7 +209,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
||||||
load.total = load.user + load.nice + load.system + load.idle;
|
load.total = load.user + load.nice + load.system + load.idle;
|
||||||
|
|
||||||
if(load.total != last_load.total)
|
if (load.total != last_load.total)
|
||||||
{
|
{
|
||||||
curr_load->user = load.user - last_load.user;
|
curr_load->user = load.user - last_load.user;
|
||||||
curr_load->nice = load.nice - last_load.nice;
|
curr_load->nice = load.nice - last_load.nice;
|
||||||
@@ -231,7 +231,7 @@ int machine_get_loadavg(double *load)
|
|||||||
{
|
{
|
||||||
double loadavg[1];
|
double loadavg[1];
|
||||||
|
|
||||||
if(getloadavg(loadavg, 1) == -1)
|
if (getloadavg(loadavg, 1) == -1)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*load = loadavg[0];
|
*load = loadavg[0];
|
||||||
@@ -246,13 +246,13 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
|
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
|
|
||||||
if(sysctlbyname("vm.stats.vm.v_page_count", &total_pages, &size, NULL, 0) < 0)
|
if (sysctlbyname("vm.stats.vm.v_page_count", &total_pages, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl vm.stats.vm.v_page_count");
|
perror("sysctl vm.stats.vm.v_page_count");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sysctlbyname("vm.stats.vm.v_free_count", &free_pages, &size, NULL, 0) < 0)
|
if (sysctlbyname("vm.stats.vm.v_free_count", &free_pages, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl vm.stats.vm.v_free_count");
|
perror("sysctl vm.stats.vm.v_free_count");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -271,7 +271,7 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
result[1].total = 0;
|
result[1].total = 0;
|
||||||
result[1].free = 0;
|
result[1].free = 0;
|
||||||
|
|
||||||
if(swapmode(&total_pages, &free_pages) != -1)
|
if (swapmode(&total_pages, &free_pages) != -1)
|
||||||
{
|
{
|
||||||
result[1].total = total_pages;
|
result[1].total = total_pages;
|
||||||
result[1].free = free_pages;
|
result[1].free = free_pages;
|
||||||
@@ -287,24 +287,24 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
procinfo_type *p;
|
procinfo_type *p;
|
||||||
kvm_t *kvmd;
|
kvm_t *kvmd;
|
||||||
|
|
||||||
if((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_open");
|
perror("kvm_open");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
||||||
if(kprocs == NULL)
|
if (kprocs == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_getprocs");
|
perror("kvm_getprocs");
|
||||||
kvm_close(kvmd);
|
kvm_close(kvmd);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < nproc; i++)
|
for (i = 0; i < nproc; i++)
|
||||||
{
|
{
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
perror("mem_top_malloc");
|
perror("mem_top_malloc");
|
||||||
kvm_close(kvmd);
|
kvm_close(kvmd);
|
||||||
@@ -340,19 +340,19 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
load_type curr_load;
|
load_type curr_load;
|
||||||
|
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
if(sysctlbyname("hw.ncpu", &num, &size, NULL, 0) < 0)
|
if (sysctlbyname("hw.ncpu", &num, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl hw.ncpu");
|
perror("sysctl hw.ncpu");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*numcpus = num;
|
*numcpus = num;
|
||||||
num = num > 8 ? 8 : num;
|
num = num > 8 ? 8 : num;
|
||||||
/* Don't know how to get per-cpu-load values */
|
/* Don't know how to get per-cpu-load values */
|
||||||
for(i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
result[i] = curr_load;
|
result[i] = curr_load;
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
|
|
||||||
size = sizeof(boottime);
|
size = sizeof(boottime);
|
||||||
time(&now);
|
time(&now);
|
||||||
if(sysctlbyname("kern.boottime", &boottime, &size, NULL, 0) < 0)
|
if (sysctlbyname("kern.boottime", &boottime, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.cp_time failed");
|
perror("sysctl kern.cp_time failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -377,7 +377,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
|
|
||||||
*up = (double)(now - boottime.tv_sec);
|
*up = (double)(now - boottime.tv_sec);
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
*idle = 100.;
|
*idle = 100.;
|
||||||
else
|
else
|
||||||
*idle = 100.*curr_load.idle/curr_load.total;
|
*idle = 100.*curr_load.idle/curr_load.total;
|
||||||
@@ -394,14 +394,14 @@ static int swapmode(int *retavail, int *retfree)
|
|||||||
*retavail = 0;
|
*retavail = 0;
|
||||||
*retfree = 0;
|
*retfree = 0;
|
||||||
|
|
||||||
if((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
||||||
{
|
{
|
||||||
perror("read kvm");
|
perror("read kvm");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = kvm_getswapinfo(kvmd, swapary, 1, 0);
|
n = kvm_getswapinfo(kvmd, swapary, 1, 0);
|
||||||
if(n < 0 || swapary[0].ksw_total == 0)
|
if (n < 0 || swapary[0].ksw_total == 0)
|
||||||
{
|
{
|
||||||
/* strange */
|
/* strange */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,20 +53,20 @@ int machine_init()
|
|||||||
loadavg_fd = -1;
|
loadavg_fd = -1;
|
||||||
meminfo_fd = -1;
|
meminfo_fd = -1;
|
||||||
|
|
||||||
if(uptime_fd == -1)
|
if (uptime_fd == -1)
|
||||||
{
|
{
|
||||||
uptime_fd = open("/proc/uptime", O_RDONLY);
|
uptime_fd = open("/proc/uptime", O_RDONLY);
|
||||||
if(uptime_fd < 0)
|
if (uptime_fd < 0)
|
||||||
{
|
{
|
||||||
perror("open /proc/uptime");
|
perror("open /proc/uptime");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_fd == -1)
|
if (load_fd == -1)
|
||||||
{
|
{
|
||||||
load_fd = open("/proc/stat", O_RDONLY);
|
load_fd = open("/proc/stat", O_RDONLY);
|
||||||
if(load_fd < 0)
|
if (load_fd < 0)
|
||||||
{
|
{
|
||||||
perror("open /proc/stat");
|
perror("open /proc/stat");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -74,10 +74,10 @@ int machine_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_GETLOADAVG
|
#ifndef USE_GETLOADAVG
|
||||||
if(loadavg_fd == -1)
|
if (loadavg_fd == -1)
|
||||||
{
|
{
|
||||||
loadavg_fd = open("/proc/loadavg", O_RDONLY);
|
loadavg_fd = open("/proc/loadavg", O_RDONLY);
|
||||||
if(loadavg_fd < 0)
|
if (loadavg_fd < 0)
|
||||||
{
|
{
|
||||||
perror("open /proc/loadavg");
|
perror("open /proc/loadavg");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -85,20 +85,20 @@ int machine_init()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(meminfo_fd == -1)
|
if (meminfo_fd == -1)
|
||||||
{
|
{
|
||||||
meminfo_fd = open("/proc/meminfo", O_RDONLY);
|
meminfo_fd = open("/proc/meminfo", O_RDONLY);
|
||||||
if(meminfo_fd < 0)
|
if (meminfo_fd < 0)
|
||||||
{
|
{
|
||||||
perror("open /proc/meminfo");
|
perror("open /proc/meminfo");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(batt_fd == -1)
|
if (batt_fd == -1)
|
||||||
{
|
{
|
||||||
batt_fd = open("/proc/apm", O_RDONLY);
|
batt_fd = open("/proc/apm", O_RDONLY);
|
||||||
if(batt_fd < 0)
|
if (batt_fd < 0)
|
||||||
{
|
{
|
||||||
//perror("open /proc/apm");
|
//perror("open /proc/apm");
|
||||||
batt_fd = -1;
|
batt_fd = -1;
|
||||||
@@ -110,25 +110,25 @@ int machine_init()
|
|||||||
|
|
||||||
int machine_close()
|
int machine_close()
|
||||||
{
|
{
|
||||||
if(batt_fd != -1)
|
if (batt_fd != -1)
|
||||||
close(batt_fd);
|
close(batt_fd);
|
||||||
batt_fd = -1;
|
batt_fd = -1;
|
||||||
|
|
||||||
if(load_fd != -1)
|
if (load_fd != -1)
|
||||||
close(load_fd);
|
close(load_fd);
|
||||||
load_fd = -1;
|
load_fd = -1;
|
||||||
|
|
||||||
#ifndef USE_GETLOADAVG
|
#ifndef USE_GETLOADAVG
|
||||||
if(loadavg_fd != -1)
|
if (loadavg_fd != -1)
|
||||||
close(loadavg_fd);
|
close(loadavg_fd);
|
||||||
loadavg_fd = -1;
|
loadavg_fd = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(meminfo_fd != -1)
|
if (meminfo_fd != -1)
|
||||||
close(meminfo_fd);
|
close(meminfo_fd);
|
||||||
meminfo_fd = -1;
|
meminfo_fd = -1;
|
||||||
|
|
||||||
if(uptime_fd != -1)
|
if (uptime_fd != -1)
|
||||||
close(uptime_fd);
|
close(uptime_fd);
|
||||||
uptime_fd = -1;
|
uptime_fd = -1;
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
char str[64];
|
char str[64];
|
||||||
int battstat;
|
int battstat;
|
||||||
|
|
||||||
if(batt_fd == -1)
|
if (batt_fd == -1)
|
||||||
{
|
{
|
||||||
*acstat = LCDP_AC_ON;
|
*acstat = LCDP_AC_ON;
|
||||||
*battflag = LCDP_BATT_ABSENT;
|
*battflag = LCDP_BATT_ABSENT;
|
||||||
@@ -178,28 +178,28 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lseek(batt_fd, 0, 0) != 0)
|
if (lseek(batt_fd, 0, 0) != 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
if(read(batt_fd, str, sizeof(str) - 1) < 0)
|
if (read(batt_fd, str, sizeof(str) - 1) < 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
if(3 > sscanf(str + 13, "0x%x 0x%x 0x%x %d", acstat, &battstat, battflag, percent))
|
if (3 > sscanf(str + 13, "0x%x 0x%x 0x%x %d", acstat, &battstat, battflag, percent))
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
if(*battflag == 0xff)
|
if (*battflag == 0xff)
|
||||||
*battflag = LCDP_BATT_UNKNOWN;
|
*battflag = LCDP_BATT_UNKNOWN;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(*battflag & 1)
|
if (*battflag & 1)
|
||||||
*battflag = LCDP_BATT_HIGH;
|
*battflag = LCDP_BATT_HIGH;
|
||||||
if(*battflag & 2)
|
if (*battflag & 2)
|
||||||
*battflag = LCDP_BATT_LOW;
|
*battflag = LCDP_BATT_LOW;
|
||||||
if(*battflag & 4)
|
if (*battflag & 4)
|
||||||
*battflag = LCDP_BATT_CRITICAL;
|
*battflag = LCDP_BATT_CRITICAL;
|
||||||
if(*battflag & 8 || battstat == 3)
|
if (*battflag & 8 || battstat == 3)
|
||||||
*battflag = LCDP_BATT_CHARGING;
|
*battflag = LCDP_BATT_CHARGING;
|
||||||
if(*battflag & 128)
|
if (*battflag & 128)
|
||||||
*battflag = LCDP_BATT_ABSENT;
|
*battflag = LCDP_BATT_ABSENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,9 +241,9 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
// Get rid of old, unmounted filesystems...
|
// Get rid of old, unmounted filesystems...
|
||||||
memset(fs, 0, sizeof(mounts_type) * 256);
|
memset(fs, 0, sizeof(mounts_type) * 256);
|
||||||
|
|
||||||
while(x < 256)
|
while (x < 256)
|
||||||
{
|
{
|
||||||
if(fgets(line, 256, mtab_fd) == NULL)
|
if (fgets(line, 256, mtab_fd) == NULL)
|
||||||
{
|
{
|
||||||
fclose (mtab_fd);
|
fclose (mtab_fd);
|
||||||
*cnt = x;
|
*cnt = x;
|
||||||
@@ -273,7 +273,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
fs[x].blocks = fsinfo.f_blocks;
|
fs[x].blocks = fsinfo.f_blocks;
|
||||||
if(fs[x].blocks > 0)
|
if (fs[x].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[x].bsize = fsinfo.f_bsize;
|
fs[x].bsize = fsinfo.f_bsize;
|
||||||
fs[x].bfree = fsinfo.f_bfree;
|
fs[x].bfree = fsinfo.f_bfree;
|
||||||
@@ -313,7 +313,7 @@ int machine_get_loadavg(double *load)
|
|||||||
#ifdef USE_GETLOADAVG
|
#ifdef USE_GETLOADAVG
|
||||||
double loadavg[LOADAVG_NSTATS];
|
double loadavg[LOADAVG_NSTATS];
|
||||||
|
|
||||||
if(getloadavg(loadavg, LOADAVG_NSTATS) < 0)
|
if (getloadavg(loadavg, LOADAVG_NSTATS) < 0)
|
||||||
{
|
{
|
||||||
perror("getloadavg");
|
perror("getloadavg");
|
||||||
*load = 1.;
|
*load = 1.;
|
||||||
@@ -368,19 +368,19 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
VmRSSLineLen = strlen(VmRSSLine);
|
VmRSSLineLen = strlen(VmRSSLine);
|
||||||
int threshold = 400, unique;
|
int threshold = 400, unique;
|
||||||
|
|
||||||
if((proc = opendir("/proc")) == NULL)
|
if ((proc = opendir("/proc")) == NULL)
|
||||||
{
|
{
|
||||||
perror("mem_top_screen: unable to open /proc");
|
perror("mem_top_screen: unable to open /proc");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while((procdir = readdir(proc)))
|
while ((procdir = readdir(proc)))
|
||||||
{
|
{
|
||||||
if(!index("1234567890", procdir->d_name[0]))
|
if (!index("1234567890", procdir->d_name[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprintf(buf, "/proc/%s/status", procdir->d_name);
|
sprintf(buf, "/proc/%s/status", procdir->d_name);
|
||||||
if((StatusFile = fopen(buf, "r")) == NULL)
|
if ((StatusFile = fopen(buf, "r")) == NULL)
|
||||||
{
|
{
|
||||||
// Not a serious error; process has finished before we could
|
// Not a serious error; process has finished before we could
|
||||||
// examine it:
|
// examine it:
|
||||||
@@ -388,29 +388,29 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
procRSS = procSize = procData = procStk = procExe = 0;
|
procRSS = procSize = procData = procStk = procExe = 0;
|
||||||
while(fgets(buf, sizeof(buf), StatusFile))
|
while (fgets(buf, sizeof(buf), StatusFile))
|
||||||
{
|
{
|
||||||
if(!strncmp(buf, NameLine, NameLineLen))
|
if (!strncmp(buf, NameLine, NameLineLen))
|
||||||
{
|
{
|
||||||
/* Name: procName */
|
/* Name: procName */
|
||||||
sscanf(buf, "%*s %s", procName);
|
sscanf(buf, "%*s %s", procName);
|
||||||
} else if(!strncmp(buf, VmSizeLine, VmSizeLineLen))
|
} else if (!strncmp(buf, VmSizeLine, VmSizeLineLen))
|
||||||
{
|
{
|
||||||
/* VmSize: procSize kB */
|
/* VmSize: procSize kB */
|
||||||
sscanf(buf, "%*s %d", &procSize);
|
sscanf(buf, "%*s %d", &procSize);
|
||||||
} else if(!strncmp (buf, VmRSSLine, VmRSSLineLen))
|
} else if (!strncmp (buf, VmRSSLine, VmRSSLineLen))
|
||||||
{
|
{
|
||||||
/* VmRSS: procRSS kB */
|
/* VmRSS: procRSS kB */
|
||||||
sscanf(buf, "%*s %d", &procRSS);
|
sscanf(buf, "%*s %d", &procRSS);
|
||||||
} else if(!strncmp(buf, VmDataLine, VmDataLineLen))
|
} else if (!strncmp(buf, VmDataLine, VmDataLineLen))
|
||||||
{
|
{
|
||||||
/* VmData: procData kB */
|
/* VmData: procData kB */
|
||||||
sscanf(buf, "%*s %d", &procData);
|
sscanf(buf, "%*s %d", &procData);
|
||||||
} else if(!strncmp(buf, VmStkLine, VmStkLineLen))
|
} else if (!strncmp(buf, VmStkLine, VmStkLineLen))
|
||||||
{
|
{
|
||||||
/* VmStk: procStk kB */
|
/* VmStk: procStk kB */
|
||||||
sscanf(buf, "%*s %d", &procStk);
|
sscanf(buf, "%*s %d", &procStk);
|
||||||
} else if(!strncmp(buf, VmExeLine, VmExeLineLen))
|
} else if (!strncmp(buf, VmExeLine, VmExeLineLen))
|
||||||
{
|
{
|
||||||
/* VmExe: procExe kB */
|
/* VmExe: procExe kB */
|
||||||
sscanf(buf, "%*s %d", &procExe);
|
sscanf(buf, "%*s %d", &procExe);
|
||||||
@@ -418,7 +418,7 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
}
|
}
|
||||||
fclose(StatusFile);
|
fclose(StatusFile);
|
||||||
|
|
||||||
if(procSize > threshold)
|
if (procSize > threshold)
|
||||||
{
|
{
|
||||||
// Figure out if it's sharing any memory...
|
// Figure out if it's sharing any memory...
|
||||||
unique = 1;
|
unique = 1;
|
||||||
@@ -426,22 +426,22 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
p = LL_Get (procs);
|
p = LL_Get (procs);
|
||||||
if(p)
|
if (p)
|
||||||
{
|
{
|
||||||
if(0 == strcmp(p->name, procName))
|
if (0 == strcmp(p->name, procName))
|
||||||
{
|
{
|
||||||
unique = 0;
|
unique = 0;
|
||||||
p->number++;
|
p->number++;
|
||||||
p->totl += procData + procStk + procExe;
|
p->totl += procData + procStk + procExe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(LL_Next(procs) == 0);
|
} while (LL_Next(procs) == 0);
|
||||||
|
|
||||||
// If this is the first one by this name...
|
// If this is the first one by this name...
|
||||||
if(unique)
|
if (unique)
|
||||||
{
|
{
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
perror("mem_top_screen: Error allocating process entry");
|
perror("mem_top_screen: Error allocating process entry");
|
||||||
break;
|
break;
|
||||||
@@ -471,9 +471,9 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
|
|
||||||
// Look for lines starting with "cpu0", "cpu1", etc.
|
// Look for lines starting with "cpu0", "cpu1", etc.
|
||||||
token = strtok(procbuf, "\n");
|
token = strtok(procbuf, "\n");
|
||||||
while(token)
|
while (token)
|
||||||
{
|
{
|
||||||
if((strlen(token) > 3) && (!strncmp(token, "cpu", 3)) && isdigit(token[3]))
|
if ((strlen(token) > 3) && (!strncmp(token, "cpu", 3)) && isdigit(token[3]))
|
||||||
{
|
{
|
||||||
sscanf(token, "%*s %lu %lu %lu %lu", &curr_load[*numcpus].user, &curr_load[*numcpus].nice, &curr_load[*numcpus].system, &curr_load[*numcpus].idle);
|
sscanf(token, "%*s %lu %lu %lu %lu", &curr_load[*numcpus].user, &curr_load[*numcpus].nice, &curr_load[*numcpus].system, &curr_load[*numcpus].idle);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ int machine_init()
|
|||||||
/* get the page size with "getpagesize" and calculate pageshift from it */
|
/* get the page size with "getpagesize" and calculate pageshift from it */
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
pageshift = 0;
|
pageshift = 0;
|
||||||
while(pagesize > 1)
|
while (pagesize > 1)
|
||||||
{
|
{
|
||||||
pageshift++;
|
pageshift++;
|
||||||
pagesize >>= 1;
|
pagesize >>= 1;
|
||||||
@@ -93,7 +93,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
int apmd;
|
int apmd;
|
||||||
struct apm_power_info apmi;
|
struct apm_power_info apmi;
|
||||||
|
|
||||||
if((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
if ((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
||||||
{
|
{
|
||||||
*acstat = LCDP_AC_ON;
|
*acstat = LCDP_AC_ON;
|
||||||
*battflag = LCDP_BATT_ABSENT;
|
*battflag = LCDP_BATT_ABSENT;
|
||||||
@@ -102,7 +102,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(&apmi, 0, sizeof(apmi));
|
memset(&apmi, 0, sizeof(apmi));
|
||||||
if(ioctl(apmd, APM_IOC_GETPOWER, &apmi) == -1)
|
if (ioctl(apmd, APM_IOC_GETPOWER, &apmi) == -1)
|
||||||
{
|
{
|
||||||
perror("APM_IOC_GETPOWER failed in get_batt_stat()");
|
perror("APM_IOC_GETPOWER failed in get_batt_stat()");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -144,14 +144,14 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
int statcnt, fscnt, i;
|
int statcnt, fscnt, i;
|
||||||
|
|
||||||
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
||||||
if(fscnt == 0)
|
if (fscnt == 0)
|
||||||
{
|
{
|
||||||
perror("getmntinfo");
|
perror("getmntinfo");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
for(statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
for (statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
||||||
{
|
{
|
||||||
if(strcmp(pp->f_fstypename, "procfs")
|
if (strcmp(pp->f_fstypename, "procfs")
|
||||||
&& strcmp(pp->f_fstypename, "kernfs")
|
&& strcmp(pp->f_fstypename, "kernfs")
|
||||||
&& strcmp(pp->f_fstypename, "linprocfs")
|
&& strcmp(pp->f_fstypename, "linprocfs")
|
||||||
#ifndef STAT_NFS
|
#ifndef STAT_NFS
|
||||||
@@ -167,7 +167,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
||||||
|
|
||||||
fs[statcnt].blocks = pp->f_blocks;
|
fs[statcnt].blocks = pp->f_blocks;
|
||||||
if(fs[statcnt].blocks > 0)
|
if (fs[statcnt].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[statcnt].bsize = pp->f_bsize;
|
fs[statcnt].bsize = pp->f_bsize;
|
||||||
fs[statcnt].bfree = pp->f_bfree;
|
fs[statcnt].bfree = pp->f_bfree;
|
||||||
@@ -194,7 +194,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
mib[0] = CTL_KERN;
|
mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_CP_TIME;
|
mib[1] = KERN_CP_TIME;
|
||||||
size = sizeof(cp_time);
|
size = sizeof(cp_time);
|
||||||
if(sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.cp_time failed");
|
perror("sysctl kern.cp_time failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -206,7 +206,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
||||||
load.total = load.user + load.nice + load.system + load.idle;
|
load.total = load.user + load.nice + load.system + load.idle;
|
||||||
|
|
||||||
if(load.total != last_load.total)
|
if (load.total != last_load.total)
|
||||||
{
|
{
|
||||||
curr_load->user = load.user - last_load.user;
|
curr_load->user = load.user - last_load.user;
|
||||||
curr_load->nice = load.nice - last_load.nice;
|
curr_load->nice = load.nice - last_load.nice;
|
||||||
@@ -228,7 +228,7 @@ int machine_get_loadavg(double *load)
|
|||||||
{
|
{
|
||||||
double loadavg[1];
|
double loadavg[1];
|
||||||
|
|
||||||
if(getloadavg(loadavg, 1) == -1)
|
if (getloadavg(loadavg, 1) == -1)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*load = loadavg[0];
|
*load = loadavg[0];
|
||||||
@@ -245,7 +245,7 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
mib[0] = CTL_VM;
|
mib[0] = CTL_VM;
|
||||||
mib[1] = VM_UVMEXP2;
|
mib[1] = VM_UVMEXP2;
|
||||||
size = sizeof(uvmexp);
|
size = sizeof(uvmexp);
|
||||||
if(sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl vm.uvmexp2 failed");
|
perror("sysctl vm.uvmexp2 failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -276,23 +276,23 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
procinfo_type *p;
|
procinfo_type *p;
|
||||||
|
|
||||||
kprocs = NULL;
|
kprocs = NULL;
|
||||||
if((kvmd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open")) == NULL)
|
if ((kvmd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open")) == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_openfiles");
|
perror("kvm_openfiles");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
kprocs = kvm_getproc2(kvmd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), &nproc);
|
kprocs = kvm_getproc2(kvmd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), &nproc);
|
||||||
if(kprocs == NULL)
|
if (kprocs == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_getproc2");
|
perror("kvm_getproc2");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < nproc; i++)
|
for (i = 0; i < nproc; i++)
|
||||||
{
|
{
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
perror("mem_top_malloc");
|
perror("mem_top_malloc");
|
||||||
kvm_close(kvmd);
|
kvm_close(kvmd);
|
||||||
@@ -322,19 +322,19 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
|
|
||||||
if(sysctl(mib, 2, &num, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &num, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl hw.ncpu");
|
perror("sysctl hw.ncpu");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*numcpus = num;
|
*numcpus = num;
|
||||||
num = num > 8 ? 8 : num;
|
num = num > 8 ? 8 : num;
|
||||||
/* Don't know how to get per-cpu-load values */
|
/* Don't know how to get per-cpu-load values */
|
||||||
for(i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
result[i] = curr_load;
|
result[i] = curr_load;
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
mib[1] = KERN_BOOTTIME;
|
mib[1] = KERN_BOOTTIME;
|
||||||
size = sizeof(boottime);
|
size = sizeof(boottime);
|
||||||
time(&now);
|
time(&now);
|
||||||
if(sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.boottime failed");
|
perror("sysctl kern.boottime failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -362,7 +362,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
|
|
||||||
*up = (double)(now - boottime.tv_sec);
|
*up = (double)(now - boottime.tv_sec);
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
*idle = 100.;
|
*idle = 100.;
|
||||||
else
|
else
|
||||||
*idle = 100.*curr_load.idle/curr_load.total;
|
*idle = 100.*curr_load.idle/curr_load.total;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ int machine_init()
|
|||||||
/* get the page size with "getpagesize" and calculate pageshift from it */
|
/* get the page size with "getpagesize" and calculate pageshift from it */
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
pageshift = 0;
|
pageshift = 0;
|
||||||
while(pagesize > 1)
|
while (pagesize > 1)
|
||||||
{
|
{
|
||||||
pageshift++;
|
pageshift++;
|
||||||
pagesize >>= 1;
|
pagesize >>= 1;
|
||||||
@@ -91,13 +91,13 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
|
|||||||
*battflag = LCDP_BATT_ABSENT;
|
*battflag = LCDP_BATT_ABSENT;
|
||||||
*percent = 100;
|
*percent = 100;
|
||||||
|
|
||||||
if((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
if ((apmd = open("/dev/apm", O_RDONLY)) == -1)
|
||||||
{
|
{
|
||||||
perror("get_battstat_open");
|
perror("get_battstat_open");
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ioctl(apmd, APM_IOC_GETPOWER, &api) == -1)
|
if (ioctl(apmd, APM_IOC_GETPOWER, &api) == -1)
|
||||||
{
|
{
|
||||||
perror("get_battstat_ioctl");
|
perror("get_battstat_ioctl");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -152,14 +152,14 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
int statcnt, fscnt, i;
|
int statcnt, fscnt, i;
|
||||||
|
|
||||||
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
|
||||||
if(fscnt == 0)
|
if (fscnt == 0)
|
||||||
{
|
{
|
||||||
perror("getmntinfo");
|
perror("getmntinfo");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
for(statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
for (statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
|
||||||
{
|
{
|
||||||
if(strcmp(pp->f_fstypename, "procfs")
|
if (strcmp(pp->f_fstypename, "procfs")
|
||||||
&& strcmp(pp->f_fstypename, "kernfs")
|
&& strcmp(pp->f_fstypename, "kernfs")
|
||||||
&& strcmp(pp->f_fstypename, "linprocfs")
|
&& strcmp(pp->f_fstypename, "linprocfs")
|
||||||
#ifndef STAT_NFS
|
#ifndef STAT_NFS
|
||||||
@@ -175,7 +175,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
|
||||||
|
|
||||||
fs[statcnt].blocks = pp->f_blocks;
|
fs[statcnt].blocks = pp->f_blocks;
|
||||||
if(fs[statcnt].blocks > 0)
|
if (fs[statcnt].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[statcnt].bsize = pp->f_bsize;
|
fs[statcnt].bsize = pp->f_bsize;
|
||||||
fs[statcnt].bfree = pp->f_bfree;
|
fs[statcnt].bfree = pp->f_bfree;
|
||||||
@@ -202,7 +202,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
mib[0] = CTL_KERN;
|
mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_CPTIME;
|
mib[1] = KERN_CPTIME;
|
||||||
size = sizeof(cp_time);
|
size = sizeof(cp_time);
|
||||||
if(sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.cp_time failed");
|
perror("sysctl kern.cp_time failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -214,7 +214,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
load.idle = (unsigned long) (cp_time[CP_IDLE]);
|
||||||
load.total = load.user + load.nice + load.system + load.idle;
|
load.total = load.user + load.nice + load.system + load.idle;
|
||||||
|
|
||||||
if(load.total != last_load.total)
|
if (load.total != last_load.total)
|
||||||
{
|
{
|
||||||
curr_load->user = load.user - last_load.user;
|
curr_load->user = load.user - last_load.user;
|
||||||
curr_load->nice = load.nice - last_load.nice;
|
curr_load->nice = load.nice - last_load.nice;
|
||||||
@@ -236,7 +236,7 @@ int machine_get_loadavg(double *load)
|
|||||||
{
|
{
|
||||||
double loadavg[1];
|
double loadavg[1];
|
||||||
|
|
||||||
if(getloadavg(loadavg, 1) == -1)
|
if (getloadavg(loadavg, 1) == -1)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*load = loadavg[0];
|
*load = loadavg[0];
|
||||||
@@ -254,7 +254,7 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
mib[1] = VM_UVMEXP;
|
mib[1] = VM_UVMEXP;
|
||||||
size = sizeof(suvm);
|
size = sizeof(suvm);
|
||||||
|
|
||||||
if(sysctl(mib, 2, &suvm, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &suvm, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl vm.uvmexp failed");
|
perror("sysctl vm.uvmexp failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -284,24 +284,24 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
procinfo_type *p;
|
procinfo_type *p;
|
||||||
kvm_t *kvmd;
|
kvm_t *kvmd;
|
||||||
|
|
||||||
if((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_open");
|
perror("kvm_open");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
||||||
if(kprocs == NULL)
|
if (kprocs == NULL)
|
||||||
{
|
{
|
||||||
perror("kvm_getprocs");
|
perror("kvm_getprocs");
|
||||||
kvm_close(kvmd);
|
kvm_close(kvmd);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < nproc; i++)
|
for (i = 0; i < nproc; i++)
|
||||||
{
|
{
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
perror("mem_top_malloc");
|
perror("mem_top_malloc");
|
||||||
kvm_close(kvmd);
|
kvm_close(kvmd);
|
||||||
@@ -330,19 +330,19 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
|
|
||||||
if(sysctl(mib, 2, &num, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &num, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl hw.ncpu");
|
perror("sysctl hw.ncpu");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*numcpus = num;
|
*numcpus = num;
|
||||||
num = num > 8 ? 8 : num;
|
num = num > 8 ? 8 : num;
|
||||||
/* Don't know how to get per-cpu-load values */
|
/* Don't know how to get per-cpu-load values */
|
||||||
for(i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
result[i] = curr_load;
|
result[i] = curr_load;
|
||||||
}
|
}
|
||||||
@@ -362,7 +362,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
mib[1] = KERN_BOOTTIME;
|
mib[1] = KERN_BOOTTIME;
|
||||||
size = sizeof(boottime);
|
size = sizeof(boottime);
|
||||||
time(&now);
|
time(&now);
|
||||||
if(sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
|
if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
|
||||||
{
|
{
|
||||||
perror("sysctl kern.boottime failed");
|
perror("sysctl kern.boottime failed");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -370,7 +370,7 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
|
|
||||||
*up = (double)(now - boottime.tv_sec);
|
*up = (double)(now - boottime.tv_sec);
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
*idle = 100.;
|
*idle = 100.;
|
||||||
else
|
else
|
||||||
*idle = 100.*curr_load.idle/curr_load.total;
|
*idle = 100.*curr_load.idle/curr_load.total;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ int machine_init()
|
|||||||
kc = NULL;
|
kc = NULL;
|
||||||
|
|
||||||
kc = kstat_open();
|
kc = kstat_open();
|
||||||
if(kc == NULL)
|
if (kc == NULL)
|
||||||
{
|
{
|
||||||
perror("kstat_open");
|
perror("kstat_open");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -48,7 +48,7 @@ int machine_init()
|
|||||||
|
|
||||||
int machine_close()
|
int machine_close()
|
||||||
{
|
{
|
||||||
if(kc != NULL)
|
if (kc != NULL)
|
||||||
{
|
{
|
||||||
kstat_close(kc);
|
kstat_close(kc);
|
||||||
kc = NULL;
|
kc = NULL;
|
||||||
@@ -87,9 +87,9 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
// Get rid of old, unmounted filesystems...
|
// Get rid of old, unmounted filesystems...
|
||||||
memset(fs, 0, sizeof(mounts_type) * 256);
|
memset(fs, 0, sizeof(mounts_type) * 256);
|
||||||
|
|
||||||
while(x < 256)
|
while (x < 256)
|
||||||
{
|
{
|
||||||
if(fgets(line, 256, mtab_fd) == NULL)
|
if (fgets(line, 256, mtab_fd) == NULL)
|
||||||
{
|
{
|
||||||
fclose(mtab_fd);
|
fclose(mtab_fd);
|
||||||
*cnt = x;
|
*cnt = x;
|
||||||
@@ -98,7 +98,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
|
|
||||||
sscanf(line, "%s %s %s", fs[x].dev, fs[x].mpoint, fs[x].type);
|
sscanf(line, "%s %s %s", fs[x].dev, fs[x].mpoint, fs[x].type);
|
||||||
|
|
||||||
if( strcmp(fs[x].type, "proc")
|
if ( strcmp(fs[x].type, "proc")
|
||||||
#ifndef STAT_NFS
|
#ifndef STAT_NFS
|
||||||
&& strcmp(fs[x].type, "nfs")
|
&& strcmp(fs[x].type, "nfs")
|
||||||
#endif
|
#endif
|
||||||
@@ -118,7 +118,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
fs[x].blocks = fsinfo.f_blocks;
|
fs[x].blocks = fsinfo.f_blocks;
|
||||||
if(fs[x].blocks > 0)
|
if (fs[x].blocks > 0)
|
||||||
{
|
{
|
||||||
fs[x].bsize = fsinfo.f_bsize;
|
fs[x].bsize = fsinfo.f_bsize;
|
||||||
fs[x].bfree = fsinfo.f_bfree;
|
fs[x].bfree = fsinfo.f_bfree;
|
||||||
@@ -144,25 +144,25 @@ int machine_get_load(load_type *curr_load)
|
|||||||
struct cpu_stat cinfo;
|
struct cpu_stat cinfo;
|
||||||
|
|
||||||
k_space = kstat_lookup(kc, "cpu_stat", 0, "cpu_stat0");
|
k_space = kstat_lookup(kc, "cpu_stat", 0, "cpu_stat0");
|
||||||
if(k_space == NULL)
|
if (k_space == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "kstat lookup error\n");
|
fprintf(stderr, "kstat lookup error\n");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kstat_read(kc, k_space, NULL) == -1)
|
if (kstat_read(kc, k_space, NULL) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "kstat read error\n");
|
fprintf(stderr, "kstat read error\n");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
k_space = kstat_lookup(kc, "cpu_stat", -1, "cpu_stat0");
|
k_space = kstat_lookup(kc, "cpu_stat", -1, "cpu_stat0");
|
||||||
if(k_space == NULL)
|
if (k_space == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "kstat lookup error\n");
|
fprintf(stderr, "kstat lookup error\n");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if(kstat_read(kc, k_space, &cinfo) == -1)
|
if (kstat_read(kc, k_space, &cinfo) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "kstat read error\n");
|
fprintf(stderr, "kstat read error\n");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -173,7 +173,7 @@ int machine_get_load(load_type *curr_load)
|
|||||||
load.nice = cinfo.cpu_sysinfo.cpu[CPU_WAIT];
|
load.nice = cinfo.cpu_sysinfo.cpu[CPU_WAIT];
|
||||||
load.total = load.user + load.nice + load.system + load.idle;
|
load.total = load.user + load.nice + load.system + load.idle;
|
||||||
|
|
||||||
if(load.total != last_load.total)
|
if (load.total != last_load.total)
|
||||||
{
|
{
|
||||||
curr_load->user = load.user - last_load.user;
|
curr_load->user = load.user - last_load.user;
|
||||||
curr_load->nice = load.nice - last_load.nice;
|
curr_load->nice = load.nice - last_load.nice;
|
||||||
@@ -195,7 +195,7 @@ int machine_get_loadavg(double *load)
|
|||||||
{
|
{
|
||||||
double loadavg[1];
|
double loadavg[1];
|
||||||
|
|
||||||
if(getloadavg(loadavg, 1) == -1)
|
if (getloadavg(loadavg, 1) == -1)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*load = loadavg[0];
|
*load = loadavg[0];
|
||||||
@@ -219,47 +219,47 @@ int machine_get_meminfo(meminfo_type *result)
|
|||||||
result[0].cache = 0;
|
result[0].cache = 0;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if((num = swapctl(SC_GETNSWP, 0)) == -1)
|
if ((num = swapctl(SC_GETNSWP, 0)) == -1)
|
||||||
{
|
{
|
||||||
perror("swapctl: GETNSWP");
|
perror("swapctl: GETNSWP");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(num == 0)
|
if (num == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No Swap Devices Configured\n");
|
fprintf(stderr, "No Swap Devices Configured\n");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate swaptable for num+1 entries */
|
/* allocate swaptable for num+1 entries */
|
||||||
if((s = (swaptbl_t*)malloc(num * sizeof(swapent_t) + sizeof(struct swaptable))) == NULL)
|
if ((s = (swaptbl_t*)malloc(num * sizeof(swapent_t) + sizeof(struct swaptable))) == NULL)
|
||||||
{
|
{
|
||||||
perror("malloc swap");
|
perror("malloc swap");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate num+1 string holders */
|
/* allocate num+1 string holders */
|
||||||
if((strtab = (char*)malloc((num + 1) * MAXSTRSIZE)) == NULL)
|
if ((strtab = (char*)malloc((num + 1) * MAXSTRSIZE)) == NULL)
|
||||||
{
|
{
|
||||||
perror("malloc string holder");
|
perror("malloc string holder");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize string pointers */
|
/* initialize string pointers */
|
||||||
for(i = 0; i < (num + 1); i++)
|
for (i = 0; i < (num + 1); i++)
|
||||||
{
|
{
|
||||||
s->swt_ent[i].ste_path = strtab + (i * MAXSTRSIZE);
|
s->swt_ent[i].ste_path = strtab + (i * MAXSTRSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->swt_n = num + 1;
|
s->swt_n = num + 1;
|
||||||
if((n = swapctl(SC_LIST, s)) < 0)
|
if ((n = swapctl(SC_LIST, s)) < 0)
|
||||||
{
|
{
|
||||||
perror("swapctl");
|
perror("swapctl");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* more were added */
|
/* more were added */
|
||||||
if(n > num)
|
if (n > num)
|
||||||
{
|
{
|
||||||
free(s);
|
free(s);
|
||||||
free(strtab);
|
free(strtab);
|
||||||
@@ -269,7 +269,7 @@ again:
|
|||||||
result[1].total = 0;
|
result[1].total = 0;
|
||||||
result[1].free = 0;
|
result[1].free = 0;
|
||||||
|
|
||||||
for(i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
result[1].total = result[1].total + s->swt_ent[i].ste_pages * sysconf(_SC_PAGESIZE) / 1024;
|
result[1].total = result[1].total + s->swt_ent[i].ste_pages * sysconf(_SC_PAGESIZE) / 1024;
|
||||||
result[1].free = result[1].free + s->swt_ent[i].ste_free * sysconf(_SC_PAGESIZE) / 1024;
|
result[1].free = result[1].free + s->swt_ent[i].ste_free * sysconf(_SC_PAGESIZE) / 1024;
|
||||||
@@ -290,21 +290,21 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
int procSize, procRSS, procData, procStk, procExe;
|
int procSize, procRSS, procData, procStk, procExe;
|
||||||
int threshold = 400, unique;
|
int threshold = 400, unique;
|
||||||
|
|
||||||
if((proc = opendir("/proc")) == NULL)
|
if ((proc = opendir("/proc")) == NULL)
|
||||||
{
|
{
|
||||||
perror("open /proc");
|
perror("open /proc");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while((procdir = readdir(proc)))
|
while ((procdir = readdir(proc)))
|
||||||
{
|
{
|
||||||
psinfo_t psinfo;
|
psinfo_t psinfo;
|
||||||
|
|
||||||
if(!index("1234567890", procdir->d_name[0]))
|
if (!index("1234567890", procdir->d_name[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprintf(buf, "/proc/%s/psinfo", procdir->d_name);
|
sprintf(buf, "/proc/%s/psinfo", procdir->d_name);
|
||||||
if((StatusFile = fopen(buf, "r")) == NULL)
|
if ((StatusFile = fopen(buf, "r")) == NULL)
|
||||||
{
|
{
|
||||||
// Not a serious error; process has finished before we could
|
// Not a serious error; process has finished before we could
|
||||||
// examine it:
|
// examine it:
|
||||||
@@ -324,7 +324,7 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
|
|
||||||
fclose(StatusFile);
|
fclose(StatusFile);
|
||||||
|
|
||||||
if(procSize > threshold)
|
if (procSize > threshold)
|
||||||
{
|
{
|
||||||
// Figure out if it's sharing any memory...
|
// Figure out if it's sharing any memory...
|
||||||
unique = 1;
|
unique = 1;
|
||||||
@@ -332,22 +332,22 @@ int machine_get_procs(LinkedList *procs)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
p = LL_Get(procs);
|
p = LL_Get(procs);
|
||||||
if(p)
|
if (p)
|
||||||
{
|
{
|
||||||
if(0 == strcmp(p->name, procName))
|
if (0 == strcmp(p->name, procName))
|
||||||
{
|
{
|
||||||
unique = 0;
|
unique = 0;
|
||||||
p->number++;
|
p->number++;
|
||||||
p->totl += procData + procStk + procExe;
|
p->totl += procData + procStk + procExe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}while(LL_Next(procs) == 0);
|
} while (LL_Next(procs) == 0);
|
||||||
|
|
||||||
// If this is the first one by this name...
|
// If this is the first one by this name...
|
||||||
if(unique)
|
if (unique)
|
||||||
{
|
{
|
||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if(p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
perror("allocating process entry");
|
perror("allocating process entry");
|
||||||
goto end; // Ack! I hate goto's!
|
goto end; // Ack! I hate goto's!
|
||||||
@@ -376,12 +376,12 @@ int machine_get_smpload(load_type *result, int *numcpus)
|
|||||||
char buffer[16];
|
char buffer[16];
|
||||||
|
|
||||||
*numcpus = sysconf(_SC_NPROCESSORS_CONF);
|
*numcpus = sysconf(_SC_NPROCESSORS_CONF);
|
||||||
for(count = 0; count < MAX_CPUS; count++)
|
for (count = 0; count < MAX_CPUS; count++)
|
||||||
{
|
{
|
||||||
sprintf(buffer, "cpu_stat%d", count);
|
sprintf(buffer, "cpu_stat%d", count);
|
||||||
|
|
||||||
k_space = kstat_lookup(kc, "cpu_stat", count, buffer);
|
k_space = kstat_lookup(kc, "cpu_stat", count, buffer);
|
||||||
if((k_space != NULL) && (kstat_read(kc, k_space, NULL) != -1))
|
if ((k_space != NULL) && (kstat_read(kc, k_space, NULL) != -1))
|
||||||
{
|
{
|
||||||
struct cpu_stat cinfo;
|
struct cpu_stat cinfo;
|
||||||
|
|
||||||
@@ -426,12 +426,12 @@ int machine_get_uptime(double *up, double *idle)
|
|||||||
id.ut_type = BOOT_TIME;
|
id.ut_type = BOOT_TIME;
|
||||||
|
|
||||||
u = getutxid(&id);
|
u = getutxid(&id);
|
||||||
if(u == NULL)
|
if (u == NULL)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
||||||
*up = time(0) - u->ut_xtime;
|
*up = time(0) - u->ut_xtime;
|
||||||
|
|
||||||
if(machine_get_load(&curr_load) == FALSE)
|
if (machine_get_load(&curr_load) == FALSE)
|
||||||
*idle = 100.;
|
*idle = 100.;
|
||||||
else
|
else
|
||||||
*idle = 100.*curr_load.idle/curr_load.total;
|
*idle = 100.*curr_load.idle/curr_load.total;
|
||||||
|
|||||||
+161
-19
@@ -45,25 +45,37 @@ static void HelpScreen();
|
|||||||
static void exit_program(int val);
|
static void exit_program(int val);
|
||||||
static void main_loop();
|
static void main_loop();
|
||||||
|
|
||||||
static mode *sequence = NULL;
|
|
||||||
static int islow = -1;
|
static int islow = -1;
|
||||||
|
|
||||||
// 1/8th second is a single time unit...
|
// 1/8th second is a single time unit...
|
||||||
#define TIME_UNIT 125000
|
#define TIME_UNIT 125000
|
||||||
|
|
||||||
/* list of modes to run */
|
/* list of modes to run */
|
||||||
static mode default_sequence[] =
|
#ifdef LCDPROC_MENUS
|
||||||
|
mode sequence[] =
|
||||||
{
|
{
|
||||||
// longname which on off inv timer visible
|
// flags default ACTIVE will run by default
|
||||||
|
// longname which on off inv timer flags
|
||||||
|
{ "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE,}, // [C]PU
|
||||||
|
{ "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE,}, // [M]emory
|
||||||
|
{ "Load", 'X', 64, 128, 1, 0xffff, ACTIVE,}, // [X]-load (load histogram)
|
||||||
|
{ "TimeDate", 'T', 4, 64, 0, 0xffff, ACTIVE,}, // [T]ime/Date
|
||||||
|
{ "About", 'A', 999, 9999, 0, 0xffff, ACTIVE,}, // [A]bout (credits)
|
||||||
|
#else
|
||||||
|
mode *sequence = NULL;
|
||||||
|
|
||||||
|
mode default_sequence[] =
|
||||||
|
{
|
||||||
|
// longname which on off inv timer visible/flags
|
||||||
{ "CPU", 'C', 1, 2, 0, 0xffff, 0,}, // [C]PU
|
{ "CPU", 'C', 1, 2, 0, 0xffff, 0,}, // [C]PU
|
||||||
{ "Memory", 'M', 4, 16, 0, 0xffff, 0,}, // [M]emory
|
{ "Memory", 'M', 4, 16, 0, 0xffff, 0,}, // [M]emory
|
||||||
{ "Load", 'X', 64, 128, 1, 0xffff, 0,}, // [X]-load (load histogram)
|
{ "Load", 'X', 64, 128, 1, 0xffff, 0,}, // [X]-load (load histogram)
|
||||||
{ "TimeDate", 'T', 4, 64, 0, 0xffff, 0,}, // [T]ime/Date
|
{ "TimeDate", 'T', 4, 64, 0, 0xffff, 0,}, // [T]ime/Date
|
||||||
{ "About", 'A', 999, 9999, 0, 0xffff, 0,}, // [A]bout (credits)
|
{ "About", 'A', 999, 9999, 0, 0xffff, 0,}, // [A]bout (credits)
|
||||||
|
|
||||||
{ NULL, 1, 0, 0, 0, 0, 0,}, // Modes after this line will not be run by default...
|
{ NULL, 1, 0, 0, 0, 0, 0,}, // Modes after this line will not be run by default...
|
||||||
// ... all non-default modes must be in here!
|
// ... all non-default modes must be in here!
|
||||||
// ... they will not show up otherwise.
|
// ... they will not show up otherwise.
|
||||||
|
#endif
|
||||||
{ "SMP-CPU", 'P', 1, 2, 0, 0xffff, 0,}, // CPU_SM[P]
|
{ "SMP-CPU", 'P', 1, 2, 0, 0xffff, 0,}, // CPU_SM[P]
|
||||||
{ "OldTime", 'O', 4, 64, 0, 0xffff, 0,}, // [O]ld Timescreen
|
{ "OldTime", 'O', 4, 64, 0, 0xffff, 0,}, // [O]ld Timescreen
|
||||||
{ "BigClock", 'K', 4, 64, 0, 0xffff, 0,}, // big cloc[K]
|
{ "BigClock", 'K', 4, 64, 0, 0xffff, 0,}, // big cloc[K]
|
||||||
@@ -76,6 +88,13 @@ static mode default_sequence[] =
|
|||||||
{ NULL, 0, 0, 0, 0, 0,}, // No more.. all done.
|
{ NULL, 0, 0, 0, 0, 0,}, // No more.. all done.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int seqlen = sizeof(sequence) / sizeof(mode);
|
||||||
|
#else
|
||||||
|
int seqlen = sizeof(default_sequence) / sizeof(mode);
|
||||||
|
#endif //LCDPROC_MENUS
|
||||||
|
|
||||||
|
|
||||||
// TODO: Config file; not just command line
|
// TODO: Config file; not just command line
|
||||||
|
|
||||||
const char *get_hostname()
|
const char *get_hostname()
|
||||||
@@ -93,6 +112,38 @@ const char *get_sysrelease()
|
|||||||
return(unamebuf.release);
|
return(unamebuf.release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS //set_mode function
|
||||||
|
int set_mode(int shortname, char * longname, int state)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
/* ignore already selected modes */
|
||||||
|
for (k = 0; (k < seqlen) && (sequence[k].which != 0); k++) {
|
||||||
|
if (((sequence[k].longname != NULL) &&
|
||||||
|
(0 == strcasecmp(longname, sequence[k].longname))) ||
|
||||||
|
(shortname == sequence[k].which)) {
|
||||||
|
if (!state) {
|
||||||
|
sequence[k].flags &= (~ACTIVE & ~INITIALIZED); /* both the active and inititialized bits */
|
||||||
|
sprintf (buffer, "screen_del %c\n", shortname );
|
||||||
|
sock_send_string (sock, buffer);
|
||||||
|
} else
|
||||||
|
sequence[k].flags |= ACTIVE;
|
||||||
|
return 1; //found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; //not found
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_modes()
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
/* ignore already selected modes */
|
||||||
|
for (k = 0; (k < seqlen) && (sequence[k].which != 0); k++) {
|
||||||
|
sequence[k].flags &= (~ACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //LCDPROC_MENUS
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -101,8 +152,6 @@ main(int argc, char **argv)
|
|||||||
char *server = NULL;
|
char *server = NULL;
|
||||||
int port = LCDPORT;
|
int port = LCDPORT;
|
||||||
int daemonize = FALSE;
|
int daemonize = FALSE;
|
||||||
/* determine length of default_sequence[] */
|
|
||||||
int seqlen = sizeof(default_sequence) / sizeof(mode);
|
|
||||||
|
|
||||||
/* get uname information */
|
/* get uname information */
|
||||||
if (uname(&unamebuf) == -1) {
|
if (uname(&unamebuf) == -1) {
|
||||||
@@ -110,6 +159,9 @@ main(int argc, char **argv)
|
|||||||
return(EXIT_FAILURE);
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
// sequence = default_sequence;
|
||||||
|
#else
|
||||||
/* allocate sequence */
|
/* allocate sequence */
|
||||||
sequence = (mode *) malloc(seqlen * sizeof(mode));
|
sequence = (mode *) malloc(seqlen * sizeof(mode));
|
||||||
if (sequence == NULL) {
|
if (sequence == NULL) {
|
||||||
@@ -122,6 +174,7 @@ main(int argc, char **argv)
|
|||||||
//sequence[i] = default_sequence[i];
|
//sequence[i] = default_sequence[i];
|
||||||
memcpy(&sequence[i], &default_sequence[i], sizeof(mode));
|
memcpy(&sequence[i], &default_sequence[i], sizeof(mode));
|
||||||
}
|
}
|
||||||
|
#endif //LCDPROC_MENUS
|
||||||
|
|
||||||
/* setup error handlers */
|
/* setup error handlers */
|
||||||
signal(SIGINT, exit_program); // Ctrl-C
|
signal(SIGINT, exit_program); // Ctrl-C
|
||||||
@@ -164,6 +217,14 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
/* parse arguments */
|
||||||
|
if (argc > 1 ) //user specified some modes, so clear all defaults
|
||||||
|
clear_modes();
|
||||||
|
for (i = (optind > 0) ? optind : 1; i < argc; i++) {
|
||||||
|
int shortname = (strlen(argv[i]) == 1) ? toupper(argv[i][0]) : '\0';
|
||||||
|
int found = set_mode(shortname, argv[i], 1);
|
||||||
|
#else
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
for (i = (optind > 0) ? optind : 1, j = 0; i < argc; i++) {
|
for (i = (optind > 0) ? optind : 1, j = 0; i < argc; i++) {
|
||||||
int shortname = (strlen(argv[i]) == 1) ? toupper(argv[i][0]) : '\0';
|
int shortname = (strlen(argv[i]) == 1) ? toupper(argv[i][0]) : '\0';
|
||||||
@@ -186,7 +247,7 @@ main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to find the mode from the mode list */
|
// try to find the mode from the mode list
|
||||||
for (k = 0; k < seqlen; k++) {
|
for (k = 0; k < seqlen; k++) {
|
||||||
if (((default_sequence[k].longname != NULL) &&
|
if (((default_sequence[k].longname != NULL) &&
|
||||||
(0 == strcasecmp(argv[i], default_sequence[k].longname))) ||
|
(0 == strcasecmp(argv[i], default_sequence[k].longname))) ||
|
||||||
@@ -200,7 +261,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!found) {
|
if (!found) {
|
||||||
fprintf(stderr, "Invalid Mode: %c, ignoring\n", argv[i][0]);
|
fprintf(stderr, "Invalid Mode: %c, ignoring\n", argv[i][0]);
|
||||||
return(EXIT_FAILURE);
|
return(EXIT_FAILURE);
|
||||||
@@ -255,7 +316,7 @@ HelpScreen ()
|
|||||||
printf("Usage: lcdproc [-s server] [-p port] [-e islow] [-d] [modelist]\n");
|
printf("Usage: lcdproc [-s server] [-p port] [-e islow] [-d] [modelist]\n");
|
||||||
printf("\tOptions in []'s are optional.\n");
|
printf("\tOptions in []'s are optional.\n");
|
||||||
printf("\tmodelist is \"mode [mode mode ...]\"\n");
|
printf("\tmodelist is \"mode [mode mode ...]\"\n");
|
||||||
printf("\tMode letters: \t[C]pu [G]raph [T]ime [M]emory [X]load [D]isk [B]attery\n"
|
printf ("\tMode letters:\t[C]pu [G]raph [T]ime [M]emory [X]load [D]isk [B]attery\n"
|
||||||
"\t\t\tproc_[S]izes [O]ld_time big_cloc[K] [E]ssential_clock\n"
|
"\t\t\tproc_[S]izes [O]ld_time big_cloc[K] [E]ssential_clock\n"
|
||||||
"\t\t\t[U]ptime CPU_SM[P] [A]bout\n");
|
"\t\t\t[U]ptime CPU_SM[P] [A]bout\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -273,13 +334,63 @@ HelpScreen ()
|
|||||||
void
|
void
|
||||||
exit_program(int val)
|
exit_program(int val)
|
||||||
{
|
{
|
||||||
|
//printf("exit program\n");
|
||||||
Quit = 1;
|
Quit = 1;
|
||||||
sock_close(sock);
|
sock_close(sock);
|
||||||
mode_close();
|
mode_close();
|
||||||
|
#ifndef LCDPROC_MENUS
|
||||||
free(sequence);
|
free(sequence);
|
||||||
|
#endif
|
||||||
exit(val);
|
exit(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS //menus_init
|
||||||
|
int
|
||||||
|
menus_init ()
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = 0; sequence[k].which ; k++) {
|
||||||
|
if (sequence[k].longname) {
|
||||||
|
sprintf (buffer, "menu_add_item {} %c checkbox {%s} -value %s\n", sequence[k].which, sequence[k].longname, sequence[k].flags & ACTIVE ? "on" : "off");
|
||||||
|
sock_send_string (sock, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TESTMENUS
|
||||||
|
// # to be entered on escape from test_menu (but overwritten
|
||||||
|
// # for test_{checkbox,ring}
|
||||||
|
sock_send_string (sock, "menu_add_item {} ask menu {Leave menus?} -is_hidden true\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {ask} ask_yes action {Yes} -next _quit_\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {ask} ask_no action {No} -next _close_\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {} test menu {Test}\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_action action {Action}\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_checkbox checkbox {Checkbox}\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_ring ring {Ring} -strings {one\ttwo\tthree}\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_slider slider {Slider} -mintext < -maxtext > -value 50\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_numeric numeric {Numeric} -value 42\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_alpha alpha {Alpha} -value abc\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_ip ip {IP} -v6 false -value 192.168.1.1\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test} test_menu menu {Menu}\n");
|
||||||
|
sock_send_string (sock, "menu_add_item {test_menu} test_menu_action action {Submenu's action}\n");
|
||||||
|
|
||||||
|
// # no successor for menus. Since test_checkbox and test_ring have their
|
||||||
|
// # own predecessors defined the "ask" rule will not work for them
|
||||||
|
sock_send_string (sock, "menu_set_item {} test -prev {ask}\n");
|
||||||
|
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_action -next {test_checkbox}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_checkbox -next {test_ring} -prev test_action\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_ring -next {test_slider} -prev {test_checkbox}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_slider -next {test_numeric} -prev {test_ring}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_numeric -next {test_alpha} -prev {test_slider}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_alpha -next {test_ip} -prev {test_numeric}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_ip -next {test_menu} -prev {test_alpha}\n");
|
||||||
|
sock_send_string (sock, "menu_set_item {test} test_menu_action -next {_close_}\n");
|
||||||
|
#endif //TESTMENUS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif //LCDPROC_MENUS
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
// Main program loop...
|
// Main program loop...
|
||||||
//
|
//
|
||||||
@@ -304,7 +415,7 @@ main_loop()
|
|||||||
while (len > 0)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
// Now split the string into tokens...
|
// Now split the string into tokens...
|
||||||
//for(i=0; i<argc; i++) argv[i]=NULL; // Get rid of old tokens
|
//for (i=0; i<argc; i++) argv[i]=NULL; // Get rid of old tokens
|
||||||
argc = 0;
|
argc = 0;
|
||||||
newtoken = 1;
|
newtoken = 1;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
@@ -328,22 +439,30 @@ main_loop()
|
|||||||
//printf("%s %s\n", argv[0], argv[1]);
|
//printf("%s %s\n", argv[0], argv[1]);
|
||||||
if (0 == strcmp(argv[0], "listen"))
|
if (0 == strcmp(argv[0], "listen"))
|
||||||
{
|
{
|
||||||
for(j = 0; sequence[j].which; j++)
|
for (j = 0; sequence[j].which; j++)
|
||||||
{
|
{
|
||||||
if (sequence[j].which == argv[1][0])
|
if (sequence[j].which == argv[1][0])
|
||||||
{
|
{
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
sequence[j].flags |= VISIBLE;
|
||||||
|
#else
|
||||||
sequence[j].visible = 1;
|
sequence[j].visible = 1;
|
||||||
|
#endif
|
||||||
//debug("Listen %s\n", argv[1]);
|
//debug("Listen %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (0 == strcmp(argv[0], "ignore"))
|
else if (0 == strcmp(argv[0], "ignore"))
|
||||||
{
|
{
|
||||||
for(j = 0; sequence[j].which; j++)
|
for (j = 0; sequence[j].which; j++)
|
||||||
{
|
{
|
||||||
if (sequence[j].which == argv[1][0])
|
if (sequence[j].which == argv[1][0])
|
||||||
{
|
{
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
sequence[j].flags &= ~VISIBLE;
|
||||||
|
#else
|
||||||
sequence[j].visible = 0;
|
sequence[j].visible = 0;
|
||||||
|
#endif
|
||||||
//debug("Ignore %s\n", argv[1]);
|
//debug("Ignore %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,13 +471,23 @@ main_loop()
|
|||||||
{
|
{
|
||||||
debug("Key %s\n", argv[1]);
|
debug("Key %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
else if (0 == strcmp(argv[0], "menuevent"))
|
||||||
|
{
|
||||||
|
if (argc == 4 && (0 == strcmp(argv[1], "update")))
|
||||||
|
{
|
||||||
|
set_mode(argv[2][0],"", strcmp(argv[3],"off"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
else if (0 == strcmp(argv[0], "menu"))
|
else if (0 == strcmp(argv[0], "menu"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if (0 == strcmp(argv[0], "connect"))
|
else if (0 == strcmp(argv[0], "connect"))
|
||||||
{
|
{
|
||||||
int a;
|
int a;
|
||||||
for(a = 1; a < argc; a++)
|
for (a = 1; a < argc; a++)
|
||||||
{
|
{
|
||||||
if (0 == strcmp(argv[a], "wid"))
|
if (0 == strcmp(argv[a], "wid"))
|
||||||
lcd_wid = atoi(argv[++a]);
|
lcd_wid = atoi(argv[++a]);
|
||||||
@@ -370,7 +499,14 @@ main_loop()
|
|||||||
lcd_cellhgt = atoi(argv[++a]);
|
lcd_cellhgt = atoi(argv[++a]);
|
||||||
}
|
}
|
||||||
connected = 1;
|
connected = 1;
|
||||||
sock_send_string(sock, "client_set -name LCDproc\n");
|
{
|
||||||
|
char buffer[8192];
|
||||||
|
snprintf(buffer, sizeof(buffer), "client_set -name {LCDproc %s}\n", get_hostname());
|
||||||
|
sock_send_string(sock, buffer);
|
||||||
|
}
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
menus_init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (0 == strcmp(argv[0], "bye"))
|
else if (0 == strcmp(argv[0], "bye"))
|
||||||
{
|
{
|
||||||
@@ -382,10 +518,10 @@ main_loop()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int j;
|
//int j;
|
||||||
for(j = 0; j < argc; j++)
|
//for (j = 0; j < argc; j++)
|
||||||
printf("%s ", argv[j]);
|
// printf("%s ", argv[j]);
|
||||||
printf("\n");
|
//printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,10 +540,16 @@ main_loop()
|
|||||||
// Update screens...
|
// Update screens...
|
||||||
if (connected)
|
if (connected)
|
||||||
{
|
{
|
||||||
for(i = 0; sequence[i].which > 1; i++)
|
for (i = 0; sequence[i].which > 0; i++)
|
||||||
{
|
{
|
||||||
sequence[i].timer++;
|
sequence[i].timer++;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
if ((sequence[i].flags & ACTIVE) == 0 )
|
||||||
|
continue;
|
||||||
|
if (sequence[i].flags & VISIBLE)
|
||||||
|
#else
|
||||||
if (sequence[i].visible)
|
if (sequence[i].visible)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (sequence[i].timer >= sequence[i].on_time)
|
if (sequence[i].timer >= sequence[i].on_time)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,8 +38,16 @@ typedef struct mode
|
|||||||
int off_time; // How often to get stats while not visible?
|
int off_time; // How often to get stats while not visible?
|
||||||
int show_invisible; // Send stats while not visible?
|
int show_invisible; // Send stats while not visible?
|
||||||
int timer; // Time since last update
|
int timer; // Time since last update
|
||||||
|
#ifdef LCDPROC_MENUS //struct mode flags
|
||||||
|
int flags; //bit 1 visible, bit 2 selected for display, bit 3 first
|
||||||
|
#else
|
||||||
int visible; // Can we be seen right now?
|
int visible; // Can we be seen right now?
|
||||||
|
#endif //LCDPROC_MENUS
|
||||||
} mode;
|
} mode;
|
||||||
|
//mode flags
|
||||||
|
#define VISIBLE 0x00000001 //currently visible
|
||||||
|
#define ACTIVE 0x00000002 //selected for display
|
||||||
|
#define INITIALIZED 0x00000004 //replaces the first variable to indicate whether the update screens are initialized
|
||||||
|
|
||||||
#define BLINK_ON 0x10
|
#define BLINK_ON 0x10
|
||||||
#define BLINK_OFF 0x11
|
#define BLINK_OFF 0x11
|
||||||
|
|||||||
+30
-10
@@ -29,16 +29,26 @@
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
mem_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
mem_screen (int rep, int display)
|
mem_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
|
||||||
static int which_title = 0;
|
static int which_title = 0;
|
||||||
static int gauge_wid = 0;
|
static int gauge_wid = 0;
|
||||||
static int gauge_offs = 0;
|
static int gauge_offs = 0;
|
||||||
meminfo_type mem[2];
|
meminfo_type mem[2];
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string(sock, "screen_add M\n");
|
sock_send_string(sock, "screen_add M\n");
|
||||||
sprintf(buffer, "screen_set M -name {Memory & Swap: %s}\n", get_hostname());
|
sprintf(buffer, "screen_set M -name {Memory & Swap: %s}\n", get_hostname());
|
||||||
@@ -136,7 +146,7 @@ mem_screen (int rep, int display)
|
|||||||
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
double value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||||
/ (double) mem[0].total;
|
/ (double) mem[0].total;
|
||||||
|
|
||||||
// printf(".0f", val) only prints the integer part
|
//printf(".0f", val) only prints the integer part
|
||||||
sprintf(buffer, "widget_set M memgauge 2 4 %.0f\n",
|
sprintf(buffer, "widget_set M memgauge 2 4 %.0f\n",
|
||||||
lcd_cellwid * gauge_wid * value);
|
lcd_cellwid * gauge_wid * value);
|
||||||
if (display)
|
if (display)
|
||||||
@@ -147,7 +157,7 @@ mem_screen (int rep, int display)
|
|||||||
if (mem[1].total > 0) {
|
if (mem[1].total > 0) {
|
||||||
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
||||||
|
|
||||||
// printf(".0f", val) only prints the integer part
|
//printf(".0f", val) only prints the integer part
|
||||||
sprintf(buffer, "widget_set M swapgauge %i 4 %.0f\n",
|
sprintf(buffer, "widget_set M swapgauge %i 4 %.0f\n",
|
||||||
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
|
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
|
||||||
if (display)
|
if (display)
|
||||||
@@ -175,7 +185,7 @@ mem_screen (int rep, int display)
|
|||||||
/ (double) mem[0].total;
|
/ (double) mem[0].total;
|
||||||
|
|
||||||
if (gauge_wid > 0) {
|
if (gauge_wid > 0) {
|
||||||
// printf(".0f", val) only prints the integer part
|
//printf(".0f", val) only prints the integer part
|
||||||
sprintf(buffer, "widget_set M memgauge %i 1 %.0f\n",
|
sprintf(buffer, "widget_set M memgauge %i 1 %.0f\n",
|
||||||
gauge_offs, lcd_cellwid * gauge_wid * value);
|
gauge_offs, lcd_cellwid * gauge_wid * value);
|
||||||
if (display)
|
if (display)
|
||||||
@@ -194,7 +204,7 @@ mem_screen (int rep, int display)
|
|||||||
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
|
||||||
|
|
||||||
if (gauge_wid > 0) {
|
if (gauge_wid > 0) {
|
||||||
// printf(".0f", val) only prints the integer part
|
//printf(".0f", val) only prints the integer part
|
||||||
sprintf(buffer, "widget_set M swapgauge %i 2 %.0f\n",
|
sprintf(buffer, "widget_set M swapgauge %i 2 %.0f\n",
|
||||||
gauge_offs, lcd_cellwid * gauge_wid * value);
|
gauge_offs, lcd_cellwid * gauge_wid * value);
|
||||||
if (display)
|
if (display)
|
||||||
@@ -238,14 +248,24 @@ sort_procs (void *a, void *b)
|
|||||||
// +--------------------+
|
// +--------------------+
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
mem_top_screen (int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
mem_top_screen (int rep, int display)
|
mem_top_screen (int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
|
||||||
LinkedList *procs;
|
LinkedList *procs;
|
||||||
int i;
|
int i;
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
|
||||||
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
|
*flags_ptr |= INITIALIZED;
|
||||||
|
#else
|
||||||
|
static int first = TRUE;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
sock_send_string(sock, "screen_add S\n");
|
sock_send_string(sock, "screen_add S\n");
|
||||||
sprintf(buffer, "screen_set S -name {Top Memory Use: %s}\n", get_hostname());
|
sprintf(buffer, "screen_set S -name {Top Memory Use: %s}\n", get_hostname());
|
||||||
@@ -297,8 +317,8 @@ mem_top_screen (int rep, int display)
|
|||||||
if (display)
|
if (display)
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
} else {
|
} else {
|
||||||
// printf("Mem hog: none?\n");
|
//printf("Mem hog: none?\n");
|
||||||
// sprintf(buffer, "widget_set S %i 1 %i {}\n", i, i);
|
//sprintf(buffer, "widget_set S %i 1 %i {}\n", i, i);
|
||||||
sprintf(buffer, "widget_set S %i 1 %i { }\n", i, i);
|
sprintf(buffer, "widget_set S %i 1 %i { }\n", i, i);
|
||||||
if (display)
|
if (display)
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#ifndef MEM_H
|
#ifndef MEM_H
|
||||||
#define MEM_H
|
#define MEM_H
|
||||||
|
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int mem_screen (int rep, int display, int * flags_ptr);
|
||||||
|
int mem_top_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int mem_screen (int rep, int display);
|
int mem_screen (int rep, int display);
|
||||||
int mem_top_screen (int rep, int display);
|
int mem_top_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+74
-11
@@ -36,13 +36,13 @@ char *buffer = NULL;
|
|||||||
int
|
int
|
||||||
mode_init()
|
mode_init()
|
||||||
{
|
{
|
||||||
if((buffer = malloc(1024)) == NULL)
|
if ((buffer = malloc(1024)) == NULL)
|
||||||
{
|
{
|
||||||
perror("malloc buffer");
|
perror("malloc buffer");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((tmp = malloc(1024)) == NULL)
|
if ((tmp = malloc(1024)) == NULL)
|
||||||
{
|
{
|
||||||
perror("malloc tmp");
|
perror("malloc tmp");
|
||||||
return(0);
|
return(0);
|
||||||
@@ -58,13 +58,13 @@ mode_close()
|
|||||||
{
|
{
|
||||||
machine_close();
|
machine_close();
|
||||||
|
|
||||||
if(tmp != NULL)
|
if (tmp != NULL)
|
||||||
{
|
{
|
||||||
free(tmp);
|
free(tmp);
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buffer != NULL)
|
if (buffer != NULL)
|
||||||
{
|
{
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
@@ -77,10 +77,68 @@ update_screen(mode *m, int display)
|
|||||||
static int status = -1;
|
static int status = -1;
|
||||||
int old_status = status;
|
int old_status = status;
|
||||||
|
|
||||||
if(m)
|
if (m)
|
||||||
{
|
{
|
||||||
switch(m->which)
|
switch(m->which)
|
||||||
{
|
{
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
case 'g':
|
||||||
|
case 'G':
|
||||||
|
status = cpu_graph_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
status = cpu_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
case 'O':
|
||||||
|
status = clock_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
case 'K':
|
||||||
|
status = big_clock_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
case 'M':
|
||||||
|
status = mem_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
case 'S':
|
||||||
|
status = mem_top_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
case 'U':
|
||||||
|
status = uptime_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
case 'T':
|
||||||
|
status = time_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
case 'D':
|
||||||
|
status = disk_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
status = xload_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
case 'B':
|
||||||
|
status = battery_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
case 'A':
|
||||||
|
status = credit_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
case 'P':
|
||||||
|
status = cpu_smp_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
case 'E':
|
||||||
|
status = essential_clock_screen(m->timer, display, &(m->flags));
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G':
|
case 'G':
|
||||||
status = cpu_graph_screen(m->timer, display);
|
status = cpu_graph_screen(m->timer, display);
|
||||||
@@ -137,18 +195,19 @@ update_screen(mode *m, int display)
|
|||||||
case 'E':
|
case 'E':
|
||||||
status = essential_clock_screen(m->timer, display);
|
status = essential_clock_screen(m->timer, display);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status != old_status)
|
if (status != old_status)
|
||||||
{
|
{
|
||||||
if(status == BACKLIGHT_OFF)
|
if (status == BACKLIGHT_OFF)
|
||||||
sock_send_string(sock, "backlight off\n");
|
sock_send_string(sock, "backlight off\n");
|
||||||
if(status == BACKLIGHT_ON)
|
if (status == BACKLIGHT_ON)
|
||||||
sock_send_string(sock, "backlight on\n");
|
sock_send_string(sock, "backlight on\n");
|
||||||
if(status == BLINK_ON)
|
if (status == BLINK_ON)
|
||||||
sock_send_string(sock, "backlight blink\n");
|
sock_send_string(sock, "backlight blink\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +223,15 @@ update_screen(mode *m, int display)
|
|||||||
// Credit Screen shows who wrote this...
|
// Credit Screen shows who wrote this...
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
credit_screen(int rep, int display, int * flags_ptr)
|
||||||
|
#else
|
||||||
credit_screen(int rep, int display)
|
credit_screen(int rep, int display)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
|
||||||
if(first)
|
if (first)
|
||||||
{
|
{
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
@@ -177,7 +240,7 @@ credit_screen(int rep, int display)
|
|||||||
sock_send_string(sock, "widget_add A title title\n");
|
sock_send_string(sock, "widget_add A title title\n");
|
||||||
sprintf(buffer, "widget_set A title {LCDPROC %s}\n", version);
|
sprintf(buffer, "widget_set A title {LCDPROC %s}\n", version);
|
||||||
sock_send_string(sock, buffer);
|
sock_send_string(sock, buffer);
|
||||||
if(lcd_hgt >= 4)
|
if (lcd_hgt >= 4)
|
||||||
{
|
{
|
||||||
sock_send_string(sock, "widget_add A one string\n");
|
sock_send_string(sock, "widget_add A one string\n");
|
||||||
sock_send_string(sock, "widget_add A two string\n");
|
sock_send_string(sock, "widget_add A two string\n");
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ int mode_init ();
|
|||||||
void mode_close ();
|
void mode_close ();
|
||||||
|
|
||||||
int update_screen (mode * m, int display);
|
int update_screen (mode * m, int display);
|
||||||
|
#ifdef LCDPROC_MENUS
|
||||||
|
int credit_screen (int rep, int display, int * flags_ptr);
|
||||||
|
#else
|
||||||
int credit_screen (int rep, int display);
|
int credit_screen (int rep, int display);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user