Cleanup and documentation updates:
- Remove shared/str.h where not used. - Remove shared/debug.h from all files as it has been completely replaced by shared/report.h (it will be removed later). - Add more doxygen comments to shared/* and clients/lcdproc/*. - Include static functions in doxygen output.
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "shared/report.h"
|
||||
#include "shared/configfile.h"
|
||||
#include "shared/sockets.h"
|
||||
|
||||
+46
-18
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/batt.c
|
||||
* Implements the 'battery' screen showing the APM battery status.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -12,13 +23,18 @@
|
||||
#include "batt.h"
|
||||
#include "machine.h"
|
||||
|
||||
|
||||
/** Map status code > status text */
|
||||
typedef struct {
|
||||
int status;
|
||||
const char *name;
|
||||
} NameTable;
|
||||
|
||||
} NameTable;
|
||||
|
||||
/**
|
||||
* Converts a numeric AC power status into a status text.
|
||||
*
|
||||
* \param status Numeric status as returned by machine_get_battstat
|
||||
* \return Name of the status
|
||||
*/
|
||||
static const char *
|
||||
ac_status(int status)
|
||||
{
|
||||
@@ -36,8 +52,14 @@ ac_status(int status)
|
||||
return ac_table[i].name;
|
||||
|
||||
return ac_table[LCDP_AC_UNKNOWN].name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a numeric battery status into a status text.
|
||||
*
|
||||
* \param status Numeric status as returned by machine_get_battstat
|
||||
* \return Name of the status
|
||||
*/
|
||||
static const char *
|
||||
battery_status(int status)
|
||||
{
|
||||
@@ -59,17 +81,25 @@ battery_status(int status)
|
||||
return batt_table[LCDP_AC_UNKNOWN].name;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Battery Screen shows apm battery status...
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## AC: 100%: myho #@| |## AC: 100%: myho #@|
|
||||
// |AC: On | |AC, Batt: Absent |
|
||||
// |Batt: Absent | +--------------------+
|
||||
// |E------------------F|
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* Battery Screen shows apm battery status...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## AC: 100%: myho #@| |## AC: 100%: myho #@|
|
||||
* |AC: On | |AC, Batt: Absent |
|
||||
* |Batt: Absent | +--------------------+
|
||||
* |E------------------F|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
battery_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -95,8 +125,6 @@ battery_screen(int rep, int display, int *flags_ptr)
|
||||
sock_send_string(sock, "widget_set B gauge 2 4 0\n");
|
||||
}
|
||||
}
|
||||
// Only run once every 16 frames...
|
||||
//if (rep & 0x0F) return 0;
|
||||
|
||||
machine_get_battstat(&acstat, &battstat, &percent);
|
||||
|
||||
@@ -117,7 +145,7 @@ battery_screen(int rep, int display, int *flags_ptr)
|
||||
if (percent > 0)
|
||||
sock_printf(sock, "widget_set B gauge 2 4 %d\n",
|
||||
(percent * gauge_wid * lcd_cellwid) / 100);
|
||||
}
|
||||
}
|
||||
else { // two-line version of the screen
|
||||
sock_printf(sock, "widget_set B one 1 2 {%sBatt: %s}\n",
|
||||
(acstat == LCDP_AC_ON) ? "AC, " : "",
|
||||
|
||||
+127
-61
@@ -1,3 +1,15 @@
|
||||
/** \file clients/lcdproc/chrono.c
|
||||
* Implements the 'OldTime', 'TimeDate', 'Uptime', 'MiniClock', and 'BigClock'
|
||||
* screens.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -37,16 +49,25 @@
|
||||
static char *tickTime(char *time, int heartbeat);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// TimeDate Screen displays current time and date, uptime, OS ver...
|
||||
//
|
||||
//+--------------------+ +--------------------+
|
||||
//|## Linux 2.6.11 ###@| |### TIME: myhost ##@|
|
||||
//|Up xxx days hh:mm:ss| |17.05.2005 11:32:57a|
|
||||
//| Wed May 17, 1998 | +--------------------+
|
||||
//|11:32:57a 100% idle|
|
||||
//+--------------------+
|
||||
//
|
||||
/**
|
||||
* TimeDate Screen displays current time and date, uptime, OS ver...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## Linux 2.6.11 ###@| |### TIME: myhost ##@|
|
||||
* |Up xxx days hh:mm:ss| |17.05.2005 11:32:57a|
|
||||
* | Wed May 17, 1998 | +--------------------+
|
||||
* |11:32:57a 100% idle|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
time_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -137,18 +158,28 @@ time_screen(int rep, int display, int *flags_ptr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End time_screen()
|
||||
} // End time_screen()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// OldTime Screen displays current time and date...
|
||||
//
|
||||
//+--------------------+ +--------------------+
|
||||
//|## DATE & TIME ####@| |### TIME: myhost ##@|
|
||||
//| myhost | |2005-05-17 11:32:57a|
|
||||
//|11:32:75a Wednesday,| +--------------------+
|
||||
//| May 17, 2005 |
|
||||
//+--------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* OldTime Screen displays current time and date...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## DATE & TIME ####@| |### TIME: myhost ##@|
|
||||
* | myhost | |2005-05-17 11:32:57a|
|
||||
* |11:32:75a Wednesday,| +--------------------+
|
||||
* | May 17, 2005 |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
clock_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -217,18 +248,28 @@ clock_screen(int rep, int display, int *flags_ptr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End clock_screen()
|
||||
} // End clock_screen()
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Uptime Screen shows info about system uptime and OS version
|
||||
//
|
||||
//+--------------------+ +--------------------+
|
||||
//|## SYSTEM UPTIME ##@| |# Linux 2.6.11: my#@|
|
||||
//| myhost | | xxx days hh:mm:ss |
|
||||
//| xxx days hh:mm:ss | +--------------------+
|
||||
//| Linux 2.6.11 |
|
||||
//+--------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Uptime Screen shows info about system uptime and OS version
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## SYSTEM UPTIME ##@| |# Linux 2.6.11: my#@|
|
||||
* | myhost | | xxx days hh:mm:ss |
|
||||
* | xxx days hh:mm:ss | +--------------------+
|
||||
* | Linux 2.6.11 |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
uptime_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -286,21 +327,31 @@ uptime_screen(int rep, int display, int *flags_ptr)
|
||||
sock_printf(sock, "widget_set U two %d 3 {%s}\n", xoffs, tmp);
|
||||
else
|
||||
sock_printf(sock, "widget_set U one %d 2 {%s}\n", xoffs, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End uptime_screen()
|
||||
} // End uptime_screen()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Big Clock Screen displays current time...
|
||||
//
|
||||
// +--------------------+
|
||||
// | _ _ _ _ |
|
||||
// | ||_ . _||_|. _| ||
|
||||
// | ||_|. _| |.|_ ||
|
||||
// | |
|
||||
// +--------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Big Clock Screen displays current time...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+
|
||||
* | _ _ _ _ |
|
||||
* | ||_ . _||_|. _| ||
|
||||
* | ||_|. _| |.|_ ||
|
||||
* | |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
big_clock_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -314,7 +365,7 @@ big_clock_screen(int rep, int display, int *flags_ptr)
|
||||
int j = 0;
|
||||
int digits = (lcd_wid >= 20) ? 6 : 4;
|
||||
int xoffs = (lcd_wid + 1 - (pos[digits-1] + 2)) / 2;
|
||||
|
||||
|
||||
// toggle colon display
|
||||
heartbeat ^= 1;
|
||||
|
||||
@@ -361,22 +412,31 @@ big_clock_screen(int rep, int display, int *flags_ptr)
|
||||
sock_printf(sock, "widget_set K c0 %d 11\n", xoffs + 7);
|
||||
if (digits > 4)
|
||||
sock_printf(sock, "widget_set K c1 %d 11\n", xoffs + 14);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End big_clock_screen()
|
||||
} // End big_clock_screen()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// MiniClock Screen displays the current time with hours & minutes only
|
||||
//
|
||||
//+--------------------+ +--------------------+
|
||||
//| | | 11:32 |
|
||||
//| 11:32 | | |
|
||||
//| | +--------------------+
|
||||
//| |
|
||||
//+--------------------+
|
||||
//
|
||||
/**
|
||||
* MiniClock Screen displays the current time with hours & minutes only
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* | | | 11:32 |
|
||||
* | 11:32 | | |
|
||||
* | | +--------------------+
|
||||
* | |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
mini_clock_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -412,11 +472,17 @@ mini_clock_screen(int rep, int display, int *flags_ptr)
|
||||
sock_printf(sock, "widget_set N one %d %d {%s}\n", xoffs, (lcd_hgt / 2), now);
|
||||
|
||||
return 0;
|
||||
} // End mini_clock_screen()
|
||||
} // End mini_clock_screen()
|
||||
|
||||
|
||||
// helper function: toggle between ':' and ' ' in time strings
|
||||
static char *tickTime(char *time, int heartbeat)
|
||||
/** Helper function: toggle between ':' and ' ' in time strings.
|
||||
* \note The time string passed is modified directly!
|
||||
* \param time String containing a formatted time value.
|
||||
* \param heartbeat Even numbers to display ':', odd to display ' '.
|
||||
* \return Pointer to the modfied time string.
|
||||
*/
|
||||
static char *
|
||||
tickTime(char *time, int heartbeat)
|
||||
{
|
||||
if (time != NULL) {
|
||||
static char colon[] = {':', ' '};
|
||||
@@ -425,7 +491,7 @@ static char *tickTime(char *time, int heartbeat)
|
||||
for (heartbeat %= 2; *ptr != '\0'; ptr++) {
|
||||
if (*ptr == colon[0])
|
||||
*ptr = colon[heartbeat];
|
||||
}
|
||||
}
|
||||
}
|
||||
return(time);
|
||||
}
|
||||
|
||||
+51
-23
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/cpu.c
|
||||
* Implements the 'CPU' and 'CPUGraph' screens.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
@@ -9,7 +20,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
@@ -18,16 +28,25 @@
|
||||
#include "util.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CPU screen shows info about percentage of the CPU being used
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## CPU 51.9%: myh #@| |CPU [---- ]48.1%@|
|
||||
// |Usr 46.0% Nice 0.0%| |U-- S- N I--- |
|
||||
// |Sys 5.9% Idle 48.1%| +--------------------+
|
||||
// |0%-------- 100%|
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* CPU screen shows info about percentage of the CPU being used
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## CPU 51.9%: myh #@| |CPU [---- ]48.1%@|
|
||||
* |Usr 46.0% Nice 0.0%| |U-- S- N I--- |
|
||||
* |Sys 5.9% Idle 48.1%| +--------------------+
|
||||
* |0%-------- 100%|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
cpu_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -110,7 +129,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
||||
cpu[CPU_BUF_SIZE - 1][2] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][3] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Only clear on first display...
|
||||
@@ -178,16 +197,25 @@ cpu_screen(int rep, int display, int *flags_ptr)
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Cpu Graph Screen shows a quick-moving histogram of CPU use.
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## CPU: myhost ####@| |CPU: myhos|| @|
|
||||
// | || | | |||| |
|
||||
// | ||| | +--------------------+
|
||||
// | |||| |
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* Cpu Graph Screen shows a quick-moving histogram of CPU use.
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## CPU: myhost ####@| |CPU: myhos|| @|
|
||||
* | || | | |||| |
|
||||
* | ||| | +--------------------+
|
||||
* | |||| |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
cpu_graph_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -208,7 +236,7 @@ cpu_graph_screen(int rep, int display, int *flags_ptr)
|
||||
|
||||
sock_send_string(sock, "screen_add G\n");
|
||||
sock_printf(sock, "screen_set G -name {CPU Graph: %s}\n", get_hostname());
|
||||
|
||||
|
||||
if (lcd_hgt >= 4) {
|
||||
sock_send_string(sock, "widget_add G title title\n");
|
||||
sock_printf(sock, "widget_set G title {CPU: %s}\n", get_hostname());
|
||||
|
||||
+20
-17
@@ -1,8 +1,5 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* cpu_smp.c - dipslay cpu info for multi-processor machines
|
||||
* Copyright (C) 2000 J Robert Ray
|
||||
* Copyright (C) 2006,7 Peter Marschall
|
||||
/** \file clients/lcdproc/cpu_smp.c
|
||||
* Display cpu info for multi-processor machines.
|
||||
*
|
||||
* Adapted from cpu.c.
|
||||
*
|
||||
@@ -16,10 +13,13 @@
|
||||
* If the number of lines used to display the bar graphs for the CPUs is smaller
|
||||
* than the LCD's height, a title line is introduced, so that the screen looks
|
||||
* similar to other lcdproc screens.
|
||||
* In all other cases (i.e. #CPUs == LCD height or #CPUs >= 2 * LCD height),
|
||||
* In all other cases (i.e. \#CPUs == LCD height or \#CPUs >= 2 * LCD height),
|
||||
* the title is left out to display as many CPUs graphs as possible.
|
||||
*
|
||||
* ---
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2000 J Robert Ray
|
||||
* Copyright (C) 2006,7 Peter Marschall
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -34,8 +34,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*******************************************************************************/
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -45,7 +44,6 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
@@ -53,9 +51,14 @@
|
||||
#include "cpu_smp.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CPU screen shows info about percentage of the CPU being used
|
||||
//
|
||||
/**
|
||||
* CPU screen shows info about percentage of the CPU being used
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -83,7 +86,7 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
*flags_ptr |= INITIALIZED;
|
||||
|
||||
sock_send_string(sock, "screen_add P\n");
|
||||
|
||||
|
||||
// print title if he have room for it
|
||||
if (lines_used < lcd_hgt) {
|
||||
sock_send_string(sock, "widget_add P title title\n");
|
||||
@@ -91,7 +94,7 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
}
|
||||
else {
|
||||
sock_send_string(sock, "screen_set P -heartbeat off\n");
|
||||
}
|
||||
}
|
||||
|
||||
sock_printf(sock, "screen_set P -name {CPU Use: %s}\n", get_hostname());
|
||||
|
||||
@@ -136,4 +139,4 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End cpu_screen()
|
||||
} // End cpu_screen()
|
||||
|
||||
+31
-12
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/disk.c
|
||||
* Implements the 'Disk' screen.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
@@ -19,18 +30,26 @@
|
||||
#include "util.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Gives disk stats.
|
||||
//
|
||||
// Stays onscreen until it is done; rolls over all mounted file systems
|
||||
// +--------------------+ +--------------------+
|
||||
// |## DISKS: myhost ##@| |## DISKS: myhost ##@|
|
||||
// |/ 18.3G E-- F| |-local 18.3G E--- F|
|
||||
// |-local 18.3G E--- F| +--------------------+
|
||||
// |/boot 949.6M E- F|
|
||||
// +--------------------+
|
||||
//
|
||||
// TODO: Disk screen! Requires virtual pages in the server, though...
|
||||
/**
|
||||
* Gives disk stats.
|
||||
* Stays onscreen until it is done; rolls over all mounted file systems
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## DISKS: myhost ##@| |## DISKS: myhost ##@|
|
||||
* |/ 18.3G E-- F| |-local 18.3G E--- F|
|
||||
* |-local 18.3G E--- F| +--------------------+
|
||||
* |/boot 949.6M E- F|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
disk_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
|
||||
+18
-14
@@ -1,10 +1,13 @@
|
||||
/* This is the LCDproc client module for EyeboxOne devices
|
||||
|
||||
/** \file clients/lcdproc/eyebox.c
|
||||
This is the LCDproc client module for EyeboxOne devices
|
||||
|
||||
This allows to use leds, one as a free CPU meter, and one
|
||||
as a free RAM meter.
|
||||
|
||||
All this is in BETA version, take it as a demo...
|
||||
*/
|
||||
|
||||
/*-
|
||||
Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -33,7 +36,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
@@ -41,7 +43,7 @@
|
||||
#include "eyebox.h"
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
int
|
||||
eyebox_screen(char display, int init)
|
||||
{
|
||||
#undef CPU_BUF_SIZE
|
||||
@@ -81,7 +83,7 @@ eyebox_screen(char display, int init)
|
||||
cpu[CPU_BUF_SIZE - 1][2] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][3] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Average values for final result
|
||||
for (i = 0; i < 5; i++) {
|
||||
@@ -92,19 +94,19 @@ eyebox_screen(char display, int init)
|
||||
cpu[CPU_BUF_SIZE][i] = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* /xBab = Use Bar
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
/*
|
||||
* /xBab = Use Bar
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
*/
|
||||
|
||||
sock_printf(sock, "widget_set %c eyebo_cpu 1 2 {/xB%d%d}\n",
|
||||
display, 2,(int)(cpu[CPU_BUF_SIZE][4]/10));
|
||||
|
||||
/*
|
||||
* /xBab = Use Bas
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
/*
|
||||
* /xBab = Use Bas
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
*/
|
||||
|
||||
value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||
@@ -114,7 +116,9 @@ eyebox_screen(char display, int init)
|
||||
return 0;
|
||||
} // End mem_screen()
|
||||
|
||||
void eyebox_clear(void){
|
||||
void
|
||||
eyebox_clear(void)
|
||||
{
|
||||
/*
|
||||
* Clear LEDs before exit
|
||||
*/
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
|
||||
int eyebox_screen(char display, int init);
|
||||
void eyebox_clear(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+73
-51
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
netlcdclient - Client for LCDproc which shows networks statistics
|
||||
/** \file clients/lcdproc/iface.c
|
||||
* Shows networks statistics. Imported from netlcdclient.
|
||||
*/
|
||||
|
||||
/*-
|
||||
Copyright (C) 2002 Luis Llorente Campo <luisllorente@luisllorente.com>
|
||||
Multiinterface Extension by Stephan Skrodzki <skrodzki@stevekist.de>
|
||||
Adaptions to lcdproc by Andrew Foss with fixes by M. Dolze
|
||||
@@ -19,7 +21,6 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -31,10 +32,10 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
#include "shared/report.h"
|
||||
#include "shared/configfile.h"
|
||||
#include "main.h"
|
||||
#include "machine.h"
|
||||
#include "util.h"
|
||||
#include "iface.h"
|
||||
|
||||
@@ -43,12 +44,13 @@
|
||||
|
||||
|
||||
static int iface_count = 0; /* number of interfaces */
|
||||
|
||||
static char unit_label[10] = "B"; /* default unit label is Bytes */
|
||||
static int transfer_screen = 0; /* by default, transfer screen is not shown */
|
||||
|
||||
|
||||
/* reads and parses configuration file */
|
||||
/** Reads and parses configuration file.
|
||||
* \return 0 on success, -1 on error
|
||||
*/
|
||||
static int
|
||||
iface_process_configfile(void)
|
||||
{
|
||||
@@ -60,14 +62,14 @@ iface_process_configfile(void)
|
||||
|
||||
for (iface_count = 0; iface_count < MAX_INTERFACES; iface_count++) {
|
||||
char iface_label[12];
|
||||
|
||||
|
||||
sprintf(iface_label, "Interface%i", iface_count);
|
||||
debug(RPT_DEBUG, "Label %s count %i", iface_label, iface_count);
|
||||
iface[iface_count].name = strdup(config_get_string("Iface", iface_label, 0, ""));
|
||||
if (iface[iface_count].name == NULL) {
|
||||
report(RPT_CRIT, "malloc failure");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (*iface[iface_count].name == '\0')
|
||||
break;
|
||||
sprintf(iface_label, "Alias%i", iface_count);
|
||||
@@ -78,7 +80,7 @@ iface_process_configfile(void)
|
||||
debug(RPT_DEBUG, "Interface %i: %s alias %s",
|
||||
iface_count, iface[iface_count].name, iface[iface_count].alias);
|
||||
}
|
||||
|
||||
|
||||
unit = config_get_string("Iface", "Unit", 0, "byte");
|
||||
if ((strcasecmp(unit, "byte") == 0) ||
|
||||
(strcasecmp(unit, "bytes") == 0))
|
||||
@@ -92,7 +94,7 @@ iface_process_configfile(void)
|
||||
else {
|
||||
report(RPT_ERR, "illegal Unit value: %s", unit);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
unit_label[sizeof(unit_label)-1] = '\0';
|
||||
|
||||
transfer_screen = config_get_bool("Iface", "Transfer", 0, 0);
|
||||
@@ -101,29 +103,39 @@ iface_process_configfile(void)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// IFace screen shows info about percentage of the Network interface usage/throughput
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## Net Load: LAN ##@| |### Net Load ######@|
|
||||
// |UL: 123.456 Kb| |LAN: U: 34kb D: 56Mb|
|
||||
// |DL: 654.321 Kb| +--------------------+
|
||||
// |Total: 777.777 Kb|
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* IFace screen shows info about percentage of the Network interface usage /
|
||||
* throughput.
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## Net Load: LAN ##@| |### Net Load ######@|
|
||||
* |UL: 123.456 Kb| |LAN: U: 34kb D: 56Mb|
|
||||
* |DL: 654.321 Kb| +--------------------+
|
||||
* |Total: 777.777 Kb|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
iface_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
//ALF TODO need to make this actual time since last run
|
||||
/* ALF TODO need to make this actual time since last run */
|
||||
unsigned int interval = difftime(time(NULL), iface[0].last_online); /* interval since last update */
|
||||
int iface_nmbr;
|
||||
|
||||
|
||||
if (!interval)
|
||||
return 0; /* need at least 1 second, no divide by 0 */
|
||||
|
||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||
*flags_ptr |= INITIALIZED;
|
||||
|
||||
|
||||
/* get configuration options */
|
||||
iface_process_configfile();
|
||||
|
||||
@@ -148,11 +160,11 @@ iface_screen(int rep, int display, int *flags_ptr)
|
||||
/*read iface_parameter stats */
|
||||
if (!machine_get_iface_stats(&iface[iface_nmbr])) {
|
||||
/* there was an error, so we exit the loop */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* actualize speed values in display */
|
||||
actualize_speed_screen(&iface[iface_nmbr], interval, iface_nmbr);
|
||||
actualize_speed_screen(&iface[iface_nmbr], interval, iface_nmbr);
|
||||
|
||||
/* if needed, actualize transfer values in display */
|
||||
if (transfer_screen)
|
||||
@@ -166,13 +178,12 @@ iface_screen(int rep, int display, int *flags_ptr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End iface_screen()
|
||||
} /* End iface_screen() */
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Send commands to server to add speed screen with all required widgets
|
||||
*************************************************************************
|
||||
/**
|
||||
* Send commands to server to add speed screen with all required widgets.
|
||||
*/
|
||||
void
|
||||
initialize_speed_screen(void)
|
||||
@@ -213,7 +224,7 @@ initialize_speed_screen(void)
|
||||
sock_printf(sock, "widget_set I title {Net Load (packets)}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sock_send_string (sock, "widget_add I f frame\n");
|
||||
|
||||
// frame from (2, left) to (width, height) that is iface_count lines high
|
||||
@@ -231,11 +242,15 @@ initialize_speed_screen(void)
|
||||
|
||||
} /* initialize_speed_screen() */
|
||||
|
||||
/*************************************************************************
|
||||
/**
|
||||
* Format the value (in bytes) passed as parameter according to its scale,
|
||||
* adding the proper suffix. Store the formatted value string in the
|
||||
* variable 'buff' passed as pointer.
|
||||
*************************************************************************
|
||||
* \param buff Pointer to target buffer
|
||||
* \param value Number of bytes
|
||||
* \param unit String describing the unit. If this contains 'b', \c value is
|
||||
* converted to bits. If this contains 'B', value is converted
|
||||
* to binary multiples (1024 bytes = 1 KiB).
|
||||
*/
|
||||
void
|
||||
format_value (char *buff, double value, char *unit)
|
||||
@@ -260,11 +275,15 @@ format_value (char *buff, double value, char *unit)
|
||||
|
||||
} /* format_value() */
|
||||
|
||||
/*************************************************************************
|
||||
/**
|
||||
* Format the value (in bytes) passed as parameter according to its scale,
|
||||
* adding the proper suffix. Store the formatted value string in the
|
||||
* variable 'buff' passed as pointer. Version for multi-interfaces mode
|
||||
*************************************************************************
|
||||
* variable 'buff' passed as pointer. Version for multi-interfaces mode.
|
||||
* \param buff Pointer to target buffer
|
||||
* \param value Number of bytes
|
||||
* \param unit String describing the unit. If this contains 'b', \c value is
|
||||
* converted to bits. If this contains 'B', value is converted
|
||||
* to binary multiples (1024 bytes = 1 KiB).
|
||||
*/
|
||||
void
|
||||
format_value_multi_interface (char *buff, double value, char *unit)
|
||||
@@ -290,9 +309,10 @@ format_value_multi_interface (char *buff, double value, char *unit)
|
||||
|
||||
} /* format_value_multi_interface() */
|
||||
|
||||
/*************************************************************************
|
||||
* Format the time in ASCII, depending on the elapsed time
|
||||
*************************************************************************
|
||||
/**
|
||||
* Format the time in ASCII, depending on the elapsed time.
|
||||
* \param buff Pointer to buffer for storing result
|
||||
* \param last_online Time value
|
||||
*/
|
||||
void
|
||||
get_time_string (char *buff, time_t last_online)
|
||||
@@ -307,7 +327,7 @@ get_time_string (char *buff, time_t last_online)
|
||||
sprintf(buff, "never");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Transform Unix time format to UTC time format */
|
||||
strcpy(timebuff, ctime(&last_online));
|
||||
|
||||
@@ -323,11 +343,13 @@ get_time_string (char *buff, time_t last_online)
|
||||
}
|
||||
} /* get_time_string() */
|
||||
|
||||
/*************************************************************************
|
||||
/**
|
||||
* Actualize values in display, calculating speeds in the defined interval
|
||||
* of time and sending proper commands to server. If measure unit is
|
||||
* 'pkt', we don't format this speed. Is always XXXX pkt/s
|
||||
*************************************************************************
|
||||
* 'pkt', we don't format this speed. Is always XXXX pkt/s.
|
||||
* \param iface Pointer to interface data
|
||||
* \param interval Time of last update
|
||||
* \param index Interface index
|
||||
*/
|
||||
void
|
||||
actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
||||
@@ -336,7 +358,7 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
||||
double rc_speed;
|
||||
double tr_speed;
|
||||
|
||||
if ((iface_count == 1) && ( lcd_hgt >= 4)) { /* single interface mode */
|
||||
if ((iface_count == 1) && ( lcd_hgt >= 4)) { /* single interface mode */
|
||||
if (iface->status == up) {
|
||||
/* Calculate Download speed */
|
||||
if (strstr(unit_label, "pkt")) { /* don't format this value */
|
||||
@@ -407,14 +429,13 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
|
||||
}
|
||||
} /* actualize_speed_screen() */
|
||||
|
||||
/*************************************************************************
|
||||
* Send commands to server to add transfer screen with all required widgets
|
||||
*************************************************************************
|
||||
/**
|
||||
* Send commands to server to add transfer screen with all required widgets.
|
||||
*/
|
||||
void
|
||||
initialize_transfer_screen(void)
|
||||
{
|
||||
int iface_nmbr; /* interface number */
|
||||
int iface_nmbr; /* interface number */
|
||||
|
||||
/* Add screen */
|
||||
sock_send_string(sock, "screen_add NT\n");
|
||||
@@ -456,10 +477,11 @@ initialize_transfer_screen(void)
|
||||
}
|
||||
} /* initialize_transfer_screen() */
|
||||
|
||||
/*************************************************************************
|
||||
/**
|
||||
* Actualize values in display, formatting transfer measures and sending
|
||||
* proper commands to server. Traffic is shown in "bytes" unit
|
||||
*************************************************************************
|
||||
* proper commands to server. Traffic is shown in "bytes" unit.
|
||||
* \param iface Pointer to interface data
|
||||
* \param index Interface index
|
||||
*/
|
||||
void
|
||||
actualize_transfer_screen(IfaceInfo *iface, int index)
|
||||
|
||||
+19
-28
@@ -1,51 +1,42 @@
|
||||
#ifndef IFACE_H
|
||||
#define IFACE_H
|
||||
/* netlcdclient.h - definitions and function prototipes
|
||||
*
|
||||
/** \file clients/lcdproc/iface.h
|
||||
* Definitions and function prototypes for \c iface.c.
|
||||
* Imported from \c netlcdclient.h.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2002 Luis Llorente Campo
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*/
|
||||
|
||||
|
||||
#include <time.h>
|
||||
#include "machine.h"
|
||||
#ifndef IFACE_H
|
||||
#define IFACE_H
|
||||
|
||||
#define MAX_INTERFACES 3 /* max number of interfaces in multi-interface mode */
|
||||
|
||||
int iface_screen(int rep, int display, int *flags_ptr);
|
||||
IfaceInfo iface[MAX_INTERFACES]; /* interface info */
|
||||
|
||||
/************************/
|
||||
/* Functions prototipes */
|
||||
/************************/
|
||||
|
||||
/* read interface stats from /proc/net/dev */
|
||||
/** Update screen content */
|
||||
int iface_screen(int rep, int display, int *flags_ptr);
|
||||
/** read interface stats from /proc/net/dev */
|
||||
int get_iface_stats(IfaceInfo *interface);
|
||||
|
||||
/* send initial commands to server to add the speed screen */
|
||||
/** send initial commands to server to add the speed screen */
|
||||
void initialize_speed_screen(void);
|
||||
|
||||
/* send initial commands to server to add the transfer screen */
|
||||
/** send initial commands to server to add the transfer screen */
|
||||
void initialize_transfer_screen(void);
|
||||
|
||||
/* format the time in ASCII */
|
||||
/** format the time in ASCII */
|
||||
void get_time_string(char *buff, time_t last_online);
|
||||
|
||||
/* format value, scaling value and adding proper suffixes */
|
||||
/** format value, scaling value and adding proper suffixes */
|
||||
void format_value(char *buff, double value, char *unit);
|
||||
|
||||
/* format value, scaling value and adding proper suffixes (for multi-interface
|
||||
/** format value, scaling value and adding proper suffixes (for multi-interface
|
||||
* mode) */
|
||||
void format_value_multi_interface(char *buff, double value, char *unit);
|
||||
|
||||
/* actualize widgets values in speed screen */
|
||||
/** actualize widgets values in speed screen */
|
||||
void actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index);
|
||||
|
||||
/* actualize widgets values in transfer screen */
|
||||
/** actualize widgets values in transfer screen */
|
||||
void actualize_transfer_screen(IfaceInfo *iface, int index);
|
||||
|
||||
#endif
|
||||
|
||||
+32
-12
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/load.c
|
||||
* Implements the 'Load' screen.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -16,16 +27,25 @@
|
||||
#include "load.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Shows a display very similar to "xload"'s histogram.
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## LOAD 0.44: myh #@| |myhost 0.24 1|
|
||||
// | 1| | |||||||||||0|
|
||||
// | |||||| | +--------------------+
|
||||
// | |||| |||||||| 0|
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* Shows a display very similar to "xload"'s histogram.
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## LOAD 0.44: myh #@| |myhost 0.24 1|
|
||||
* | 1| | |||||||||||0|
|
||||
* | |||||| | +--------------------+
|
||||
* | |||| |||||||| 0|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return The backlight state
|
||||
*/
|
||||
int
|
||||
xload_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -109,7 +129,7 @@ xload_screen(int rep, int display, int *flags_ptr)
|
||||
status = (loadmax > lowLoad) ? BACKLIGHT_ON : BACKLIGHT_OFF;
|
||||
if (loads[lcd_wid - 2] > highLoad)
|
||||
status = BLINK_ON;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
} // End xload_screen()
|
||||
} // End xload_screen()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** \file machine.h
|
||||
/** \file clients/lcdproc/machine.h
|
||||
* Common data types and function declarations
|
||||
* for OS specific sources in \c machine_{Darwin,Linux,SunOS,*BSD}.c.
|
||||
*
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/** \file clients/lcdproc/machine_Darwin.c
|
||||
* Collects system information on MacOS / Darwin.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2003 Thomas Runge (coto@core.de)
|
||||
* Mach and Darwin specific code is Copyright (c) 2006 Eric Pooch (epooch@tenon.com)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/** \file clients/lcdproc/machine_FreeBSD.c
|
||||
* Collects system information on FreeBSD.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2003 Thomas Runge (coto@core.de)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/** \file clients/lcdproc/machine_Linux.c
|
||||
* Collects system information on Linux.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#ifdef linux
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/** \file clients/lcdproc/machine_NetBSD.c
|
||||
* Collects system information on NetBSD.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2003 Thomas Runge (coto@core.de)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/** \file clients/lcdproc/machine_OpenBSD.c
|
||||
* Collects system information on OpenBSD.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2003 Thomas Runge (coto@core.de)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/** \file clients/lcdproc/machine_SunOS.c
|
||||
* Collects system information on Solaris.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#ifdef sun
|
||||
|
||||
|
||||
+167
-144
@@ -1,3 +1,17 @@
|
||||
/** \file clients/lcdproc/main.c
|
||||
* Contains main(), plus signal callback functions and a help screen.
|
||||
*
|
||||
* Program init, command-line handling, and the main loop are
|
||||
* implemented here.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -21,11 +35,11 @@
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
#include "shared/report.h"
|
||||
#include "shared/configfile.h"
|
||||
#include "getopt.h"
|
||||
#include "getopt.h" /* This is our local getopt.h! */
|
||||
|
||||
/* Import screens */
|
||||
#include "batt.h"
|
||||
#include "chrono.h"
|
||||
#include "cpu.h"
|
||||
@@ -39,8 +53,7 @@
|
||||
# include "eyebox.h"
|
||||
#endif
|
||||
|
||||
// TODO: Commenting... Everything!
|
||||
|
||||
/* The following 8 variables are defined 'external' in main.h! */
|
||||
int Quit = 0;
|
||||
int sock = -1;
|
||||
|
||||
@@ -51,21 +64,17 @@ int lcd_wid = 0;
|
||||
int lcd_hgt = 0;
|
||||
int lcd_cellwid = 0;
|
||||
int lcd_cellhgt = 0;
|
||||
|
||||
static struct utsname unamebuf;
|
||||
|
||||
/*
|
||||
Mode List:
|
||||
See below... (default_sequence[])
|
||||
*/
|
||||
|
||||
/* local prototypes */
|
||||
static void HelpScreen(int exit_state);
|
||||
static void exit_program(int val);
|
||||
static void main_loop(void);
|
||||
static int process_configfile(char *cfgfile);
|
||||
|
||||
|
||||
// 1/8th second is a single time unit...
|
||||
#define TIME_UNIT 125000
|
||||
#define TIME_UNIT 125000 /**< 1/8th second is a single time unit. */
|
||||
|
||||
#if !defined(SYSCONFDIR)
|
||||
# define SYSCONFDIR "/etc"
|
||||
@@ -82,11 +91,11 @@ static int process_configfile(char *cfgfile);
|
||||
#define DEFAULT_REPORTDEST RPT_DEST_STDERR
|
||||
#define DEFAULT_REPORTLEVEL RPT_WARNING
|
||||
|
||||
/* list of screen modes to run */
|
||||
/** list of screen modes to run */
|
||||
ScreenMode sequence[] =
|
||||
{
|
||||
// flags default ACTIVE will run by default
|
||||
// longname which on off inv timer flags
|
||||
/* flags default ACTIVE will run by default */
|
||||
/* longname which on off inv timer flags */
|
||||
{ "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE, cpu_screen }, // [C]PU
|
||||
{ "Iface", 'I', 1, 2, 0, 0xffff, 0, iface_screen }, // [I]face
|
||||
{ "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE, mem_screen }, // [M]emory
|
||||
@@ -106,69 +115,77 @@ ScreenMode sequence[] =
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* All variables are set to 'unset' values*/
|
||||
static int islow = -1;
|
||||
/* All variables are set to 'unset' values */
|
||||
static int islow = -1; /**< pause after mode update (in 1/100s) */
|
||||
char *progname = "lcdproc";
|
||||
char *server = NULL;
|
||||
int port = LCDPORT;
|
||||
int foreground = FALSE;
|
||||
char *server = NULL;
|
||||
int port = LCDPORT;
|
||||
int foreground = FALSE;
|
||||
static int report_level = UNSET_INT;
|
||||
static int report_dest = UNSET_INT;
|
||||
static int report_dest = UNSET_INT;
|
||||
char *configfile = NULL;
|
||||
char *pidfile = NULL;
|
||||
int pidfile_written = FALSE;
|
||||
char *displayname = NULL;
|
||||
char *displayname = NULL; /**< display name for the main menu */
|
||||
|
||||
|
||||
const char *get_hostname(void)
|
||||
/** Returns the network name of this machine */
|
||||
const char *
|
||||
get_hostname(void)
|
||||
{
|
||||
return(unamebuf.nodename);
|
||||
return (unamebuf.nodename);
|
||||
}
|
||||
|
||||
/** Returns the name of the client's OS */
|
||||
const char *
|
||||
get_sysname(void)
|
||||
{
|
||||
return (unamebuf.sysname);
|
||||
}
|
||||
|
||||
/** Returns the release version of the client's OS */
|
||||
const char *
|
||||
get_sysrelease(void)
|
||||
{
|
||||
return (unamebuf.release);
|
||||
}
|
||||
|
||||
|
||||
const char *get_sysname(void)
|
||||
{
|
||||
return(unamebuf.sysname);
|
||||
}
|
||||
|
||||
|
||||
const char *get_sysrelease(void)
|
||||
{
|
||||
return(unamebuf.release);
|
||||
}
|
||||
|
||||
|
||||
static int set_mode(int shortname, char *longname, int state)
|
||||
/** Enables or disables (and deletes) a screen */
|
||||
static int
|
||||
set_mode(int shortname, char *longname, int state)
|
||||
{
|
||||
int k;
|
||||
|
||||
/* ignore already selected modes */
|
||||
for (k = 0; sequence[k].which != 0; k++) {
|
||||
if (((sequence[k].longname != NULL) &&
|
||||
(0 == strcasecmp(longname, sequence[k].longname))) ||
|
||||
(toupper(shortname) == sequence[k].which)) {
|
||||
if (!state) {
|
||||
/* clean both the active and initialized bits since we delete the screen */
|
||||
/*
|
||||
* clean both the active and initialized bits
|
||||
* since we delete the screen
|
||||
*/
|
||||
sequence[k].flags &= (~ACTIVE & ~INITIALIZED);
|
||||
/* delete the screen if we are connected */
|
||||
if (sock >= 0) {
|
||||
sock_printf(sock, "screen_del %c\n", sequence[k].which);
|
||||
}
|
||||
} else
|
||||
}
|
||||
}
|
||||
else
|
||||
sequence[k].flags |= ACTIVE;
|
||||
return 1; //found
|
||||
return 1; /* found */
|
||||
}
|
||||
}
|
||||
return 0; //not found
|
||||
return 0; /* not found */
|
||||
}
|
||||
|
||||
|
||||
static void clear_modes(void)
|
||||
/** Sets all screens inactive */
|
||||
static void
|
||||
clear_modes(void)
|
||||
{
|
||||
int k;
|
||||
|
||||
/* ignore already selected modes */
|
||||
for (k = 0; sequence[k].which != 0; k++) {
|
||||
sequence[k].flags &= (~ACTIVE);
|
||||
}
|
||||
@@ -182,38 +199,38 @@ main(int argc, char **argv)
|
||||
int c;
|
||||
|
||||
/* set locale for cwdate & time formatting in chrono.c */
|
||||
setlocale(LC_TIME, "" );
|
||||
setlocale(LC_TIME, "");
|
||||
|
||||
/* get uname information */
|
||||
if (uname(&unamebuf) == -1) {
|
||||
perror("uname");
|
||||
return(EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* setup error handlers */
|
||||
signal(SIGINT, exit_program); // Ctrl-C
|
||||
signal(SIGTERM, exit_program); // "regular" kill
|
||||
signal(SIGHUP, exit_program); // kill -HUP
|
||||
signal(SIGPIPE, exit_program); // write to closed socket
|
||||
signal(SIGKILL, exit_program); // kill -9 [cannot be trapped; but ...]
|
||||
signal(SIGINT, exit_program); /* Ctrl-C */
|
||||
signal(SIGTERM, exit_program); /* "regular" kill */
|
||||
signal(SIGHUP, exit_program); /* kill -HUP */
|
||||
signal(SIGPIPE, exit_program); /* write to closed socket */
|
||||
signal(SIGKILL, exit_program); /* kill -9 [cannot be trapped; but ...] */
|
||||
|
||||
/* No error output from getopt */
|
||||
opterr = 0;
|
||||
|
||||
/* get options from command line */
|
||||
while ((c = getopt( argc, argv, "s:p:e:c:fhv")) > 0) {
|
||||
while ((c = getopt(argc, argv, "s:p:e:c:fhv")) > 0) {
|
||||
char *end;
|
||||
|
||||
switch (c) {
|
||||
// c is for config file
|
||||
/* c is for config file */
|
||||
case 'c':
|
||||
configfile = optarg;
|
||||
break;
|
||||
// s is for server
|
||||
/* s is for server */
|
||||
case 's':
|
||||
server = optarg;
|
||||
break;
|
||||
// p is for port
|
||||
/* p is for port */
|
||||
case 'p':
|
||||
port = strtol(optarg, &end, 0);
|
||||
if ((*optarg == '\0') || (*end != '\0') ||
|
||||
@@ -239,25 +256,26 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "LCDproc %s\n", version);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
// otherwise... Get help!
|
||||
case '?': // unknown option or missing argument
|
||||
/* otherwise... Get help! */
|
||||
case '?': /* unknown option or missing argument */
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
HelpScreen(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read config file*/
|
||||
/* Read config file */
|
||||
cfgresult = process_configfile(configfile);
|
||||
if (cfgresult < 0) {
|
||||
fprintf(stderr, "Error reading config file\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set default reporting options */
|
||||
if (report_dest == UNSET_INT)
|
||||
report_dest = DEFAULT_REPORTDEST;
|
||||
if( report_level == UNSET_INT)
|
||||
if (report_level == UNSET_INT)
|
||||
report_level = DEFAULT_REPORTLEVEL;
|
||||
|
||||
/* Set reporting settings */
|
||||
@@ -267,75 +285,75 @@ main(int argc, char **argv)
|
||||
if (argc > max(optind, 1)) {
|
||||
int i;
|
||||
|
||||
// if no config file was read, ignore hard coded default modes
|
||||
/*
|
||||
* if no config file was read, ignore hard coded default
|
||||
* modes
|
||||
*/
|
||||
if (cfgresult == 0)
|
||||
clear_modes();
|
||||
|
||||
// turn additional options on or off (using ! as prefix)
|
||||
/* turn additional options on or off (using ! as prefix) */
|
||||
for (i = max(optind, 1); i < argc; i++) {
|
||||
int state = (*argv[i] == '!') ? 0 : 1;
|
||||
char *name = (state) ? argv[i] : argv[i]+1;
|
||||
char *name = (state) ? argv[i] : argv[i] + 1;
|
||||
int shortname = (strlen(name) == 1) ? name[0] : '\0';
|
||||
// debug: fprintf(stderr, "%s%s", (state) ? "" : "!", name);
|
||||
int found = set_mode(shortname, name, state);
|
||||
|
||||
if (!found) {
|
||||
fprintf(stderr, "Invalid Screen: %s\n", name);
|
||||
return(EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (server == NULL)
|
||||
server = DEFAULT_SERVER;
|
||||
|
||||
// Connect to the server...
|
||||
usleep(500000); // wait for the server to start up
|
||||
/* Connect to the server... */
|
||||
sock = sock_connect(server, port);
|
||||
if (sock < 0) {
|
||||
fprintf(stderr, "Error connecting to LCD server %s on port %d.\n"
|
||||
"Check to see that the server is running and operating normally.\n",
|
||||
server, port);
|
||||
return(EXIT_FAILURE);
|
||||
"Check to see that the server is running and operating normally.\n",
|
||||
server, port);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
sock_send_string(sock, "hello\n");
|
||||
usleep(500000); // wait for the server to say hi.
|
||||
usleep(500000); /* wait for the server to say hi. */
|
||||
|
||||
// We grab the real values below, from the "connect" line.
|
||||
/* We grab the real values below, from the "connect" line. */
|
||||
lcd_wid = 20;
|
||||
lcd_hgt = 4;
|
||||
lcd_cellwid = 5;
|
||||
lcd_cellhgt = 8;
|
||||
|
||||
if (foreground != TRUE) {
|
||||
if (daemon(1,0) != 0) {
|
||||
if (daemon(1, 0) != 0) {
|
||||
fprintf(stderr, "Error: daemonize failed\n");
|
||||
return(EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (pidfile != NULL) {
|
||||
FILE *pidf = fopen(pidfile, "w");
|
||||
|
||||
if (pidf) {
|
||||
fprintf(pidf, "%d\n", (int) getpid());
|
||||
fprintf(pidf, "%d\n", (int)getpid());
|
||||
fclose(pidf);
|
||||
pidfile_written = TRUE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Error creating pidfile %s: %s\n",
|
||||
pidfile, strerror(errno));
|
||||
return(EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init the status gatherers...
|
||||
/* Init the status gatherers... */
|
||||
mode_init();
|
||||
|
||||
// And spew stuff!
|
||||
/* And spew stuff! */
|
||||
main_loop();
|
||||
|
||||
// Clean up & exit
|
||||
exit_program(EXIT_SUCCESS);
|
||||
|
||||
/* NOTREACHED */
|
||||
@@ -343,10 +361,12 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
/* reads and parses configuration filei
|
||||
* returns: 1 if configfile was read,
|
||||
* 0 if default configfile doesn't exist
|
||||
* <0 on error
|
||||
/**
|
||||
* Reads and parses configuration file.
|
||||
* \param configfile The configfile to read or NULL for the default config.
|
||||
* \retval 1 if configfile was read,
|
||||
* \retval 0 if default configfile doesn't exist
|
||||
* \retval <0 on error
|
||||
*/
|
||||
static int
|
||||
process_configfile(char *configfile)
|
||||
@@ -356,22 +376,24 @@ process_configfile(char *configfile)
|
||||
|
||||
debug(RPT_DEBUG, "%s(%s)", __FUNCTION__, (configfile) ? configfile : "<null>");
|
||||
|
||||
/* Read config settings*/
|
||||
/* Read config settings */
|
||||
|
||||
if (configfile == NULL) {
|
||||
struct stat statbuf;
|
||||
|
||||
// if default config file does not exist, do not consider this an error
|
||||
/*
|
||||
* if default config file does not exist, do not consider
|
||||
* this an error and continue
|
||||
*/
|
||||
if ((lstat(DEFAULT_CONFIGFILE, &statbuf) == -1) && (errno = ENOENT))
|
||||
return 0;
|
||||
|
||||
configfile = DEFAULT_CONFIGFILE;
|
||||
}
|
||||
|
||||
|
||||
if (config_read_file(configfile) != 0) {
|
||||
report(RPT_CRIT, "Could not read config file: %s", configfile);
|
||||
return -1;
|
||||
//report(RPT_WARNING, "Could not read config file: %s", configfile);
|
||||
}
|
||||
|
||||
if (server == NULL) {
|
||||
@@ -387,7 +409,8 @@ process_configfile(char *configfile)
|
||||
if (report_dest == UNSET_INT) {
|
||||
if (config_get_bool(progname, "ReportToSyslog", 0, 0)) {
|
||||
report_dest = RPT_DEST_SYSLOG;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
report_dest = RPT_DEST_STDERR;
|
||||
}
|
||||
}
|
||||
@@ -405,14 +428,15 @@ process_configfile(char *configfile)
|
||||
displayname = strdup(tmp);
|
||||
|
||||
/*
|
||||
* check for config file variables to override all the sequence defaults
|
||||
* check for config file variables to override all the sequence
|
||||
* defaults
|
||||
*/
|
||||
for (k = 0; sequence[k].which != 0; k++) {
|
||||
for (k = 0; sequence[k].which != 0; k++) {
|
||||
if (sequence[k].longname != NULL) {
|
||||
sequence[k].on_time = config_get_int(sequence[k].longname, "OnTime", 0, sequence[k].on_time);
|
||||
sequence[k].off_time = config_get_int(sequence[k].longname, "OffTime", 0, sequence[k].off_time);
|
||||
sequence[k].show_invisible = config_get_bool(sequence[k].longname, "ShowInvisible", 0, sequence[k].show_invisible);
|
||||
if (config_get_bool( sequence[k].longname, "Active", 0, sequence[k].flags & ACTIVE))
|
||||
if (config_get_bool(sequence[k].longname, "Active", 0, sequence[k].flags & ACTIVE))
|
||||
sequence[k].flags |= ACTIVE;
|
||||
else
|
||||
sequence[k].flags &= (~ACTIVE);
|
||||
@@ -422,8 +446,9 @@ process_configfile(char *configfile)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Print help screen and exit */
|
||||
void
|
||||
HelpScreen (int exit_state)
|
||||
HelpScreen(int exit_state)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"lcdproc - LCDproc system status information viewer\n"
|
||||
@@ -464,9 +489,8 @@ HelpScreen (int exit_state)
|
||||
exit(exit_state);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Called upon TERM and INTR signals...
|
||||
//
|
||||
|
||||
/** Called upon TERM and INTR signals. Also removes the pid-file. */
|
||||
void
|
||||
exit_program(int val)
|
||||
{
|
||||
@@ -486,21 +510,23 @@ exit_program(int val)
|
||||
|
||||
#ifdef LCDPROC_MENUS
|
||||
int
|
||||
menus_init ()
|
||||
menus_init()
|
||||
{
|
||||
int k;
|
||||
int k;
|
||||
|
||||
for (k = 0; sequence[k].which ; k++) {
|
||||
for (k = 0; sequence[k].which; k++) {
|
||||
if (sequence[k].longname) {
|
||||
sock_printf(sock, "menu_add_item {} %c checkbox {%s} -value %s\n",
|
||||
sequence[k].which, sequence[k].longname,
|
||||
(sequence[k].flags & ACTIVE) ? "on" : "off");
|
||||
sequence[k].which, sequence[k].longname,
|
||||
(sequence[k].flags & ACTIVE) ? "on" : "off");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LCDPROC_CLIENT_TESTMENUS
|
||||
// # to be entered on escape from test_menu (but overwritten
|
||||
// # for test_{checkbox,ring}
|
||||
/*
|
||||
* 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");
|
||||
@@ -514,9 +540,11 @@ menus_init ()
|
||||
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
|
||||
/*
|
||||
* 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");
|
||||
@@ -527,16 +555,14 @@ menus_init ()
|
||||
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 //LCDPROC_CLIENT_TESTMENUS
|
||||
#endif /* LCDPROC_CLIENT_TESTMENUS */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif //LCDPROC_MENUS
|
||||
#endif /* LCDPROC_MENUS */
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Main program loop...
|
||||
//
|
||||
/** Main program loop... */
|
||||
void
|
||||
main_loop(void)
|
||||
{
|
||||
@@ -547,16 +573,13 @@ main_loop(void)
|
||||
int argc, newtoken;
|
||||
int len;
|
||||
|
||||
// Main loop
|
||||
// Run whatever screen we want, then wait. Woo-hoo!
|
||||
while (!Quit) {
|
||||
// Check for server input...
|
||||
/* Check for server input... */
|
||||
len = sock_recv(sock, buf, 8000);
|
||||
|
||||
// Handle server input...
|
||||
/* Handle server input... */
|
||||
while (len > 0) {
|
||||
// Now split the string into tokens...
|
||||
//for (i=0; i<argc; i++) argv[i]=NULL; // Get rid of old tokens
|
||||
/* Now split the string into tokens... */
|
||||
argc = 0;
|
||||
newtoken = 1;
|
||||
|
||||
@@ -565,22 +588,22 @@ main_loop(void)
|
||||
case ' ':
|
||||
newtoken = 1;
|
||||
buf[i] = 0;
|
||||
break;
|
||||
default: // regular chars, keep tokenizing
|
||||
break;
|
||||
default: /* regular chars, keep
|
||||
* tokenizing */
|
||||
if (newtoken)
|
||||
argv[argc++] = buf + i;
|
||||
newtoken = 0;
|
||||
break;
|
||||
break;
|
||||
case '\0':
|
||||
case '\n':
|
||||
buf[i] = 0;
|
||||
if (argc > 0) {
|
||||
//printf("%s %s\n", argv[0], argv[1]);
|
||||
if (0 == strcmp(argv[0], "listen")) {
|
||||
for (j = 0; sequence[j].which; j++) {
|
||||
if (sequence[j].which == argv[1][0]) {
|
||||
sequence[j].flags |= VISIBLE;
|
||||
//debug(RPT_DEBUG, "Listen %s", argv[1]);
|
||||
debug(RPT_DEBUG, "Listen %s", argv[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -588,7 +611,7 @@ main_loop(void)
|
||||
for (j = 0; sequence[j].which; j++) {
|
||||
if (sequence[j].which == argv[1][0]) {
|
||||
sequence[j].flags &= ~VISIBLE;
|
||||
//debug(RPT_DEBUG, "Ignore %s", argv[1]);
|
||||
debug(RPT_DEBUG, "Ignore %s", argv[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -598,7 +621,7 @@ main_loop(void)
|
||||
#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"));
|
||||
set_mode(argv[2][0], "", strcmp(argv[3], "off"));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -627,32 +650,31 @@ main_loop(void)
|
||||
#endif
|
||||
}
|
||||
else if (0 == strcmp(argv[0], "bye")) {
|
||||
//printf("Exiting LCDproc\n");
|
||||
exit_program(EXIT_SUCCESS);
|
||||
}
|
||||
else if (0 == strcmp(argv[0], "success")) {
|
||||
}
|
||||
else {
|
||||
//int j;
|
||||
//for (j = 0; j < argc; j++)
|
||||
// printf("%s ", argv[j]);
|
||||
//printf("\n");
|
||||
/*
|
||||
int j;
|
||||
for (j = 0; j < argc; j++)
|
||||
printf("%s ", argv[j]);
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// Restart tokenizing
|
||||
/* Restart tokenizing */
|
||||
argc = 0;
|
||||
newtoken = 1;
|
||||
break;
|
||||
} // switch( buf[i] )
|
||||
break;
|
||||
} /* switch( buf[i] ) */
|
||||
}
|
||||
|
||||
len = sock_recv(sock, buf, 8000);
|
||||
//debug("\n");
|
||||
}
|
||||
|
||||
// Gather stats...
|
||||
// Update screens...
|
||||
/* Gather stats and update screens */
|
||||
if (connected) {
|
||||
for (i = 0; sequence[i].which > 0; i++) {
|
||||
sequence[i].timer++;
|
||||
@@ -663,14 +685,14 @@ main_loop(void)
|
||||
if (sequence[i].flags & VISIBLE) {
|
||||
if (sequence[i].timer >= sequence[i].on_time) {
|
||||
sequence[i].timer = 0;
|
||||
// Now, update the screen...
|
||||
/* Now, update the screen... */
|
||||
update_screen(&sequence[i], 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sequence[i].timer >= sequence[i].off_time) {
|
||||
sequence[i].timer = 0;
|
||||
// Now, update the screen...
|
||||
/* Now, update the screen... */
|
||||
update_screen(&sequence[i], sequence[i].show_invisible);
|
||||
}
|
||||
}
|
||||
@@ -679,8 +701,9 @@ main_loop(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Now sleep...
|
||||
/* Now sleep... */
|
||||
usleep(TIME_UNIT);
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
+24
-12
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/main.h
|
||||
* Contains mode related defines and structures.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
@@ -32,22 +43,23 @@ extern int lcd_hgt;
|
||||
extern int lcd_cellwid;
|
||||
extern int lcd_cellhgt;
|
||||
|
||||
/** Screen data structure */
|
||||
typedef struct _screen_mode
|
||||
{
|
||||
char *longname; // Which screen is it?
|
||||
char which; // Which screen is it?
|
||||
int on_time; // How often to update while visible?
|
||||
int off_time; // How often to get stats while not visible?
|
||||
int show_invisible; // Send stats while not visible?
|
||||
int timer; // Time since last update
|
||||
int flags; // bit 1 visible, bit 2 selected for display, bit 3 first
|
||||
int (*func)(int,int,int *); // function pointer
|
||||
char *longname; /**< Which screen is it (long name)? */
|
||||
char which; /**< Which screen is it (short name)? */
|
||||
int on_time; /**< How often to update while visible? */
|
||||
int off_time; /**< How often to get stats while not visible? */
|
||||
int show_invisible; /**< Send stats while not visible? */
|
||||
int timer; /**< Time since last update */
|
||||
int flags; /**< See mode flags defines */
|
||||
int (*func)(int,int,int *); /**< Pointer to init / update function */
|
||||
} ScreenMode;
|
||||
|
||||
//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
|
||||
/* mode flags */
|
||||
#define VISIBLE 0x00000001 /**< currently visible */
|
||||
#define ACTIVE 0x00000002 /**< selected for display */
|
||||
#define INITIALIZED 0x00000004 /**< screen had already been initialized */
|
||||
|
||||
#define BLINK_ON 0x10
|
||||
#define BLINK_OFF 0x11
|
||||
|
||||
+57
-24
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/mem.c
|
||||
* Implements the 'Memory' and 'ProcSize' screens.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -18,16 +29,25 @@
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Mem Screen displays info about memory and swap usage...
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## MEM #### SWAP #@| |M 758.3M [- ] 35.3%@|
|
||||
// | 758.3M Totl 1.884G | |S 1.884G [ ] 0.1% |
|
||||
// | 490.8M Free 1.882G | +--------------------+
|
||||
// |E--- F E F|
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* Mem Screen displays info about memory and swap usage...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## MEM #### SWAP #@| |M 758.3M [- ] 35.3%@|
|
||||
* | 758.3M Totl 1.884G | |S 1.884G [ ] 0.1% |
|
||||
* | 490.8M Free 1.882G | +--------------------+
|
||||
* |E--- F E F|
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
mem_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -134,7 +154,7 @@ mem_screen(int rep, int display, int *flags_ptr)
|
||||
if (display)
|
||||
sock_printf(sock, "widget_set M memgauge 2 4 %.0f\n",
|
||||
lcd_cellwid * gauge_wid * value);
|
||||
}
|
||||
}
|
||||
|
||||
// Free swap graph
|
||||
if (mem[1].total > 0) {
|
||||
@@ -144,7 +164,7 @@ mem_screen(int rep, int display, int *flags_ptr)
|
||||
if (display)
|
||||
sock_printf(sock, "widget_set M swapgauge %i 4 %.0f\n",
|
||||
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -171,7 +191,7 @@ mem_screen(int rep, int display, int *flags_ptr)
|
||||
if (display)
|
||||
sock_printf(sock, "widget_set M memgauge %i 1 %.0f\n",
|
||||
gauge_offs, lcd_cellwid * gauge_wid * value);
|
||||
}
|
||||
}
|
||||
|
||||
sprintf_percent(tmp, value * 100);
|
||||
}
|
||||
@@ -200,6 +220,10 @@ mem_screen(int rep, int display, int *flags_ptr)
|
||||
} // End mem_screen()
|
||||
|
||||
|
||||
/**
|
||||
* Compares memory usage two procinfo structures and returns 1 (true) if the
|
||||
* second one's is larger than the first one's, 0 (false) otherwise.
|
||||
*/
|
||||
static int
|
||||
sort_procs(void *a, void *b)
|
||||
{
|
||||
@@ -215,16 +239,25 @@ sort_procs(void *a, void *b)
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Mem Top Screen displays info about top 5 memory hogs...
|
||||
//
|
||||
// +--------------------+ +--------------------+
|
||||
// |## TOP MEM: myhos #@| |## TOP MEM: myhos #@|
|
||||
// |1 110.4M mysqld | |1 110.4M mysqld |
|
||||
// |2 35.38M konqueror(2| +--------------------+
|
||||
// |3 29.21M XFree86 |
|
||||
// +--------------------+
|
||||
//
|
||||
/**
|
||||
* Mem Top Screen displays info about top 5 memory hogs...
|
||||
*
|
||||
*\verbatim
|
||||
*
|
||||
* +--------------------+ +--------------------+
|
||||
* |## TOP MEM: myhos #@| |## TOP MEM: myhos #@|
|
||||
* |1 110.4M mysqld | |1 110.4M mysqld |
|
||||
* |2 35.38M konqueror(2| +--------------------+
|
||||
* |3 29.21M XFree86 |
|
||||
* +--------------------+
|
||||
*
|
||||
*\endverbatim
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
mem_top_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -281,7 +314,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
||||
else
|
||||
sock_printf(sock, "widget_set S %i 1 %i {%i %5s %s}\n",
|
||||
i, i, i, mem, p->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//printf("Mem hog: none?\n");
|
||||
|
||||
+45
-24
@@ -1,3 +1,14 @@
|
||||
/** \file clients/lcdproc/mode.c
|
||||
* Implements the 'About' screen and contains wrappers for machine dependend
|
||||
* initialization / closing.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -16,16 +27,14 @@
|
||||
|
||||
#include "shared/sockets.h"
|
||||
|
||||
#include "mode.h"
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
#include "machine.h"
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
# include "eyebox.h"
|
||||
#endif
|
||||
|
||||
// TODO: Clean this up... Support multiple display sizes..
|
||||
|
||||
#endif
|
||||
|
||||
/** Initialize mode specific things. */
|
||||
int
|
||||
mode_init(void)
|
||||
{
|
||||
@@ -34,12 +43,23 @@ mode_init(void)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/** Clean up modes on exit */
|
||||
void
|
||||
mode_close(void)
|
||||
{
|
||||
machine_close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls the mode specific screen init / update function and updates the Eyebox
|
||||
* screen as well. Sets the backlight state according to return value of the
|
||||
* mode specific screen function.
|
||||
*
|
||||
* \param m The screen mode
|
||||
* \param display Flag whether to update screen even if not visible.
|
||||
* \return Backlight state
|
||||
*/
|
||||
int
|
||||
update_screen(ScreenMode *m, int display)
|
||||
{
|
||||
@@ -48,8 +68,9 @@ update_screen(ScreenMode *m, int display)
|
||||
|
||||
if (m && m->func) {
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
/* Save the initialized flag (may be modified by m->func) */
|
||||
int init_flag = (m->flags & INITIALIZED);
|
||||
#endif
|
||||
#endif
|
||||
status = m->func(m->timer, display, &(m->flags));
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
/* Eyebox Init */
|
||||
@@ -57,11 +78,10 @@ update_screen(ScreenMode *m, int display)
|
||||
eyebox_screen(m->which,0);
|
||||
/* Eyebox Flush */
|
||||
eyebox_screen(m->which,1);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (status != old_status)
|
||||
{
|
||||
if (status != old_status) {
|
||||
if (status == BACKLIGHT_OFF)
|
||||
sock_send_string(sock, "backlight off\n");
|
||||
if (status == BACKLIGHT_ON)
|
||||
@@ -74,13 +94,14 @@ update_screen(ScreenMode *m, int display)
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////// Let the Modes Begin! /////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Credit Screen shows who wrote this...
|
||||
//
|
||||
/**
|
||||
* Credit Screen shows who wrote this...
|
||||
*
|
||||
* \param rep Time since last screen update
|
||||
* \param display 1 if screen is visible or data should be updated
|
||||
* \param flags_ptr Mode flags
|
||||
* \return Always 0
|
||||
*/
|
||||
int
|
||||
credit_screen(int rep, int display, int *flags_ptr)
|
||||
{
|
||||
@@ -158,8 +179,8 @@ credit_screen(int rep, int display, int *flags_ptr)
|
||||
int contr_num = 0;
|
||||
int i;
|
||||
|
||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||
*flags_ptr |= INITIALIZED;
|
||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||
*flags_ptr |= INITIALIZED;
|
||||
|
||||
/* get number of contributors */
|
||||
for (contr_num = 0; contributors[contr_num] != NULL; contr_num++)
|
||||
@@ -173,22 +194,22 @@ credit_screen(int rep, int display, int *flags_ptr)
|
||||
sock_printf(sock, "widget_set A text 1 2 %d 2 h 8 {%s}\n",
|
||||
lcd_wid, "LCDproc was brought to you by:");
|
||||
}
|
||||
|
||||
// frame from (2nd/3rd line, left) to (last line, right)
|
||||
|
||||
/* frame from (2nd/3rd line, left) to (last line, right) */
|
||||
sock_send_string(sock, "widget_add A f frame\n");
|
||||
sock_printf(sock, "widget_set A f 1 %i %i %i %i %i v %i\n",
|
||||
((lcd_hgt >= 4) ? 3 : 2), lcd_wid, lcd_hgt, lcd_wid, contr_num,
|
||||
// scroll rate: 1 line every X ticks (= 1/8 sec)
|
||||
((lcd_hgt >= 4) ? 8 : 12));
|
||||
|
||||
// frame contents
|
||||
/* frame contents */
|
||||
for (i = 1; i < contr_num; i++) {
|
||||
sock_printf(sock, "widget_add A c%i string -in f\n", i);
|
||||
sock_printf(sock, "widget_set A c%i 1 %i {%s}\n", i, i, contributors[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
} // End credit_screen()
|
||||
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#ifndef MODE_H
|
||||
#define MODE_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
int mode_init(void);
|
||||
void mode_close(void);
|
||||
|
||||
int update_screen(ScreenMode *m, int display);
|
||||
|
||||
int credit_screen(int rep, int display, int *flags_ptr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "shared/report.h"
|
||||
#include "shared/configfile.h"
|
||||
#include "shared/sockets.h"
|
||||
|
||||
+1
-1
@@ -307,7 +307,7 @@ EXTRACT_PRIVATE = YES
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
|
||||
# defined locally in source files will be included in the documentation.
|
||||
|
||||
@@ -10,18 +10,27 @@ Here we provide functions that should be used by all parts of the program.
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="debug.h">
|
||||
<sect1 id="report.h">
|
||||
<title>report.h : Debugging and reporting</title>
|
||||
|
||||
<para>To enable the debug() function on all of the software, just type:
|
||||
./configure --enable-debug and recompile with 'make'.</para>
|
||||
<screen>./configure --enable-debug and recompile with 'make'.</screen></para>
|
||||
|
||||
<para>To enable the debug() function only in specific files:
|
||||
1) Configure without enabling debug (that is without --enable-debug)
|
||||
2) Edit the source file that you want to debug and put the following
|
||||
line at the top, before the #include "report.h" line:
|
||||
#define DEBUG
|
||||
3) Then recompile with 'make'
|
||||
<procedure><title>Enabling the debug() function only in specific files:</title>
|
||||
<step>
|
||||
<para>Configure without enabling debug (that is without --enable-debug).</para>
|
||||
</step>
|
||||
<step>
|
||||
<para>Edit the source file that you want to debug and put the following line
|
||||
at the top, before the #include "report.h" line: <code>#define DEBUG</code>.
|
||||
</para>
|
||||
</step>
|
||||
<step>
|
||||
<para>Then recompile with 'make'.</para>
|
||||
</step>
|
||||
</procedure>
|
||||
|
||||
<para>
|
||||
This way, the global DEBUG macro is off but is locally enabled in
|
||||
certains parts of the software.</para>
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#endif
|
||||
#include "lcd.h"
|
||||
#include "bayrad.h"
|
||||
//#include "drv_base.h"
|
||||
#include "shared/str.h"
|
||||
#include "report.h"
|
||||
#include "lcd_lib.h"
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#define DEBUG 1
|
||||
#include "lcd.h"
|
||||
#include "shared/str.h"
|
||||
#include "glk.h"
|
||||
#include "glkproto.h"
|
||||
#include "report.h"
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "hd44780-i2c.h"
|
||||
#include "hd44780-low.h"
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "report.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -401,8 +401,8 @@ static void setLIS2Fans(int fd, int fan1, int fan2, int fan3, int fan4)
|
||||
|
||||
/**
|
||||
* Write a character.
|
||||
* \param fd File handle to write to.
|
||||
* \param ch Character to write.
|
||||
* \param fd File handle to write to.
|
||||
* \param code Character to write.
|
||||
*/
|
||||
static void writeChar(int fd, unsigned char code)
|
||||
{
|
||||
|
||||
@@ -1428,7 +1428,7 @@ HD44780_output(Driver *drvthis, int on)
|
||||
* \param dispOffsets Array to store display offsets.
|
||||
* \param dOffsize Size of dispOffsets.
|
||||
* \param dispSizeArray Array of display vertical sizes (= spanlist).
|
||||
* \param spanlist '\0'-terminated input span list in comma delimited format.
|
||||
* \param spanlist '\\0'-terminated input span list in comma delimited format.
|
||||
* \return Number of span elements, -1 on parse error.
|
||||
*/
|
||||
static int
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "lcd.h"
|
||||
#include "i2500vfd.h"
|
||||
#include "report.h"
|
||||
|
||||
@@ -1018,7 +1018,7 @@ imonlcd_output(Driver *drvthis, int state)
|
||||
icon |= IMON_ICON_OGG;
|
||||
break;
|
||||
case 3:
|
||||
icon |= IMON_ICON_WMA;
|
||||
icon |= IMON_ICON_WMA2;
|
||||
break;
|
||||
case 4:
|
||||
icon |= IMON_ICON_WAV;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "lcd.h"
|
||||
#include "irmanin.h"
|
||||
#include "report.h"
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "lcd.h"
|
||||
#include "shared/str.h"
|
||||
#include "irtrans.h"
|
||||
#include "irtrans_remote.h"
|
||||
#include "irtrans_network.h"
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "lcd.h"
|
||||
#include "joy.h"
|
||||
#include "report.h"
|
||||
#include "shared/str.h"
|
||||
|
||||
#define JOY_NAMELENGTH 128
|
||||
#define JOY_DEFAULT_DEVICE "/dev/js0"
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
|
||||
#include "lcd.h"
|
||||
#include "lb216.h"
|
||||
#include "shared/str.h"
|
||||
#include "report.h"
|
||||
//#include "drv_base.h"
|
||||
|
||||
#define LB216_DEFAULT_DEVICE "/dev/lcd"
|
||||
#define LB216_DEFAULT_SPEED 9600
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "report.h"
|
||||
#include "lcd_lib.h"
|
||||
/*
|
||||
#include "shared/str.h"
|
||||
#include "server/configfile.h"
|
||||
*/
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
#define WR 0x01
|
||||
#define IODELAY 500
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "lcd.h"
|
||||
#include "sed1520.h"
|
||||
#include "report.h"
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "shared/str.h"
|
||||
#include "lcd.h"
|
||||
#include "stv5730.h"
|
||||
#include "report.h"
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "report.h"
|
||||
#include "lcd_lib.h"
|
||||
|
||||
#include "shared/str.h"
|
||||
|
||||
#define SLI_DEFAULT_DEVICE "/dev/lcd"
|
||||
|
||||
typedef enum {
|
||||
|
||||
+23
-14
@@ -1,4 +1,4 @@
|
||||
/** \file LL.c
|
||||
/** \file shared/LL.c
|
||||
* Define routines to deal with doubly linked lists
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,7 @@ LL_Destroy(LinkedList *list)
|
||||
}
|
||||
|
||||
|
||||
/* Move to another entry in the list.
|
||||
/** Move to another entry in the list.
|
||||
* Set list's \c current pointer to the node denoted to by \c whereto.
|
||||
* \param list List object.
|
||||
* \param whereto Direction where to set the list's \c current pointer
|
||||
@@ -127,7 +127,7 @@ LL_GoTo(LinkedList *list, Direction whereto)
|
||||
}
|
||||
|
||||
|
||||
/* Return to the beginning of the list.
|
||||
/** Return to the beginning of the list.
|
||||
* Set list's \c current pointer to the first node in the list.
|
||||
* \param list List object.
|
||||
* \retval <0 error: no list given
|
||||
@@ -530,7 +530,7 @@ LL_Remove(LinkedList *list, void *data, Direction whereto)
|
||||
* \retval 0 success
|
||||
*/
|
||||
int
|
||||
LL_Push(LinkedList *list, void *add) // Add node to end of list
|
||||
LL_Push(LinkedList *list, void *add)
|
||||
{
|
||||
if (!list)
|
||||
return -1;
|
||||
@@ -550,7 +550,7 @@ LL_Push(LinkedList *list, void *add) // Add node to end of list
|
||||
* \return Pointer to data of deleted node; \c NULL on error.
|
||||
*/
|
||||
void *
|
||||
LL_Pop(LinkedList *list) // Remove node from end of list
|
||||
LL_Pop(LinkedList *list)
|
||||
{
|
||||
if (!list)
|
||||
return NULL;
|
||||
@@ -568,7 +568,7 @@ LL_Pop(LinkedList *list) // Remove node from end of list
|
||||
* \return Pointer to last node's data; \c NULL on error.
|
||||
*/
|
||||
void *
|
||||
LL_Top(LinkedList *list) // Peek at end node
|
||||
LL_Top(LinkedList *list)
|
||||
{
|
||||
return LL_GetLast(list);
|
||||
}
|
||||
@@ -580,7 +580,7 @@ LL_Top(LinkedList *list) // Peek at end node
|
||||
* \return Pointer to data of deleted node; \c NULL on error.
|
||||
*/
|
||||
void *
|
||||
LL_Shift(LinkedList *list) // Remove node from start of list
|
||||
LL_Shift(LinkedList *list)
|
||||
{
|
||||
if (!list)
|
||||
return NULL;
|
||||
@@ -598,7 +598,7 @@ LL_Shift(LinkedList *list) // Remove node from start of list
|
||||
* \return Pointer to first node's data; \c NULL on error.
|
||||
*/
|
||||
void *
|
||||
LL_Look(LinkedList *list) // Peek at first node
|
||||
LL_Look(LinkedList *list)
|
||||
{
|
||||
return LL_GetFirst(list);
|
||||
}
|
||||
@@ -612,7 +612,7 @@ LL_Look(LinkedList *list) // Peek at first node
|
||||
* \retval 0 success
|
||||
*/
|
||||
int
|
||||
LL_Unshift(LinkedList *list, void *add) // Add node to beginning of list
|
||||
LL_Unshift(LinkedList *list, void *add)
|
||||
{
|
||||
if (!list)
|
||||
return -1;
|
||||
@@ -625,9 +625,14 @@ LL_Unshift(LinkedList *list, void *add) // Add node to beginning of list
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Add an item to the end of its "priority group"
|
||||
// The list is assumed to be sorted already...
|
||||
/** Add an item to the end of its "priority group"
|
||||
* The list is assumed to be sorted already.
|
||||
* \param list List object.
|
||||
* \param add Pointer to new node's data.
|
||||
* \param compare Pointer to a comparison function.
|
||||
* \retval <0 error
|
||||
* \retval 0 success
|
||||
*/
|
||||
int
|
||||
LL_PriorityEnqueue(LinkedList *list, void *add, int (*compare)(void *, void *))
|
||||
{
|
||||
@@ -661,9 +666,13 @@ LL_PriorityEnqueue(LinkedList *list, void *add, int (*compare)(void *, void *))
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/** Switch two nodes positions.
|
||||
* \param one First list object.
|
||||
* \param two Second list object.
|
||||
* \return -1 on error, 0 on success
|
||||
*/
|
||||
int
|
||||
LL_SwapNodes(LL_node *one, LL_node *two) // Switch two nodes positions...
|
||||
LL_SwapNodes(LL_node *one, LL_node *two)
|
||||
{
|
||||
LL_node *firstprev, *firstnext;
|
||||
LL_node *secondprev, *secondnext;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/** \file shared/LL.h
|
||||
* Define routines to deal with doubly linked lists
|
||||
*/
|
||||
|
||||
#ifndef LL_H
|
||||
#define LL_H
|
||||
|
||||
|
||||
+8
-7
@@ -1,6 +1,10 @@
|
||||
/*
|
||||
/** \file shared/report.c
|
||||
* Contains reporting functions.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* report.c
|
||||
* This file is part of LCDd, the lcdproc server.
|
||||
* This file is part of LCDproc.
|
||||
*
|
||||
* This file is released under the GNU General Public License. Refer to the
|
||||
* COPYING file distributed with this package.
|
||||
@@ -8,14 +12,9 @@
|
||||
* Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||
* 2001, Joris Robijn
|
||||
* 2005, Peter Marschall
|
||||
*
|
||||
* Contains reporting functions
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "report.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -25,6 +24,8 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "report.h"
|
||||
|
||||
static int report_level = RPT_INFO;
|
||||
static int report_dest = RPT_DEST_STORE;
|
||||
|
||||
|
||||
+8
-2
@@ -1,4 +1,8 @@
|
||||
/*
|
||||
/** \file shared/report.h
|
||||
* Contains reporting functions.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* report.h
|
||||
* This file is part of LCDd, the lcdproc server.
|
||||
*
|
||||
@@ -13,7 +17,8 @@
|
||||
#ifndef REPORT_H
|
||||
#define REPORT_H
|
||||
|
||||
/* DEBUGGING / REPORTING
|
||||
/** DEBUGGING / REPORTING
|
||||
*\verbatim
|
||||
*
|
||||
* To enable the debug() function on all of the software, just type:
|
||||
* ./configure --enable-debug
|
||||
@@ -53,6 +58,7 @@
|
||||
* function.
|
||||
* The code that this function generates will not be in the executable when
|
||||
* compiled without debugging. This way memory and CPU cycles are saved.
|
||||
*\endverbatim
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
+76
-20
@@ -1,3 +1,13 @@
|
||||
/** \file shared/sockets.c
|
||||
* Socket functions available to server and clients.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of LCDproc.
|
||||
*
|
||||
* Feel free to use this in your own clients... :)
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
@@ -24,17 +34,18 @@
|
||||
#include "report.h"
|
||||
#include "sockets.h"
|
||||
|
||||
/**************************************************
|
||||
LCDproc client sockets code...
|
||||
|
||||
Feel free to use this in your own clients... :)
|
||||
**************************************************/
|
||||
|
||||
// Length of longest transmission allowed at once...
|
||||
#define MAXMSG 8192
|
||||
|
||||
typedef struct sockaddr_in sockaddr_in;
|
||||
|
||||
/**
|
||||
* Tries to resolve a resolve a hostname.
|
||||
* \param name Pointer to resolves IP-address
|
||||
* \param hostname Hostname or IP-address (as string)
|
||||
* \param port Port number
|
||||
* \return 0 on success, -1 on error.
|
||||
*/
|
||||
static int
|
||||
sock_init_sockaddr (sockaddr_in *name, const char *hostname, unsigned short int port)
|
||||
{
|
||||
@@ -51,10 +62,14 @@ sock_init_sockaddr (sockaddr_in *name, const char *hostname, unsigned short int
|
||||
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
// Client functions...
|
||||
/**
|
||||
* Connect to server.
|
||||
* \param host Hostname or IP-address
|
||||
* \param port Port number
|
||||
* \return socket file descriptor on success, -1 on error
|
||||
*/
|
||||
int
|
||||
sock_connect (char *host, unsigned short int port)
|
||||
{
|
||||
@@ -102,6 +117,11 @@ sock_connect (char *host, unsigned short int port)
|
||||
return sock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from server.
|
||||
* \param fd Socket file descriptor
|
||||
* \return 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
sock_close (int fd)
|
||||
{
|
||||
@@ -115,7 +135,13 @@ sock_close (int fd)
|
||||
}
|
||||
|
||||
|
||||
/** send printf-like formatted output */
|
||||
/**
|
||||
* Send printf-like formatted output.
|
||||
* \param fd Socket file descriptor
|
||||
* \param format Format string
|
||||
* \param ... Arguments to the format string
|
||||
* \return Number of bytes sent.
|
||||
*/
|
||||
int
|
||||
sock_printf(int fd, const char *format, .../*args*/ )
|
||||
{
|
||||
@@ -137,14 +163,26 @@ sock_printf(int fd, const char *format, .../*args*/ )
|
||||
return sock_send_string(fd, buf);
|
||||
}
|
||||
|
||||
// Send/receive lines of text
|
||||
/**
|
||||
* Send lines of text.
|
||||
* \param fd Socket file descriptor
|
||||
* \param string Pointer to the string to send.
|
||||
* \return Number of bytes sent.
|
||||
*/
|
||||
int
|
||||
sock_send_string (int fd, char *string)
|
||||
{
|
||||
return sock_send(fd, string, strlen(string));
|
||||
}
|
||||
|
||||
// Recv gives only one line per call...
|
||||
/**
|
||||
* Receive a line of text.
|
||||
* Recv gives only one line per call...
|
||||
* \param fd Socket file descriptor
|
||||
* \param dest Pointer to buffer to store the received data
|
||||
* \param maxlen Number of bytes to read at most (size of buffer)
|
||||
* \return Number of bytes received.
|
||||
*/
|
||||
int
|
||||
sock_recv_string (int fd, char *dest, size_t maxlen)
|
||||
{
|
||||
@@ -198,7 +236,13 @@ sock_recv_string (int fd, char *dest, size_t maxlen)
|
||||
return recvBytes;
|
||||
}
|
||||
|
||||
// Send/receive raw data
|
||||
/**
|
||||
* Send raw data.
|
||||
* \param fd Socket file descriptor
|
||||
* \param src Buffer holding the data to send
|
||||
* \param size Number of bytes to send at most
|
||||
* \return Number of bytes sent.
|
||||
*/
|
||||
int
|
||||
sock_send (int fd, void *src, size_t size)
|
||||
{
|
||||
@@ -235,6 +279,13 @@ sock_send (int fd, void *src, size_t size)
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive raw data.
|
||||
* \param fd Socket file descriptor
|
||||
* \param dest Pointer to buffer to store the received data
|
||||
* \param maxlen Number of bytes to read at most (size of buffer)
|
||||
* \return Number of bytes received.
|
||||
*/
|
||||
int
|
||||
sock_recv (int fd, void *dest, size_t maxlen)
|
||||
{
|
||||
@@ -262,6 +313,10 @@ sock_recv (int fd, void *dest, size_t maxlen)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Return the error message for the last error occured.
|
||||
* \return Error message string
|
||||
*/
|
||||
char*
|
||||
sock_geterror(void)
|
||||
{
|
||||
@@ -295,21 +350,22 @@ sock_geterror(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/** prints error to logfile and sends it to the client.
|
||||
* @param fd socket
|
||||
* @param message the message to send (without the "huh? ") */
|
||||
/**
|
||||
* Send an already formatted error message to the client.
|
||||
* \param fd socket
|
||||
* \param message the message to send (without the "huh? ") */
|
||||
int sock_send_error(int fd, char* message)
|
||||
{
|
||||
// simple: performance penalty isn't worth more work...
|
||||
return sock_printf_error(fd, message);
|
||||
}
|
||||
|
||||
/** prints printf-like formatted output to logfile and sends it to the
|
||||
* client.
|
||||
* @note don't add a the "huh? " to the message. This is done by this
|
||||
/**
|
||||
* Print printf-like formatted output to logfile and sends it to the client.
|
||||
* \note don't add a the "huh? " to the message. This is done by this
|
||||
* method
|
||||
* @param fd socket
|
||||
* @param format a printf format */
|
||||
* \param fd socket
|
||||
* \param format a printf format */
|
||||
int
|
||||
sock_printf_error(int fd, const char *format, .../*args*/ )
|
||||
{
|
||||
|
||||
+16
-66
@@ -1,3 +1,7 @@
|
||||
/** \file shared/sockets.h
|
||||
* Socket functions available to server and clients.
|
||||
*/
|
||||
|
||||
#ifndef SOCKETS_H
|
||||
#define SOCKETS_H
|
||||
|
||||
@@ -15,81 +19,27 @@
|
||||
# define SHUT_RDWR 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
Socket functions available to server and clients...
|
||||
(ignore the rest of the comments... I was babbling out random ideas)
|
||||
|
||||
This should have stuff to read/write sockets, open/close them, etc...
|
||||
*/
|
||||
|
||||
// Client functions...
|
||||
/** Connect to server on host, port */
|
||||
int sock_connect (char *host, unsigned short int port);
|
||||
/** Disconnect from server */
|
||||
int sock_close (int fd);
|
||||
// Send/receive lines of text
|
||||
/** Send printf-like formatted output */
|
||||
int sock_printf (int fd, const char *format, .../*args*/);
|
||||
/** Send lines of text */
|
||||
int sock_send_string (int fd, char *string);
|
||||
// Recv gives only one line per call...
|
||||
int sock_recv_string (int fd, char *dest, size_t maxlen);
|
||||
// Send/receive raw data
|
||||
/** Send raw data */
|
||||
int sock_send (int fd, void *src, size_t size);
|
||||
/** Receive a line of text */
|
||||
int sock_recv_string (int fd, char *dest, size_t maxlen);
|
||||
/** Receive raw data */
|
||||
int sock_recv (int fd, void *dest, size_t maxlen);
|
||||
|
||||
/* Return error message string for the socket function */
|
||||
|
||||
/** Return the error message for the last error occured */
|
||||
char *sock_geterror(void);
|
||||
/** Send an already formatted error message to the client */
|
||||
int sock_send_error(int fd, char* message);
|
||||
/** Print printf-like formatted output to logfile and send it to the client */
|
||||
int sock_printf_error(int fd, const char *format, .../*args*/);
|
||||
|
||||
// Er, ignore the rest of this file. I'll clean it up sometime...
|
||||
|
||||
/*****************************************************************
|
||||
LCDproc command line interface?: (while running)
|
||||
|
||||
-command
|
||||
Tells LCDproc to interpret stdin as raw commands to send through
|
||||
the socket. Input must be formatted as above, in socket interface.
|
||||
-function f
|
||||
Runs LCDproc external function f, where f is one of the predefined
|
||||
functions which can be assigned to keypad keys. (like NEXTMODE, etc)
|
||||
-key x
|
||||
Simulates keypad press of key 'x', where 'x' is (A-Z).
|
||||
-print [time]
|
||||
Prints stdin on LCD one line at a time, with no line-wrapping (raw),
|
||||
with [time] frames between updates (lines).
|
||||
-wrap [time]
|
||||
Prints stdin as with "-print", but with line wrapping when possible.
|
||||
-contrast xxx
|
||||
Sets contrast to xxx (decimal)
|
||||
-backlight [on/off]
|
||||
Turns backlight [on/off/auto], or toggles it.
|
||||
If [off], stays off.
|
||||
If [on], stays on.
|
||||
If [auto], LCDproc controls backlight based on load, etc...
|
||||
-exit
|
||||
-quit
|
||||
Duh... :)
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/*****************************************************************
|
||||
LCDproc stuff supported in config file (loose approximation):
|
||||
|
||||
Grammar is tcl-style. I.e., "command arg1 arg2 ...".
|
||||
Spaces are used as argument separators, *until* it thinks it has the final
|
||||
argument. So, "function thing shell myprogram arg1 arg2 arg3" would be
|
||||
split into "function", "thing", "shell", and "myprogram arg1 arg2 arg3".
|
||||
|
||||
User-definable functions (use built-in's to create new ones?):
|
||||
Function mp3NextSong Shell /usr/local/bin/mp3player -next
|
||||
Function MySequence Sequence cpu mem xload
|
||||
Function OtherSequence Sequence time cd xload
|
||||
|
||||
Keypad keys can be bound to any _function_:
|
||||
Key A mp3NextSong
|
||||
Key B HaltSystem
|
||||
Key C Menu
|
||||
Key D Next/+
|
||||
Key E OtherSequence
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
+23
-4
@@ -1,10 +1,29 @@
|
||||
/** \file shared/str.c
|
||||
* Commmand / argument parsing functions (for use in clients).
|
||||
*/
|
||||
|
||||
/*-
|
||||
* This file is part of LCDproc.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "report.h"
|
||||
#include "str.h"
|
||||
|
||||
/** Split elements of a string into an array of strings.
|
||||
* Elements are typically commands and arguments.
|
||||
* \param **argv Pointer to the array which will store the arguments
|
||||
* \param *str The string to be parsed
|
||||
* \param max_args Number of arguments to parse (typically the size of argv)
|
||||
* \retval <0 Error.
|
||||
* \retval >=0 The number of arguments parsed.
|
||||
*/
|
||||
int
|
||||
get_args (char **argv, char *str, int max_args)
|
||||
{
|
||||
@@ -19,11 +38,11 @@ get_args (char **argv, char *str, int max_args)
|
||||
if (max_args < 1)
|
||||
return 0;
|
||||
|
||||
//debug("get_args(%i): string=%s", max_args, str);
|
||||
debug(RPT_DEBUG, "get_args(%i): string=%s", max_args, str);
|
||||
|
||||
// Parse the command line...
|
||||
/* Parse the command line... */
|
||||
for (item = strtok (str, delimiters); item; item = strtok (NULL, delimiters)) {
|
||||
//debug("get_args: item=%s", item);
|
||||
debug(RPT_DEBUG, "get_args: item=%s", item);
|
||||
if (i < max_args) {
|
||||
argv[i] = item;
|
||||
i++;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/** \file shared/str.h
|
||||
* Commmand / argument parsing functions (for use in clients).
|
||||
*/
|
||||
|
||||
#ifndef STR_H
|
||||
#define STR_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user