mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
C++ conversions WIP.
Currently stuck on an issue with g++ and using '%lli' with printf/scanf.
This commit is contained in:
parent
d3a8c4d22e
commit
620e9876a4
@ -190,16 +190,12 @@ if(BUILD_AUDACIOUS)
|
|||||||
set(WANT_GLIB true)
|
set(WANT_GLIB true)
|
||||||
if(NOT BUILD_AUDACIOUS_LEGACY)
|
if(NOT BUILD_AUDACIOUS_LEGACY)
|
||||||
pkg_check_modules(AUDACIOUS REQUIRED audacious>=1.4.0 dbus-glib-1 gobject-2.0)
|
pkg_check_modules(AUDACIOUS REQUIRED audacious>=1.4.0 dbus-glib-1 gobject-2.0)
|
||||||
# do we need this below?
|
set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES})
|
||||||
#CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
|
set(conky_includes ${conky_includes} ${AUDACIOUS_INCLUDE_DIRS})
|
||||||
#AC_CHECK_HEADERS([audacious/audctrl.h audacious/dbus.h glib.h glib-object.h],
|
|
||||||
# [], AC_MSG_ERROR([required header(s) not found]))
|
|
||||||
else(NOT BUILD_AUDACIOUS_LEGACY)
|
else(NOT BUILD_AUDACIOUS_LEGACY)
|
||||||
pkg_check_modules(AUDACIOUS REQUIRED audacious<1.4.0)
|
pkg_check_modules(AUDACIOUS REQUIRED audacious<1.4.0)
|
||||||
# do we need this below?
|
set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES})
|
||||||
#CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
|
set(conky_includes ${conky_includes} ${AUDACIOUS_INCLUDE_DIRS})
|
||||||
#AC_CHECK_HEADERS([audacious/beepctrl.h glib.h], [], AC_MSG_ERROR([required header(s) not found]))
|
|
||||||
#CPPFLAGS="$save_CPPFLAGS"
|
|
||||||
endif(NOT BUILD_AUDACIOUS_LEGACY)
|
endif(NOT BUILD_AUDACIOUS_LEGACY)
|
||||||
endif(BUILD_AUDACIOUS)
|
endif(BUILD_AUDACIOUS)
|
||||||
|
|
||||||
|
@ -34,14 +34,15 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
|
|||||||
message(FATAL_ERROR "You must remove the autotools generated file '${CMAKE_CURRENT_SOURCE_DIR}/build.h' in order to build with CMake.")
|
message(FATAL_ERROR "You must remove the autotools generated file '${CMAKE_CURRENT_SOURCE_DIR}/build.h' in order to build with CMake.")
|
||||||
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
|
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
|
||||||
|
|
||||||
set(conky_sources colours.cc combine.cc common.c conky.cc core.cc diskio.c
|
set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc
|
||||||
entropy.c exec.cc fs.c mail.cc mixer.c net_stat.c template.c timed_thread.cc
|
diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.c
|
||||||
mboxscan.c read_tcp.c scroll.c specials.c tailhead.c temphelper.c
|
timed_thread.cc mboxscan.c read_tcp.c scroll.cc specials.cc tailhead.cc
|
||||||
text_object.c timeinfo.c top.c algebra.c prioqueue.c proc.c user.c)
|
temphelper.cc text_object.c timeinfo.c top.cc algebra.c prioqueue.c proc.c
|
||||||
|
user.c)
|
||||||
|
|
||||||
# Platform specific sources
|
# Platform specific sources
|
||||||
if(OS_LINUX)
|
if(OS_LINUX)
|
||||||
set(linux linux.c users.c sony.c i8k.c)
|
set(linux linux.cc users.cc sony.c i8k.cc)
|
||||||
set(optional_sources ${optional_sources} ${linux})
|
set(optional_sources ${optional_sources} ${linux})
|
||||||
endif(OS_LINUX)
|
endif(OS_LINUX)
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ endif(OS_NETBSD)
|
|||||||
|
|
||||||
# Optional sources
|
# Optional sources
|
||||||
if(BUILD_AUDACIOUS)
|
if(BUILD_AUDACIOUS)
|
||||||
set(audacious audacious.c)
|
set(audacious audacious.cc)
|
||||||
set(optional_sources ${optional_sources} ${audacious})
|
set(optional_sources ${optional_sources} ${audacious})
|
||||||
endif(BUILD_AUDACIOUS)
|
endif(BUILD_AUDACIOUS)
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ if(BUILD_BMPX)
|
|||||||
endif(BUILD_BMPX)
|
endif(BUILD_BMPX)
|
||||||
|
|
||||||
if(BUILD_IBM)
|
if(BUILD_IBM)
|
||||||
set(ibm ibm.c smapi.c)
|
set(ibm ibm.cc smapi.cc)
|
||||||
set(optional_sources ${optional_sources} ${ibm})
|
set(optional_sources ${optional_sources} ${ibm})
|
||||||
endif(BUILD_IBM)
|
endif(BUILD_IBM)
|
||||||
|
|
||||||
@ -106,12 +107,12 @@ if(BUILD_PORT_MONITORS)
|
|||||||
endif(BUILD_PORT_MONITORS)
|
endif(BUILD_PORT_MONITORS)
|
||||||
|
|
||||||
if(BUILD_X11)
|
if(BUILD_X11)
|
||||||
set(x11 x11.c fonts.c)
|
set(x11 x11.cc fonts.c)
|
||||||
set(optional_sources ${optional_sources} ${x11})
|
set(optional_sources ${optional_sources} ${x11})
|
||||||
endif(BUILD_X11)
|
endif(BUILD_X11)
|
||||||
|
|
||||||
if(BUILD_HDDTEMP)
|
if(BUILD_HDDTEMP)
|
||||||
set(hddtemp hddtemp.c)
|
set(hddtemp hddtemp.cc)
|
||||||
set(optional_sources ${optional_sources} ${hddtemp})
|
set(optional_sources ${optional_sources} ${hddtemp})
|
||||||
endif(BUILD_HDDTEMP)
|
endif(BUILD_HDDTEMP)
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ if(BUILD_WEATHER)
|
|||||||
endif(BUILD_WEATHER)
|
endif(BUILD_WEATHER)
|
||||||
|
|
||||||
if(BUILD_LUA)
|
if(BUILD_LUA)
|
||||||
set(lua llua.c)
|
set(lua llua.cc)
|
||||||
set(optional_sources ${optional_sources} ${lua})
|
set(optional_sources ${optional_sources} ${lua})
|
||||||
endif(BUILD_LUA)
|
endif(BUILD_LUA)
|
||||||
|
|
||||||
|
@ -22,10 +22,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include <config.h>
|
||||||
#include "conky.h"
|
#include "conky.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "audacious.h"
|
#include "audacious.h"
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#ifndef AUDACIOUS_LEGACY
|
#ifndef AUDACIOUS_LEGACY
|
||||||
@ -72,13 +73,10 @@ void update_audacious(void)
|
|||||||
if (create_audacious_thread() != 0) {
|
if (create_audacious_thread() != 0) {
|
||||||
CRIT_ERR(NULL, NULL, "unable to create audacious thread!");
|
CRIT_ERR(NULL, NULL, "unable to create audacious thread!");
|
||||||
}
|
}
|
||||||
timed_thread_register(info.audacious.p_timed_thread,
|
|
||||||
&info.audacious.p_timed_thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timed_thread_lock(info.audacious.p_timed_thread);
|
std::lock_guard<std::mutex> lock(info.audacious.p_timed_thread->mutex());
|
||||||
memcpy(&info.audacious.items, audacious_items, sizeof(audacious_items));
|
memcpy(&info.audacious.items, audacious_items, sizeof(audacious_items));
|
||||||
timed_thread_unlock(info.audacious.p_timed_thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
@ -90,12 +88,12 @@ int create_audacious_thread(void)
|
|||||||
{
|
{
|
||||||
if (!info.audacious.p_timed_thread) {
|
if (!info.audacious.p_timed_thread) {
|
||||||
info.audacious.p_timed_thread =
|
info.audacious.p_timed_thread =
|
||||||
timed_thread_create(audacious_thread_func, NULL,
|
timed_thread::create(std::bind(audacious_thread_func,
|
||||||
info.music_player_interval * 1000000);
|
std::placeholders::_1), info.music_player_interval *
|
||||||
|
1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.audacious.p_timed_thread
|
if (!info.audacious.p_timed_thread) {
|
||||||
|| timed_thread_run(info.audacious.p_timed_thread)) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +109,7 @@ int destroy_audacious_thread(void)
|
|||||||
{
|
{
|
||||||
/* Is a worker is thread running? If not, no error. */
|
/* Is a worker is thread running? If not, no error. */
|
||||||
if (info.audacious.p_timed_thread) {
|
if (info.audacious.p_timed_thread) {
|
||||||
timed_thread_destroy(info.audacious.p_timed_thread,
|
info.audacious.p_timed_thread.reset();
|
||||||
&info.audacious.p_timed_thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -121,8 +118,7 @@ int destroy_audacious_thread(void)
|
|||||||
/* ---------------------------------------------------
|
/* ---------------------------------------------------
|
||||||
* Worker thread function for audacious data sampling.
|
* Worker thread function for audacious data sampling.
|
||||||
* --------------------------------------------------- */
|
* --------------------------------------------------- */
|
||||||
__attribute((noreturn))
|
void audacious_thread_func(thread_handle &handle)
|
||||||
void *audacious_thread_func(void *pvoid)
|
|
||||||
{
|
{
|
||||||
static audacious_t items;
|
static audacious_t items;
|
||||||
gint playpos, frames, length;
|
gint playpos, frames, length;
|
||||||
@ -136,7 +132,6 @@ void *audacious_thread_func(void *pvoid)
|
|||||||
gint session;
|
gint session;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pvoid = (void *) pvoid; /* avoid warning */
|
|
||||||
session = 0;
|
session = 0;
|
||||||
psong = NULL;
|
psong = NULL;
|
||||||
pfilename = NULL;
|
pfilename = NULL;
|
||||||
@ -240,38 +235,38 @@ void *audacious_thread_func(void *pvoid)
|
|||||||
sizeof(items[AUDACIOUS_MAIN_VOLUME]) - 1, "%d", vol);
|
sizeof(items[AUDACIOUS_MAIN_VOLUME]) - 1, "%d", vol);
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
{
|
||||||
/* Deliver the refreshed items array to audacious_items. */
|
/* Deliver the refreshed items array to audacious_items. */
|
||||||
timed_thread_lock(info.audacious.p_timed_thread);
|
std::lock_guard<std::mutex> lock(handle.mutex());
|
||||||
memcpy(&audacious_items, items, sizeof(items));
|
memcpy(&audacious_items, items, sizeof(items));
|
||||||
timed_thread_unlock(info.audacious.p_timed_thread);
|
}
|
||||||
|
|
||||||
if (timed_thread_test(info.audacious.p_timed_thread, 0)) {
|
if (handle.test(0)) {
|
||||||
#ifndef AUDACIOUS_LEGACY
|
#ifndef AUDACIOUS_LEGACY
|
||||||
/* release reference to dbus proxy */
|
/* release reference to dbus proxy */
|
||||||
g_object_unref(session);
|
g_object_unref(session);
|
||||||
#endif
|
#endif
|
||||||
timed_thread_exit(info.audacious.p_timed_thread);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_audacious_title(struct text_object *obj, char *p, int p_max_size)
|
void print_audacious_title(struct text_object *, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
snprintf(p, info.audacious.max_title_len > 0
|
snprintf(p, info.audacious.max_title_len > 0
|
||||||
? info.audacious.max_title_len : p_max_size, "%s",
|
? info.audacious.max_title_len : p_max_size, "%s",
|
||||||
info.audacious.items[AUDACIOUS_TITLE]);
|
info.audacious.items[AUDACIOUS_TITLE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
double audacious_barval(struct text_object *obj)
|
double audacious_barval(struct text_object *)
|
||||||
{
|
{
|
||||||
(void)obj;
|
|
||||||
|
|
||||||
return atof(info.audacious.items[AUDACIOUS_POSITION_SECONDS]) /
|
return atof(info.audacious.items[AUDACIOUS_POSITION_SECONDS]) /
|
||||||
atof(info.audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
atof(info.audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define AUDACIOUS_PRINT_GENERATOR(name, idx) \
|
#define AUDACIOUS_PRINT_GENERATOR(name, idx) \
|
||||||
void print_audacious_##name(struct text_object *obj, char *p, int p_max_size) \
|
void print_audacious_##name(struct text_object *, char *p, int p_max_size) \
|
||||||
{ \
|
{ \
|
||||||
snprintf(p, p_max_size, "%s", info.audacious.items[AUDACIOUS_##idx]); \
|
snprintf(p, p_max_size, "%s", info.audacious.items[AUDACIOUS_##idx]); \
|
||||||
}
|
}
|
@ -27,10 +27,6 @@
|
|||||||
|
|
||||||
#include "timed_thread.h"
|
#include "timed_thread.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum _audacious_items {
|
enum _audacious_items {
|
||||||
AUDACIOUS_STATUS = 0,
|
AUDACIOUS_STATUS = 0,
|
||||||
AUDACIOUS_TITLE,
|
AUDACIOUS_TITLE,
|
||||||
@ -54,7 +50,7 @@ typedef char audacious_t[13][128];
|
|||||||
typedef struct audacious_s {
|
typedef struct audacious_s {
|
||||||
audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */
|
audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */
|
||||||
int max_title_len; /* e.g. ${audacious_title 50} */
|
int max_title_len; /* e.g. ${audacious_title 50} */
|
||||||
timed_thread *p_timed_thread;
|
timed_thread_ptr p_timed_thread;
|
||||||
} AUDACIOUS_S;
|
} AUDACIOUS_S;
|
||||||
|
|
||||||
/* create a worker thread for audacious media player status */
|
/* create a worker thread for audacious media player status */
|
||||||
@ -67,7 +63,7 @@ int destroy_audacious_thread(void);
|
|||||||
void update_audacious(void);
|
void update_audacious(void);
|
||||||
|
|
||||||
/* Thread functions */
|
/* Thread functions */
|
||||||
void *audacious_thread_func(void *);
|
void audacious_thread_func(thread_handle &handle);
|
||||||
|
|
||||||
void print_audacious_status(struct text_object *, char *, int);
|
void print_audacious_status(struct text_object *, char *, int);
|
||||||
void print_audacious_title(struct text_object *, char *, int);
|
void print_audacious_title(struct text_object *, char *, int);
|
||||||
@ -84,8 +80,4 @@ void print_audacious_playlist_position(struct text_object *, char *, int);
|
|||||||
void print_audacious_main_volume(struct text_object *, char *, int);
|
void print_audacious_main_volume(struct text_object *, char *, int);
|
||||||
double audacious_barval(struct text_object *);
|
double audacious_barval(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
48
src/c-funcs.c
Normal file
48
src/c-funcs.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||||
|
*
|
||||||
|
* Conky, a system monitor, based on torsmo
|
||||||
|
*
|
||||||
|
* Please see COPYING for details
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2010 Brenden Matthews, et. al. (see AUTHORS)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "c-funcs.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int sscanf_c(const char *__restrict s, const char *__restrict format, ...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
ret = vsscanf(s, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snprintf_c(char *__restrict s, size_t maxlen, const char *__restrict
|
||||||
|
format, ...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
ret = vsnprintf(s, maxlen, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
45
src/c-funcs.h
Normal file
45
src/c-funcs.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||||
|
*
|
||||||
|
* Conky, a system monitor, based on torsmo
|
||||||
|
*
|
||||||
|
* Please see COPYING for details
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2010 Brenden Matthews, et. al. (see AUTHORS)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _c_funcs_h_
|
||||||
|
#define _c_funcs_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* these functions provide a workaround for a problem in g++ claiming to not
|
||||||
|
* support long longs with these functions */
|
||||||
|
|
||||||
|
int sscanf_c(const char *__restrict s, const char *__restrict format, ...);
|
||||||
|
|
||||||
|
int snprintf_c(char *__restrict s, size_t maxlen, const char *__restrict format,
|
||||||
|
...);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _c_funcs_h_ */
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#include "temphelper.h"
|
#include "temphelper.h"
|
||||||
#include "timeinfo.h"
|
#include "timeinfo.h"
|
||||||
#include "top.h"
|
#include "top.h"
|
||||||
|
#include "c-funcs.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -47,6 +48,7 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/* check for OS and include appropriate headers */
|
/* check for OS and include appropriate headers */
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@ -267,20 +269,20 @@ void format_seconds_short(char *buf, unsigned int n, long seconds)
|
|||||||
|
|
||||||
/* Linked list containing the functions to call upon each update interval.
|
/* Linked list containing the functions to call upon each update interval.
|
||||||
* Populated while initialising text objects in construct_text_object(). */
|
* Populated while initialising text objects in construct_text_object(). */
|
||||||
static struct update_cb {
|
struct update_cb {
|
||||||
struct update_cb *next;
|
struct update_cb *next;
|
||||||
void (*func)(void);
|
void (*func)(void);
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
sem_t start_wait, end_wait;
|
sem_t start_wait, end_wait;
|
||||||
|
update_cb() : next(NULL), func(NULL) {}
|
||||||
|
|
||||||
/* set to 1 when starting the thread
|
/* set to 1 when starting the thread
|
||||||
* set to 0 to request thread termination */
|
* set to 0 to request thread termination */
|
||||||
volatile char running;
|
volatile char running;
|
||||||
} update_cb_head = {
|
|
||||||
.next = NULL,
|
|
||||||
.func = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct update_cb update_cb_head;
|
||||||
|
|
||||||
static void *run_update_callback(void *) __attribute__((noreturn));
|
static void *run_update_callback(void *) __attribute__((noreturn));
|
||||||
|
|
||||||
static int threading_started = 0;
|
static int threading_started = 0;
|
||||||
@ -300,7 +302,7 @@ void add_update_callback(void (*func)(void))
|
|||||||
uc = uc->next;
|
uc = uc->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
uc->next = malloc(sizeof(struct update_cb));
|
uc->next = new update_cb;
|
||||||
uc = uc->next;
|
uc = uc->next;
|
||||||
|
|
||||||
memset(uc, 0, sizeof(struct update_cb));
|
memset(uc, 0, sizeof(struct update_cb));
|
||||||
@ -370,7 +372,7 @@ void start_update_threading(void)
|
|||||||
|
|
||||||
static void *run_update_callback(void *data)
|
static void *run_update_callback(void *data)
|
||||||
{
|
{
|
||||||
struct update_cb *ucb = data;
|
struct update_cb *ucb = static_cast<struct update_cb *>(data);
|
||||||
|
|
||||||
if (!ucb || !ucb->func) pthread_exit(NULL);
|
if (!ucb || !ucb->func) pthread_exit(NULL);
|
||||||
|
|
||||||
@ -382,7 +384,7 @@ static void *run_update_callback(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int no_buffers;
|
extern int no_buffers;
|
||||||
|
|
||||||
void update_stuff(void)
|
void update_stuff(void)
|
||||||
{
|
{
|
||||||
@ -622,12 +624,12 @@ void print_evaluate(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
int if_empty_iftest(struct text_object *obj)
|
int if_empty_iftest(struct text_object *obj)
|
||||||
{
|
{
|
||||||
char buf[max_user_text];
|
std::vector<char> buf(max_user_text);
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||||
|
|
||||||
if (strlen(buf) != 0) {
|
if (strlen(&(buf[0])) != 0) {
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -750,56 +752,56 @@ void print_battery_short(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
|
|
||||||
void print_to_bytes(struct text_object *obj, char *p, int p_max_size)
|
|
||||||
{
|
|
||||||
char buf[max_user_text];
|
|
||||||
long long bytes;
|
|
||||||
char unit[16]; // 16 because we can also have long names (like mega-bytes)
|
|
||||||
|
|
||||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
|
||||||
if(sscanf(buf, "%lli%s", &bytes, unit) == 2 && strlen(unit) < 16){
|
|
||||||
if(strncasecmp("b", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes);
|
|
||||||
else if(strncasecmp("k", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024);
|
|
||||||
else if(strncasecmp("m", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024);
|
|
||||||
else if(strncasecmp("g", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024);
|
|
||||||
else if(strncasecmp("t", unit, 1) == 0) snprintf(buf, max_user_text, "%lli", bytes * 1024 * 1024 * 1024 * 1024);
|
|
||||||
}
|
|
||||||
snprintf(p, p_max_size, "%s", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_blink(struct text_object *obj, char *p, int p_max_size)
|
void print_blink(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
//blinking like this can look a bit ugly if the chars in the font don't have the same width
|
//blinking like this can look a bit ugly if the chars in the font don't have the same width
|
||||||
char buf[max_user_text];
|
std::vector<char> buf(max_user_text);
|
||||||
static int visible = 1;
|
static int visible = 1;
|
||||||
static int last_len = 0;
|
static int last_len = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(buf, 0, max_user_text);
|
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||||
last_len = strlen(buf);
|
last_len = strlen(&(buf[0]));
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < last_len; i++)
|
for (i = 0; i < last_len; i++)
|
||||||
buf[i] = ' ';
|
buf[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(p, p_max_size, "%s", buf);
|
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||||
visible = !visible;
|
visible = !visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_include(struct text_object *obj, char *p, int p_max_size)
|
void print_include(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
char buf[max_user_text];
|
std::vector<char> buf(max_user_text);
|
||||||
|
|
||||||
if (!obj->sub)
|
if (!obj->sub)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||||
snprintf(p, p_max_size, "%s", buf);
|
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_to_bytes(struct text_object *obj, char *p, int p_max_size)
|
||||||
|
{
|
||||||
|
std::vector<char> buf(max_user_text);
|
||||||
|
long long bytes;
|
||||||
|
char unit[16]; // 16 because we can also have long names (like mega-bytes)
|
||||||
|
|
||||||
|
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||||
|
if(sscanf(&(buf[0]), "%lli%s", &bytes, unit) == 2 && strlen(unit) < 16){
|
||||||
|
if(strncasecmp("b", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes);
|
||||||
|
else if(strncasecmp("k", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024);
|
||||||
|
else if(strncasecmp("m", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024);
|
||||||
|
else if(strncasecmp("g", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024 * 1024);
|
||||||
|
else if(strncasecmp("t", unit, 1) == 0) snprintf(&(buf[0]), max_user_text, "%lli", bytes * 1024 * 1024 * 1024 * 1024);
|
||||||
|
}
|
||||||
|
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void print_updates(struct text_object *obj, char *p, int p_max_size)
|
void print_updates(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
(void)obj;
|
(void)obj;
|
11
src/common.h
11
src/common.h
@ -15,6 +15,12 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void print_to_bytes(struct text_object *, char *, int);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void add_update_callback(void (*func)(void));
|
void add_update_callback(void (*func)(void));
|
||||||
void free_update_callbacks(void);
|
void free_update_callbacks(void);
|
||||||
void start_update_threading(void);
|
void start_update_threading(void);
|
||||||
@ -128,15 +134,10 @@ uint8_t battery_percentage(struct text_object *);
|
|||||||
void print_battery_short(struct text_object *, char *, int);
|
void print_battery_short(struct text_object *, char *, int);
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
|
|
||||||
void print_to_bytes(struct text_object *, char *, int);
|
|
||||||
void print_blink(struct text_object *, char *, int);
|
void print_blink(struct text_object *, char *, int);
|
||||||
void print_include(struct text_object *, char *, int);
|
void print_include(struct text_object *, char *, int);
|
||||||
|
|
||||||
void print_updates(struct text_object *, char *, int);
|
void print_updates(struct text_object *, char *, int);
|
||||||
int updatenr_iftest(struct text_object *);
|
int updatenr_iftest(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _COMMON_H */
|
#endif /* _COMMON_H */
|
||||||
|
18
src/conky.h
18
src/conky.h
@ -31,7 +31,7 @@
|
|||||||
#ifndef _conky_h_
|
#ifndef _conky_h_
|
||||||
#define _conky_h_
|
#define _conky_h_
|
||||||
|
|
||||||
#include "config.h" /* defines */
|
#include <config.h> /* defines */
|
||||||
#include "common.h" /* at least for struct dns_data */
|
#include "common.h" /* at least for struct dns_data */
|
||||||
#include <sys/utsname.h> /* struct uname_s */
|
#include <sys/utsname.h> /* struct uname_s */
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -66,10 +66,6 @@ char *strndup(const char *s, size_t n);
|
|||||||
/* forward define to make gcc happy */
|
/* forward define to make gcc happy */
|
||||||
struct text_object;
|
struct text_object;
|
||||||
|
|
||||||
#ifdef AUDACIOUS
|
|
||||||
#include "audacious.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BMPX
|
#ifdef BMPX
|
||||||
#include "bmpx.h"
|
#include "bmpx.h"
|
||||||
#endif
|
#endif
|
||||||
@ -91,12 +87,18 @@ struct text_object;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
/* C++ headers */
|
/* this hack exists only to get around a compilation issue with some files
|
||||||
|
* being converted to C++, will need a better solution */
|
||||||
|
|
||||||
|
/* C++ headers */
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
#include "ccurl_thread.h"
|
#include "ccurl_thread.h"
|
||||||
#endif /* HAVE_CURL */
|
#endif /* HAVE_CURL */
|
||||||
|
|
||||||
|
#ifdef AUDACIOUS
|
||||||
|
#include "audacious.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef RSS
|
#ifdef RSS
|
||||||
@ -194,6 +196,9 @@ enum {
|
|||||||
BATTERY_TIME
|
BATTERY_TIME
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/* this hack exists only to get around a compilation issue with some files
|
||||||
|
* being converted to C++, will need a better solution */
|
||||||
struct information {
|
struct information {
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
@ -249,6 +254,7 @@ struct information {
|
|||||||
|
|
||||||
short kflags; /* kernel settings, see enum KFLAG */
|
short kflags; /* kernel settings, see enum KFLAG */
|
||||||
};
|
};
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* needed by linux.c and top.c -> outsource somewhere */
|
/* needed by linux.c and top.c -> outsource somewhere */
|
||||||
enum {
|
enum {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -37,23 +37,12 @@
|
|||||||
#include "specials.h"
|
#include "specials.h"
|
||||||
#include "text_object.h"
|
#include "text_object.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/* this is the root of all per disk stats,
|
/* this is the root of all per disk stats,
|
||||||
* also containing the totals. */
|
* also containing the totals. */
|
||||||
struct diskio_stat stats = {
|
struct diskio_stat stats;
|
||||||
.next = NULL,
|
|
||||||
.sample = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
||||||
.sample_read = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
||||||
.sample_write = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
||||||
.current = 0,
|
|
||||||
.current_read = 0,
|
|
||||||
.current_write = 0,
|
|
||||||
.last = UINT_MAX,
|
|
||||||
.last_read = UINT_MAX,
|
|
||||||
.last_write = UINT_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
void clear_diskio_stats(void)
|
void clear_diskio_stats(void)
|
||||||
{
|
{
|
||||||
@ -70,7 +59,7 @@ void clear_diskio_stats(void)
|
|||||||
struct diskio_stat *prepare_diskio_stat(const char *s)
|
struct diskio_stat *prepare_diskio_stat(const char *s)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char stat_name[text_buffer_size], device_name[text_buffer_size];
|
std::vector<char> stat_name(text_buffer_size), device_name(text_buffer_size);
|
||||||
struct diskio_stat *cur = &stats;
|
struct diskio_stat *cur = &stats;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
@ -79,29 +68,29 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
|
|||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
if (strncmp(s, "/dev/", 5) == 0) {
|
if (strncmp(s, "/dev/", 5) == 0) {
|
||||||
// supplied a /dev/device arg, so cut off the /dev part
|
// supplied a /dev/device arg, so cut off the /dev part
|
||||||
strncpy(device_name, s + 5, text_buffer_size);
|
strncpy(&(device_name[0]), s + 5, text_buffer_size);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
strncpy(device_name, s, text_buffer_size);
|
strncpy(&(device_name[0]), s, text_buffer_size);
|
||||||
|
|
||||||
snprintf(stat_name, text_buffer_size, "/dev/%s", device_name);
|
snprintf(&(stat_name[0]), text_buffer_size, "/dev/%s", &(device_name[0]));
|
||||||
|
|
||||||
if (stat(stat_name, &sb)) {
|
if (stat(&(stat_name[0]), &sb)) {
|
||||||
NORM_ERR("diskio device '%s' does not exist", s);
|
NORM_ERR("diskio device '%s' does not exist", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lookup existing */
|
/* lookup existing */
|
||||||
while (cur->next) {
|
while (cur->next) {
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
if (!strcmp(cur->dev, device_name)) {
|
if (!strcmp(cur->dev, &(device_name[0]))) {
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no existing found, make a new one */
|
/* no existing found, make a new one */
|
||||||
cur->next = calloc(1, sizeof(struct diskio_stat));
|
cur->next = new diskio_stat;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
cur->dev = strndup(device_name, text_buffer_size);
|
cur->dev = strndup(&(device_name[0]), text_buffer_size);
|
||||||
cur->last = UINT_MAX;
|
cur->last = UINT_MAX;
|
||||||
cur->last_read = UINT_MAX;
|
cur->last_read = UINT_MAX;
|
||||||
cur->last_write = UINT_MAX;
|
cur->last_write = UINT_MAX;
|
||||||
@ -121,7 +110,7 @@ void parse_diskio_arg(struct text_object *obj, const char *arg)
|
|||||||
*/
|
*/
|
||||||
static void print_diskio_dir(struct text_object *obj, int dir, char *p, int p_max_size)
|
static void print_diskio_dir(struct text_object *obj, int dir, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct diskio_stat *diskio = obj->data.opaque;
|
struct diskio_stat *diskio = (struct diskio_stat *)obj->data.opaque;
|
||||||
double val;
|
double val;
|
||||||
|
|
||||||
if (!diskio)
|
if (!diskio)
|
||||||
@ -167,21 +156,21 @@ void parse_diskiograph_arg(struct text_object *obj, const char *arg)
|
|||||||
|
|
||||||
double diskiographval(struct text_object *obj)
|
double diskiographval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct diskio_stat *diskio = obj->data.opaque;
|
struct diskio_stat *diskio = (struct diskio_stat *)obj->data.opaque;
|
||||||
|
|
||||||
return (diskio ? diskio->current : 0);
|
return (diskio ? diskio->current : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double diskiographval_read(struct text_object *obj)
|
double diskiographval_read(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct diskio_stat *diskio = obj->data.opaque;
|
struct diskio_stat *diskio = (struct diskio_stat *)obj->data.opaque;
|
||||||
|
|
||||||
return (diskio ? diskio->current_read : 0);
|
return (diskio ? diskio->current_read : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double diskiographval_write(struct text_object *obj)
|
double diskiographval_write(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct diskio_stat *diskio = obj->data.opaque;
|
struct diskio_stat *diskio = (struct diskio_stat *)obj->data.opaque;
|
||||||
|
|
||||||
return (diskio ? diskio->current_write : 0);
|
return (diskio ? diskio->current_write : 0);
|
||||||
}
|
}
|
21
src/diskio.h
21
src/diskio.h
@ -30,11 +30,22 @@
|
|||||||
#ifndef DISKIO_H_
|
#ifndef DISKIO_H_
|
||||||
#define DISKIO_H_
|
#define DISKIO_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#include <limits.h>
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct diskio_stat {
|
struct diskio_stat {
|
||||||
|
diskio_stat() :
|
||||||
|
next(NULL),
|
||||||
|
current(0),
|
||||||
|
current_read(0),
|
||||||
|
current_write(0),
|
||||||
|
last(UINT_MAX),
|
||||||
|
last_read(UINT_MAX),
|
||||||
|
last_write(UINT_MAX)
|
||||||
|
{
|
||||||
|
memset(sample, 0, sizeof(sample) / sizeof(sample[0]));
|
||||||
|
memset(sample_read, 0, sizeof(sample_read) / sizeof(sample_read[0]));
|
||||||
|
memset(sample_write, 0, sizeof(sample_write) / sizeof(sample_write[0]));
|
||||||
|
}
|
||||||
struct diskio_stat *next;
|
struct diskio_stat *next;
|
||||||
char *dev;
|
char *dev;
|
||||||
double sample[15];
|
double sample[15];
|
||||||
@ -66,8 +77,4 @@ double diskiographval_read(struct text_object *);
|
|||||||
double diskiographval_write(struct text_object *);
|
double diskiographval_write(struct text_object *);
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* DISKIO_H_ */
|
#endif /* DISKIO_H_ */
|
||||||
|
@ -41,14 +41,14 @@
|
|||||||
#include "openbsd.h"
|
#include "openbsd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct {
|
struct _entropy {
|
||||||
|
_entropy() : avail(0), poolsize(0) {}
|
||||||
unsigned int avail;
|
unsigned int avail;
|
||||||
unsigned int poolsize;
|
unsigned int poolsize;
|
||||||
} entropy = {
|
|
||||||
.avail = 0,
|
|
||||||
.poolsize = 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static _entropy entropy;
|
||||||
|
|
||||||
void update_entropy(void)
|
void update_entropy(void)
|
||||||
{
|
{
|
||||||
get_entropy_avail(&entropy.avail);
|
get_entropy_avail(&entropy.avail);
|
@ -31,10 +31,6 @@
|
|||||||
#ifndef _ENTROPY_H
|
#ifndef _ENTROPY_H
|
||||||
#define _ENTROPY_H
|
#define _ENTROPY_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void update_entropy(void);
|
void update_entropy(void);
|
||||||
|
|
||||||
void print_entropy_avail(struct text_object *, char *, int);
|
void print_entropy_avail(struct text_object *, char *, int);
|
||||||
@ -42,8 +38,4 @@ uint8_t entropy_percentage(struct text_object *);
|
|||||||
void print_entropy_poolsize(struct text_object *, char *, int);
|
void print_entropy_poolsize(struct text_object *, char *, int);
|
||||||
double entropy_barval(struct text_object *);
|
double entropy_barval(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _ENTROPY_H */
|
#endif /* _ENTROPY_H */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -91,7 +91,7 @@ void clear_fs_stats(void)
|
|||||||
|
|
||||||
struct fs_stat *prepare_fs_stat(const char *s)
|
struct fs_stat *prepare_fs_stat(const char *s)
|
||||||
{
|
{
|
||||||
struct fs_stat *new = 0;
|
struct fs_stat *next = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* lookup existing or get new */
|
/* lookup existing or get new */
|
||||||
@ -101,18 +101,18 @@ struct fs_stat *prepare_fs_stat(const char *s)
|
|||||||
return &fs_stats[i];
|
return &fs_stats[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new = &fs_stats[i];
|
next = &fs_stats[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* new path */
|
/* new path */
|
||||||
if (!new) {
|
if (!next) {
|
||||||
NORM_ERR("too many fs stats");
|
NORM_ERR("too many fs stats");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strncpy(new->path, s, DEFAULT_TEXT_BUFFER_SIZE);
|
strncpy(next->path, s, DEFAULT_TEXT_BUFFER_SIZE);
|
||||||
new->set = 1;
|
next->set = 1;
|
||||||
update_fs_stat(new);
|
update_fs_stat(next);
|
||||||
return new;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_fs_stat(struct fs_stat *fs)
|
static void update_fs_stat(struct fs_stat *fs)
|
||||||
@ -214,7 +214,7 @@ void init_fs_bar(struct text_object *obj, const char *arg)
|
|||||||
static double do_fs_barval(struct text_object *obj, int be_free_bar)
|
static double do_fs_barval(struct text_object *obj, int be_free_bar)
|
||||||
{
|
{
|
||||||
double val = 1.0;
|
double val = 1.0;
|
||||||
struct fs_stat *fs = obj->data.opaque;
|
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!fs)
|
if (!fs)
|
||||||
return 0;
|
return 0;
|
||||||
@ -245,7 +245,7 @@ void init_fs(struct text_object *obj, const char *arg)
|
|||||||
|
|
||||||
static uint8_t fs_percentage(struct text_object *obj, int be_free)
|
static uint8_t fs_percentage(struct text_object *obj, int be_free)
|
||||||
{
|
{
|
||||||
struct fs_stat *fs = obj->data.opaque;
|
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||||
int val = 100;
|
int val = 100;
|
||||||
|
|
||||||
if (!fs)
|
if (!fs)
|
||||||
@ -273,7 +273,7 @@ uint8_t fs_used_percentage(struct text_object *obj)
|
|||||||
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \
|
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \
|
||||||
void print_fs_##name(struct text_object *obj, char *p, int p_max_size) \
|
void print_fs_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||||
{ \
|
{ \
|
||||||
struct fs_stat *fs = obj->data.opaque; \
|
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque; \
|
||||||
if (fs) \
|
if (fs) \
|
||||||
human_readable(expr, p, p_max_size); \
|
human_readable(expr, p, p_max_size); \
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ HUMAN_PRINT_FS_GENERATOR(used, fs->size - fs->free)
|
|||||||
|
|
||||||
void print_fs_type(struct text_object *obj, char *p, int p_max_size)
|
void print_fs_type(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct fs_stat *fs = obj->data.opaque;
|
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (fs)
|
if (fs)
|
||||||
snprintf(p, p_max_size, "%s", fs->type);
|
snprintf(p, p_max_size, "%s", fs->type);
|
38
src/fs.h
38
src/fs.h
@ -1,14 +1,38 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
|
*
|
||||||
|
* Conky, a system monitor, based on torsmo
|
||||||
|
*
|
||||||
|
* Any original torsmo code is licensed under the BSD license
|
||||||
|
*
|
||||||
|
* All code written since the fork of torsmo is licensed under the GPL
|
||||||
|
*
|
||||||
|
* Please see COPYING for details
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||||
|
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
|
||||||
|
* (see AUTHORS)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _FS_H
|
#ifndef _FS_H
|
||||||
#define _FS_H
|
#define _FS_H
|
||||||
|
|
||||||
#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */
|
#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* needed here and by fs.c */
|
/* needed here and by fs.c */
|
||||||
struct fs_stat {
|
struct fs_stat {
|
||||||
char path[DEFAULT_TEXT_BUFFER_SIZE];
|
char path[DEFAULT_TEXT_BUFFER_SIZE];
|
||||||
@ -38,8 +62,4 @@ void update_fs_stats(void);
|
|||||||
struct fs_stat *prepare_fs_stat(const char *path);
|
struct fs_stat *prepare_fs_stat(const char *path);
|
||||||
void clear_fs_stats(void);
|
void clear_fs_stats(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _FS_H */
|
#endif /* _FS_H */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -47,15 +47,16 @@
|
|||||||
static char *hddtemp_host = NULL;
|
static char *hddtemp_host = NULL;
|
||||||
static char *hddtemp_port = NULL;
|
static char *hddtemp_port = NULL;
|
||||||
|
|
||||||
static struct hdd_info {
|
struct hdd_info {
|
||||||
|
hdd_info() : next(0) {}
|
||||||
struct hdd_info *next;
|
struct hdd_info *next;
|
||||||
char *dev;
|
char *dev;
|
||||||
short temp;
|
short temp;
|
||||||
char unit;
|
char unit;
|
||||||
} hdd_info_head = {
|
|
||||||
.next = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct hdd_info hdd_info_head;
|
||||||
|
|
||||||
void set_hddtemp_host(const char *host)
|
void set_hddtemp_host(const char *host)
|
||||||
{
|
{
|
||||||
if (hddtemp_host)
|
if (hddtemp_host)
|
||||||
@ -75,7 +76,7 @@ static void __free_hddtemp_info(struct hdd_info *hdi)
|
|||||||
if (hdi->next)
|
if (hdi->next)
|
||||||
__free_hddtemp_info(hdi->next);
|
__free_hddtemp_info(hdi->next);
|
||||||
free(hdi->dev);
|
free(hdi->dev);
|
||||||
free(hdi);
|
delete hdi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_hddtemp_info(void)
|
static void free_hddtemp_info(void)
|
||||||
@ -95,7 +96,7 @@ static void add_hddtemp_info(char *dev, short temp, char unit)
|
|||||||
while (hdi->next)
|
while (hdi->next)
|
||||||
hdi = hdi->next;
|
hdi = hdi->next;
|
||||||
|
|
||||||
hdi->next = malloc(sizeof(struct hdd_info));
|
hdi->next = new hdd_info;
|
||||||
memset(hdi->next, 0, sizeof(struct hdd_info));
|
memset(hdi->next, 0, sizeof(struct hdd_info));
|
||||||
hdi->next->dev = strdup(dev);
|
hdi->next->dev = strdup(dev);
|
||||||
hdi->next->temp = temp;
|
hdi->next->temp = temp;
|
||||||
@ -137,12 +138,12 @@ static char *fetch_hddtemp_output(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buflen = 1024;
|
buflen = 1024;
|
||||||
buf = malloc(buflen);
|
buf = (char*)malloc(buflen);
|
||||||
while ((rlen = recv(sockfd, buf + offset, buflen - offset - 1, 0)) > 0) {
|
while ((rlen = recv(sockfd, buf + offset, buflen - offset - 1, 0)) > 0) {
|
||||||
offset += rlen;
|
offset += rlen;
|
||||||
if (buflen - offset < 1) {
|
if (buflen - offset < 1) {
|
||||||
buflen += 1024;
|
buflen += 1024;
|
||||||
buf = realloc(buf, buflen);
|
buf = (char*)realloc(buf, buflen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rlen < 0)
|
if (rlen < 0)
|
@ -1,20 +1,41 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
|
*
|
||||||
|
* Conky, a system monitor, based on torsmo
|
||||||
|
*
|
||||||
|
* Any original torsmo code is licensed under the BSD license
|
||||||
|
*
|
||||||
|
* All code written since the fork of torsmo is licensed under the GPL
|
||||||
|
*
|
||||||
|
* Please see COPYING for details
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||||
|
* Copyright (c) 2007 Toni Spets
|
||||||
|
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
|
||||||
|
* (see AUTHORS)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef HDDTEMP_H_
|
#ifndef HDDTEMP_H_
|
||||||
#define HDDTEMP_H_
|
#define HDDTEMP_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void set_hddtemp_host(const char *);
|
void set_hddtemp_host(const char *);
|
||||||
void set_hddtemp_port(const char *);
|
void set_hddtemp_port(const char *);
|
||||||
void update_hddtemp(void);
|
void update_hddtemp(void);
|
||||||
void free_hddtemp(struct text_object *);
|
void free_hddtemp(struct text_object *);
|
||||||
void print_hddtemp(struct text_object *, char *, int);
|
void print_hddtemp(struct text_object *, char *, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*HDDTEMP_H_*/
|
#endif /*HDDTEMP_H_*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include "temphelper.h"
|
#include "temphelper.h"
|
||||||
#include "text_object.h"
|
#include "text_object.h"
|
||||||
|
|
||||||
struct {
|
struct _i8k {
|
||||||
char *version;
|
char *version;
|
||||||
char *bios;
|
char *bios;
|
||||||
char *serial;
|
char *serial;
|
12
src/i8k.h
12
src/i8k.h
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -32,10 +32,6 @@
|
|||||||
#ifndef _I8K_H
|
#ifndef _I8K_H
|
||||||
#define _I8K_H
|
#define _I8K_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void update_i8k(void);
|
void update_i8k(void);
|
||||||
void print_i8k_left_fan_status(struct text_object *, char *, int);
|
void print_i8k_left_fan_status(struct text_object *, char *, int);
|
||||||
void print_i8k_cpu_temp(struct text_object *, char *, int);
|
void print_i8k_cpu_temp(struct text_object *, char *, int);
|
||||||
@ -48,8 +44,4 @@ void print_i8k_left_fan_rpm(struct text_object *, char *, int);
|
|||||||
void print_i8k_right_fan_rpm(struct text_object *, char *, int);
|
void print_i8k_right_fan_rpm(struct text_object *, char *, int);
|
||||||
void print_i8k_buttons_status(struct text_object *, char *, int);
|
void print_i8k_buttons_status(struct text_object *, char *, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _I8K_H */
|
#endif /* _I8K_H */
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
* Any original torsmo code is licensed under the BSD license
|
|
||||||
*
|
|
||||||
* All code written since the fork of torsmo is licensed under the GPL
|
|
||||||
*
|
|
||||||
* Please see COPYING for details
|
* Please see COPYING for details
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||||
@ -36,6 +32,7 @@
|
|||||||
#include "net_stat.h"
|
#include "net_stat.h"
|
||||||
#include "diskio.h"
|
#include "diskio.h"
|
||||||
#include "temphelper.h"
|
#include "temphelper.h"
|
||||||
|
#include "c-funcs.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -178,17 +175,17 @@ void update_meminfo(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(buf, "MemTotal:", 9) == 0) {
|
if (strncmp(buf, "MemTotal:", 9) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.memmax);
|
sscanf_c(buf, "%*s %llu", &info.memmax);
|
||||||
} else if (strncmp(buf, "MemFree:", 8) == 0) {
|
} else if (strncmp(buf, "MemFree:", 8) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.memfree);
|
sscanf_c(buf, "%*s %llu", &info.memfree);
|
||||||
} else if (strncmp(buf, "SwapTotal:", 10) == 0) {
|
} else if (strncmp(buf, "SwapTotal:", 10) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.swapmax);
|
sscanf_c(buf, "%*s %llu", &info.swapmax);
|
||||||
} else if (strncmp(buf, "SwapFree:", 9) == 0) {
|
} else if (strncmp(buf, "SwapFree:", 9) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.swapfree);
|
sscanf_c(buf, "%*s %llu", &info.swapfree);
|
||||||
} else if (strncmp(buf, "Buffers:", 8) == 0) {
|
} else if (strncmp(buf, "Buffers:", 8) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.buffers);
|
sscanf_c(buf, "%*s %llu", &info.buffers);
|
||||||
} else if (strncmp(buf, "Cached:", 7) == 0) {
|
} else if (strncmp(buf, "Cached:", 7) == 0) {
|
||||||
sscanf(buf, "%*s %llu", &info.cached);
|
sscanf_c(buf, "%*s %llu", &info.cached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +418,7 @@ void update_net_stats(void)
|
|||||||
last_trans = ns->trans;
|
last_trans = ns->trans;
|
||||||
|
|
||||||
/* bytes packets errs drop fifo frame compressed multicast|bytes ... */
|
/* bytes packets errs drop fifo frame compressed multicast|bytes ... */
|
||||||
sscanf(p, "%lld %*d %*d %*d %*d %*d %*d %*d %lld",
|
sscanf_c(p, "%lld %*d %*d %*d %*d %*d %*d %*d %lld",
|
||||||
&r, &t);
|
&r, &t);
|
||||||
|
|
||||||
/* if recv or trans is less than last time, an overflow happened */
|
/* if recv or trans is less than last time, an overflow happened */
|
||||||
@ -442,7 +439,7 @@ void update_net_stats(void)
|
|||||||
/*** ip addr patch ***/
|
/*** ip addr patch ***/
|
||||||
i = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
|
i = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||||
|
|
||||||
conf.ifc_buf = malloc(sizeof(struct ifreq) * MAX_NET_INTERFACES);
|
conf.ifc_buf = (char*)malloc(sizeof(struct ifreq) * MAX_NET_INTERFACES);
|
||||||
conf.ifc_len = sizeof(struct ifreq) * MAX_NET_INTERFACES;
|
conf.ifc_len = sizeof(struct ifreq) * MAX_NET_INTERFACES;
|
||||||
memset(conf.ifc_buf, 0, conf.ifc_len);
|
memset(conf.ifc_buf, 0, conf.ifc_len);
|
||||||
|
|
||||||
@ -644,7 +641,7 @@ void determine_longstat(char *buf)
|
|||||||
|
|
||||||
KFLAG_SETOFF(KFLAG_IS_LONGSTAT);
|
KFLAG_SETOFF(KFLAG_IS_LONGSTAT);
|
||||||
/* scanf will either return -1 or 1 because there is only 1 assignment */
|
/* scanf will either return -1 or 1 because there is only 1 assignment */
|
||||||
if (sscanf(buf, "%*s %*d %*d %*d %*d %llu", &iowait) > 0) {
|
if (sscanf_c(buf, "%*s %*d %*d %*d %*d %llu", &iowait) > 0) {
|
||||||
KFLAG_SETON(KFLAG_IS_LONGSTAT);
|
KFLAG_SETON(KFLAG_IS_LONGSTAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,7 +674,7 @@ void get_cpu_count(void)
|
|||||||
info.cpu_count++;
|
info.cpu_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.cpu_usage = malloc((info.cpu_count + 1) * sizeof(float));
|
info.cpu_usage = (float*)malloc((info.cpu_count + 1) * sizeof(float));
|
||||||
|
|
||||||
fclose(stat_fp);
|
fclose(stat_fp);
|
||||||
}
|
}
|
||||||
@ -725,7 +722,7 @@ void update_stat(void)
|
|||||||
|
|
||||||
if (!global_cpu) {
|
if (!global_cpu) {
|
||||||
malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
|
malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
|
||||||
cpu = malloc(malloc_cpu_size);
|
cpu = (struct cpu_info *)malloc(malloc_cpu_size);
|
||||||
memset(cpu, 0, malloc_cpu_size);
|
memset(cpu, 0, malloc_cpu_size);
|
||||||
global_cpu = cpu;
|
global_cpu = cpu;
|
||||||
}
|
}
|
||||||
@ -753,7 +750,7 @@ void update_stat(void)
|
|||||||
} else {
|
} else {
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
}
|
||||||
sscanf(buf, stat_template, &(cpu[idx].cpu_user),
|
sscanf_c(buf, stat_template, &(cpu[idx].cpu_user),
|
||||||
&(cpu[idx].cpu_nice), &(cpu[idx].cpu_system),
|
&(cpu[idx].cpu_nice), &(cpu[idx].cpu_system),
|
||||||
&(cpu[idx].cpu_idle), &(cpu[idx].cpu_iowait),
|
&(cpu[idx].cpu_idle), &(cpu[idx].cpu_iowait),
|
||||||
&(cpu[idx].cpu_irq), &(cpu[idx].cpu_softirq),
|
&(cpu[idx].cpu_irq), &(cpu[idx].cpu_softirq),
|
||||||
@ -1070,7 +1067,7 @@ static void parse_sysfs_sensor(struct text_object *obj, const char *arg, const c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBGP("parsed %s args: '%s' '%s' %d %f %f\n", type, buf1, buf2, n, factor, offset);
|
DBGP("parsed %s args: '%s' '%s' %d %f %f\n", type, buf1, buf2, n, factor, offset);
|
||||||
sf = malloc(sizeof(struct sysfs));
|
sf = (struct sysfs*)malloc(sizeof(struct sysfs));
|
||||||
memset(sf, 0, sizeof(struct sysfs));
|
memset(sf, 0, sizeof(struct sysfs));
|
||||||
sf->fd = open_sysfs_sensor(path, (*buf1) ? buf1 : 0, buf2, n,
|
sf->fd = open_sysfs_sensor(path, (*buf1) ? buf1 : 0, buf2, n,
|
||||||
&sf->arg, sf->devtype);
|
&sf->arg, sf->devtype);
|
||||||
@ -1093,7 +1090,7 @@ PARSER_GENERATOR(platform, "/sys/bus/platform/devices/")
|
|||||||
void print_sysfs_sensor(struct text_object *obj, char *p, int p_max_size)
|
void print_sysfs_sensor(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
double r;
|
double r;
|
||||||
struct sysfs *sf = obj->data.opaque;
|
struct sysfs *sf = (struct sysfs *)obj->data.opaque;
|
||||||
|
|
||||||
if (!sf)
|
if (!sf)
|
||||||
return;
|
return;
|
||||||
@ -1114,7 +1111,7 @@ void print_sysfs_sensor(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void free_sysfs_sensor(struct text_object *obj)
|
void free_sysfs_sensor(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct sysfs *sf = obj->data.opaque;
|
struct sysfs *sf = (struct sysfs *)obj->data.opaque;
|
||||||
|
|
||||||
if (!sf)
|
if (!sf)
|
||||||
return;
|
return;
|
@ -5,10 +5,6 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void print_disk_protect_queue(struct text_object *, char *, int);
|
void print_disk_protect_queue(struct text_object *, char *, int);
|
||||||
|
|
||||||
void print_ioscheduler(struct text_object *, char *, int);
|
void print_ioscheduler(struct text_object *, char *, int);
|
||||||
@ -34,8 +30,4 @@ int get_entropy_poolsize(unsigned int *);
|
|||||||
|
|
||||||
void update_stat(void);
|
void update_stat(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _LINUX_H */
|
#endif /* _LINUX_H */
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#ifdef LUA_EXTRAS
|
#ifdef LUA_EXTRAS
|
||||||
#include <tolua++.h>
|
#include <tolua++.h>
|
||||||
#endif /* LUA_EXTRAS */
|
#endif /* LUA_EXTRAS */
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYS_INOTIFY_H
|
#ifdef HAVE_SYS_INOTIFY_H
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
@ -51,7 +53,7 @@ static int llua_conky_parse(lua_State *L)
|
|||||||
{
|
{
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
char *str;
|
char *str;
|
||||||
char *buf = calloc(1, max_user_text);
|
char *buf = (char*)calloc(1, max_user_text);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
lua_pushstring(L, "incorrect arguments, conky_parse(string) takes exactly 1 argument");
|
lua_pushstring(L, "incorrect arguments, conky_parse(string) takes exactly 1 argument");
|
||||||
lua_error(L);
|
lua_error(L);
|
||||||
@ -97,7 +99,7 @@ void llua_init(void)
|
|||||||
lua_getglobal(lua_L, "package");
|
lua_getglobal(lua_L, "package");
|
||||||
lua_getfield(lua_L, -1, "cpath");
|
lua_getfield(lua_L, -1, "cpath");
|
||||||
old_path = strdup(lua_tostring(lua_L, -1));
|
old_path = strdup(lua_tostring(lua_L, -1));
|
||||||
new_path = malloc(strlen(old_path) + strlen(libs) + 1);
|
new_path = (char*)malloc(strlen(old_path) + strlen(libs) + 1);
|
||||||
strcpy(new_path, libs);
|
strcpy(new_path, libs);
|
||||||
strcat(new_path, old_path);
|
strcat(new_path, old_path);
|
||||||
lua_pushstring(lua_L, new_path);
|
lua_pushstring(lua_L, new_path);
|
||||||
@ -328,7 +330,7 @@ static struct _lua_notify_s *lua_notifies = 0;
|
|||||||
|
|
||||||
static struct _lua_notify_s *llua_notify_list_do_alloc(const char *name)
|
static struct _lua_notify_s *llua_notify_list_do_alloc(const char *name)
|
||||||
{
|
{
|
||||||
struct _lua_notify_s *ret = malloc(sizeof(struct _lua_notify_s));
|
struct _lua_notify_s *ret = (struct _lua_notify_s *)malloc(sizeof(struct _lua_notify_s));
|
||||||
memset(ret, 0, sizeof(struct _lua_notify_s));
|
memset(ret, 0, sizeof(struct _lua_notify_s));
|
||||||
strncpy(ret->name, name, DEFAULT_TEXT_BUFFER_SIZE);
|
strncpy(ret->name, name, DEFAULT_TEXT_BUFFER_SIZE);
|
||||||
return ret;
|
return ret;
|
10
src/llua.h
10
src/llua.h
@ -24,9 +24,11 @@
|
|||||||
#ifndef LUA_H_
|
#ifndef LUA_H_
|
||||||
#define LUA_H_
|
#define LUA_H_
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
|
}
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -36,10 +38,6 @@
|
|||||||
|
|
||||||
#define LUAPREFIX "conky_"
|
#define LUAPREFIX "conky_"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* load a lua script */
|
/* load a lua script */
|
||||||
void llua_load(const char *script);
|
void llua_load(const char *script);
|
||||||
/* close lua stuff */
|
/* close lua stuff */
|
||||||
@ -73,8 +71,4 @@ void print_lua(struct text_object *, char *, int);
|
|||||||
void print_lua_parse(struct text_object *, char *, int);
|
void print_lua_parse(struct text_object *, char *, int);
|
||||||
double lua_barval(struct text_object *);
|
double lua_barval(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* LUA_H_*/
|
#endif /* LUA_H_*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
39
src/mixer.h
39
src/mixer.h
@ -1,12 +1,37 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
|
*
|
||||||
|
* Conky, a system monitor, based on torsmo
|
||||||
|
*
|
||||||
|
* Any original torsmo code is licensed under the BSD license
|
||||||
|
*
|
||||||
|
* All code written since the fork of torsmo is licensed under the GPL
|
||||||
|
*
|
||||||
|
* Please see COPYING for details
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||||
|
* Copyright (c) 2007 Toni Spets
|
||||||
|
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
|
||||||
|
* (see AUTHORS)
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef MIXER_H_
|
#ifndef MIXER_H_
|
||||||
#define MIXER_H_
|
#define MIXER_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void parse_mixer_arg(struct text_object *, const char *);
|
void parse_mixer_arg(struct text_object *, const char *);
|
||||||
uint8_t mixer_percentage(struct text_object *obj);
|
uint8_t mixer_percentage(struct text_object *obj);
|
||||||
uint8_t mixerl_percentage(struct text_object *obj);
|
uint8_t mixerl_percentage(struct text_object *obj);
|
||||||
@ -18,8 +43,4 @@ double mixer_barval(struct text_object *);
|
|||||||
double mixerl_barval(struct text_object *);
|
double mixerl_barval(struct text_object *);
|
||||||
double mixerr_barval(struct text_object *);
|
double mixerr_barval(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*MIXER_H_*/
|
#endif /*MIXER_H_*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -95,7 +95,7 @@ void parse_net_stat_bar_arg(struct text_object *obj, const char *arg, void *free
|
|||||||
|
|
||||||
void print_downspeed(struct text_object *obj, char *p, int p_max_size)
|
void print_downspeed(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -105,7 +105,7 @@ void print_downspeed(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_downspeedf(struct text_object *obj, char *p, int p_max_size)
|
void print_downspeedf(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -115,7 +115,7 @@ void print_downspeedf(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_upspeed(struct text_object *obj, char *p, int p_max_size)
|
void print_upspeed(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -125,7 +125,7 @@ void print_upspeed(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_upspeedf(struct text_object *obj, char *p, int p_max_size)
|
void print_upspeedf(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -135,7 +135,7 @@ void print_upspeedf(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_totaldown(struct text_object *obj, char *p, int p_max_size)
|
void print_totaldown(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -145,7 +145,7 @@ void print_totaldown(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_totalup(struct text_object *obj, char *p, int p_max_size)
|
void print_totalup(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -155,7 +155,7 @@ void print_totalup(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
void print_addr(struct text_object *obj, char *p, int p_max_size)
|
void print_addr(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -177,7 +177,7 @@ void print_addr(struct text_object *obj, char *p, int p_max_size)
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
void print_addrs(struct text_object *obj, char *p, int p_max_size)
|
void print_addrs(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -208,14 +208,14 @@ void parse_net_stat_graph_arg(struct text_object *obj, const char *arg, void *fr
|
|||||||
|
|
||||||
double downspeedgraphval(struct text_object *obj)
|
double downspeedgraphval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
return (ns ? (ns->recv_speed / 1024.0) : 0);
|
return (ns ? (ns->recv_speed / 1024.0) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double upspeedgraphval(struct text_object *obj)
|
double upspeedgraphval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
return (ns ? (ns->trans_speed / 1024.0) : 0);
|
return (ns ? (ns->trans_speed / 1024.0) : 0);
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ double upspeedgraphval(struct text_object *obj)
|
|||||||
#ifdef HAVE_IWLIB
|
#ifdef HAVE_IWLIB
|
||||||
void print_wireless_essid(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_essid(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -234,7 +234,7 @@ void print_wireless_essid(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
void print_wireless_mode(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_mode(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -243,7 +243,7 @@ void print_wireless_mode(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
void print_wireless_bitrate(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_bitrate(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -252,7 +252,7 @@ void print_wireless_bitrate(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
void print_wireless_ap(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_ap(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -261,7 +261,7 @@ void print_wireless_ap(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
void print_wireless_link_qual(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_link_qual(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -270,7 +270,7 @@ void print_wireless_link_qual(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
void print_wireless_link_qual_max(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_link_qual_max(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -279,7 +279,7 @@ void print_wireless_link_qual_max(struct text_object *obj, char *p, int p_max_si
|
|||||||
}
|
}
|
||||||
void print_wireless_link_qual_perc(struct text_object *obj, char *p, int p_max_size)
|
void print_wireless_link_qual_perc(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return;
|
return;
|
||||||
@ -294,7 +294,7 @@ void print_wireless_link_qual_perc(struct text_object *obj, char *p, int p_max_s
|
|||||||
}
|
}
|
||||||
double wireless_link_barval(struct text_object *obj)
|
double wireless_link_barval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct net_stat *ns = obj->data.opaque;
|
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ns)
|
if (!ns)
|
||||||
return 0;
|
return 0;
|
||||||
@ -333,7 +333,7 @@ int interface_up(struct text_object *obj)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
char *dev = obj->data.opaque;
|
char *dev = (char*)obj->data.opaque;
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return 0;
|
return 0;
|
||||||
@ -375,14 +375,14 @@ END_TRUE:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
struct _dns_data {
|
||||||
|
_dns_data() : nscount(0), ns_list(0) {}
|
||||||
int nscount;
|
int nscount;
|
||||||
char **ns_list;
|
char **ns_list;
|
||||||
} dns_data = {
|
|
||||||
.nscount = 0,
|
|
||||||
.ns_list = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static _dns_data dns_data;
|
||||||
|
|
||||||
void free_dns_data(struct text_object *obj)
|
void free_dns_data(struct text_object *obj)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -420,7 +420,7 @@ void update_dns_data(void)
|
|||||||
if (!strncmp(line, "nameserver ", 11)) {
|
if (!strncmp(line, "nameserver ", 11)) {
|
||||||
line[strlen(line) - 1] = '\0'; // remove trailing newline
|
line[strlen(line) - 1] = '\0'; // remove trailing newline
|
||||||
dns_data.nscount++;
|
dns_data.nscount++;
|
||||||
dns_data.ns_list = realloc(dns_data.ns_list, dns_data.nscount * sizeof(char *));
|
dns_data.ns_list = (char**)realloc(dns_data.ns_list, dns_data.nscount * sizeof(char *));
|
||||||
dns_data.ns_list[dns_data.nscount - 1] = strndup(line + 11, text_buffer_size);
|
dns_data.ns_list[dns_data.nscount - 1] = strndup(line + 11, text_buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -33,10 +33,6 @@
|
|||||||
|
|
||||||
#include <sys/socket.h> /* struct sockaddr */
|
#include <sys/socket.h> /* struct sockaddr */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct net_stat {
|
struct net_stat {
|
||||||
char *dev;
|
char *dev;
|
||||||
int up;
|
int up;
|
||||||
@ -102,8 +98,4 @@ void update_dns_data(void);
|
|||||||
void parse_nameserver_arg(struct text_object *, const char *);
|
void parse_nameserver_arg(struct text_object *, const char *);
|
||||||
void print_nameserver(struct text_object *, char *, int);
|
void print_nameserver(struct text_object *, char *, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _NET_STAT_H */
|
#endif /* _NET_STAT_H */
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#ifndef _PRIOQUEUE_H
|
#ifndef _PRIOQUEUE_H
|
||||||
#define _PRIOQUEUE_H
|
#define _PRIOQUEUE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
/* forward-define for private data */
|
/* forward-define for private data */
|
||||||
struct prio_queue;
|
struct prio_queue;
|
||||||
|
|
||||||
@ -63,4 +66,8 @@ void *pop_prio_elem(prio_queue_t);
|
|||||||
/* clear and free the given queue */
|
/* clear and free the given queue */
|
||||||
void free_prio_queue(prio_queue_t);
|
void free_prio_queue(prio_queue_t);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _PRIOQUEUE_H */
|
#endif /* _PRIOQUEUE_H */
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -31,6 +32,7 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "specials.h"
|
#include "specials.h"
|
||||||
#include "text_object.h"
|
#include "text_object.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct scroll_data {
|
struct scroll_data {
|
||||||
char *text;
|
char *text;
|
||||||
@ -45,7 +47,7 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr
|
|||||||
struct scroll_data *sd;
|
struct scroll_data *sd;
|
||||||
int n1 = 0, n2 = 0;
|
int n1 = 0, n2 = 0;
|
||||||
|
|
||||||
sd = malloc(sizeof(struct scroll_data));
|
sd = (struct scroll_data *)malloc(sizeof(struct scroll_data));
|
||||||
memset(sd, 0, sizeof(struct scroll_data));
|
memset(sd, 0, sizeof(struct scroll_data));
|
||||||
|
|
||||||
sd->resetcolor = get_current_text_color();
|
sd->resetcolor = get_current_text_color();
|
||||||
@ -59,7 +61,7 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr
|
|||||||
} else {
|
} else {
|
||||||
sd->step = 1;
|
sd->step = 1;
|
||||||
}
|
}
|
||||||
sd->text = malloc(strlen(arg + n1) + sd->show + 1);
|
sd->text = (char*)malloc(strlen(arg + n1) + sd->show + 1);
|
||||||
|
|
||||||
if (strlen(arg) > sd->show) {
|
if (strlen(arg) > sd->show) {
|
||||||
for(n2 = 0; (unsigned int) n2 < sd->show; n2++) {
|
for(n2 = 0; (unsigned int) n2 < sd->show; n2++) {
|
||||||
@ -72,7 +74,7 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr
|
|||||||
|
|
||||||
strcat(sd->text, arg + n1);
|
strcat(sd->text, arg + n1);
|
||||||
sd->start = 0;
|
sd->start = 0;
|
||||||
obj->sub = malloc(sizeof(struct text_object));
|
obj->sub = (struct text_object *)malloc(sizeof(struct text_object));
|
||||||
extract_variable_text_internal(obj->sub, sd->text);
|
extract_variable_text_internal(obj->sub, sd->text);
|
||||||
|
|
||||||
obj->data.opaque = sd;
|
obj->data.opaque = sd;
|
||||||
@ -86,15 +88,15 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr
|
|||||||
|
|
||||||
void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct scroll_data *sd = obj->data.opaque;
|
struct scroll_data *sd = (struct scroll_data *)obj->data.opaque;
|
||||||
unsigned int j, colorchanges = 0, frontcolorchanges = 0, visibcolorchanges = 0, strend;
|
unsigned int j, colorchanges = 0, frontcolorchanges = 0, visibcolorchanges = 0, strend;
|
||||||
char *pwithcolors;
|
char *pwithcolors;
|
||||||
char buf[max_user_text];
|
std::vector<char> buf(max_user_text);
|
||||||
|
|
||||||
if (!sd)
|
if (!sd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||||
for(j = 0; buf[j] != 0; j++) {
|
for(j = 0; buf[j] != 0; j++) {
|
||||||
switch(buf[j]) {
|
switch(buf[j]) {
|
||||||
case '\n': //place all the lines behind each other with LINESEPARATOR between them
|
case '\n': //place all the lines behind each other with LINESEPARATOR between them
|
||||||
@ -107,17 +109,17 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//no scrolling necessary if the length of the text to scroll is too short
|
//no scrolling necessary if the length of the text to scroll is too short
|
||||||
if (strlen(buf) - colorchanges <= sd->show) {
|
if (strlen(&(buf[0])) - colorchanges <= sd->show) {
|
||||||
snprintf(p, p_max_size, "%s", buf);
|
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//make sure a colorchange at the front is not part of the string we are going to show
|
//make sure a colorchange at the front is not part of the string we are going to show
|
||||||
while(*(buf + sd->start) == SPECIAL_CHAR) {
|
while(buf[sd->start] == SPECIAL_CHAR) {
|
||||||
sd->start++;
|
sd->start++;
|
||||||
}
|
}
|
||||||
//place all chars that should be visible in p, including colorchanges
|
//place all chars that should be visible in p, including colorchanges
|
||||||
for(j=0; j < sd->show + visibcolorchanges; j++) {
|
for(j=0; j < sd->show + visibcolorchanges; j++) {
|
||||||
p[j] = *(buf + sd->start + j);
|
p[j] = buf[sd->start + j];
|
||||||
if(p[j] == SPECIAL_CHAR) {
|
if(p[j] == SPECIAL_CHAR) {
|
||||||
visibcolorchanges++;
|
visibcolorchanges++;
|
||||||
}
|
}
|
||||||
@ -132,7 +134,7 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
|||||||
for(j = 0; j < sd->start; j++) {
|
for(j = 0; j < sd->start; j++) {
|
||||||
if(buf[j] == SPECIAL_CHAR) frontcolorchanges++;
|
if(buf[j] == SPECIAL_CHAR) frontcolorchanges++;
|
||||||
}
|
}
|
||||||
pwithcolors=malloc(strlen(p) + 1 + colorchanges - visibcolorchanges);
|
pwithcolors=(char*)malloc(strlen(p) + 1 + colorchanges - visibcolorchanges);
|
||||||
for(j = 0; j < frontcolorchanges; j++) {
|
for(j = 0; j < frontcolorchanges; j++) {
|
||||||
pwithcolors[j] = SPECIAL_CHAR;
|
pwithcolors[j] = SPECIAL_CHAR;
|
||||||
}
|
}
|
||||||
@ -148,14 +150,14 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
|||||||
free(pwithcolors);
|
free(pwithcolors);
|
||||||
//scroll
|
//scroll
|
||||||
sd->start += sd->step;
|
sd->start += sd->step;
|
||||||
if(buf[sd->start] == 0 || sd->start > strlen(buf)){
|
if(buf[sd->start] == 0 || sd->start > strlen(&(buf[0]))){
|
||||||
sd->start = 0;
|
sd->start = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_scroll(struct text_object *obj)
|
void free_scroll(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct scroll_data *sd = obj->data.opaque;
|
struct scroll_data *sd = (struct scroll_data *)obj->data.opaque;
|
||||||
|
|
||||||
if (!sd)
|
if (!sd)
|
||||||
return;
|
return;
|
11
src/scroll.h
11
src/scroll.h
@ -1,4 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -29,16 +30,8 @@
|
|||||||
#ifndef _SCROLL_H
|
#ifndef _SCROLL_H
|
||||||
#define _SCROLL_H
|
#define _SCROLL_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void parse_scroll_arg(struct text_object *, const char *, void *);
|
void parse_scroll_arg(struct text_object *, const char *, void *);
|
||||||
void print_scroll(struct text_object *, char *, int);
|
void print_scroll(struct text_object *, char *, int);
|
||||||
void free_scroll(struct text_object *);
|
void free_scroll(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SCROLL_H */
|
#endif /* _SCROLL_H */
|
||||||
|
@ -98,7 +98,7 @@ const char *scan_gauge(struct text_object *obj, const char *args, double scale)
|
|||||||
{
|
{
|
||||||
struct gauge *g;
|
struct gauge *g;
|
||||||
|
|
||||||
g = malloc(sizeof(struct gauge));
|
g = (struct gauge *)malloc(sizeof(struct gauge));
|
||||||
memset(g, 0, sizeof(struct gauge));
|
memset(g, 0, sizeof(struct gauge));
|
||||||
|
|
||||||
/*width and height*/
|
/*width and height*/
|
||||||
@ -130,7 +130,7 @@ const char *scan_bar(struct text_object *obj, const char *args, double scale)
|
|||||||
{
|
{
|
||||||
struct bar *b;
|
struct bar *b;
|
||||||
|
|
||||||
b = malloc(sizeof(struct bar));
|
b = (struct bar *)malloc(sizeof(struct bar));
|
||||||
memset(b, 0, sizeof(struct bar));
|
memset(b, 0, sizeof(struct bar));
|
||||||
|
|
||||||
/* zero width means all space that is available */
|
/* zero width means all space that is available */
|
||||||
@ -169,7 +169,7 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale)
|
|||||||
char buf[1024];
|
char buf[1024];
|
||||||
memset(buf, 0, 1024);
|
memset(buf, 0, 1024);
|
||||||
|
|
||||||
g = malloc(sizeof(struct graph));
|
g = (struct graph *)malloc(sizeof(struct graph));
|
||||||
memset(g, 0, sizeof(struct graph));
|
memset(g, 0, sizeof(struct graph));
|
||||||
obj->special_data = g;
|
obj->special_data = g;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ static struct special_t *new_special(char *buf, enum special_types t)
|
|||||||
void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, double usage)
|
void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, double usage)
|
||||||
{
|
{
|
||||||
static const char *gaugevals[] = { "_. ", "\\. ", " | ", " ./", " ._" };
|
static const char *gaugevals[] = { "_. ", "\\. ", " | ", " ./", " ._" };
|
||||||
struct gauge *g = obj->special_data;
|
struct gauge *g = (struct gauge *)obj->special_data;
|
||||||
|
|
||||||
snprintf(p, p_max_size, "%s", gaugevals[round_to_int(usage * 4 / g->scale)]);
|
snprintf(p, p_max_size, "%s", gaugevals[round_to_int(usage * 4 / g->scale)]);
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, double
|
|||||||
void new_gauge_in_x11(struct text_object *obj, char *buf, double usage)
|
void new_gauge_in_x11(struct text_object *obj, char *buf, double usage)
|
||||||
{
|
{
|
||||||
struct special_t *s = 0;
|
struct special_t *s = 0;
|
||||||
struct gauge *g = obj->special_data;
|
struct gauge *g = (struct gauge *)obj->special_data;
|
||||||
|
|
||||||
if ((output_methods & TO_X) == 0)
|
if ((output_methods & TO_X) == 0)
|
||||||
return;
|
return;
|
||||||
@ -293,7 +293,7 @@ void new_gauge_in_x11(struct text_object *obj, char *buf, double usage)
|
|||||||
|
|
||||||
void new_gauge(struct text_object *obj, char *p, int p_max_size, double usage)
|
void new_gauge(struct text_object *obj, char *p, int p_max_size, double usage)
|
||||||
{
|
{
|
||||||
struct gauge *g = obj->special_data;
|
struct gauge *g = (struct gauge *)obj->special_data;
|
||||||
|
|
||||||
if (!p_max_size || !g)
|
if (!p_max_size || !g)
|
||||||
return;
|
return;
|
||||||
@ -368,7 +368,7 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
|
|||||||
void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
||||||
{
|
{
|
||||||
struct special_t *s = 0;
|
struct special_t *s = 0;
|
||||||
struct graph *g = obj->special_data;
|
struct graph *g = (struct graph *)obj->special_data;
|
||||||
|
|
||||||
if ((output_methods & TO_X) == 0)
|
if ((output_methods & TO_X) == 0)
|
||||||
return;
|
return;
|
||||||
@ -386,7 +386,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
} else {
|
} else {
|
||||||
s->graph_width = MAX_GRAPH_DEPTH - 2;
|
s->graph_width = MAX_GRAPH_DEPTH - 2;
|
||||||
}
|
}
|
||||||
s->graph = malloc(s->graph_width * sizeof(double));
|
s->graph = (double*)malloc(s->graph_width * sizeof(double));
|
||||||
memset(s->graph, 0, s->graph_width * sizeof(double));
|
memset(s->graph, 0, s->graph_width * sizeof(double));
|
||||||
s->scale = 100;
|
s->scale = 100;
|
||||||
}
|
}
|
||||||
@ -429,7 +429,7 @@ void scan_stippled_hr(struct text_object *obj, const char *arg)
|
|||||||
{
|
{
|
||||||
struct stippled_hr *sh;
|
struct stippled_hr *sh;
|
||||||
|
|
||||||
sh = malloc(sizeof(struct stippled_hr));
|
sh = (struct stippled_hr *)malloc(sizeof(struct stippled_hr));
|
||||||
memset(sh, 0, sizeof(struct stippled_hr));
|
memset(sh, 0, sizeof(struct stippled_hr));
|
||||||
|
|
||||||
sh->arg = get_stippled_borders();
|
sh->arg = get_stippled_borders();
|
||||||
@ -449,7 +449,7 @@ void scan_stippled_hr(struct text_object *obj, const char *arg)
|
|||||||
void new_stippled_hr(struct text_object *obj, char *p, int p_max_size)
|
void new_stippled_hr(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct special_t *s = 0;
|
struct special_t *s = 0;
|
||||||
struct stippled_hr *sh = obj->special_data;
|
struct stippled_hr *sh = (struct stippled_hr *)obj->special_data;
|
||||||
|
|
||||||
if ((output_methods & TO_X) == 0)
|
if ((output_methods & TO_X) == 0)
|
||||||
return;
|
return;
|
||||||
@ -494,7 +494,7 @@ void new_bg(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
static void new_bar_in_shell(struct text_object *obj, char* buffer, int buf_max_size, double usage)
|
static void new_bar_in_shell(struct text_object *obj, char* buffer, int buf_max_size, double usage)
|
||||||
{
|
{
|
||||||
struct bar *b = obj->special_data;
|
struct bar *b = (struct bar *)obj->special_data;
|
||||||
int width, i, scaledusage;
|
int width, i, scaledusage;
|
||||||
|
|
||||||
if (!b)
|
if (!b)
|
||||||
@ -522,7 +522,7 @@ static void new_bar_in_shell(struct text_object *obj, char* buffer, int buf_max_
|
|||||||
static void new_bar_in_x11(struct text_object *obj, char *buf, double usage)
|
static void new_bar_in_x11(struct text_object *obj, char *buf, double usage)
|
||||||
{
|
{
|
||||||
struct special_t *s = 0;
|
struct special_t *s = 0;
|
||||||
struct bar *b = obj->special_data;
|
struct bar *b = (struct bar *)obj->special_data;
|
||||||
|
|
||||||
if ((output_methods & TO_X) == 0)
|
if ((output_methods & TO_X) == 0)
|
||||||
return;
|
return;
|
||||||
@ -542,7 +542,7 @@ static void new_bar_in_x11(struct text_object *obj, char *buf, double usage)
|
|||||||
/* usage is in range [0,255] */
|
/* usage is in range [0,255] */
|
||||||
void new_bar(struct text_object *obj, char *p, int p_max_size, double usage)
|
void new_bar(struct text_object *obj, char *p, int p_max_size, double usage)
|
||||||
{
|
{
|
||||||
struct bar *b = obj->special_data;
|
struct bar *b = (struct bar *)obj->special_data;
|
||||||
|
|
||||||
if (!p_max_size || !b)
|
if (!p_max_size || !b)
|
||||||
return;
|
return;
|
||||||
@ -607,7 +607,7 @@ void scan_tab(struct text_object *obj, const char *arg)
|
|||||||
{
|
{
|
||||||
struct tab *t;
|
struct tab *t;
|
||||||
|
|
||||||
t = malloc(sizeof(struct tab));
|
t = (struct tab *)malloc(sizeof(struct tab));
|
||||||
memset(t, 0, sizeof(struct tab));
|
memset(t, 0, sizeof(struct tab));
|
||||||
|
|
||||||
t->width = 10;
|
t->width = 10;
|
||||||
@ -627,7 +627,7 @@ void scan_tab(struct text_object *obj, const char *arg)
|
|||||||
void new_tab(struct text_object *obj, char *p, int p_max_size)
|
void new_tab(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct special_t *s = 0;
|
struct special_t *s = 0;
|
||||||
struct tab *t = obj->special_data;
|
struct tab *t = (struct tab *)obj->special_data;
|
||||||
|
|
||||||
if (!t || !p_max_size)
|
if (!t || !p_max_size)
|
||||||
return;
|
return;
|
@ -29,10 +29,6 @@
|
|||||||
#ifndef _SPECIALS_H
|
#ifndef _SPECIALS_H
|
||||||
#define _SPECIALS_H
|
#define _SPECIALS_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* special stuff in text_buffer */
|
/* special stuff in text_buffer */
|
||||||
|
|
||||||
#define SPECIAL_CHAR '\x01'
|
#define SPECIAL_CHAR '\x01'
|
||||||
@ -124,8 +120,4 @@ void new_alignc(struct text_object *, char *, int);
|
|||||||
void new_goto(struct text_object *, char *, int);
|
void new_goto(struct text_object *, char *, int);
|
||||||
void new_tab(struct text_object *, char *, int);
|
void new_tab(struct text_object *, char *, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SPECIALS_H */
|
#endif /* _SPECIALS_H */
|
||||||
|
@ -71,7 +71,7 @@ static void tailstring(char *string, int endofstring, int wantedlines) {
|
|||||||
|
|
||||||
void free_tailhead(struct text_object *obj)
|
void free_tailhead(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct headtail *ht = obj->data.opaque;
|
struct headtail *ht = (struct headtail *)obj->data.opaque;
|
||||||
if (!ht)
|
if (!ht)
|
||||||
return;
|
return;
|
||||||
if (ht->logfile)
|
if (ht->logfile)
|
||||||
@ -86,10 +86,10 @@ void init_tailhead(const char* type, const char* arg, struct text_object *obj, v
|
|||||||
unsigned int args;
|
unsigned int args;
|
||||||
struct headtail *ht;
|
struct headtail *ht;
|
||||||
|
|
||||||
ht = malloc(sizeof(struct headtail));
|
ht = (struct headtail *)malloc(sizeof(struct headtail));
|
||||||
memset(ht, 0, sizeof(struct headtail));
|
memset(ht, 0, sizeof(struct headtail));
|
||||||
|
|
||||||
ht->logfile = malloc(DEFAULT_TEXT_BUFFER_SIZE);
|
ht->logfile = (char*)malloc(DEFAULT_TEXT_BUFFER_SIZE);
|
||||||
memset(ht->logfile, 0, DEFAULT_TEXT_BUFFER_SIZE);
|
memset(ht->logfile, 0, DEFAULT_TEXT_BUFFER_SIZE);
|
||||||
|
|
||||||
ht->max_uses = DEFAULT_MAX_HEADTAIL_USES;
|
ht->max_uses = DEFAULT_MAX_HEADTAIL_USES;
|
||||||
@ -118,7 +118,7 @@ static void print_tailhead(const char* type, struct text_object *obj, char *p, i
|
|||||||
int fd, i, endofstring = 0, linescounted = 0;
|
int fd, i, endofstring = 0, linescounted = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct headtail *ht = obj->data.opaque;
|
struct headtail *ht = (struct headtail *)obj->data.opaque;
|
||||||
|
|
||||||
if (!ht)
|
if (!ht)
|
||||||
return;
|
return;
|
||||||
@ -248,3 +248,4 @@ void print_words(struct text_object *obj, char *p, int p_max_size)
|
|||||||
snprintf(p, p_max_size, "%d", words);
|
snprintf(p, p_max_size, "%d", words);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
@ -30,10 +30,6 @@
|
|||||||
#ifndef _TAILHEAD_H
|
#ifndef _TAILHEAD_H
|
||||||
#define _TAILHEAD_H
|
#define _TAILHEAD_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void free_tailhead(struct text_object *);
|
void free_tailhead(struct text_object *);
|
||||||
void init_tailhead(const char *, const char *, struct text_object *, void *);
|
void init_tailhead(const char *, const char *, struct text_object *, void *);
|
||||||
void print_head(struct text_object *, char *, int);
|
void print_head(struct text_object *, char *, int);
|
||||||
@ -42,8 +38,4 @@ void print_tail(struct text_object *, char *, int);
|
|||||||
void print_lines(struct text_object *, char *, int);
|
void print_lines(struct text_object *, char *, int);
|
||||||
void print_words(struct text_object *, char *, int);
|
void print_words(struct text_object *, char *, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _TAILHEAD_H */
|
#endif /* _TAILHEAD_H */
|
||||||
|
@ -24,10 +24,6 @@
|
|||||||
#ifndef TEMPHELPER_H
|
#ifndef TEMPHELPER_H
|
||||||
#define TEMPHELPER_H
|
#define TEMPHELPER_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum TEMP_UNIT {
|
enum TEMP_UNIT {
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT
|
TEMP_FAHRENHEIT
|
||||||
@ -36,8 +32,4 @@ enum TEMP_UNIT {
|
|||||||
int set_temp_output_unit(const char *);
|
int set_temp_output_unit(const char *);
|
||||||
int temp_print(char *, size_t, double, enum TEMP_UNIT);
|
int temp_print(char *, size_t, double, enum TEMP_UNIT);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* TEMPHELPER_H */
|
#endif /* TEMPHELPER_H */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
|
||||||
*
|
*
|
||||||
* Conky, a system monitor, based on torsmo
|
* Conky, a system monitor, based on torsmo
|
||||||
*
|
*
|
||||||
@ -63,7 +63,7 @@ static void hash_process(struct process *p)
|
|||||||
bucket = p->pid & (HTABSIZE - 1);
|
bucket = p->pid & (HTABSIZE - 1);
|
||||||
|
|
||||||
/* insert a new element on bucket's top */
|
/* insert a new element on bucket's top */
|
||||||
phe = malloc(sizeof(struct proc_hash_entry));
|
phe = (struct proc_hash_entry *)malloc(sizeof(struct proc_hash_entry));
|
||||||
phe->proc = p;
|
phe->proc = p;
|
||||||
phe->next = proc_hash_table[bucket].next;
|
phe->next = proc_hash_table[bucket].next;
|
||||||
proc_hash_table[bucket].next = phe;
|
proc_hash_table[bucket].next = phe;
|
||||||
@ -540,7 +540,7 @@ static unsigned long long calc_cpu_total(void)
|
|||||||
unsigned long long irq = 0;
|
unsigned long long irq = 0;
|
||||||
unsigned long long softirq = 0;
|
unsigned long long softirq = 0;
|
||||||
unsigned long long steal = 0;
|
unsigned long long steal = 0;
|
||||||
const char *template =
|
const char *template_ =
|
||||||
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC;
|
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC;
|
||||||
|
|
||||||
ps = open("/proc/stat", O_RDONLY);
|
ps = open("/proc/stat", O_RDONLY);
|
||||||
@ -550,7 +550,7 @@ static unsigned long long calc_cpu_total(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sscanf(line, template, &cpu, &niceval, &systemval, &idle, &iowait, &irq,
|
sscanf(line, template_, &cpu, &niceval, &systemval, &idle, &iowait, &irq,
|
||||||
&softirq, &steal);
|
&softirq, &steal);
|
||||||
total = cpu + niceval + systemval + idle + iowait + irq + softirq + steal;
|
total = cpu + niceval + systemval + idle + iowait + irq + softirq + steal;
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ static void calc_io_each(void)
|
|||||||
/* cpu comparison function for prio queue */
|
/* cpu comparison function for prio queue */
|
||||||
static int compare_cpu(void *va, void *vb)
|
static int compare_cpu(void *va, void *vb)
|
||||||
{
|
{
|
||||||
struct process *a = va, *b = vb;
|
struct process *a = (struct process *)va, *b = (struct process *)vb;
|
||||||
|
|
||||||
if (a->amount < b->amount) {
|
if (a->amount < b->amount) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -613,7 +613,7 @@ static int compare_cpu(void *va, void *vb)
|
|||||||
/* mem comparison function for prio queue */
|
/* mem comparison function for prio queue */
|
||||||
static int compare_mem(void *va, void *vb)
|
static int compare_mem(void *va, void *vb)
|
||||||
{
|
{
|
||||||
struct process *a = va, *b = vb;
|
struct process *a = (struct process *)va, *b = (struct process *)vb;
|
||||||
|
|
||||||
if (a->rss < b->rss) {
|
if (a->rss < b->rss) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -627,7 +627,7 @@ static int compare_mem(void *va, void *vb)
|
|||||||
/* CPU time comparision function for prio queue */
|
/* CPU time comparision function for prio queue */
|
||||||
static int compare_time(void *va, void *vb)
|
static int compare_time(void *va, void *vb)
|
||||||
{
|
{
|
||||||
struct process *a = va, *b = vb;
|
struct process *a = (struct process *)va, *b = (struct process *)vb;
|
||||||
|
|
||||||
return b->total_cpu_time - a->total_cpu_time;
|
return b->total_cpu_time - a->total_cpu_time;
|
||||||
}
|
}
|
||||||
@ -636,7 +636,7 @@ static int compare_time(void *va, void *vb)
|
|||||||
/* I/O comparision function for prio queue */
|
/* I/O comparision function for prio queue */
|
||||||
static int compare_io(void *va, void *vb)
|
static int compare_io(void *va, void *vb)
|
||||||
{
|
{
|
||||||
struct process *a = va, *b = vb;
|
struct process *a = (struct process *)va, *b = (struct process *)vb;
|
||||||
|
|
||||||
if (a->io_perc < b->io_perc) {
|
if (a->io_perc < b->io_perc) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -726,14 +726,14 @@ void process_find_top(struct process **cpu, struct process **mem,
|
|||||||
|
|
||||||
for (i = 0; i < MAX_SP; i++) {
|
for (i = 0; i < MAX_SP; i++) {
|
||||||
if (top_cpu)
|
if (top_cpu)
|
||||||
cpu[i] = pop_prio_elem(cpu_queue);
|
cpu[i] = (process*)pop_prio_elem(cpu_queue);
|
||||||
if (top_mem)
|
if (top_mem)
|
||||||
mem[i] = pop_prio_elem(mem_queue);
|
mem[i] = (process*)pop_prio_elem(mem_queue);
|
||||||
if (top_time)
|
if (top_time)
|
||||||
ptime[i] = pop_prio_elem(time_queue);
|
ptime[i] = (process*)pop_prio_elem(time_queue);
|
||||||
#ifdef IOSTATS
|
#ifdef IOSTATS
|
||||||
if (top_io)
|
if (top_io)
|
||||||
io[i] = pop_prio_elem(io_queue);
|
io[i] = (process*)pop_prio_elem(io_queue);
|
||||||
#endif /* IOSTATS */
|
#endif /* IOSTATS */
|
||||||
}
|
}
|
||||||
free_prio_queue(cpu_queue);
|
free_prio_queue(cpu_queue);
|
||||||
@ -803,7 +803,7 @@ int set_top_name_width(const char *s)
|
|||||||
|
|
||||||
static void print_top_name(struct text_object *obj, char *p, int p_max_size)
|
static void print_top_name(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct top_data *td = obj->data.opaque;
|
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
if (!td || !td->list || !td->list[td->num])
|
if (!td || !td->list || !td->list[td->num])
|
||||||
@ -815,7 +815,7 @@ static void print_top_name(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
static void print_top_mem(struct text_object *obj, char *p, int p_max_size)
|
static void print_top_mem(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct top_data *td = obj->data.opaque;
|
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
if (!td || !td->list || !td->list[td->num])
|
if (!td || !td->list || !td->list[td->num])
|
||||||
@ -827,7 +827,7 @@ static void print_top_mem(struct text_object *obj, char *p, int p_max_size)
|
|||||||
|
|
||||||
static void print_top_time(struct text_object *obj, char *p, int p_max_size)
|
static void print_top_time(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct top_data *td = obj->data.opaque;
|
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||||
int width;
|
int width;
|
||||||
char *timeval;
|
char *timeval;
|
||||||
|
|
||||||
@ -843,7 +843,7 @@ static void print_top_time(struct text_object *obj, char *p, int p_max_size)
|
|||||||
#define PRINT_TOP_GENERATOR(name, width, fmt, field) \
|
#define PRINT_TOP_GENERATOR(name, width, fmt, field) \
|
||||||
static void print_top_##name(struct text_object *obj, char *p, int p_max_size) \
|
static void print_top_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||||
{ \
|
{ \
|
||||||
struct top_data *td = obj->data.opaque; \
|
struct top_data *td = (struct top_data *)obj->data.opaque; \
|
||||||
if (!td || !td->list || !td->list[td->num]) \
|
if (!td || !td->list || !td->list[td->num]) \
|
||||||
return; \
|
return; \
|
||||||
snprintf(p, MIN(p_max_size, width), fmt, td->list[td->num]->field); \
|
snprintf(p, MIN(p_max_size, width), fmt, td->list[td->num]->field); \
|
||||||
@ -852,7 +852,7 @@ static void print_top_##name(struct text_object *obj, char *p, int p_max_size) \
|
|||||||
#define PRINT_TOP_HR_GENERATOR(name, field, denom) \
|
#define PRINT_TOP_HR_GENERATOR(name, field, denom) \
|
||||||
static void print_top_##name(struct text_object *obj, char *p, int p_max_size) \
|
static void print_top_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||||
{ \
|
{ \
|
||||||
struct top_data *td = obj->data.opaque; \
|
struct top_data *td = (struct top_data *)obj->data.opaque; \
|
||||||
if (!td || !td->list || !td->list[td->num]) \
|
if (!td || !td->list || !td->list[td->num]) \
|
||||||
return; \
|
return; \
|
||||||
human_readable(td->list[td->num]->field / denom, p, p_max_size); \
|
human_readable(td->list[td->num]->field / denom, p, p_max_size); \
|
||||||
@ -870,7 +870,7 @@ PRINT_TOP_GENERATOR(io_perc, 7, "%6.2f", io_perc)
|
|||||||
|
|
||||||
static void free_top(struct text_object *obj)
|
static void free_top(struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct top_data *td = obj->data.opaque;
|
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||||
|
|
||||||
if (!td)
|
if (!td)
|
||||||
return;
|
return;
|
||||||
@ -891,7 +891,7 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->data.opaque = td = malloc(sizeof(struct top_data));
|
obj->data.opaque = td = (struct top_data *)malloc(sizeof(struct top_data));
|
||||||
memset(td, 0, sizeof(struct top_data));
|
memset(td, 0, sizeof(struct top_data));
|
||||||
|
|
||||||
if (s[3] == 0) {
|
if (s[3] == 0) {
|
@ -64,9 +64,6 @@
|
|||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
* Defines *
|
* Defines *
|
||||||
@ -150,9 +147,4 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj);
|
|||||||
/* return zero on success, non-zero otherwise */
|
/* return zero on success, non-zero otherwise */
|
||||||
int set_top_name_width(const char *);
|
int set_top_name_width(const char *);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _top_h_ */
|
#endif /* _top_h_ */
|
||||||
|
@ -118,14 +118,14 @@ static void tty_user_time(char *ptr, char *tty)
|
|||||||
static void users_alloc(struct information *ptr)
|
static void users_alloc(struct information *ptr)
|
||||||
{
|
{
|
||||||
if (ptr->users.names == NULL) {
|
if (ptr->users.names == NULL) {
|
||||||
ptr->users.names = malloc(text_buffer_size);
|
ptr->users.names = (char*)malloc(text_buffer_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ptr->users.terms == NULL) {
|
if (ptr->users.terms == NULL) {
|
||||||
ptr->users.terms = malloc(text_buffer_size);
|
ptr->users.terms = (char*)malloc(text_buffer_size);
|
||||||
}
|
}
|
||||||
if (ptr->users.times == NULL) {
|
if (ptr->users.times == NULL) {
|
||||||
ptr->users.times = malloc(text_buffer_size);
|
ptr->users.times = (char*)malloc(text_buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ static void update_user_time(char *tty)
|
|||||||
char temp[BUFLEN] = "";
|
char temp[BUFLEN] = "";
|
||||||
|
|
||||||
if (current_info->users.ctime == NULL) {
|
if (current_info->users.ctime == NULL) {
|
||||||
current_info->users.ctime = malloc(text_buffer_size);
|
current_info->users.ctime = (char*)malloc(text_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_user_time(temp, tty);
|
tty_user_time(temp, tty);
|
||||||
@ -145,14 +145,14 @@ static void update_user_time(char *tty)
|
|||||||
free(current_info->users.ctime);
|
free(current_info->users.ctime);
|
||||||
current_info->users.ctime = 0;
|
current_info->users.ctime = 0;
|
||||||
}
|
}
|
||||||
current_info->users.ctime = malloc(text_buffer_size);
|
current_info->users.ctime = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.ctime, temp, text_buffer_size);
|
strncpy(current_info->users.ctime, temp, text_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
if (current_info->users.ctime) {
|
if (current_info->users.ctime) {
|
||||||
free(current_info->users.ctime);
|
free(current_info->users.ctime);
|
||||||
current_info->users.ctime = 0;
|
current_info->users.ctime = 0;
|
||||||
}
|
}
|
||||||
current_info->users.ctime = malloc(text_buffer_size);
|
current_info->users.ctime = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.ctime, "broken", text_buffer_size);
|
strncpy(current_info->users.ctime, "broken", text_buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,14 +169,14 @@ void update_users(void)
|
|||||||
free(current_info->users.names);
|
free(current_info->users.names);
|
||||||
current_info->users.names = 0;
|
current_info->users.names = 0;
|
||||||
}
|
}
|
||||||
current_info->users.names = malloc(text_buffer_size);
|
current_info->users.names = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.names, temp, text_buffer_size);
|
strncpy(current_info->users.names, temp, text_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
if (current_info->users.names) {
|
if (current_info->users.names) {
|
||||||
free(current_info->users.names);
|
free(current_info->users.names);
|
||||||
current_info->users.names = 0;
|
current_info->users.names = 0;
|
||||||
}
|
}
|
||||||
current_info->users.names = malloc(text_buffer_size);
|
current_info->users.names = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.names, "broken", text_buffer_size);
|
strncpy(current_info->users.names, "broken", text_buffer_size);
|
||||||
}
|
}
|
||||||
user_num(&t);
|
user_num(&t);
|
||||||
@ -195,14 +195,14 @@ void update_users(void)
|
|||||||
free(current_info->users.terms);
|
free(current_info->users.terms);
|
||||||
current_info->users.terms = 0;
|
current_info->users.terms = 0;
|
||||||
}
|
}
|
||||||
current_info->users.terms = malloc(text_buffer_size);
|
current_info->users.terms = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.terms, temp, text_buffer_size);
|
strncpy(current_info->users.terms, temp, text_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
if (current_info->users.terms) {
|
if (current_info->users.terms) {
|
||||||
free(current_info->users.terms);
|
free(current_info->users.terms);
|
||||||
current_info->users.terms = 0;
|
current_info->users.terms = 0;
|
||||||
}
|
}
|
||||||
current_info->users.terms = malloc(text_buffer_size);
|
current_info->users.terms = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.terms, "broken", text_buffer_size);
|
strncpy(current_info->users.terms, "broken", text_buffer_size);
|
||||||
}
|
}
|
||||||
user_time(temp);
|
user_time(temp);
|
||||||
@ -211,14 +211,14 @@ void update_users(void)
|
|||||||
free(current_info->users.times);
|
free(current_info->users.times);
|
||||||
current_info->users.times = 0;
|
current_info->users.times = 0;
|
||||||
}
|
}
|
||||||
current_info->users.times = malloc(text_buffer_size);
|
current_info->users.times = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.times, temp, text_buffer_size);
|
strncpy(current_info->users.times, temp, text_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
if (current_info->users.times) {
|
if (current_info->users.times) {
|
||||||
free(current_info->users.times);
|
free(current_info->users.times);
|
||||||
current_info->users.times = 0;
|
current_info->users.times = 0;
|
||||||
}
|
}
|
||||||
current_info->users.times = malloc(text_buffer_size);
|
current_info->users.times = (char*)malloc(text_buffer_size);
|
||||||
strncpy(current_info->users.times, "broken", text_buffer_size);
|
strncpy(current_info->users.times, "broken", text_buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,10 +31,6 @@
|
|||||||
#ifndef _USERS_H
|
#ifndef _USERS_H
|
||||||
#define _USERS_H
|
#define _USERS_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void update_users(void);
|
void update_users(void);
|
||||||
|
|
||||||
void print_user_names(struct text_object *, char *, int);
|
void print_user_names(struct text_object *, char *, int);
|
||||||
@ -48,8 +44,4 @@ void free_user_terms(struct text_object *);
|
|||||||
void free_user_times(struct text_object *);
|
void free_user_times(struct text_object *);
|
||||||
void free_user_time(struct text_object *);
|
void free_user_time(struct text_object *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _USERS_H */
|
#endif /* _USERS_H */
|
||||||
|
@ -700,7 +700,7 @@ static inline void get_x11_desktop_names(Display *current_display, Window root,
|
|||||||
free(current_info->x11.desktop.all_names);
|
free(current_info->x11.desktop.all_names);
|
||||||
current_info->x11.desktop.all_names = NULL;
|
current_info->x11.desktop.all_names = NULL;
|
||||||
}
|
}
|
||||||
current_info->x11.desktop.all_names = malloc(nitems*sizeof(char));
|
current_info->x11.desktop.all_names = (char*)malloc(nitems*sizeof(char));
|
||||||
memcpy(current_info->x11.desktop.all_names, prop, nitems);
|
memcpy(current_info->x11.desktop.all_names, prop, nitems);
|
||||||
current_info->x11.desktop.nitems = nitems;
|
current_info->x11.desktop.nitems = nitems;
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ static inline void get_x11_desktop_current_name(char *names)
|
|||||||
free(current_info->x11.desktop.name);
|
free(current_info->x11.desktop.name);
|
||||||
current_info->x11.desktop.name = NULL;
|
current_info->x11.desktop.name = NULL;
|
||||||
}
|
}
|
||||||
current_info->x11.desktop.name = malloc((i-j)*sizeof(char));
|
current_info->x11.desktop.name = (char*)malloc((i-j)*sizeof(char));
|
||||||
//desktop names can be empty but should always be not null
|
//desktop names can be empty but should always be not null
|
||||||
strcpy( current_info->x11.desktop.name, (char *)&names[j] );
|
strcpy( current_info->x11.desktop.name, (char *)&names[j] );
|
||||||
break;
|
break;
|
@ -94,10 +94,6 @@ extern int workarea[4];
|
|||||||
extern struct conky_window window;
|
extern struct conky_window window;
|
||||||
extern char window_created;
|
extern char window_created;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void init_X11(const char*);
|
void init_X11(const char*);
|
||||||
void init_window(int use_own_window, int width, int height, int set_trans,
|
void init_window(int use_own_window, int width, int height, int set_trans,
|
||||||
int back_colour, char **argv, int argc);
|
int back_colour, char **argv, int argc);
|
||||||
@ -118,9 +114,5 @@ void free_desktop_info(void);
|
|||||||
void xdbe_swap_buffers(void);
|
void xdbe_swap_buffers(void);
|
||||||
#endif /* HAVE_XDBE */
|
#endif /* HAVE_XDBE */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*X11_H_*/
|
#endif /*X11_H_*/
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
Loading…
Reference in New Issue
Block a user