cleanup iface.c (thanks M. Dolze)

This commit is contained in:
marschap
2006-05-07 17:32:35 +00:00
parent 08bb695d8d
commit c6a1f841a7
15 changed files with 132 additions and 528 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ time_screen (int rep, int display, int *flags_ptr)
sprintf (buffer, "widget_set T three %i 4 {%s}\n", xoffs, tmp); sprintf (buffer, "widget_set T three %i 4 {%s}\n", xoffs, tmp);
if (display) if (display)
sock_send_string (sock, buffer); sock_send_string (sock, buffer);
} }
else { // 2 line version of the screen else { // 2 line version of the screen
if (lcd_wid >= 20) // 20+x columns if (lcd_wid >= 20) // 20+x columns
sprintf(tmp, "%02d.%02d.%04d %s", sprintf(tmp, "%02d.%02d.%04d %s",
+3 -3
View File
@@ -24,18 +24,18 @@
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* --- * ---
* *
* $Source$ * $Source$
* $Revision$ $Date$ * $Revision$ $Date$
* Checked in by: $Author$ * Checked in by: $Author$
+1 -1
View File
@@ -20,7 +20,7 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 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
// +--------------------+ +--------------------+ // +--------------------+ +--------------------+
+52 -458
View File
@@ -1,7 +1,7 @@
/* /*
netlcdclient - Client for LCDproc which shows networks statistics netlcdclient - Client for LCDproc which shows networks statistics
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
Cleanup, reorganization by Peter Marschall Cleanup, reorganization by Peter Marschall
@@ -18,7 +18,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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
@@ -30,30 +30,18 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "iface.h"
#ifdef NETLCDCLIENT
#include "sockets.h"
#else
#include "shared/sockets.h" #include "shared/sockets.h"
#include "shared/debug.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"
#define UNSET_INT -1 #include "util.h"
#include "iface.h"
#define UNSET_INT -1
#define UNSET_STR "\01" #define UNSET_STR "\01"
#endif //NETLCDCLIENT
#ifdef NETLCDCLIENT
/* Option flags and global variables */
char *program_name; /* the name the program was run with */
int port = 13666; /* default port */
char server[256] = "localhost"; /* default server */
int daemon_mode = 0; /* by default, no daemon mode */
int sock = 0; /* socket handler */
#endif //NETLCDCLIENT
int iface_count = 0; /* number of interfaces */ int iface_count = 0; /* number of interfaces */
char unit_label[10] = "B"; /* default unit label is Bytes */ char unit_label[10] = "B"; /* default unit label is Bytes */
@@ -75,255 +63,6 @@ static struct option const long_options[] =
}; };
#ifdef NETLCDCLIENT
/*************************************************************************
* MAIN PROGRAM FUNCTION
*************************************************************************
*/
int
main (int argc, char **argv)
{
IfaceInfo iface[MAX_INTERFACES]; /* interface info */
int len; /* bytes read from server */
char readbuff[MAXMSG]; /* read buffer from server */
unsigned int sleep_time = 1; /* interval between updates (1 second) */
int pid; /* child process identificator for daemon mode */
int iface_nmbr; /* loop variable for the interface */
/* Capture signals to exit program cleanly */
signal(SIGINT, exit_program); /* Ctrl-C */
signal(SIGTERM, exit_program); /* kill */
signal(SIGHUP, exit_program); /* kill -HUP */
signal(SIGKILL, exit_program); /* kill -KILL */
/* get program name from command line */
program_name = argv[0];
/* parse command line parameters */
decode_switches (argc, argv);
/* check if any interface name has been introduced */
if (iface_count == 0) {
/* no one has been introduced, so exit the program showing help */
printf("No interface selected, please, use --interface option\n");
usage (1);
}
/* check if we go to daemon mode */
if (daemon_mode) {
signal(SIGTTOU, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
/* create child process */
pid = fork();
/* create new session */
setsid();
signal(SIGHUP, SIG_IGN);
if (pid != 0) { /* we are the parent process and exit */
exit(0);
}
/* from here, we are the child process */
}
/* Try to connect to server */
sock = sock_connect(server, port);
if (sock < 0) { /* there was some error and exit */
fprintf(stderr, "Error: Could not connect to %s:%d\n", server, port);
exit(0);
}
/* Say "hello" to server */
sock_send_string(sock, "hello\n");
/* Wait the server to be prepared */
usleep(500000);
/* Read server response */
len = sock_recv(sock, readbuff, MAXMSG);
/* Now we are ready to send commands to server */
/* set initial speed screen with widgets */
initialize_speed_screen();
/* set initial transfer screen if needed */
if (transfer_screen) {
initialize_transfer_screen();
}
/* initialize all interface structs */
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
iface[iface_nmbr].last_online = 0;
iface[iface_nmbr].status = down;
}
/* main loop */
while (1) {
/* read server responses */
len = sock_recv(sock, readbuff, MAXMSG);
/* for each interface do */
for (iface_nmbr = 0; iface_nmbr < iface_count; iface_nmbr++) {
/*read iface_parameter stats */
if (!get_iface_stats(&iface[iface_nmbr])) {
/* there was an error, so we exit the loop */
break;
}
/* actualize speed values in display */
actualize_speed_screen(&iface[iface_nmbr], sleep_time, iface_nmbr);
/* if needed, actualize transfer values in display */
if (transfer_screen)
actualize_transfer_screen(&iface[iface_nmbr], iface_nmbr);
/* Actual values are the old ones in the next loop */
iface[iface_nmbr].rc_byte_old = iface[iface_nmbr].rc_byte;
iface[iface_nmbr].tr_byte_old = iface[iface_nmbr].tr_byte;
iface[iface_nmbr].rc_pkt_old = iface[iface_nmbr].rc_pkt;
iface[iface_nmbr].tr_pkt_old = iface[iface_nmbr].tr_pkt;
}
/* Wait some time to do the main loop again */
sleep(sleep_time);
}
/* Before exit the program, close the socket */
sock_close(sock);
exit (0);
} /* main() */
/*************************************************************************
* END MAIN PROGRAM FUNCTION
**************************************************************************/
/*************************************************************************
* Set all the option flags according to the switches specified.
* Return the index of the first non-option argument.
*************************************************************************
*/
static int
decode_switches (int argc, char **argv)
{
int c;
while ((c = getopt_long (argc, argv, "i:a:s:p:u:tdhV", \
long_options, (int *) 0)) != EOF) {
switch (c) {
case 'i':
/* Check number of interfaces introduced */
if (iface_count >= MAX_INTERFACES) {
fprintf(stderr, "Too many interfaces introduced. "
"Only %d are supported.\n", MAX_INTERFACES);
exit(0);
}
iface[iface_count].name = strdup(optarg);
// make alias point to the same string as the interface name
iface[iface_count].alias = iface[iface_count].name;
iface_count++;
break;
case 'a':
iface[iface_count-1].alias = strdup(optarg);
break;
case 's':
strncpy(server, optarg, sizeof(server));
server[sizeof(server)-1] = '\0';
break;
case 'p':
port = atoi(optarg);
break;
case 'u':
/* check for valid values */
if (strstr(optarg, "byte"))
strncpy(unit_label, "B", sizeof(unit_label));
else if (strstr(optarg, "bit"))
strncpy(unit_label, "b", sizeof(unit_label));
else if (strstr(optarg, "packet"))
strncpy(unit_label, "pkt", sizeof(unit_label));
else {
fprintf(stderr, "netlcdclient: argument '%s' for -u parameter is not valid\n", optarg);
usage(0);
}
unit_label[sizeof(unit_label)-1] = '\0';
break;
case 't':
transfer_screen = 1; /* show transfer screen */
break;
case 'd':
daemon_mode = 1; /* go to daemon mode */
break;
case 'V': /* show version */
fprintf(stdout, "netlcdclient v%s\n", VERSION);
exit(0);
case 'h': /* show help */
usage(0);
exit(0);
}
}
return optind;
} /* decode_switches() */
/*************************************************************************
* Show program help and exit.
*************************************************************************
*/
static void
usage (int status)
{
printf ("\n"
"netlcdclient v%s for LCDproc, by Luis Llorente\n", VERSION);
printf ("\n"
"Usage: %s -i <interface> [-a alias] [ -tdhV ] [ -s server ] [ -p port ] [-u unit]\n", program_name);
printf ("\n"
"Options in []'s are optional.\n"
" -i , --interface=INTERFACE show INTERFACE statistics\n"
" -a , --alias=ALIAS alias name for the interface (-a has to \n"
" follow -i)\n"
" -s, --server=SERVER connect to SERVER (default is localhost)\n"
" -p, --port=NUMBER connect to specified port number (default\n"
" is 13666)\n"
" -u, --unit=TYPE speed measure unit. Available units are:\n"
" byte (default)\n"
" bit\n"
" packet\n"
" -t, --transfer add screen with transferred traffic\n"
" -d, --daemon run in the background\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
);
printf("\n"
"Example:\n"
" %s -s my.server.org -p 2300 -u bit -i eth0 -a LAN\n", program_name);
exit (status);
} /* usage() */
#else
/* reads and parses configuration file */ /* reads and parses configuration file */
static int static int
iface_process_configfile() iface_process_configfile()
@@ -429,11 +168,11 @@ iface_screen(int rep, int display, int *flags_ptr)
/* actualize speed values in display */ /* 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 needed, actualize transfer values in display */
if (transfer_screen) if (transfer_screen)
actualize_transfer_screen(&iface[iface_nmbr], iface_nmbr); actualize_transfer_screen(&iface[iface_nmbr], iface_nmbr);
/* Actual values are the old ones in the next loop */ /* Actual values are the old ones in the next loop */
iface[iface_nmbr].rc_byte_old = iface[iface_nmbr].rc_byte; iface[iface_nmbr].rc_byte_old = iface[iface_nmbr].rc_byte;
iface[iface_nmbr].tr_byte_old = iface[iface_nmbr].tr_byte; iface[iface_nmbr].tr_byte_old = iface[iface_nmbr].tr_byte;
@@ -444,13 +183,12 @@ iface_screen(int rep, int display, int *flags_ptr)
return 0; return 0;
} // End iface_screen() } // End iface_screen()
#endif //NETLCDCLIENT
/************************************************************************* /*************************************************************************
* Read interface statistics from system and store in the struct * Read interface statistics from system and store in the struct
* passed as a pointer. If there are no errors, it returns 1. If errors, * passed as a pointer. If there are no errors, it returns 1. If errors,
* returns 0. * returns 0.
************************************************************************* *************************************************************************
*/ */
int int
@@ -491,8 +229,8 @@ get_iface_stats (IfaceInfo *interface)
&interface->tr_byte, &interface->tr_byte,
&interface->tr_pkt); &interface->tr_pkt);
/* if is the first time we call this function, /* if is the first time we call this function,
* old values are the same as new so we don't * old values are the same as new so we don't
* get big speeds when calculating * get big speeds when calculating
*/ */
if (first_time) { if (first_time) {
@@ -510,7 +248,7 @@ get_iface_stats (IfaceInfo *interface)
} }
else { /* error when opening the file */ else { /* error when opening the file */
fprintf(stderr,"Error: Could not open %s\n", DEVFILE); report(RPT_CRIT, "Error: Could not open %s\n", DEVFILE);
return 0; /* something went wrong */ return 0; /* something went wrong */
} }
#endif #endif
@@ -542,7 +280,7 @@ get_iface_stats (IfaceInfo *interface)
name[4] = rows; /* set the interface index */ name[4] = rows; /* set the interface index */
/* retrive the ifmibdata for the current index */ /* retrive the ifmibdata for the current index */
if (sysctl(name, 6, &ifmd, &len, NULL, 0) == -1) { if (sysctl(name, 6, &ifmd, &len, NULL, 0) == -1) {
perror("sysctl_read"); report(RPT_ERR, "Reading ifmibdata failed");
break; break;
} }
/* check if its interface name matches */ /* check if its interface name matches */
@@ -568,10 +306,10 @@ get_iface_stats (IfaceInfo *interface)
} }
} }
/* if we are here there is no interface with the given name */ /* if we are here there is no interface with the given name */
fprintf(stderr, "There is no interface named %s\n", interface->name); report(RPT_CRIT, "There is no interface named %s", interface->name);
return 0; return 0;
} else { } else {
perror("get_iface_stats"); report(RPT_CRIT, "Reading interface count via sysctl failed");
return 0; return 0;
} }
@@ -600,7 +338,7 @@ initialize_speed_screen(void)
if ((iface_count == 1) && (lcd_hgt >= 4 )) { /* Single interface mode */ if ((iface_count == 1) && (lcd_hgt >= 4 )) { /* Single interface mode */
/* Set title */ /* Set title */
sock_printf(sock, "widget_set I title {Net Load: %s}\n", iface[0].alias); sock_printf(sock, "widget_set I title {Net Load: %s}\n", iface[0].alias);
/* Add and set download, upload and total string widgets */ /* Add and set download, upload and total string widgets */
sock_send_string(sock, "widget_add I dl string\n"); sock_send_string(sock, "widget_add I dl string\n");
sock_send_string(sock, "widget_set I dl 1 2 {DL:}\n"); sock_send_string(sock, "widget_set I dl 1 2 {DL:}\n");
@@ -637,7 +375,7 @@ initialize_speed_screen(void)
iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias); iface_nmbr, iface_nmbr+1, iface[iface_nmbr].alias);
} }
} }
} /* initialize_speed_screen() */ } /* initialize_speed_screen() */
/************************************************************************* /*************************************************************************
@@ -646,75 +384,25 @@ initialize_speed_screen(void)
* variable 'buff' passed as pointer. * variable 'buff' passed as pointer.
************************************************************************* *************************************************************************
*/ */
void void
format_value (char *buff, double value, char *unit) format_value (char *buff, double value, char *unit)
{ {
float formated_value; /* Convert bytes to bits, if necessary */
if (strstr(unit, "b"))
/* if the measure unit is in 'b' (bits), the value passed must
* be converted to bits (from bytes)
*/
if (strstr(unit, "b")) {
value *= 8; value *= 8;
}
/* bytes, bits or packets */ /* If units are bytes, then divide by 2^10, otherwise by 10^3 */
if (value < 1024) { char *mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
sprintf(buff, "%8ld %s",(long)value, unit);
return;
}
/* Kilobytes, Kilobits of Kilopackets */
if (value < 1000000.0f) {
if (strstr(unit, "B")) { /* 1 KB = 1024 */
formated_value = (float) value / 1024.0f;
}
else { /* 1 K = 1000 */
formated_value = (float) value / 1000.0f;
}
sprintf(buff, "%8.3f K%s", formated_value, unit); /* Formatting rules:
return; * - if original value was < 1000, output decimal value only
} * - otherwise format with 3 precision
*/
if (mag[0] == 0)
sprintf(buff, "%8ld %s", (long) value, unit);
else
sprintf(buff, "%7.3f %s%s", value, mag, unit);
/* Megabytes, Megabits or Megapackets */
if (value < 1000000000.0f) {
if (strstr(unit, "B")) { /* 1 MB = 1024 KB */
formated_value = (float) value / 1048576.0f; /* 1024 ^ 2 */
}
else { /* 1 M = 1000 K */
formated_value = (float) value / 1000000.0f; /* 1000 ^ 2 */
}
sprintf(buff, "%8.3f M%s", formated_value, unit);
return;
}
/* Gigabytes, Gigabits or Gigapackets */
if (value < 1000000000000.0f) {
if (strstr(unit, "B")) { /* 1 GB = 1024 MB */
formated_value = (float) value / 1073741824.0f; /* 1024 ^ 3 */
}
else { /* 1 G = 1000 M */
formated_value = (float) value / 1000000000.0f; /* 1000 ^ 3 */
}
sprintf(buff, "%8.3f G%s", formated_value, unit);
return;
}
/* Terabytes, Terabits or Terapackets */
if (value >= 1000000000000.0f) {
if (strstr(unit, "B")) { /* 1 TB = 1024 GB */
formated_value = (float) value / 1099511627776.0f; /* 1024 ^ 4 */
}
else { /* 1 T = 1000 G */
formated_value = (float) value / 1000000000000.0f; /* 1000 ^ 4 */
}
sprintf(buff, "%8.3f T%s", formated_value, unit);
return;
}
} /* format_value() */ } /* format_value() */
/************************************************************************* /*************************************************************************
@@ -723,107 +411,33 @@ format_value (char *buff, double value, char *unit)
* variable 'buff' passed as pointer. Version for multi-interfaces mode * variable 'buff' passed as pointer. Version for multi-interfaces mode
************************************************************************* *************************************************************************
*/ */
void void
format_value_multi_interface (char *buff, double value, char *unit) format_value_multi_interface (char *buff, double value, char *unit)
{ {
char mybuff[20]; /* temp buffer */ if (strstr(unit, "b"))
float formated_value;
/* if the measure unit is in 'b' (bits), the value passed must
* be converted to bits (from bytes)
*/
if (strstr(unit, "b")) {
value *= 8; value *= 8;
}
/* bytes, bits or packets */ char *mag = convert_double(&value, (strstr(unit, "B")) ? 1024 : 1000, 1.0f);
if (value < 1000) {
sprintf(buff, "%3ld ", (long)value);
return;
}
/* Kilobytes, Kilobits of Kilopackets */
if (value < 1000000) {
if (strstr(unit, "B")) { /* 1 KB = 1024 */
formated_value = (float) value / 1024.0f;
}
else { /* 1 K = 1000 */
formated_value = (float) value / 1000.0f;
}
sprintf(mybuff, "%3.1f", formated_value); /* Formatting rules:
if (mybuff[2] != '.') { * - if original value was < 1000, output decimal value only
sprintf(buff, "%.3sK", mybuff); * - with 1 precision if <10
} * - decimal value with magnitude otherwise
else { */
sprintf(buff, " %.2sK", mybuff); if (mag[0] == 0)
} sprintf(buff, "%4ld", (long) value);
return; else if (value < 10)
} sprintf(buff, "%3.1f%s", value, mag);
else
sprintf(buff, "%3.f%s", value, mag);
/* Megabytes, Megabits or Megapackets */
if (value < 1000000000.0f) {
if (strstr(unit, "B")) { /* 1 MB = 1024 KB */
formated_value = (float) value / 1048576.0f; /* 1024 ^ 2 */
}
else { /* 1 M = 1000 K */
formated_value = (float) value / 1000000.0f; /* 1000 ^ 2 */
}
sprintf(mybuff, "%3.1f", formated_value);
if (mybuff[2] != '.') {
sprintf(buff, "%.3sM", mybuff);
}
else {
sprintf(buff, " %.2sM", mybuff);
}
return;
}
/* Gigabytes, Gigabits or Gigapackets */
if (value < 1000000000000.0f) {
if (strstr(unit, "B")) { /* 1 GB = 1024 MB */
formated_value = (float) value / 1073741824.0f; /* 1024 ^ 3 */
}
else { /* 1 G = 1000 M */
formated_value = (float) value / 1000000000.0f; /* 1000 ^ 3 */
}
sprintf(mybuff, "%3.1f", formated_value);
if (mybuff[2] != '.') {
sprintf(buff, "%.3sG", mybuff);
}
else {
sprintf(buff, " %.2sG", mybuff);
}
return;
}
/* Terabytes, Terabits or Terapackets */
if (value >= 1000000000000.0f) {
if (strstr(unit, "B")) { /* 1 TB = 1024 GB */
formated_value = (float) value / 1099511627776.0f; /* 1024 ^ 4 */
}
else { /* 1 T = 1000 G */
formated_value = (float) value / 1000000000000.0f; /* 1000 ^ 4 */
}
sprintf(mybuff, "%3.1f", formated_value);
if (mybuff[2] != '.') {
sprintf(buff, "%.3sT", mybuff);
}
else {
sprintf(buff, " %.2sT", mybuff);
}
return;
}
} /* 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
************************************************************************* *************************************************************************
*/ */
void void
get_time_string (char *buff, time_t last_online) get_time_string (char *buff, time_t last_online)
{ {
@@ -854,7 +468,7 @@ get_time_string (char *buff, time_t last_online)
/************************************************************************* /*************************************************************************
* 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
************************************************************************* *************************************************************************
*/ */
@@ -970,7 +584,7 @@ initialize_transfer_screen(void)
/* Set title (transfer screen is always in "bytes") */ /* Set title (transfer screen is always in "bytes") */
sock_send_string(sock, "widget_set NT title {Net Transfer (bytes)}\n"); sock_send_string(sock, "widget_set NT title {Net Transfer (bytes)}\n");
sock_send_string(sock, "widget_add NT f frame\n"); sock_send_string(sock, "widget_add NT f frame\n");
// frame from (2, left) to (width, height) that is iface_count lines high // frame from (2, left) to (width, height) that is iface_count lines high
sock_printf(sock, "widget_set NT f 1 2 %d %d %d %d v 16\n", sock_printf(sock, "widget_set NT f 1 2 %d %d %d %d v 16\n",
lcd_wid, lcd_hgt, lcd_wid, iface_count, lcd_wid, lcd_hgt, lcd_wid, iface_count,
@@ -986,7 +600,7 @@ 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
************************************************************************* *************************************************************************
*/ */
@@ -1028,27 +642,7 @@ actualize_transfer_screen(IfaceInfo *iface, int index)
else { /* Interface is down */ else { /* Interface is down */
get_time_string(transfer, iface->last_online); get_time_string(transfer, iface->last_online);
sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (%s)}\n", sock_printf(sock, "widget_set NT i%1d 1 %1d {%5.5s NA (%s)}\n",
index, index+1, iface[index].alias, transfer); index, index+1, iface[index].alias, transfer);
} }
} }
} /* actualize_transfer_screen() */ } /* actualize_transfer_screen() */
#ifdef NETLCDCLIENT
/*************************************************************************
* Exit the program in a clean way
*************************************************************************
*/
void
exit_program (int val)
{
/* check if socket is open and close it */
if (sock != 0) {
sock_close(sock);
}
fprintf(stderr, "\nExiting netlcdclient....\n");
exit(0);
} /* exit_program() */
#endif //NETLCDCLIENT
-11
View File
@@ -61,12 +61,6 @@ IfaceInfo iface[MAX_INTERFACES]; /* interface info */
/* Functions prototipes */ /* Functions prototipes */
/************************/ /************************/
/* show usage options */
static void usage (int status);
/* parse command line parameters */
static int decode_switches (int argc, char **argv);
/* 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);
@@ -92,9 +86,4 @@ 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);
#ifdef NETLCDCLIENT
/* exit the program cleanly */
void exit_program (int val);
#endif //NETLCDCLIENT
#endif #endif
+1 -1
View File
@@ -86,7 +86,7 @@ xload_screen (int rep, int display, int *flags_ptr)
factor = (double) (lcd_cellhgt * gauge_hgt) / (double) loadtop; factor = (double) (lcd_cellhgt * gauge_hgt) / (double) loadtop;
// display load // display load
sprintf (tmp, "widget_set X top %i %i %i\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt), loadtop); sprintf (tmp, "widget_set X top %i %i %i\n", lcd_wid, (lcd_hgt + 1 - gauge_hgt), loadtop);
sock_send_string (sock, tmp); sock_send_string (sock, tmp);
+7 -7
View File
@@ -15,7 +15,7 @@
* 3. Neither the name of the author nor the names of its contributors * 3. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -127,7 +127,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
} }
else if (CFDictionaryGetValueIfPresent(pSource, CFSTR(kIOPSIsChargingKey), &psValue)) else if (CFDictionaryGetValueIfPresent(pSource, CFSTR(kIOPSIsChargingKey), &psValue))
{ {
/* We are running on an AC power source, /* We are running on an AC power source,
but we also have a battery power source present. */ but we also have a battery power source present. */
if (CFBooleanGetValue(psValue) > 0) if (CFBooleanGetValue(psValue) > 0)
@@ -149,7 +149,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
*percent = (int)((double)curCapacity/(double)maxCapacity * 100); *percent = (int)((double)curCapacity/(double)maxCapacity * 100);
/* There is a way to check this through the IOKit, /* There is a way to check this through the IOKit,
but I am not sure what gets for kIOPSLowWarnLevelKey and kIOPSDeadWarnLevelKey, and this is easier. but I am not sure what gets for kIOPSLowWarnLevelKey and kIOPSDeadWarnLevelKey, and this is easier.
*/ */
if (*battflag == LCDP_BATT_UNKNOWN) { if (*battflag == LCDP_BATT_UNKNOWN) {
@@ -176,11 +176,11 @@ int machine_get_fs(mounts_type fs[], int *cnt)
{ {
struct statfs *mntbuf; struct statfs *mntbuf;
struct statfs *pp; struct statfs *pp;
int statcnt, fscnt, i; int statcnt, fscnt, i;
fscnt = getmntinfo(&mntbuf, MNT_WAIT); fscnt = getmntinfo(&mntbuf, MNT_WAIT);
if (fscnt == 0) if (fscnt == 0)
{ {
perror("getmntinfo"); perror("getmntinfo");
return(FALSE); return(FALSE);
} }
@@ -393,7 +393,7 @@ int machine_get_uptime(double *up, double *idle)
else else
*idle = 100.*curr_load.idle/curr_load.total; *idle = 100.*curr_load.idle/curr_load.total;
return(TRUE); return(TRUE);
} }
static int swapmode(int *rettotal, int *retfree) static int swapmode(int *rettotal, int *retfree)
+6 -6
View File
@@ -15,7 +15,7 @@
* 3. Neither the name of the author nor the names of its contributors * 3. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -146,11 +146,11 @@ int machine_get_fs(mounts_type fs[], int *cnt)
{ {
struct statfs *mntbuf; struct statfs *mntbuf;
struct statfs *pp; struct statfs *pp;
int statcnt, fscnt, i; int statcnt, fscnt, i;
fscnt = getmntinfo(&mntbuf, MNT_WAIT); fscnt = getmntinfo(&mntbuf, MNT_WAIT);
if (fscnt == 0) if (fscnt == 0)
{ {
perror("getmntinfo"); perror("getmntinfo");
return(FALSE); return(FALSE);
} }
@@ -295,7 +295,7 @@ int machine_get_procs(LinkedList *procs)
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc); kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
if (kprocs == NULL) if (kprocs == NULL)
{ {
perror("kvm_getprocs"); perror("kvm_getprocs");
kvm_close(kvmd); kvm_close(kvmd);
return(FALSE); return(FALSE);
@@ -382,7 +382,7 @@ int machine_get_uptime(double *up, double *idle)
else else
*idle = 100.*curr_load.idle/curr_load.total; *idle = 100.*curr_load.idle/curr_load.total;
return(TRUE); return(TRUE);
} }
static int swapmode(int *retavail, int *retfree) static int swapmode(int *retavail, int *retfree)
+6 -6
View File
@@ -15,7 +15,7 @@
* 3. Neither the name of the author nor the names of its contributors * 3. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -103,7 +103,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
memset(&apmi, 0, sizeof(apmi)); memset(&apmi, 0, sizeof(apmi));
if (ioctl(apmd, APM_IOC_GETPOWER, &apmi) == -1) if (ioctl(apmd, APM_IOC_GETPOWER, &apmi) == -1)
{ {
perror("APM_IOC_GETPOWER failed in get_batt_stat()"); perror("APM_IOC_GETPOWER failed in get_batt_stat()");
return(FALSE); return(FALSE);
} }
@@ -141,11 +141,11 @@ int machine_get_fs(mounts_type fs[], int *cnt)
struct statfs *mntbuf; struct statfs *mntbuf;
struct statfs *pp; struct statfs *pp;
#endif #endif
int statcnt, fscnt, i; int statcnt, fscnt, i;
fscnt = getmntinfo(&mntbuf, MNT_WAIT); fscnt = getmntinfo(&mntbuf, MNT_WAIT);
if (fscnt == 0) if (fscnt == 0)
{ {
perror("getmntinfo"); perror("getmntinfo");
return(FALSE); return(FALSE);
} }
@@ -367,7 +367,7 @@ int machine_get_uptime(double *up, double *idle)
else else
*idle = 100.*curr_load.idle/curr_load.total; *idle = 100.*curr_load.idle/curr_load.total;
return(TRUE); return(TRUE);
} }
#endif /* __NetBSD__ */ #endif /* __NetBSD__ */
+6 -6
View File
@@ -15,7 +15,7 @@
* 3. Neither the name of the author nor the names of its contributors * 3. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -149,11 +149,11 @@ int machine_get_fs(mounts_type fs[], int *cnt)
{ {
struct statfs *mntbuf; struct statfs *mntbuf;
struct statfs *pp; struct statfs *pp;
int statcnt, fscnt, i; int statcnt, fscnt, i;
fscnt = getmntinfo(&mntbuf, MNT_WAIT); fscnt = getmntinfo(&mntbuf, MNT_WAIT);
if (fscnt == 0) if (fscnt == 0)
{ {
perror("getmntinfo"); perror("getmntinfo");
return(FALSE); return(FALSE);
} }
@@ -292,7 +292,7 @@ int machine_get_procs(LinkedList *procs)
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc); kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
if (kprocs == NULL) if (kprocs == NULL)
{ {
perror("kvm_getprocs"); perror("kvm_getprocs");
kvm_close(kvmd); kvm_close(kvmd);
return(FALSE); return(FALSE);
@@ -375,7 +375,7 @@ int machine_get_uptime(double *up, double *idle)
else else
*idle = 100.*curr_load.idle/curr_load.total; *idle = 100.*curr_load.idle/curr_load.total;
return(TRUE); return(TRUE);
} }
#endif /* __OpenBSD__ */ #endif /* __OpenBSD__ */
+1 -1
View File
@@ -436,7 +436,7 @@ int machine_get_uptime(double *up, double *idle)
else else
*idle = 100.*curr_load.idle/curr_load.total; *idle = 100.*curr_load.idle/curr_load.total;
return(TRUE); return(TRUE);
} }
#endif /* sun */ #endif /* sun */
+11 -11
View File
@@ -61,14 +61,14 @@ static int process_configfile(char *cfgfile);
// 1/8th second is a single time unit... // 1/8th second is a single time unit...
#define TIME_UNIT 125000 #define TIME_UNIT 125000
#if !defined(SYSCONFDIR) #if !defined(SYSCONFDIR)
# define SYSCONFDIR "/etc" # define SYSCONFDIR "/etc"
#endif #endif
#define UNSET_INT -1 #define UNSET_INT -1
#define UNSET_STR "\01" #define UNSET_STR "\01"
#define DEFAULT_SERVER "127.0.0.1" #define DEFAULT_SERVER "127.0.0.1"
#define DEFAULT_CONFIGFILE SYSCONFDIR "/lcdproc.conf" #define DEFAULT_CONFIGFILE SYSCONFDIR "/lcdproc.conf"
#define DEFAULT_REPORTDEST RPT_DEST_STDERR #define DEFAULT_REPORTDEST RPT_DEST_STDERR
@@ -78,7 +78,7 @@ static int process_configfile(char *cfgfile);
mode sequence[] = mode 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
@@ -87,13 +87,13 @@ mode sequence[] =
{ "About", 'A', 999, 9999, 0, 0xffff, ACTIVE, credit_screen }, // [A]bout (credits) { "About", 'A', 999, 9999, 0, 0xffff, ACTIVE, credit_screen }, // [A]bout (credits)
{ "SMP-CPU", 'P', 1, 2, 0, 0xffff, 0, cpu_smp_screen }, // CPU_SM[P] { "SMP-CPU", 'P', 1, 2, 0, 0xffff, 0, cpu_smp_screen }, // CPU_SM[P]
{ "OldTime", 'O', 4, 64, 0, 0xffff, 0, clock_screen }, // [O]ld Timescreen { "OldTime", 'O', 4, 64, 0, 0xffff, 0, clock_screen }, // [O]ld Timescreen
{ "BigClock", 'K', 4, 64, 0, 0xffff, 0, big_clock_screen }, // big cloc[K] { "BigClock", 'K', 4, 64, 0, 0xffff, 0, big_clock_screen }, // big cloc[K]
{ "Uptime", 'U', 4, 128, 0, 0xffff, 0, uptime_screen }, // Old [U]ptime Screen { "Uptime", 'U', 4, 128, 0, 0xffff, 0, uptime_screen }, // Old [U]ptime Screen
{ "Battery", 'B', 32, 256, 1, 0xffff, 0, battery_screen }, // [B]attery Status { "Battery", 'B', 32, 256, 1, 0xffff, 0, battery_screen }, // [B]attery Status
{ "CPUGraph", 'G', 1, 2, 0, 0xffff, 0, cpu_graph_screen }, // CPU histogram [G]raph { "CPUGraph", 'G', 1, 2, 0, 0xffff, 0, cpu_graph_screen }, // CPU histogram [G]raph
{ "ProcSize", 'S', 16, 256, 1, 0xffff, 0, mem_top_screen }, // [S]ize of biggest processes { "ProcSize", 'S', 16, 256, 1, 0xffff, 0, mem_top_screen }, // [S]ize of biggest processes
{ "Disk", 'D', 256, 256, 1, 0xffff, 0, disk_screen }, // [D]isk stats { "Disk", 'D', 256, 256, 1, 0xffff, 0, disk_screen }, // [D]isk stats
{ "MiniClock", 'N', 4, 64, 0, 0xffff, 0, mini_clock_screen }, // Mi[n]i clock { "MiniClock", 'N', 4, 64, 0, 0xffff, 0, mini_clock_screen }, // Mi[n]i clock
{ NULL, 0, 0, 0, 0, 0, 0, NULL}, // No more.. all done. { NULL, 0, 0, 0, 0, 0, 0, NULL}, // No more.. all done.
}; };
@@ -136,12 +136,12 @@ int set_mode(int shortname, char *longname, int state)
/* ignore already selected modes */ /* 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 inititialized 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);
/* delte 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);
} }
@@ -262,7 +262,7 @@ main(int argc, char **argv)
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';
fprintf(stderr, "%s%s\n", (state) ? "" : "!", name); // debug: fprintf(stderr, "%s%s\n", (state) ? "" : "!", name);
int found = set_mode(shortname, name, state); int found = set_mode(shortname, name, state);
if (!found) { if (!found) {
+2 -2
View File
@@ -147,7 +147,7 @@ mem_screen (int rep, int display, int *flags_ptr)
double value = 1.0 - ((double) mem[1].free / (double) mem[1].total); double value = 1.0 - ((double) mem[1].free / (double) mem[1].total);
//printf(".0f", val) only prints the integer part //printf(".0f", val) only prints the integer part
sprintf(buffer, "widget_set M swapgauge %i 4 %.0f\n", sprintf(buffer, "widget_set M swapgauge %i 4 %.0f\n",
lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value); lcd_wid - gauge_wid, lcd_cellwid * gauge_wid * value);
if (display) if (display)
sock_send_string(sock, buffer); sock_send_string(sock, buffer);
@@ -194,7 +194,7 @@ mem_screen (int rep, int display, int *flags_ptr)
if (gauge_wid > 0) { if (gauge_wid > 0) {
//printf(".0f", val) only prints the integer part //printf(".0f", val) only prints the integer part
sprintf(buffer, "widget_set M swapgauge %i 2 %.0f\n", sprintf(buffer, "widget_set M swapgauge %i 2 %.0f\n",
gauge_offs, lcd_cellwid * gauge_wid * value); gauge_offs, lcd_cellwid * gauge_wid * value);
if (display) if (display)
sock_send_string(sock, buffer); sock_send_string(sock, buffer);
+32 -14
View File
@@ -9,18 +9,18 @@
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* --- * ---
* *
* $Source$ * $Source$
* $Revision$ * $Revision$
* Checked in by: $Author$ * Checked in by: $Author$
@@ -35,25 +35,16 @@ char *
sprintf_memory(char *dst, double value, double roundlimit) sprintf_memory(char *dst, double value, double roundlimit)
{ {
if (dst != NULL) { if (dst != NULL) {
static char *units[] = { "", "k", "M", "G", "T", "P", "E", "Z", "Y", NULL };
int offs = 0;
char *format = "%.1f%s"; char *format = "%.1f%s";
if ((roundlimit <= 0.0) || (roundlimit > 1.0)) char *unit = convert_double(&value, 1024, roundlimit);
roundlimit = 0.5;
while (units[offs] != NULL) {
if (value <= 1024 * roundlimit)
break;
offs++;
value /= 1024;
}
if (value < 100) if (value < 100)
format = "%.2f%s"; format = "%.2f%s";
if (value < 10) if (value < 10)
format = "%.3f%s"; format = "%.3f%s";
sprintf(dst, format, value, units[offs]); sprintf(dst, format, value, unit);
} }
return dst; return dst;
} }
@@ -72,4 +63,31 @@ sprintf_percent(char *dst, double percent)
return dst; return dst;
} }
/** converts a value with unit value
* does not do formatting
* base : should be 1000 for decimal and 1024 for binary units
* roundlimit : set < 1.0 if precision of original input value is not sufficient
*/
char *
convert_double(double *value, int base, double roundlimit)
{
static char *units[] = { "", "k", "M", "G", "T", "P", "E", "Z", "Y", NULL };
int off = 0;
if ((roundlimit <= 0.0) || (roundlimit > 1.0))
roundlimit = 0.5;
/* Get value's order of magnitude */
while (units[off] != NULL) {
/* Note: the check for 1000 is to idenfity the number of
* characters in the output needed, not to decide if to scale value.
*/
if (*value < 1000 * roundlimit)
break;
off++;
*value /= base;
}
return units[off];
}
/* EOF */ /* EOF */
+3
View File
@@ -40,6 +40,9 @@ char *sprintf_memory(char *dst, double value, double roundlimit);
/** print a percentage value to a given string */ /** print a percentage value to a given string */
char *sprintf_percent(char *dst, double percent); char *sprintf_percent(char *dst, double percent);
/** converts value into power-of-x representation */
char *convert_double(double *value, int base, double roundlimit);
#endif /* LCDPROC_UTIL_H */ #endif /* LCDPROC_UTIL_H */
/* EOF */ /* EOF */