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)
|
||||
if(NOT BUILD_AUDACIOUS_LEGACY)
|
||||
pkg_check_modules(AUDACIOUS REQUIRED audacious>=1.4.0 dbus-glib-1 gobject-2.0)
|
||||
# do we need this below?
|
||||
#CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
|
||||
#AC_CHECK_HEADERS([audacious/audctrl.h audacious/dbus.h glib.h glib-object.h],
|
||||
# [], AC_MSG_ERROR([required header(s) not found]))
|
||||
set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${AUDACIOUS_INCLUDE_DIRS})
|
||||
else(NOT BUILD_AUDACIOUS_LEGACY)
|
||||
pkg_check_modules(AUDACIOUS REQUIRED audacious<1.4.0)
|
||||
# do we need this below?
|
||||
#CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
|
||||
#AC_CHECK_HEADERS([audacious/beepctrl.h glib.h], [], AC_MSG_ERROR([required header(s) not found]))
|
||||
#CPPFLAGS="$save_CPPFLAGS"
|
||||
set(conky_libs ${conky_libs} ${AUDACIOUS_LIBRARIES})
|
||||
set(conky_includes ${conky_includes} ${AUDACIOUS_INCLUDE_DIRS})
|
||||
endif(NOT BUILD_AUDACIOUS_LEGACY)
|
||||
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.")
|
||||
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
|
||||
|
||||
set(conky_sources colours.cc combine.cc common.c conky.cc core.cc diskio.c
|
||||
entropy.c exec.cc fs.c mail.cc mixer.c net_stat.c template.c timed_thread.cc
|
||||
mboxscan.c read_tcp.c scroll.c specials.c tailhead.c temphelper.c
|
||||
text_object.c timeinfo.c top.c algebra.c prioqueue.c proc.c user.c)
|
||||
set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc
|
||||
diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.c
|
||||
timed_thread.cc mboxscan.c read_tcp.c scroll.cc specials.cc tailhead.cc
|
||||
temphelper.cc text_object.c timeinfo.c top.cc algebra.c prioqueue.c proc.c
|
||||
user.c)
|
||||
|
||||
# Platform specific sources
|
||||
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})
|
||||
endif(OS_LINUX)
|
||||
|
||||
@ -69,7 +70,7 @@ endif(OS_NETBSD)
|
||||
|
||||
# Optional sources
|
||||
if(BUILD_AUDACIOUS)
|
||||
set(audacious audacious.c)
|
||||
set(audacious audacious.cc)
|
||||
set(optional_sources ${optional_sources} ${audacious})
|
||||
endif(BUILD_AUDACIOUS)
|
||||
|
||||
@ -79,7 +80,7 @@ if(BUILD_BMPX)
|
||||
endif(BUILD_BMPX)
|
||||
|
||||
if(BUILD_IBM)
|
||||
set(ibm ibm.c smapi.c)
|
||||
set(ibm ibm.cc smapi.cc)
|
||||
set(optional_sources ${optional_sources} ${ibm})
|
||||
endif(BUILD_IBM)
|
||||
|
||||
@ -106,12 +107,12 @@ if(BUILD_PORT_MONITORS)
|
||||
endif(BUILD_PORT_MONITORS)
|
||||
|
||||
if(BUILD_X11)
|
||||
set(x11 x11.c fonts.c)
|
||||
set(x11 x11.cc fonts.c)
|
||||
set(optional_sources ${optional_sources} ${x11})
|
||||
endif(BUILD_X11)
|
||||
|
||||
if(BUILD_HDDTEMP)
|
||||
set(hddtemp hddtemp.c)
|
||||
set(hddtemp hddtemp.cc)
|
||||
set(optional_sources ${optional_sources} ${hddtemp})
|
||||
endif(BUILD_HDDTEMP)
|
||||
|
||||
@ -136,7 +137,7 @@ if(BUILD_WEATHER)
|
||||
endif(BUILD_WEATHER)
|
||||
|
||||
if(BUILD_LUA)
|
||||
set(lua llua.c)
|
||||
set(lua llua.cc)
|
||||
set(optional_sources ${optional_sources} ${lua})
|
||||
endif(BUILD_LUA)
|
||||
|
||||
|
@ -22,10 +22,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <config.h>
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "audacious.h"
|
||||
#include <mutex>
|
||||
|
||||
#include <glib.h>
|
||||
#ifndef AUDACIOUS_LEGACY
|
||||
@ -72,13 +73,10 @@ void update_audacious(void)
|
||||
if (create_audacious_thread() != 0) {
|
||||
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));
|
||||
timed_thread_unlock(info.audacious.p_timed_thread);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
@ -90,12 +88,12 @@ int create_audacious_thread(void)
|
||||
{
|
||||
if (!info.audacious.p_timed_thread) {
|
||||
info.audacious.p_timed_thread =
|
||||
timed_thread_create(audacious_thread_func, NULL,
|
||||
info.music_player_interval * 1000000);
|
||||
timed_thread::create(std::bind(audacious_thread_func,
|
||||
std::placeholders::_1), info.music_player_interval *
|
||||
1000000);
|
||||
}
|
||||
|
||||
if (!info.audacious.p_timed_thread
|
||||
|| timed_thread_run(info.audacious.p_timed_thread)) {
|
||||
if (!info.audacious.p_timed_thread) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -111,8 +109,7 @@ int destroy_audacious_thread(void)
|
||||
{
|
||||
/* Is a worker is thread running? If not, no error. */
|
||||
if (info.audacious.p_timed_thread) {
|
||||
timed_thread_destroy(info.audacious.p_timed_thread,
|
||||
&info.audacious.p_timed_thread);
|
||||
info.audacious.p_timed_thread.reset();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -121,8 +118,7 @@ int destroy_audacious_thread(void)
|
||||
/* ---------------------------------------------------
|
||||
* Worker thread function for audacious data sampling.
|
||||
* --------------------------------------------------- */
|
||||
__attribute((noreturn))
|
||||
void *audacious_thread_func(void *pvoid)
|
||||
void audacious_thread_func(thread_handle &handle)
|
||||
{
|
||||
static audacious_t items;
|
||||
gint playpos, frames, length;
|
||||
@ -136,7 +132,6 @@ void *audacious_thread_func(void *pvoid)
|
||||
gint session;
|
||||
#endif
|
||||
|
||||
pvoid = (void *) pvoid; /* avoid warning */
|
||||
session = 0;
|
||||
psong = NULL;
|
||||
pfilename = NULL;
|
||||
@ -240,38 +235,38 @@ void *audacious_thread_func(void *pvoid)
|
||||
sizeof(items[AUDACIOUS_MAIN_VOLUME]) - 1, "%d", vol);
|
||||
|
||||
} while (0);
|
||||
{
|
||||
/* 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));
|
||||
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
|
||||
/* release reference to dbus proxy */
|
||||
g_object_unref(session);
|
||||
#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
|
||||
? info.audacious.max_title_len : p_max_size, "%s",
|
||||
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]) /
|
||||
atof(info.audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
||||
}
|
||||
|
||||
#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]); \
|
||||
}
|
@ -27,10 +27,6 @@
|
||||
|
||||
#include "timed_thread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum _audacious_items {
|
||||
AUDACIOUS_STATUS = 0,
|
||||
AUDACIOUS_TITLE,
|
||||
@ -54,7 +50,7 @@ typedef char audacious_t[13][128];
|
||||
typedef struct audacious_s {
|
||||
audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */
|
||||
int max_title_len; /* e.g. ${audacious_title 50} */
|
||||
timed_thread *p_timed_thread;
|
||||
timed_thread_ptr p_timed_thread;
|
||||
} AUDACIOUS_S;
|
||||
|
||||
/* create a worker thread for audacious media player status */
|
||||
@ -67,7 +63,7 @@ int destroy_audacious_thread(void);
|
||||
void update_audacious(void);
|
||||
|
||||
/* 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_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);
|
||||
double audacious_barval(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#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 -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -37,6 +37,7 @@
|
||||
#include "temphelper.h"
|
||||
#include "timeinfo.h"
|
||||
#include "top.h"
|
||||
#include "c-funcs.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
@ -47,6 +48,7 @@
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <vector>
|
||||
|
||||
/* check for OS and include appropriate headers */
|
||||
#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.
|
||||
* Populated while initialising text objects in construct_text_object(). */
|
||||
static struct update_cb {
|
||||
struct update_cb {
|
||||
struct update_cb *next;
|
||||
void (*func)(void);
|
||||
pthread_t thread;
|
||||
sem_t start_wait, end_wait;
|
||||
update_cb() : next(NULL), func(NULL) {}
|
||||
|
||||
/* set to 1 when starting the thread
|
||||
* set to 0 to request thread termination */
|
||||
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 int threading_started = 0;
|
||||
@ -300,7 +302,7 @@ void add_update_callback(void (*func)(void))
|
||||
uc = uc->next;
|
||||
}
|
||||
|
||||
uc->next = malloc(sizeof(struct update_cb));
|
||||
uc->next = new update_cb;
|
||||
uc = uc->next;
|
||||
|
||||
memset(uc, 0, sizeof(struct update_cb));
|
||||
@ -370,7 +372,7 @@ void start_update_threading(void)
|
||||
|
||||
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);
|
||||
|
||||
@ -382,7 +384,7 @@ static void *run_update_callback(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
int no_buffers;
|
||||
extern int no_buffers;
|
||||
|
||||
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)
|
||||
{
|
||||
char buf[max_user_text];
|
||||
std::vector<char> buf(max_user_text);
|
||||
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;
|
||||
}
|
||||
return result;
|
||||
@ -750,56 +752,56 @@ void print_battery_short(struct text_object *obj, char *p, int p_max_size)
|
||||
}
|
||||
#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)
|
||||
{
|
||||
//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 last_len = 0;
|
||||
int i;
|
||||
|
||||
memset(buf, 0, max_user_text);
|
||||
|
||||
if (visible) {
|
||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
||||
last_len = strlen(buf);
|
||||
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||
last_len = strlen(&(buf[0]));
|
||||
} else {
|
||||
for (i = 0; i < last_len; i++)
|
||||
buf[i] = ' ';
|
||||
}
|
||||
|
||||
snprintf(p, p_max_size, "%s", buf);
|
||||
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||
visible = !visible;
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
generate_text_internal(buf, max_user_text, *obj->sub);
|
||||
snprintf(p, p_max_size, "%s", buf);
|
||||
generate_text_internal(&(buf[0]), max_user_text, *obj->sub);
|
||||
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)obj;
|
11
src/common.h
11
src/common.h
@ -15,6 +15,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void print_to_bytes(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void add_update_callback(void (*func)(void));
|
||||
void free_update_callbacks(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);
|
||||
#endif /* !__OpenBSD__ */
|
||||
|
||||
void print_to_bytes(struct text_object *, char *, int);
|
||||
void print_blink(struct text_object *, char *, int);
|
||||
void print_include(struct text_object *, char *, int);
|
||||
|
||||
void print_updates(struct text_object *, char *, int);
|
||||
int updatenr_iftest(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _COMMON_H */
|
||||
|
18
src/conky.h
18
src/conky.h
@ -31,7 +31,7 @@
|
||||
#ifndef _conky_h_
|
||||
#define _conky_h_
|
||||
|
||||
#include "config.h" /* defines */
|
||||
#include <config.h> /* defines */
|
||||
#include "common.h" /* at least for struct dns_data */
|
||||
#include <sys/utsname.h> /* struct uname_s */
|
||||
#include <arpa/inet.h>
|
||||
@ -66,10 +66,6 @@ char *strndup(const char *s, size_t n);
|
||||
/* forward define to make gcc happy */
|
||||
struct text_object;
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
#endif
|
||||
|
||||
#ifdef BMPX
|
||||
#include "bmpx.h"
|
||||
#endif
|
||||
@ -91,12 +87,18 @@ struct text_object;
|
||||
#endif
|
||||
|
||||
#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
|
||||
#include "ccurl_thread.h"
|
||||
#endif /* HAVE_CURL */
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
#endif
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef RSS
|
||||
@ -194,6 +196,9 @@ enum {
|
||||
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 {
|
||||
unsigned int mask;
|
||||
|
||||
@ -249,6 +254,7 @@ struct information {
|
||||
|
||||
short kflags; /* kernel settings, see enum KFLAG */
|
||||
};
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* needed by linux.c and top.c -> outsource somewhere */
|
||||
enum {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -37,23 +37,12 @@
|
||||
#include "specials.h"
|
||||
#include "text_object.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
/* this is the root of all per disk stats,
|
||||
* also containing the totals. */
|
||||
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,
|
||||
};
|
||||
struct diskio_stat stats;
|
||||
|
||||
void clear_diskio_stats(void)
|
||||
{
|
||||
@ -70,7 +59,7 @@ void clear_diskio_stats(void)
|
||||
struct diskio_stat *prepare_diskio_stat(const char *s)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!s)
|
||||
@ -79,29 +68,29 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
|
||||
#if defined(__FreeBSD__)
|
||||
if (strncmp(s, "/dev/", 5) == 0) {
|
||||
// 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
|
||||
#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);
|
||||
}
|
||||
|
||||
/* lookup existing */
|
||||
while (cur->next) {
|
||||
cur = cur->next;
|
||||
if (!strcmp(cur->dev, device_name)) {
|
||||
if (!strcmp(cur->dev, &(device_name[0]))) {
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
/* no existing found, make a new one */
|
||||
cur->next = calloc(1, sizeof(struct diskio_stat));
|
||||
cur->next = new diskio_stat;
|
||||
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_read = 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)
|
||||
{
|
||||
struct diskio_stat *diskio = obj->data.opaque;
|
||||
struct diskio_stat *diskio = (struct diskio_stat *)obj->data.opaque;
|
||||
double val;
|
||||
|
||||
if (!diskio)
|
||||
@ -167,21 +156,21 @@ void parse_diskiograph_arg(struct text_object *obj, const char *arg)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
21
src/diskio.h
21
src/diskio.h
@ -30,11 +30,22 @@
|
||||
#ifndef DISKIO_H_
|
||||
#define DISKIO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
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;
|
||||
char *dev;
|
||||
double sample[15];
|
||||
@ -66,8 +77,4 @@ double diskiographval_read(struct text_object *);
|
||||
double diskiographval_write(struct text_object *);
|
||||
#endif /* X11 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DISKIO_H_ */
|
||||
|
@ -41,14 +41,14 @@
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
|
||||
static struct {
|
||||
struct _entropy {
|
||||
_entropy() : avail(0), poolsize(0) {}
|
||||
unsigned int avail;
|
||||
unsigned int poolsize;
|
||||
} entropy = {
|
||||
.avail = 0,
|
||||
.poolsize = 0,
|
||||
};
|
||||
|
||||
static _entropy entropy;
|
||||
|
||||
void update_entropy(void)
|
||||
{
|
||||
get_entropy_avail(&entropy.avail);
|
@ -31,10 +31,6 @@
|
||||
#ifndef _ENTROPY_H
|
||||
#define _ENTROPY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void update_entropy(void);
|
||||
|
||||
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);
|
||||
double entropy_barval(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ENTROPY_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -91,7 +91,7 @@ void clear_fs_stats(void)
|
||||
|
||||
struct fs_stat *prepare_fs_stat(const char *s)
|
||||
{
|
||||
struct fs_stat *new = 0;
|
||||
struct fs_stat *next = 0;
|
||||
unsigned i;
|
||||
|
||||
/* lookup existing or get new */
|
||||
@ -101,18 +101,18 @@ struct fs_stat *prepare_fs_stat(const char *s)
|
||||
return &fs_stats[i];
|
||||
}
|
||||
} else {
|
||||
new = &fs_stats[i];
|
||||
next = &fs_stats[i];
|
||||
}
|
||||
}
|
||||
/* new path */
|
||||
if (!new) {
|
||||
if (!next) {
|
||||
NORM_ERR("too many fs stats");
|
||||
return 0;
|
||||
}
|
||||
strncpy(new->path, s, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
new->set = 1;
|
||||
update_fs_stat(new);
|
||||
return new;
|
||||
strncpy(next->path, s, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
next->set = 1;
|
||||
update_fs_stat(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
double val = 1.0;
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||
|
||||
if (!fs)
|
||||
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)
|
||||
{
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||
int val = 100;
|
||||
|
||||
if (!fs)
|
||||
@ -273,7 +273,7 @@ uint8_t fs_used_percentage(struct text_object *obj)
|
||||
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \
|
||||
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) \
|
||||
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)
|
||||
{
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
struct fs_stat *fs = (struct fs_stat *)obj->data.opaque;
|
||||
|
||||
if (fs)
|
||||
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
|
||||
#define _FS_H
|
||||
|
||||
#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* needed here and by fs.c */
|
||||
struct fs_stat {
|
||||
char path[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
@ -38,8 +62,4 @@ void update_fs_stats(void);
|
||||
struct fs_stat *prepare_fs_stat(const char *path);
|
||||
void clear_fs_stats(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FS_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -47,15 +47,16 @@
|
||||
static char *hddtemp_host = NULL;
|
||||
static char *hddtemp_port = NULL;
|
||||
|
||||
static struct hdd_info {
|
||||
struct hdd_info {
|
||||
hdd_info() : next(0) {}
|
||||
struct hdd_info *next;
|
||||
char *dev;
|
||||
short temp;
|
||||
char unit;
|
||||
} hdd_info_head = {
|
||||
.next = NULL,
|
||||
};
|
||||
|
||||
struct hdd_info hdd_info_head;
|
||||
|
||||
void set_hddtemp_host(const char *host)
|
||||
{
|
||||
if (hddtemp_host)
|
||||
@ -75,7 +76,7 @@ static void __free_hddtemp_info(struct hdd_info *hdi)
|
||||
if (hdi->next)
|
||||
__free_hddtemp_info(hdi->next);
|
||||
free(hdi->dev);
|
||||
free(hdi);
|
||||
delete hdi;
|
||||
}
|
||||
|
||||
static void free_hddtemp_info(void)
|
||||
@ -95,7 +96,7 @@ static void add_hddtemp_info(char *dev, short temp, char unit)
|
||||
while (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));
|
||||
hdi->next->dev = strdup(dev);
|
||||
hdi->next->temp = temp;
|
||||
@ -137,12 +138,12 @@ static char *fetch_hddtemp_output(void)
|
||||
}
|
||||
|
||||
buflen = 1024;
|
||||
buf = malloc(buflen);
|
||||
buf = (char*)malloc(buflen);
|
||||
while ((rlen = recv(sockfd, buf + offset, buflen - offset - 1, 0)) > 0) {
|
||||
offset += rlen;
|
||||
if (buflen - offset < 1) {
|
||||
buflen += 1024;
|
||||
buf = realloc(buf, buflen);
|
||||
buf = (char*)realloc(buf, buflen);
|
||||
}
|
||||
}
|
||||
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_
|
||||
#define HDDTEMP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void set_hddtemp_host(const char *);
|
||||
void set_hddtemp_port(const char *);
|
||||
void update_hddtemp(void);
|
||||
void free_hddtemp(struct text_object *);
|
||||
void print_hddtemp(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*HDDTEMP_H_*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -36,7 +36,7 @@
|
||||
#include "temphelper.h"
|
||||
#include "text_object.h"
|
||||
|
||||
struct {
|
||||
struct _i8k {
|
||||
char *version;
|
||||
char *bios;
|
||||
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 -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -32,10 +32,6 @@
|
||||
#ifndef _I8K_H
|
||||
#define _I8K_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void update_i8k(void);
|
||||
void print_i8k_left_fan_status(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_buttons_status(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _I8K_H */
|
||||
|
@ -3,10 +3,6 @@
|
||||
*
|
||||
* 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
|
||||
@ -36,6 +32,7 @@
|
||||
#include "net_stat.h"
|
||||
#include "diskio.h"
|
||||
#include "temphelper.h"
|
||||
#include "c-funcs.h"
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@ -178,17 +175,17 @@ void update_meminfo(void)
|
||||
}
|
||||
|
||||
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) {
|
||||
sscanf(buf, "%*s %llu", &info.memfree);
|
||||
sscanf_c(buf, "%*s %llu", &info.memfree);
|
||||
} 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) {
|
||||
sscanf(buf, "%*s %llu", &info.swapfree);
|
||||
sscanf_c(buf, "%*s %llu", &info.swapfree);
|
||||
} 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) {
|
||||
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;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* if recv or trans is less than last time, an overflow happened */
|
||||
@ -442,7 +439,7 @@ void update_net_stats(void)
|
||||
/*** ip addr patch ***/
|
||||
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;
|
||||
memset(conf.ifc_buf, 0, conf.ifc_len);
|
||||
|
||||
@ -644,7 +641,7 @@ void determine_longstat(char *buf)
|
||||
|
||||
KFLAG_SETOFF(KFLAG_IS_LONGSTAT);
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@ -677,7 +674,7 @@ void get_cpu_count(void)
|
||||
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);
|
||||
}
|
||||
@ -725,7 +722,7 @@ void update_stat(void)
|
||||
|
||||
if (!global_cpu) {
|
||||
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);
|
||||
global_cpu = cpu;
|
||||
}
|
||||
@ -753,7 +750,7 @@ void update_stat(void)
|
||||
} else {
|
||||
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_idle), &(cpu[idx].cpu_iowait),
|
||||
&(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;
|
||||
}
|
||||
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));
|
||||
sf->fd = open_sysfs_sensor(path, (*buf1) ? buf1 : 0, buf2, n,
|
||||
&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)
|
||||
{
|
||||
double r;
|
||||
struct sysfs *sf = obj->data.opaque;
|
||||
struct sysfs *sf = (struct sysfs *)obj->data.opaque;
|
||||
|
||||
if (!sf)
|
||||
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)
|
||||
{
|
||||
struct sysfs *sf = obj->data.opaque;
|
||||
struct sysfs *sf = (struct sysfs *)obj->data.opaque;
|
||||
|
||||
if (!sf)
|
||||
return;
|
@ -5,10 +5,6 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void print_disk_protect_queue(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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_H */
|
||||
|
@ -28,9 +28,11 @@
|
||||
#include "logging.h"
|
||||
#include "build.h"
|
||||
|
||||
extern "C" {
|
||||
#ifdef LUA_EXTRAS
|
||||
#include <tolua++.h>
|
||||
#endif /* LUA_EXTRAS */
|
||||
}
|
||||
|
||||
#ifdef HAVE_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 */
|
||||
char *str;
|
||||
char *buf = calloc(1, max_user_text);
|
||||
char *buf = (char*)calloc(1, max_user_text);
|
||||
if (n != 1) {
|
||||
lua_pushstring(L, "incorrect arguments, conky_parse(string) takes exactly 1 argument");
|
||||
lua_error(L);
|
||||
@ -97,7 +99,7 @@ void llua_init(void)
|
||||
lua_getglobal(lua_L, "package");
|
||||
lua_getfield(lua_L, -1, "cpath");
|
||||
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);
|
||||
strcat(new_path, old_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)
|
||||
{
|
||||
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));
|
||||
strncpy(ret->name, name, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
return ret;
|
10
src/llua.h
10
src/llua.h
@ -24,9 +24,11 @@
|
||||
#ifndef LUA_H_
|
||||
#define LUA_H_
|
||||
|
||||
extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
}
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@ -36,10 +38,6 @@
|
||||
|
||||
#define LUAPREFIX "conky_"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* load a lua script */
|
||||
void llua_load(const char *script);
|
||||
/* close lua stuff */
|
||||
@ -73,8 +71,4 @@ void print_lua(struct text_object *, char *, int);
|
||||
void print_lua_parse(struct text_object *, char *, int);
|
||||
double lua_barval(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LUA_H_*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
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_
|
||||
#define MIXER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void parse_mixer_arg(struct text_object *, const char *);
|
||||
uint8_t mixer_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 mixerr_barval(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*MIXER_H_*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
return;
|
||||
@ -177,7 +177,7 @@ void print_addr(struct text_object *obj, char *p, int p_max_size)
|
||||
#ifdef __linux__
|
||||
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)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -225,7 +225,7 @@ double upspeedgraphval(struct text_object *obj)
|
||||
#ifdef HAVE_IWLIB
|
||||
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)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
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)
|
||||
{
|
||||
struct net_stat *ns = obj->data.opaque;
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
return 0;
|
||||
@ -333,7 +333,7 @@ int interface_up(struct text_object *obj)
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
char *dev = obj->data.opaque;
|
||||
char *dev = (char*)obj->data.opaque;
|
||||
|
||||
if (!dev)
|
||||
return 0;
|
||||
@ -375,14 +375,14 @@ END_TRUE:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct {
|
||||
struct _dns_data {
|
||||
_dns_data() : nscount(0), ns_list(0) {}
|
||||
int nscount;
|
||||
char **ns_list;
|
||||
} dns_data = {
|
||||
.nscount = 0,
|
||||
.ns_list = NULL,
|
||||
};
|
||||
|
||||
static _dns_data dns_data;
|
||||
|
||||
void free_dns_data(struct text_object *obj)
|
||||
{
|
||||
int i;
|
||||
@ -420,7 +420,7 @@ void update_dns_data(void)
|
||||
if (!strncmp(line, "nameserver ", 11)) {
|
||||
line[strlen(line) - 1] = '\0'; // remove trailing newline
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -33,10 +33,6 @@
|
||||
|
||||
#include <sys/socket.h> /* struct sockaddr */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct net_stat {
|
||||
char *dev;
|
||||
int up;
|
||||
@ -102,8 +98,4 @@ void update_dns_data(void);
|
||||
void parse_nameserver_arg(struct text_object *, const char *);
|
||||
void print_nameserver(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NET_STAT_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#ifndef _PRIOQUEUE_H
|
||||
#define _PRIOQUEUE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* forward-define for private data */
|
||||
struct prio_queue;
|
||||
|
||||
@ -63,4 +66,8 @@ void *pop_prio_elem(prio_queue_t);
|
||||
/* clear and free the given queue */
|
||||
void free_prio_queue(prio_queue_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
*
|
||||
@ -31,6 +32,7 @@
|
||||
#include "logging.h"
|
||||
#include "specials.h"
|
||||
#include "text_object.h"
|
||||
#include <vector>
|
||||
|
||||
struct scroll_data {
|
||||
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;
|
||||
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));
|
||||
|
||||
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 {
|
||||
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) {
|
||||
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);
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
char *pwithcolors;
|
||||
char buf[max_user_text];
|
||||
std::vector<char> buf(max_user_text);
|
||||
|
||||
if (!sd)
|
||||
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++) {
|
||||
switch(buf[j]) {
|
||||
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
|
||||
if (strlen(buf) - colorchanges <= sd->show) {
|
||||
snprintf(p, p_max_size, "%s", buf);
|
||||
if (strlen(&(buf[0])) - colorchanges <= sd->show) {
|
||||
snprintf(p, p_max_size, "%s", &(buf[0]));
|
||||
return;
|
||||
}
|
||||
//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++;
|
||||
}
|
||||
//place all chars that should be visible in p, including colorchanges
|
||||
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) {
|
||||
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++) {
|
||||
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++) {
|
||||
pwithcolors[j] = SPECIAL_CHAR;
|
||||
}
|
||||
@ -148,14 +150,14 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
||||
free(pwithcolors);
|
||||
//scroll
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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
|
||||
*
|
||||
@ -29,16 +30,8 @@
|
||||
#ifndef _SCROLL_H
|
||||
#define _SCROLL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void parse_scroll_arg(struct text_object *, const char *, void *);
|
||||
void print_scroll(struct text_object *, char *, int);
|
||||
void free_scroll(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SCROLL_H */
|
||||
|
@ -98,7 +98,7 @@ const char *scan_gauge(struct text_object *obj, const char *args, double scale)
|
||||
{
|
||||
struct gauge *g;
|
||||
|
||||
g = malloc(sizeof(struct gauge));
|
||||
g = (struct gauge *)malloc(sizeof(struct gauge));
|
||||
memset(g, 0, sizeof(struct gauge));
|
||||
|
||||
/*width and height*/
|
||||
@ -130,7 +130,7 @@ const char *scan_bar(struct text_object *obj, const char *args, double scale)
|
||||
{
|
||||
struct bar *b;
|
||||
|
||||
b = malloc(sizeof(struct bar));
|
||||
b = (struct bar *)malloc(sizeof(struct bar));
|
||||
memset(b, 0, sizeof(struct bar));
|
||||
|
||||
/* 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];
|
||||
memset(buf, 0, 1024);
|
||||
|
||||
g = malloc(sizeof(struct graph));
|
||||
g = (struct graph *)malloc(sizeof(struct graph));
|
||||
memset(g, 0, sizeof(struct graph));
|
||||
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)
|
||||
{
|
||||
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)]);
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
struct gauge *g = obj->special_data;
|
||||
struct gauge *g = (struct gauge *)obj->special_data;
|
||||
|
||||
if (!p_max_size || !g)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return;
|
||||
@ -386,7 +386,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
||||
} else {
|
||||
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));
|
||||
s->scale = 100;
|
||||
}
|
||||
@ -429,7 +429,7 @@ void scan_stippled_hr(struct text_object *obj, const char *arg)
|
||||
{
|
||||
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));
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
struct bar *b = obj->special_data;
|
||||
struct bar *b = (struct bar *)obj->special_data;
|
||||
int width, i, scaledusage;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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] */
|
||||
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)
|
||||
return;
|
||||
@ -607,7 +607,7 @@ void scan_tab(struct text_object *obj, const char *arg)
|
||||
{
|
||||
struct tab *t;
|
||||
|
||||
t = malloc(sizeof(struct tab));
|
||||
t = (struct tab *)malloc(sizeof(struct tab));
|
||||
memset(t, 0, sizeof(struct tab));
|
||||
|
||||
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)
|
||||
{
|
||||
struct special_t *s = 0;
|
||||
struct tab *t = obj->special_data;
|
||||
struct tab *t = (struct tab *)obj->special_data;
|
||||
|
||||
if (!t || !p_max_size)
|
||||
return;
|
@ -29,10 +29,6 @@
|
||||
#ifndef _SPECIALS_H
|
||||
#define _SPECIALS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* special stuff in text_buffer */
|
||||
|
||||
#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_tab(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SPECIALS_H */
|
||||
|
@ -71,7 +71,7 @@ static void tailstring(char *string, int endofstring, int wantedlines) {
|
||||
|
||||
void free_tailhead(struct text_object *obj)
|
||||
{
|
||||
struct headtail *ht = obj->data.opaque;
|
||||
struct headtail *ht = (struct headtail *)obj->data.opaque;
|
||||
if (!ht)
|
||||
return;
|
||||
if (ht->logfile)
|
||||
@ -86,10 +86,10 @@ void init_tailhead(const char* type, const char* arg, struct text_object *obj, v
|
||||
unsigned int args;
|
||||
struct headtail *ht;
|
||||
|
||||
ht = malloc(sizeof(struct headtail));
|
||||
ht = (struct headtail *)malloc(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);
|
||||
|
||||
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;
|
||||
FILE *fp;
|
||||
struct stat st;
|
||||
struct headtail *ht = obj->data.opaque;
|
||||
struct headtail *ht = (struct headtail *)obj->data.opaque;
|
||||
|
||||
if (!ht)
|
||||
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);
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -30,10 +30,6 @@
|
||||
#ifndef _TAILHEAD_H
|
||||
#define _TAILHEAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void free_tailhead(struct text_object *);
|
||||
void init_tailhead(const char *, const char *, struct text_object *, void *);
|
||||
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_words(struct text_object *, char *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TAILHEAD_H */
|
||||
|
@ -24,10 +24,6 @@
|
||||
#ifndef TEMPHELPER_H
|
||||
#define TEMPHELPER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum TEMP_UNIT {
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT
|
||||
@ -36,8 +32,4 @@ enum TEMP_UNIT {
|
||||
int set_temp_output_unit(const char *);
|
||||
int temp_print(char *, size_t, double, enum TEMP_UNIT);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TEMPHELPER_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
/* -*- 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
|
||||
*
|
||||
@ -63,7 +63,7 @@ static void hash_process(struct process *p)
|
||||
bucket = p->pid & (HTABSIZE - 1);
|
||||
|
||||
/* 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->next = proc_hash_table[bucket].next;
|
||||
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 softirq = 0;
|
||||
unsigned long long steal = 0;
|
||||
const char *template =
|
||||
const char *template_ =
|
||||
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC;
|
||||
|
||||
ps = open("/proc/stat", O_RDONLY);
|
||||
@ -550,7 +550,7 @@ static unsigned long long calc_cpu_total(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sscanf(line, template, &cpu, &niceval, &systemval, &idle, &iowait, &irq,
|
||||
sscanf(line, template_, &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 */
|
||||
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) {
|
||||
return 1;
|
||||
@ -613,7 +613,7 @@ static int compare_cpu(void *va, void *vb)
|
||||
/* mem comparison function for prio queue */
|
||||
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) {
|
||||
return 1;
|
||||
@ -627,7 +627,7 @@ static int compare_mem(void *va, void *vb)
|
||||
/* CPU time comparision function for prio queue */
|
||||
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;
|
||||
}
|
||||
@ -636,7 +636,7 @@ static int compare_time(void *va, void *vb)
|
||||
/* I/O comparision function for prio queue */
|
||||
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) {
|
||||
return 1;
|
||||
@ -726,14 +726,14 @@ void process_find_top(struct process **cpu, struct process **mem,
|
||||
|
||||
for (i = 0; i < MAX_SP; i++) {
|
||||
if (top_cpu)
|
||||
cpu[i] = pop_prio_elem(cpu_queue);
|
||||
cpu[i] = (process*)pop_prio_elem(cpu_queue);
|
||||
if (top_mem)
|
||||
mem[i] = pop_prio_elem(mem_queue);
|
||||
mem[i] = (process*)pop_prio_elem(mem_queue);
|
||||
if (top_time)
|
||||
ptime[i] = pop_prio_elem(time_queue);
|
||||
ptime[i] = (process*)pop_prio_elem(time_queue);
|
||||
#ifdef IOSTATS
|
||||
if (top_io)
|
||||
io[i] = pop_prio_elem(io_queue);
|
||||
io[i] = (process*)pop_prio_elem(io_queue);
|
||||
#endif /* IOSTATS */
|
||||
}
|
||||
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)
|
||||
{
|
||||
struct top_data *td = obj->data.opaque;
|
||||
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||
int width;
|
||||
|
||||
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)
|
||||
{
|
||||
struct top_data *td = obj->data.opaque;
|
||||
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||
int width;
|
||||
|
||||
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)
|
||||
{
|
||||
struct top_data *td = obj->data.opaque;
|
||||
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||
int width;
|
||||
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) \
|
||||
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]) \
|
||||
return; \
|
||||
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) \
|
||||
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]) \
|
||||
return; \
|
||||
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)
|
||||
{
|
||||
struct top_data *td = obj->data.opaque;
|
||||
struct top_data *td = (struct top_data *)obj->data.opaque;
|
||||
|
||||
if (!td)
|
||||
return;
|
||||
@ -891,7 +891,7 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj)
|
||||
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));
|
||||
|
||||
if (s[3] == 0) {
|
@ -64,9 +64,6 @@
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************
|
||||
* 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 */
|
||||
int set_top_name_width(const char *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _top_h_ */
|
||||
|
@ -118,14 +118,14 @@ static void tty_user_time(char *ptr, char *tty)
|
||||
static void users_alloc(struct information *ptr)
|
||||
{
|
||||
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) {
|
||||
ptr->users.terms = malloc(text_buffer_size);
|
||||
ptr->users.terms = (char*)malloc(text_buffer_size);
|
||||
}
|
||||
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] = "";
|
||||
|
||||
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);
|
||||
@ -145,14 +145,14 @@ static void update_user_time(char *tty)
|
||||
free(current_info->users.ctime);
|
||||
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);
|
||||
} else {
|
||||
if (current_info->users.ctime) {
|
||||
free(current_info->users.ctime);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -169,14 +169,14 @@ void update_users(void)
|
||||
free(current_info->users.names);
|
||||
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);
|
||||
} else {
|
||||
if (current_info->users.names) {
|
||||
free(current_info->users.names);
|
||||
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);
|
||||
}
|
||||
user_num(&t);
|
||||
@ -195,14 +195,14 @@ void update_users(void)
|
||||
free(current_info->users.terms);
|
||||
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);
|
||||
} else {
|
||||
if (current_info->users.terms) {
|
||||
free(current_info->users.terms);
|
||||
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);
|
||||
}
|
||||
user_time(temp);
|
||||
@ -211,14 +211,14 @@ void update_users(void)
|
||||
free(current_info->users.times);
|
||||
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);
|
||||
} else {
|
||||
if (current_info->users.times) {
|
||||
free(current_info->users.times);
|
||||
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);
|
||||
}
|
||||
}
|
@ -31,10 +31,6 @@
|
||||
#ifndef _USERS_H
|
||||
#define _USERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void update_users(void);
|
||||
|
||||
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_time(struct text_object *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#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);
|
||||
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);
|
||||
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);
|
||||
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
|
||||
strcpy( current_info->x11.desktop.name, (char *)&names[j] );
|
||||
break;
|
@ -94,10 +94,6 @@ extern int workarea[4];
|
||||
extern struct conky_window window;
|
||||
extern char window_created;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void init_X11(const char*);
|
||||
void init_window(int use_own_window, int width, int height, int set_trans,
|
||||
int back_colour, char **argv, int argc);
|
||||
@ -118,9 +114,5 @@ void free_desktop_info(void);
|
||||
void xdbe_swap_buffers(void);
|
||||
#endif /* HAVE_XDBE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*X11_H_*/
|
||||
#endif /* X11 */
|
||||
|
Loading…
Reference in New Issue
Block a user