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:
mmdolze
2010-02-02 23:20:29 +00:00
parent e914ee3d72
commit 66023939a1
49 changed files with 929 additions and 590 deletions
-1
View File
@@ -16,7 +16,6 @@
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "shared/str.h"
#include "shared/report.h" #include "shared/report.h"
#include "shared/configfile.h" #include "shared/configfile.h"
#include "shared/sockets.h" #include "shared/sockets.h"
+43 -15
View File
@@ -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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -12,13 +23,18 @@
#include "batt.h" #include "batt.h"
#include "machine.h" #include "machine.h"
/** Map status code > status text */
typedef struct { typedef struct {
int status; int status;
const char *name; 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 * static const char *
ac_status(int status) ac_status(int status)
{ {
@@ -38,6 +54,12 @@ ac_status(int status)
return ac_table[LCDP_AC_UNKNOWN].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 * static const char *
battery_status(int status) battery_status(int status)
{ {
@@ -59,17 +81,25 @@ battery_status(int status)
return batt_table[LCDP_AC_UNKNOWN].name; return batt_table[LCDP_AC_UNKNOWN].name;
} }
/**
//////////////////////////////////////////////////////////////////////// * Battery Screen shows apm battery status...
// Battery Screen shows apm battery status... *
// *\verbatim
// +--------------------+ +--------------------+ *
// |## AC: 100%: myho #@| |## AC: 100%: myho #@| * +--------------------+ +--------------------+
// |AC: On | |AC, Batt: Absent | * |## AC: 100%: myho #@| |## AC: 100%: myho #@|
// |Batt: Absent | +--------------------+ * |AC: On | |AC, Batt: Absent |
// |E------------------F| * |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 int
battery_screen(int rep, int display, int *flags_ptr) 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"); 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); machine_get_battstat(&acstat, &battstat, &percent);
+118 -52
View File
@@ -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 <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -37,16 +49,25 @@
static char *tickTime(char *time, int heartbeat); static char *tickTime(char *time, int heartbeat);
////////////////////////////////////////////////////////////////////// /**
// TimeDate Screen displays current time and date, uptime, OS ver... * 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 | +--------------------+ * |## Linux 2.6.11 ###@| |### TIME: myhost ##@|
//|11:32:57a 100% idle| * |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 int
time_screen(int rep, int display, int *flags_ptr) time_screen(int rep, int display, int *flags_ptr)
{ {
@@ -139,16 +160,26 @@ time_screen(int rep, int display, int *flags_ptr)
return 0; return 0;
} // End time_screen() } // End time_screen()
//////////////////////////////////////////////////////////////////////
// OldTime Screen displays current time and date... /**
// * OldTime Screen displays current time and date...
//+--------------------+ +--------------------+ *
//|## DATE & TIME ####@| |### TIME: myhost ##@| *\verbatim
//| myhost | |2005-05-17 11:32:57a| *
//|11:32:75a Wednesday,| +--------------------+ * +--------------------+ +--------------------+
//| May 17, 2005 | * |## 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 int
clock_screen(int rep, int display, int *flags_ptr) clock_screen(int rep, int display, int *flags_ptr)
{ {
@@ -219,16 +250,26 @@ clock_screen(int rep, int display, int *flags_ptr)
return 0; return 0;
} // End clock_screen() } // End clock_screen()
////////////////////////////////////////////////////////////////////
// Uptime Screen shows info about system uptime and OS version /**
// * Uptime Screen shows info about system uptime and OS version
//+--------------------+ +--------------------+ *
//|## SYSTEM UPTIME ##@| |# Linux 2.6.11: my#@| *\verbatim
//| myhost | | xxx days hh:mm:ss | *
//| xxx days hh:mm:ss | +--------------------+ * +--------------------+ +--------------------+
//| Linux 2.6.11 | * |## 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 int
uptime_screen(int rep, int display, int *flags_ptr) uptime_screen(int rep, int display, int *flags_ptr)
{ {
@@ -291,16 +332,26 @@ uptime_screen(int rep, int display, int *flags_ptr)
return 0; 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 int
big_clock_screen(int rep, int display, int *flags_ptr) big_clock_screen(int rep, int display, int *flags_ptr)
{ {
@@ -367,16 +418,25 @@ big_clock_screen(int rep, int display, int *flags_ptr)
} // End big_clock_screen() } // End big_clock_screen()
///////////////////////////////////////////////////////////////////// /**
// MiniClock Screen displays the current time with hours & minutes only * MiniClock Screen displays the current time with hours & minutes only
// *
//+--------------------+ +--------------------+ *\verbatim
//| | | 11:32 | *
//| 11:32 | | | * +--------------------+ +--------------------+
//| | +--------------------+ * | | | 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 int
mini_clock_screen(int rep, int display, int *flags_ptr) mini_clock_screen(int rep, int display, int *flags_ptr)
{ {
@@ -415,8 +475,14 @@ mini_clock_screen(int rep, int display, int *flags_ptr)
} // End mini_clock_screen() } // End mini_clock_screen()
// helper function: toggle between ':' and ' ' in time strings /** Helper function: toggle between ':' and ' ' in time strings.
static char *tickTime(char *time, int heartbeat) * \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) { if (time != NULL) {
static char colon[] = {':', ' '}; static char colon[] = {':', ' '};
+49 -21
View File
@@ -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/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <stdlib.h> #include <stdlib.h>
@@ -9,7 +20,6 @@
#include <errno.h> #include <errno.h>
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.h"
#include "main.h" #include "main.h"
#include "mode.h" #include "mode.h"
@@ -18,16 +28,25 @@
#include "util.h" #include "util.h"
////////////////////////////////////////////////////////////////////////// /**
// CPU screen shows info about percentage of the CPU being used * 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%| +--------------------+ * |## CPU 51.9%: myh #@| |CPU [---- ]48.1%@|
// |0%-------- 100%| * |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 int
cpu_screen(int rep, int display, int *flags_ptr) cpu_screen(int rep, int display, int *flags_ptr)
{ {
@@ -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 Graph Screen shows a quick-moving histogram of CPU use.
// *
// +--------------------+ +--------------------+ *\verbatim
// |## CPU: myhost ####@| |CPU: myhos|| @| *
// | || | | |||| | * +--------------------+ +--------------------+
// | ||| | +--------------------+ * |## 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 int
cpu_graph_screen(int rep, int display, int *flags_ptr) cpu_graph_screen(int rep, int display, int *flags_ptr)
{ {
+17 -14
View File
@@ -1,8 +1,5 @@
/****************************************************************************** /** \file clients/lcdproc/cpu_smp.c
* * Display cpu info for multi-processor machines.
* cpu_smp.c - dipslay cpu info for multi-processor machines
* Copyright (C) 2000 J Robert Ray
* Copyright (C) 2006,7 Peter Marschall
* *
* Adapted from cpu.c. * Adapted from cpu.c.
* *
@@ -16,10 +13,13 @@
* If the number of lines used to display the bar graphs for the CPUs is smaller * 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 * than the LCD's height, a title line is introduced, so that the screen looks
* similar to other lcdproc screens. * 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. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, * along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* */
*******************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -45,7 +44,6 @@
#include <ctype.h> #include <ctype.h>
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.h"
#include "main.h" #include "main.h"
#include "mode.h" #include "mode.h"
@@ -53,9 +51,14 @@
#include "cpu_smp.h" #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 int
cpu_smp_screen (int rep, int display, int *flags_ptr) cpu_smp_screen (int rep, int display, int *flags_ptr)
{ {
+31 -12
View File
@@ -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/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <stdlib.h> #include <stdlib.h>
@@ -19,18 +30,26 @@
#include "util.h" #include "util.h"
/////////////////////////////////////////////////////////////////////////// /**
// Gives disk stats. * Gives disk stats.
// * Stays onscreen until it is done; rolls over all mounted file systems
// 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| +--------------------+ * |## DISKS: myhost ##@| |## DISKS: myhost ##@|
// |/boot 949.6M E- F| * |/ 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... * +--------------------+
*
*\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 int
disk_screen(int rep, int display, int *flags_ptr) disk_screen(int rep, int display, int *flags_ptr)
{ {
+7 -3
View File
@@ -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 This allows to use leds, one as a free CPU meter, and one
as a free RAM meter. as a free RAM meter.
All this is in BETA version, take it as a demo... All this is in BETA version, take it as a demo...
*/
/*-
Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -33,7 +36,6 @@
#include <errno.h> #include <errno.h>
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.h"
#include "main.h" #include "main.h"
#include "mode.h" #include "mode.h"
@@ -114,7 +116,9 @@ eyebox_screen(char display, int init)
return 0; return 0;
} // End mem_screen() } // End mem_screen()
void eyebox_clear(void){ void
eyebox_clear(void)
{
/* /*
* Clear LEDs before exit * Clear LEDs before exit
*/ */
+60 -38
View File
@@ -1,6 +1,8 @@
/* /** \file clients/lcdproc/iface.c
netlcdclient - Client for LCDproc which shows networks statistics * Shows networks statistics. Imported from netlcdclient.
*/
/*-
Copyright (C) 2002 Luis Llorente Campo <luisllorente@luisllorente.com> Copyright (C) 2002 Luis Llorente Campo <luisllorente@luisllorente.com>
Multiinterface Extension by Stephan Skrodzki <skrodzki@stevekist.de> Multiinterface Extension by Stephan Skrodzki <skrodzki@stevekist.de>
Adaptions to lcdproc by Andrew Foss with fixes by M. Dolze 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 You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <stdio.h> #include <stdio.h>
@@ -31,10 +32,10 @@
#include <time.h> #include <time.h>
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.h"
#include "shared/report.h" #include "shared/report.h"
#include "shared/configfile.h" #include "shared/configfile.h"
#include "main.h" #include "main.h"
#include "machine.h"
#include "util.h" #include "util.h"
#include "iface.h" #include "iface.h"
@@ -43,12 +44,13 @@
static int iface_count = 0; /* number of interfaces */ static int iface_count = 0; /* number of interfaces */
static char unit_label[10] = "B"; /* default unit label is Bytes */ static char unit_label[10] = "B"; /* default unit label is Bytes */
static int transfer_screen = 0; /* by default, transfer screen is not shown */ 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 static int
iface_process_configfile(void) iface_process_configfile(void)
{ {
@@ -101,20 +103,30 @@ iface_process_configfile(void)
} }
////////////////////////////////////////////////////////////////////////// /**
// IFace screen shows info about percentage of the Network interface usage/throughput * IFace screen shows info about percentage of the Network interface usage /
// * throughput.
// +--------------------+ +--------------------+ *
// |## Net Load: LAN ##@| |### Net Load ######@| *\verbatim
// |UL: 123.456 Kb| |LAN: U: 34kb D: 56Mb| *
// |DL: 654.321 Kb| +--------------------+ * +--------------------+ +--------------------+
// |Total: 777.777 Kb| * |## 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 int
iface_screen(int rep, int display, int *flags_ptr) 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 */ unsigned int interval = difftime(time(NULL), iface[0].last_online); /* interval since last update */
int iface_nmbr; int iface_nmbr;
@@ -166,13 +178,12 @@ iface_screen(int rep, int display, int *flags_ptr)
} }
return 0; 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 void
initialize_speed_screen(void) initialize_speed_screen(void)
@@ -231,11 +242,15 @@ initialize_speed_screen(void)
} /* initialize_speed_screen() */ } /* initialize_speed_screen() */
/************************************************************************* /**
* Format the value (in bytes) passed as parameter according to its scale, * Format the value (in bytes) passed as parameter according to its scale,
* adding the proper suffix. Store the formatted value string in the * adding the proper suffix. Store the formatted value string in the
* variable 'buff' passed as pointer. * 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 void
format_value (char *buff, double value, char *unit) format_value (char *buff, double value, char *unit)
@@ -260,11 +275,15 @@ format_value (char *buff, double value, char *unit)
} /* format_value() */ } /* format_value() */
/************************************************************************* /**
* Format the value (in bytes) passed as parameter according to its scale, * Format the value (in bytes) passed as parameter according to its scale,
* adding the proper suffix. Store the formatted value string in the * 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 void
format_value_multi_interface (char *buff, double value, char *unit) 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_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 void
get_time_string (char *buff, time_t last_online) get_time_string (char *buff, time_t last_online)
@@ -323,11 +343,13 @@ get_time_string (char *buff, time_t last_online)
} }
} /* get_time_string() */ } /* get_time_string() */
/************************************************************************* /**
* Actualize values in display, calculating speeds in the defined interval * Actualize values in display, calculating speeds in the defined interval
* of time and sending proper commands to server. If measure unit is * 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 void
actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index) actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
@@ -407,9 +429,8 @@ actualize_speed_screen(IfaceInfo *iface, unsigned int interval, int index)
} }
} /* actualize_speed_screen() */ } /* 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 void
initialize_transfer_screen(void) initialize_transfer_screen(void)
@@ -456,10 +477,11 @@ initialize_transfer_screen(void)
} }
} /* initialize_transfer_screen() */ } /* initialize_transfer_screen() */
/************************************************************************* /**
* Actualize values in display, formatting transfer measures and sending * 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 void
actualize_transfer_screen(IfaceInfo *iface, int index) actualize_transfer_screen(IfaceInfo *iface, int index)
+18 -27
View File
@@ -1,7 +1,9 @@
#ifndef IFACE_H /** \file clients/lcdproc/iface.h
#define IFACE_H * Definitions and function prototypes for \c iface.c.
/* netlcdclient.h - definitions and function prototipes * Imported from \c netlcdclient.h.
* */
/*-
* Copyright (C) 2002 Luis Llorente Campo * Copyright (C) 2002 Luis Llorente Campo
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -10,42 +12,31 @@
* any later version. * any later version.
*/ */
#ifndef IFACE_H
#include <time.h> #define IFACE_H
#include "machine.h"
#define MAX_INTERFACES 3 /* max number of interfaces in multi-interface mode */ #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 */ IfaceInfo iface[MAX_INTERFACES]; /* interface info */
/************************/ /** Update screen content */
/* Functions prototipes */ int iface_screen(int rep, int display, int *flags_ptr);
/************************/ /** read interface stats from /proc/net/dev */
/* read interface stats from /proc/net/dev */
int get_iface_stats(IfaceInfo *interface); 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); 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); 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); 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); 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) */ * mode) */
void format_value_multi_interface(char *buff, double value, char *unit); 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); 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); void actualize_transfer_screen(IfaceInfo *iface, int index);
#endif #endif
+30 -10
View File
@@ -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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -16,16 +27,25 @@
#include "load.h" #include "load.h"
/////////////////////////////////////////////////////////////////////////// /**
// Shows a display very similar to "xload"'s histogram. * Shows a display very similar to "xload"'s histogram.
// *
// +--------------------+ +--------------------+ *\verbatim
// |## LOAD 0.44: myh #@| |myhost 0.24 1| *
// | 1| | |||||||||||0| * +--------------------+ +--------------------+
// | |||||| | +--------------------+ * |## LOAD 0.44: myh #@| |myhost 0.24 1|
// | |||| |||||||| 0| * | 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 int
xload_screen(int rep, int display, int *flags_ptr) xload_screen(int rep, int display, int *flags_ptr)
{ {
+1 -1
View File
@@ -1,4 +1,4 @@
/** \file machine.h /** \file clients/lcdproc/machine.h
* Common data types and function declarations * Common data types and function declarations
* for OS specific sources in \c machine_{Darwin,Linux,SunOS,*BSD}.c. * for OS specific sources in \c machine_{Darwin,Linux,SunOS,*BSD}.c.
* *
+4
View File
@@ -1,3 +1,7 @@
/** \file clients/lcdproc/machine_Darwin.c
* Collects system information on MacOS / Darwin.
*/
/* Copyright (c) 2003 Thomas Runge (coto@core.de) /* Copyright (c) 2003 Thomas Runge (coto@core.de)
* Mach and Darwin specific code is Copyright (c) 2006 Eric Pooch (epooch@tenon.com) * Mach and Darwin specific code is Copyright (c) 2006 Eric Pooch (epooch@tenon.com)
* *
+3
View File
@@ -1,3 +1,6 @@
/** \file clients/lcdproc/machine_FreeBSD.c
* Collects system information on FreeBSD.
*/
/* Copyright (c) 2003 Thomas Runge (coto@core.de) /* Copyright (c) 2003 Thomas Runge (coto@core.de)
* *
+10
View File
@@ -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 #ifdef linux
+3
View File
@@ -1,3 +1,6 @@
/** \file clients/lcdproc/machine_NetBSD.c
* Collects system information on NetBSD.
*/
/* Copyright (c) 2003 Thomas Runge (coto@core.de) /* Copyright (c) 2003 Thomas Runge (coto@core.de)
* *
+3
View File
@@ -1,3 +1,6 @@
/** \file clients/lcdproc/machine_OpenBSD.c
* Collects system information on OpenBSD.
*/
/* Copyright (c) 2003 Thomas Runge (coto@core.de) /* Copyright (c) 2003 Thomas Runge (coto@core.de)
* *
+10
View File
@@ -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 #ifdef sun
+120 -97
View File
@@ -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 <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@@ -21,11 +35,11 @@
#include "main.h" #include "main.h"
#include "mode.h" #include "mode.h"
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.h"
#include "shared/report.h" #include "shared/report.h"
#include "shared/configfile.h" #include "shared/configfile.h"
#include "getopt.h" #include "getopt.h" /* This is our local getopt.h! */
/* Import screens */
#include "batt.h" #include "batt.h"
#include "chrono.h" #include "chrono.h"
#include "cpu.h" #include "cpu.h"
@@ -39,8 +53,7 @@
# include "eyebox.h" # include "eyebox.h"
#endif #endif
// TODO: Commenting... Everything! /* The following 8 variables are defined 'external' in main.h! */
int Quit = 0; int Quit = 0;
int sock = -1; int sock = -1;
@@ -51,21 +64,17 @@ int lcd_wid = 0;
int lcd_hgt = 0; int lcd_hgt = 0;
int lcd_cellwid = 0; int lcd_cellwid = 0;
int lcd_cellhgt = 0; int lcd_cellhgt = 0;
static struct utsname unamebuf; static struct utsname unamebuf;
/* /* local prototypes */
Mode List:
See below... (default_sequence[])
*/
static void HelpScreen(int exit_state); static void HelpScreen(int exit_state);
static void exit_program(int val); static void exit_program(int val);
static void main_loop(void); static void main_loop(void);
static int process_configfile(char *cfgfile); static int process_configfile(char *cfgfile);
// 1/8th second is a single time unit... #define TIME_UNIT 125000 /**< 1/8th second is a single time unit. */
#define TIME_UNIT 125000
#if !defined(SYSCONFDIR) #if !defined(SYSCONFDIR)
# define SYSCONFDIR "/etc" # define SYSCONFDIR "/etc"
@@ -82,11 +91,11 @@ static int process_configfile(char *cfgfile);
#define DEFAULT_REPORTDEST RPT_DEST_STDERR #define DEFAULT_REPORTDEST RPT_DEST_STDERR
#define DEFAULT_REPORTLEVEL RPT_WARNING #define DEFAULT_REPORTLEVEL RPT_WARNING
/* list of screen modes to run */ /** list of screen modes to run */
ScreenMode sequence[] = ScreenMode sequence[] =
{ {
// flags default ACTIVE will run by default /* flags default ACTIVE will run by default */
// longname which on off inv timer flags /* longname which on off inv timer flags */
{ "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE, cpu_screen }, // [C]PU { "CPU", 'C', 1, 2, 0, 0xffff, ACTIVE, cpu_screen }, // [C]PU
{ "Iface", 'I', 1, 2, 0, 0xffff, 0, iface_screen }, // [I]face { "Iface", 'I', 1, 2, 0, 0xffff, 0, iface_screen }, // [I]face
{ "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE, mem_screen }, // [M]emory { "Memory", 'M', 4, 16, 0, 0xffff, ACTIVE, mem_screen }, // [M]emory
@@ -106,9 +115,8 @@ ScreenMode sequence[] =
}; };
/* All variables are set to 'unset' values */ /* All variables are set to 'unset' values */
static int islow = -1; static int islow = -1; /**< pause after mode update (in 1/100s) */
char *progname = "lcdproc"; char *progname = "lcdproc";
char *server = NULL; char *server = NULL;
int port = LCDPORT; int port = LCDPORT;
@@ -118,57 +126,66 @@ static int report_dest = UNSET_INT;
char *configfile = NULL; char *configfile = NULL;
char *pidfile = NULL; char *pidfile = NULL;
int pidfile_written = FALSE; int pidfile_written = FALSE;
char *displayname = NULL; char *displayname = NULL; /**< display name for the main menu */
/** Returns the network name of this machine */
const char *get_hostname(void) const char *
get_hostname(void)
{ {
return (unamebuf.nodename); return (unamebuf.nodename);
} }
/** Returns the name of the client's OS */
const char *get_sysname(void) const char *
get_sysname(void)
{ {
return (unamebuf.sysname); return (unamebuf.sysname);
} }
/** Returns the release version of the client's OS */
const char *get_sysrelease(void) const char *
get_sysrelease(void)
{ {
return (unamebuf.release); 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; int k;
/* ignore already selected modes */
for (k = 0; sequence[k].which != 0; k++) { for (k = 0; sequence[k].which != 0; k++) {
if (((sequence[k].longname != NULL) && if (((sequence[k].longname != NULL) &&
(0 == strcasecmp(longname, sequence[k].longname))) || (0 == strcasecmp(longname, sequence[k].longname))) ||
(toupper(shortname) == sequence[k].which)) { (toupper(shortname) == sequence[k].which)) {
if (!state) { 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); sequence[k].flags &= (~ACTIVE & ~INITIALIZED);
/* delete the screen if we are connected */ /* delete the screen if we are connected */
if (sock >= 0) { if (sock >= 0) {
sock_printf(sock, "screen_del %c\n", sequence[k].which); sock_printf(sock, "screen_del %c\n", sequence[k].which);
} }
} else }
else
sequence[k].flags |= ACTIVE; 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; int k;
/* ignore already selected modes */
for (k = 0; sequence[k].which != 0; k++) { for (k = 0; sequence[k].which != 0; k++) {
sequence[k].flags &= (~ACTIVE); sequence[k].flags &= (~ACTIVE);
} }
@@ -191,11 +208,11 @@ main(int argc, char **argv)
} }
/* setup error handlers */ /* setup error handlers */
signal(SIGINT, exit_program); // Ctrl-C signal(SIGINT, exit_program); /* Ctrl-C */
signal(SIGTERM, exit_program); // "regular" kill signal(SIGTERM, exit_program); /* "regular" kill */
signal(SIGHUP, exit_program); // kill -HUP signal(SIGHUP, exit_program); /* kill -HUP */
signal(SIGPIPE, exit_program); // write to closed socket signal(SIGPIPE, exit_program); /* write to closed socket */
signal(SIGKILL, exit_program); // kill -9 [cannot be trapped; but ...] signal(SIGKILL, exit_program); /* kill -9 [cannot be trapped; but ...] */
/* No error output from getopt */ /* No error output from getopt */
opterr = 0; opterr = 0;
@@ -205,15 +222,15 @@ main(int argc, char **argv)
char *end; char *end;
switch (c) { switch (c) {
// c is for config file /* c is for config file */
case 'c': case 'c':
configfile = optarg; configfile = optarg;
break; break;
// s is for server /* s is for server */
case 's': case 's':
server = optarg; server = optarg;
break; break;
// p is for port /* p is for port */
case 'p': case 'p':
port = strtol(optarg, &end, 0); port = strtol(optarg, &end, 0);
if ((*optarg == '\0') || (*end != '\0') || if ((*optarg == '\0') || (*end != '\0') ||
@@ -239,8 +256,9 @@ main(int argc, char **argv)
fprintf(stderr, "LCDproc %s\n", version); fprintf(stderr, "LCDproc %s\n", version);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
// otherwise... Get help! /* otherwise... Get help! */
case '?': // unknown option or missing argument case '?': /* unknown option or missing argument */
/* FALLTHROUGH */
default: default:
HelpScreen(EXIT_FAILURE); HelpScreen(EXIT_FAILURE);
break; break;
@@ -267,16 +285,18 @@ main(int argc, char **argv)
if (argc > max(optind, 1)) { if (argc > max(optind, 1)) {
int i; 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) if (cfgresult == 0)
clear_modes(); 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++) { for (i = max(optind, 1); i < argc; i++) {
int state = (*argv[i] == '!') ? 0 : 1; 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'; int shortname = (strlen(name) == 1) ? name[0] : '\0';
// debug: fprintf(stderr, "%s%s", (state) ? "" : "!", name);
int found = set_mode(shortname, name, state); int found = set_mode(shortname, name, state);
if (!found) { if (!found) {
@@ -289,8 +309,7 @@ main(int argc, char **argv)
if (server == NULL) if (server == NULL)
server = DEFAULT_SERVER; server = DEFAULT_SERVER;
// Connect to the server... /* Connect to the server... */
usleep(500000); // wait for the server to start up
sock = sock_connect(server, port); sock = sock_connect(server, port);
if (sock < 0) { if (sock < 0) {
fprintf(stderr, "Error connecting to LCD server %s on port %d.\n" fprintf(stderr, "Error connecting to LCD server %s on port %d.\n"
@@ -300,9 +319,9 @@ main(int argc, char **argv)
} }
sock_send_string(sock, "hello\n"); 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_wid = 20;
lcd_hgt = 4; lcd_hgt = 4;
lcd_cellwid = 5; lcd_cellwid = 5;
@@ -321,7 +340,8 @@ main(int argc, char **argv)
fprintf(pidf, "%d\n", (int)getpid()); fprintf(pidf, "%d\n", (int)getpid());
fclose(pidf); fclose(pidf);
pidfile_written = TRUE; pidfile_written = TRUE;
} else { }
else {
fprintf(stderr, "Error creating pidfile %s: %s\n", fprintf(stderr, "Error creating pidfile %s: %s\n",
pidfile, strerror(errno)); pidfile, strerror(errno));
return (EXIT_FAILURE); return (EXIT_FAILURE);
@@ -329,13 +349,11 @@ main(int argc, char **argv)
} }
} }
// Init the status gatherers... /* Init the status gatherers... */
mode_init(); mode_init();
// And spew stuff! /* And spew stuff! */
main_loop(); main_loop();
// Clean up & exit
exit_program(EXIT_SUCCESS); exit_program(EXIT_SUCCESS);
/* NOTREACHED */ /* NOTREACHED */
@@ -343,10 +361,12 @@ main(int argc, char **argv)
} }
/* reads and parses configuration filei /**
* returns: 1 if configfile was read, * Reads and parses configuration file.
* 0 if default configfile doesn't exist * \param configfile The configfile to read or NULL for the default config.
* <0 on error * \retval 1 if configfile was read,
* \retval 0 if default configfile doesn't exist
* \retval <0 on error
*/ */
static int static int
process_configfile(char *configfile) process_configfile(char *configfile)
@@ -361,7 +381,10 @@ process_configfile(char *configfile)
if (configfile == NULL) { if (configfile == NULL) {
struct stat statbuf; 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)) if ((lstat(DEFAULT_CONFIGFILE, &statbuf) == -1) && (errno = ENOENT))
return 0; return 0;
@@ -371,7 +394,6 @@ process_configfile(char *configfile)
if (config_read_file(configfile) != 0) { if (config_read_file(configfile) != 0) {
report(RPT_CRIT, "Could not read config file: %s", configfile); report(RPT_CRIT, "Could not read config file: %s", configfile);
return -1; return -1;
//report(RPT_WARNING, "Could not read config file: %s", configfile);
} }
if (server == NULL) { if (server == NULL) {
@@ -387,7 +409,8 @@ process_configfile(char *configfile)
if (report_dest == UNSET_INT) { if (report_dest == UNSET_INT) {
if (config_get_bool(progname, "ReportToSyslog", 0, 0)) { if (config_get_bool(progname, "ReportToSyslog", 0, 0)) {
report_dest = RPT_DEST_SYSLOG; report_dest = RPT_DEST_SYSLOG;
} else { }
else {
report_dest = RPT_DEST_STDERR; report_dest = RPT_DEST_STDERR;
} }
} }
@@ -405,7 +428,8 @@ process_configfile(char *configfile)
displayname = strdup(tmp); 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) { if (sequence[k].longname != NULL) {
@@ -422,6 +446,7 @@ process_configfile(char *configfile)
return 1; return 1;
} }
/** Print help screen and exit */
void void
HelpScreen(int exit_state) HelpScreen(int exit_state)
{ {
@@ -464,9 +489,8 @@ HelpScreen (int exit_state)
exit(exit_state); exit(exit_state);
} }
///////////////////////////////////////////////////////////////////
// Called upon TERM and INTR signals... /** Called upon TERM and INTR signals. Also removes the pid-file. */
//
void void
exit_program(int val) exit_program(int val)
{ {
@@ -499,8 +523,10 @@ menus_init ()
} }
#ifdef LCDPROC_CLIENT_TESTMENUS #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 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_yes action {Yes} -next _quit_\n");
sock_send_string(sock, "menu_add_item {ask} ask_no action {No} -next _close_\n"); sock_send_string(sock, "menu_add_item {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_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} test_menu menu {Menu}\n");
sock_send_string(sock, "menu_add_item {test_menu} test_menu_action action {Submenu's action}\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 * no successor for menus. Since test_checkbox and test_ring have
// # own predecessors defined the "ask" rule will not work for them * 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 -prev {ask}\n");
sock_send_string(sock, "menu_set_item {test} test_action -next {test_checkbox}\n"); sock_send_string(sock, "menu_set_item {test} test_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_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_ip -next {test_menu} -prev {test_alpha}\n");
sock_send_string(sock, "menu_set_item {test} test_menu_action -next {_close_}\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; return 0;
} }
#endif //LCDPROC_MENUS #endif /* LCDPROC_MENUS */
/////////////////////////////////////////////////////////////////// /** Main program loop... */
// Main program loop...
//
void void
main_loop(void) main_loop(void)
{ {
@@ -547,16 +573,13 @@ main_loop(void)
int argc, newtoken; int argc, newtoken;
int len; int len;
// Main loop
// Run whatever screen we want, then wait. Woo-hoo!
while (!Quit) { while (!Quit) {
// Check for server input... /* Check for server input... */
len = sock_recv(sock, buf, 8000); len = sock_recv(sock, buf, 8000);
// Handle server input... /* Handle server input... */
while (len > 0) { while (len > 0) {
// Now split the string into tokens... /* Now split the string into tokens... */
//for (i=0; i<argc; i++) argv[i]=NULL; // Get rid of old tokens
argc = 0; argc = 0;
newtoken = 1; newtoken = 1;
@@ -566,7 +589,8 @@ main_loop(void)
newtoken = 1; newtoken = 1;
buf[i] = 0; buf[i] = 0;
break; break;
default: // regular chars, keep tokenizing default: /* regular chars, keep
* tokenizing */
if (newtoken) if (newtoken)
argv[argc++] = buf + i; argv[argc++] = buf + i;
newtoken = 0; newtoken = 0;
@@ -575,12 +599,11 @@ main_loop(void)
case '\n': case '\n':
buf[i] = 0; buf[i] = 0;
if (argc > 0) { if (argc > 0) {
//printf("%s %s\n", argv[0], argv[1]);
if (0 == strcmp(argv[0], "listen")) { if (0 == strcmp(argv[0], "listen")) {
for (j = 0; sequence[j].which; j++) { for (j = 0; sequence[j].which; j++) {
if (sequence[j].which == argv[1][0]) { if (sequence[j].which == argv[1][0]) {
sequence[j].flags |= VISIBLE; 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++) { for (j = 0; sequence[j].which; j++) {
if (sequence[j].which == argv[1][0]) { if (sequence[j].which == argv[1][0]) {
sequence[j].flags &= ~VISIBLE; sequence[j].flags &= ~VISIBLE;
//debug(RPT_DEBUG, "Ignore %s", argv[1]); debug(RPT_DEBUG, "Ignore %s", argv[1]);
} }
} }
} }
@@ -627,32 +650,31 @@ main_loop(void)
#endif #endif
} }
else if (0 == strcmp(argv[0], "bye")) { else if (0 == strcmp(argv[0], "bye")) {
//printf("Exiting LCDproc\n");
exit_program(EXIT_SUCCESS); exit_program(EXIT_SUCCESS);
} }
else if (0 == strcmp(argv[0], "success")) { else if (0 == strcmp(argv[0], "success")) {
} }
else { else {
//int j; /*
//for (j = 0; j < argc; j++) int j;
// printf("%s ", argv[j]); for (j = 0; j < argc; j++)
//printf("\n"); printf("%s ", argv[j]);
printf("\n");
*/
} }
} }
// Restart tokenizing /* Restart tokenizing */
argc = 0; argc = 0;
newtoken = 1; newtoken = 1;
break; break;
} // switch( buf[i] ) } /* switch( buf[i] ) */
} }
len = sock_recv(sock, buf, 8000); len = sock_recv(sock, buf, 8000);
//debug("\n");
} }
// Gather stats... /* Gather stats and update screens */
// Update screens...
if (connected) { if (connected) {
for (i = 0; sequence[i].which > 0; i++) { for (i = 0; sequence[i].which > 0; i++) {
sequence[i].timer++; sequence[i].timer++;
@@ -663,14 +685,14 @@ main_loop(void)
if (sequence[i].flags & VISIBLE) { if (sequence[i].flags & VISIBLE) {
if (sequence[i].timer >= sequence[i].on_time) { if (sequence[i].timer >= sequence[i].on_time) {
sequence[i].timer = 0; sequence[i].timer = 0;
// Now, update the screen... /* Now, update the screen... */
update_screen(&sequence[i], 1); update_screen(&sequence[i], 1);
} }
} }
else { else {
if (sequence[i].timer >= sequence[i].off_time) { if (sequence[i].timer >= sequence[i].off_time) {
sequence[i].timer = 0; sequence[i].timer = 0;
// Now, update the screen... /* Now, update the screen... */
update_screen(&sequence[i], sequence[i].show_invisible); update_screen(&sequence[i], sequence[i].show_invisible);
} }
} }
@@ -679,8 +701,9 @@ main_loop(void)
} }
} }
// Now sleep... /* Now sleep... */
usleep(TIME_UNIT); usleep(TIME_UNIT);
} }
} }
/* EOF */
+24 -12
View File
@@ -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 #ifndef MAIN_H
#define MAIN_H #define MAIN_H
@@ -32,22 +43,23 @@ extern int lcd_hgt;
extern int lcd_cellwid; extern int lcd_cellwid;
extern int lcd_cellhgt; extern int lcd_cellhgt;
/** Screen data structure */
typedef struct _screen_mode typedef struct _screen_mode
{ {
char *longname; // Which screen is it? char *longname; /**< Which screen is it (long name)? */
char which; // Which screen is it? char which; /**< Which screen is it (short name)? */
int on_time; // How often to update while visible? int on_time; /**< How often to update while visible? */
int off_time; // How often to get stats while not visible? int off_time; /**< How often to get stats while not visible? */
int show_invisible; // Send stats while not visible? int show_invisible; /**< Send stats while not visible? */
int timer; // Time since last update int timer; /**< Time since last update */
int flags; // bit 1 visible, bit 2 selected for display, bit 3 first int flags; /**< See mode flags defines */
int (*func)(int,int,int *); // function pointer int (*func)(int,int,int *); /**< Pointer to init / update function */
} ScreenMode; } ScreenMode;
//mode flags /* mode flags */
#define VISIBLE 0x00000001 //currently visible #define VISIBLE 0x00000001 /**< currently visible */
#define ACTIVE 0x00000002 //selected for display #define ACTIVE 0x00000002 /**< selected for display */
#define INITIALIZED 0x00000004 //replaces the first variable to indicate whether the update screens are initialized #define INITIALIZED 0x00000004 /**< screen had already been initialized */
#define BLINK_ON 0x10 #define BLINK_ON 0x10
#define BLINK_OFF 0x11 #define BLINK_OFF 0x11
+53 -20
View File
@@ -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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -18,16 +29,25 @@
#include "util.h" #include "util.h"
///////////////////////////////////////////////////////////////////////// /**
// Mem Screen displays info about memory and swap usage... * 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 | +--------------------+ * |## MEM #### SWAP #@| |M 758.3M [- ] 35.3%@|
// |E--- F E F| * | 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 int
mem_screen(int rep, int display, int *flags_ptr) mem_screen(int rep, int display, int *flags_ptr)
{ {
@@ -200,6 +220,10 @@ mem_screen(int rep, int display, int *flags_ptr)
} // End mem_screen() } // 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 static int
sort_procs(void *a, void *b) 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... * 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| +--------------------+ * |## TOP MEM: myhos #@| |## TOP MEM: myhos #@|
// |3 29.21M XFree86 | * |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 int
mem_top_screen(int rep, int display, int *flags_ptr) mem_top_screen(int rep, int display, int *flags_ptr)
{ {
+38 -17
View File
@@ -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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -16,16 +27,14 @@
#include "shared/sockets.h" #include "shared/sockets.h"
#include "mode.h"
#include "main.h" #include "main.h"
#include "mode.h"
#include "machine.h" #include "machine.h"
#ifdef LCDPROC_EYEBOXONE #ifdef LCDPROC_EYEBOXONE
# include "eyebox.h" # include "eyebox.h"
#endif #endif
// TODO: Clean this up... Support multiple display sizes.. /** Initialize mode specific things. */
int int
mode_init(void) mode_init(void)
{ {
@@ -34,12 +43,23 @@ mode_init(void)
return(0); return(0);
} }
/** Clean up modes on exit */
void void
mode_close(void) mode_close(void)
{ {
machine_close(); 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 int
update_screen(ScreenMode *m, int display) update_screen(ScreenMode *m, int display)
{ {
@@ -48,6 +68,7 @@ update_screen(ScreenMode *m, int display)
if (m && m->func) { if (m && m->func) {
#ifdef LCDPROC_EYEBOXONE #ifdef LCDPROC_EYEBOXONE
/* Save the initialized flag (may be modified by m->func) */
int init_flag = (m->flags & INITIALIZED); int init_flag = (m->flags & INITIALIZED);
#endif #endif
status = m->func(m->timer, display, &(m->flags)); status = m->func(m->timer, display, &(m->flags));
@@ -60,8 +81,7 @@ update_screen(ScreenMode *m, int display)
#endif #endif
} }
if (status != old_status) if (status != old_status) {
{
if (status == BACKLIGHT_OFF) if (status == BACKLIGHT_OFF)
sock_send_string(sock, "backlight off\n"); sock_send_string(sock, "backlight off\n");
if (status == BACKLIGHT_ON) if (status == BACKLIGHT_ON)
@@ -74,13 +94,14 @@ update_screen(ScreenMode *m, int display)
} }
/////////////////////////////////////////////////////////////////////////// /**
//////////////////////// Let the Modes Begin! ///////////////////////////// * 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
// Credit Screen shows who wrote this... * \param flags_ptr Mode flags
// * \return Always 0
*/
int int
credit_screen(int rep, int display, int *flags_ptr) credit_screen(int rep, int display, int *flags_ptr)
{ {
@@ -174,14 +195,14 @@ credit_screen(int rep, int display, int *flags_ptr)
lcd_wid, "LCDproc was brought to you by:"); 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_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", 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, ((lcd_hgt >= 4) ? 3 : 2), lcd_wid, lcd_hgt, lcd_wid, contr_num,
// scroll rate: 1 line every X ticks (= 1/8 sec) // scroll rate: 1 line every X ticks (= 1/8 sec)
((lcd_hgt >= 4) ? 8 : 12)); ((lcd_hgt >= 4) ? 8 : 12));
// frame contents /* frame contents */
for (i = 1; i < contr_num; i++) { for (i = 1; i < contr_num; i++) {
sock_printf(sock, "widget_add A c%i string -in f\n", 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]); sock_printf(sock, "widget_set A c%i 1 %i {%s}\n", i, i, contributors[i]);
@@ -189,6 +210,6 @@ credit_screen(int rep, int display, int *flags_ptr)
} }
return(0); return(0);
} // End credit_screen() }
/* EOF */
-5
View File
@@ -1,14 +1,9 @@
#ifndef MODE_H #ifndef MODE_H
#define MODE_H #define MODE_H
#include "main.h"
int mode_init(void); int mode_init(void);
void mode_close(void); void mode_close(void);
int update_screen(ScreenMode *m, int display); int update_screen(ScreenMode *m, int display);
int credit_screen(int rep, int display, int *flags_ptr); int credit_screen(int rep, int display, int *flags_ptr);
#endif #endif
-1
View File
@@ -20,7 +20,6 @@
#include "getopt.h" #include "getopt.h"
#include "shared/str.h"
#include "shared/report.h" #include "shared/report.h"
#include "shared/configfile.h" #include "shared/configfile.h"
#include "shared/sockets.h" #include "shared/sockets.h"
+1 -1
View File
@@ -307,7 +307,7 @@ EXTRACT_PRIVATE = YES
# If the EXTRACT_STATIC tag is set to YES all static members of a file # If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation. # 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) # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation. # defined locally in source files will be included in the documentation.
+17 -8
View File
@@ -10,18 +10,27 @@ Here we provide functions that should be used by all parts of the program.
</sect1> </sect1>
<sect1 id="debug.h"> <sect1 id="report.h">
<title>report.h : Debugging and reporting</title> <title>report.h : Debugging and reporting</title>
<para>To enable the debug() function on all of the software, just type: <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: <procedure><title>Enabling the debug() function only in specific files:</title>
1) Configure without enabling debug (that is without --enable-debug) <step>
2) Edit the source file that you want to debug and put the following <para>Configure without enabling debug (that is without --enable-debug).</para>
line at the top, before the #include "report.h" line: </step>
#define DEBUG <step>
3) Then recompile with 'make' <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 This way, the global DEBUG macro is off but is locally enabled in
certains parts of the software.</para> certains parts of the software.</para>
-2
View File
@@ -34,8 +34,6 @@
#endif #endif
#include "lcd.h" #include "lcd.h"
#include "bayrad.h" #include "bayrad.h"
//#include "drv_base.h"
#include "shared/str.h"
#include "report.h" #include "report.h"
#include "lcd_lib.h" #include "lcd_lib.h"
-1
View File
@@ -35,7 +35,6 @@
#define DEBUG 1 #define DEBUG 1
#include "lcd.h" #include "lcd.h"
#include "shared/str.h"
#include "glk.h" #include "glk.h"
#include "glkproto.h" #include "glkproto.h"
#include "report.h" #include "report.h"
-1
View File
@@ -53,7 +53,6 @@
#include "hd44780-i2c.h" #include "hd44780-i2c.h"
#include "hd44780-low.h" #include "hd44780-low.h"
#include "shared/str.h"
#include "report.h" #include "report.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
+1 -1
View File
@@ -402,7 +402,7 @@ static void setLIS2Fans(int fd, int fan1, int fan2, int fan3, int fan4)
/** /**
* Write a character. * Write a character.
* \param fd File handle to write to. * \param fd File handle to write to.
* \param ch Character to write. * \param code Character to write.
*/ */
static void writeChar(int fd, unsigned char code) static void writeChar(int fd, unsigned char code)
{ {
+1 -1
View File
@@ -1428,7 +1428,7 @@ HD44780_output(Driver *drvthis, int on)
* \param dispOffsets Array to store display offsets. * \param dispOffsets Array to store display offsets.
* \param dOffsize Size of dispOffsets. * \param dOffsize Size of dispOffsets.
* \param dispSizeArray Array of display vertical sizes (= spanlist). * \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. * \return Number of span elements, -1 on parse error.
*/ */
static int static int
-1
View File
@@ -39,7 +39,6 @@
# include "config.h" # include "config.h"
#endif #endif
#include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "i2500vfd.h" #include "i2500vfd.h"
#include "report.h" #include "report.h"
+1 -1
View File
@@ -1018,7 +1018,7 @@ imonlcd_output(Driver *drvthis, int state)
icon |= IMON_ICON_OGG; icon |= IMON_ICON_OGG;
break; break;
case 3: case 3:
icon |= IMON_ICON_WMA; icon |= IMON_ICON_WMA2;
break; break;
case 4: case 4:
icon |= IMON_ICON_WAV; icon |= IMON_ICON_WAV;
-1
View File
@@ -27,7 +27,6 @@
#include "config.h" #include "config.h"
#endif #endif
#include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "irmanin.h" #include "irmanin.h"
#include "report.h" #include "report.h"
-1
View File
@@ -45,7 +45,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include "lcd.h" #include "lcd.h"
#include "shared/str.h"
#include "irtrans.h" #include "irtrans.h"
#include "irtrans_remote.h" #include "irtrans_remote.h"
#include "irtrans_network.h" #include "irtrans_network.h"
-1
View File
@@ -39,7 +39,6 @@
#include "lcd.h" #include "lcd.h"
#include "joy.h" #include "joy.h"
#include "report.h" #include "report.h"
#include "shared/str.h"
#define JOY_NAMELENGTH 128 #define JOY_NAMELENGTH 128
#define JOY_DEFAULT_DEVICE "/dev/js0" #define JOY_DEFAULT_DEVICE "/dev/js0"
-2
View File
@@ -31,9 +31,7 @@
#include "lcd.h" #include "lcd.h"
#include "lb216.h" #include "lb216.h"
#include "shared/str.h"
#include "report.h" #include "report.h"
//#include "drv_base.h"
#define LB216_DEFAULT_DEVICE "/dev/lcd" #define LB216_DEFAULT_DEVICE "/dev/lcd"
#define LB216_DEFAULT_SPEED 9600 #define LB216_DEFAULT_SPEED 9600
-1
View File
@@ -50,7 +50,6 @@
#include "report.h" #include "report.h"
#include "lcd_lib.h" #include "lcd_lib.h"
/* /*
#include "shared/str.h"
#include "server/configfile.h" #include "server/configfile.h"
*/ */
-1
View File
@@ -62,7 +62,6 @@
#define WR 0x01 #define WR 0x01
#define IODELAY 500 #define IODELAY 500
#include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "sed1520.h" #include "sed1520.h"
#include "report.h" #include "report.h"
-1
View File
@@ -38,7 +38,6 @@
# include "config.h" # include "config.h"
#endif #endif
#include "shared/str.h"
#include "lcd.h" #include "lcd.h"
#include "stv5730.h" #include "stv5730.h"
#include "report.h" #include "report.h"
-2
View File
@@ -25,8 +25,6 @@
#include "report.h" #include "report.h"
#include "lcd_lib.h" #include "lcd_lib.h"
#include "shared/str.h"
#define SLI_DEFAULT_DEVICE "/dev/lcd" #define SLI_DEFAULT_DEVICE "/dev/lcd"
typedef enum { typedef enum {
+23 -14
View File
@@ -1,4 +1,4 @@
/** \file LL.c /** \file shared/LL.c
* Define routines to deal with doubly linked lists * 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. * Set list's \c current pointer to the node denoted to by \c whereto.
* \param list List object. * \param list List object.
* \param whereto Direction where to set the list's \c current pointer * \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. * Set list's \c current pointer to the first node in the list.
* \param list List object. * \param list List object.
* \retval <0 error: no list given * \retval <0 error: no list given
@@ -530,7 +530,7 @@ LL_Remove(LinkedList *list, void *data, Direction whereto)
* \retval 0 success * \retval 0 success
*/ */
int int
LL_Push(LinkedList *list, void *add) // Add node to end of list LL_Push(LinkedList *list, void *add)
{ {
if (!list) if (!list)
return -1; 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. * \return Pointer to data of deleted node; \c NULL on error.
*/ */
void * void *
LL_Pop(LinkedList *list) // Remove node from end of list LL_Pop(LinkedList *list)
{ {
if (!list) if (!list)
return NULL; 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. * \return Pointer to last node's data; \c NULL on error.
*/ */
void * void *
LL_Top(LinkedList *list) // Peek at end node LL_Top(LinkedList *list)
{ {
return LL_GetLast(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. * \return Pointer to data of deleted node; \c NULL on error.
*/ */
void * void *
LL_Shift(LinkedList *list) // Remove node from start of list LL_Shift(LinkedList *list)
{ {
if (!list) if (!list)
return NULL; 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. * \return Pointer to first node's data; \c NULL on error.
*/ */
void * void *
LL_Look(LinkedList *list) // Peek at first node LL_Look(LinkedList *list)
{ {
return LL_GetFirst(list); return LL_GetFirst(list);
} }
@@ -612,7 +612,7 @@ LL_Look(LinkedList *list) // Peek at first node
* \retval 0 success * \retval 0 success
*/ */
int int
LL_Unshift(LinkedList *list, void *add) // Add node to beginning of list LL_Unshift(LinkedList *list, void *add)
{ {
if (!list) if (!list)
return -1; 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"
// Add an item to the end of its "priority group" * The list is assumed to be sorted already.
// 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 int
LL_PriorityEnqueue(LinkedList *list, void *add, int (*compare)(void *, void *)) 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 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 *firstprev, *firstnext;
LL_node *secondprev, *secondnext; LL_node *secondprev, *secondnext;
+4
View File
@@ -1,3 +1,7 @@
/** \file shared/LL.h
* Define routines to deal with doubly linked lists
*/
#ifndef LL_H #ifndef LL_H
#define LL_H #define LL_H
+8 -7
View File
@@ -1,6 +1,10 @@
/* /** \file shared/report.c
* Contains reporting functions.
*/
/*-
* report.c * 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 * This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package. * COPYING file distributed with this package.
@@ -8,14 +12,9 @@
* Copyright (c) 1999, William Ferrell, Scott Scriven * Copyright (c) 1999, William Ferrell, Scott Scriven
* 2001, Joris Robijn * 2001, Joris Robijn
* 2005, Peter Marschall * 2005, Peter Marschall
*
* Contains reporting functions
*
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "report.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -25,6 +24,8 @@
# include <windows.h> # include <windows.h>
#endif #endif
#include "report.h"
static int report_level = RPT_INFO; static int report_level = RPT_INFO;
static int report_dest = RPT_DEST_STORE; static int report_dest = RPT_DEST_STORE;
+8 -2
View File
@@ -1,4 +1,8 @@
/* /** \file shared/report.h
* Contains reporting functions.
*/
/*-
* report.h * report.h
* This file is part of LCDd, the lcdproc server. * This file is part of LCDd, the lcdproc server.
* *
@@ -13,7 +17,8 @@
#ifndef REPORT_H #ifndef REPORT_H
#define REPORT_H #define REPORT_H
/* DEBUGGING / REPORTING /** DEBUGGING / REPORTING
*\verbatim
* *
* To enable the debug() function on all of the software, just type: * To enable the debug() function on all of the software, just type:
* ./configure --enable-debug * ./configure --enable-debug
@@ -53,6 +58,7 @@
* function. * function.
* The code that this function generates will not be in the executable when * The code that this function generates will not be in the executable when
* compiled without debugging. This way memory and CPU cycles are saved. * compiled without debugging. This way memory and CPU cycles are saved.
*\endverbatim
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
+76 -20
View File
@@ -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 <unistd.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
@@ -24,17 +34,18 @@
#include "report.h" #include "report.h"
#include "sockets.h" #include "sockets.h"
/**************************************************
LCDproc client sockets code...
Feel free to use this in your own clients... :)
**************************************************/
// Length of longest transmission allowed at once... // Length of longest transmission allowed at once...
#define MAXMSG 8192 #define MAXMSG 8192
typedef struct sockaddr_in sockaddr_in; 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 static int
sock_init_sockaddr (sockaddr_in *name, const char *hostname, unsigned short int port) 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; name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
return 0; 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 int
sock_connect (char *host, unsigned short int port) sock_connect (char *host, unsigned short int port)
{ {
@@ -102,6 +117,11 @@ sock_connect (char *host, unsigned short int port)
return sock; return sock;
} }
/**
* Disconnect from server.
* \param fd Socket file descriptor
* \return 0 on success, -1 on error.
*/
int int
sock_close (int fd) 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 int
sock_printf(int fd, const char *format, .../*args*/ ) 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); 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 int
sock_send_string (int fd, char *string) sock_send_string (int fd, char *string)
{ {
return sock_send(fd, string, strlen(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 int
sock_recv_string (int fd, char *dest, size_t maxlen) 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; 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 int
sock_send (int fd, void *src, size_t size) sock_send (int fd, void *src, size_t size)
{ {
@@ -235,6 +279,13 @@ sock_send (int fd, void *src, size_t size)
return offset; 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 int
sock_recv (int fd, void *dest, size_t maxlen) 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* char*
sock_geterror(void) sock_geterror(void)
{ {
@@ -295,21 +350,22 @@ sock_geterror(void)
#endif #endif
} }
/** prints error to logfile and sends it to the client. /**
* @param fd socket * Send an already formatted error message to the client.
* @param message the message to send (without the "huh? ") */ * \param fd socket
* \param message the message to send (without the "huh? ") */
int sock_send_error(int fd, char* message) int sock_send_error(int fd, char* message)
{ {
// simple: performance penalty isn't worth more work... // simple: performance penalty isn't worth more work...
return sock_printf_error(fd, message); return sock_printf_error(fd, message);
} }
/** prints printf-like formatted output to logfile and sends it to the /**
* client. * 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 * \note don't add a the "huh? " to the message. This is done by this
* method * method
* @param fd socket * \param fd socket
* @param format a printf format */ * \param format a printf format */
int int
sock_printf_error(int fd, const char *format, .../*args*/ ) sock_printf_error(int fd, const char *format, .../*args*/ )
{ {
+16 -66
View File
@@ -1,3 +1,7 @@
/** \file shared/sockets.h
* Socket functions available to server and clients.
*/
#ifndef SOCKETS_H #ifndef SOCKETS_H
#define SOCKETS_H #define SOCKETS_H
@@ -15,81 +19,27 @@
# define SHUT_RDWR 2 # define SHUT_RDWR 2
#endif #endif
/* /** Connect to server on host, port */
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...
int sock_connect (char *host, unsigned short int port); int sock_connect (char *host, unsigned short int port);
/** Disconnect from server */
int sock_close (int fd); int sock_close (int fd);
// Send/receive lines of text /** Send printf-like formatted output */
int sock_printf (int fd, const char *format, .../*args*/); int sock_printf (int fd, const char *format, .../*args*/);
/** Send lines of text */
int sock_send_string (int fd, char *string); int sock_send_string (int fd, char *string);
// Recv gives only one line per call... /** Send raw data */
int sock_recv_string (int fd, char *dest, size_t maxlen);
// Send/receive raw data
int sock_send (int fd, void *src, size_t size); 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); 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); char *sock_geterror(void);
/** Send an already formatted error message to the client */
int sock_send_error(int fd, char* message); 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*/); 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 #endif
+23 -4
View File
@@ -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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "debug.h" #include "report.h"
#include "str.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 int
get_args (char **argv, char *str, int max_args) 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) if (max_args < 1)
return 0; 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)) { 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) { if (i < max_args) {
argv[i] = item; argv[i] = item;
i++; i++;
+4
View File
@@ -1,3 +1,7 @@
/** \file shared/str.h
* Commmand / argument parsing functions (for use in clients).
*/
#ifndef STR_H #ifndef STR_H
#define STR_H #define STR_H