1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

fix conf_cookie for FreeBSD

While here, also clean up the #ifdef mess created
around the whole config output support.
This commit is contained in:
Phil Sutter 2009-06-21 23:46:03 +02:00
parent c6a5a060cf
commit 912ed67d03
5 changed files with 37 additions and 21 deletions

View File

@ -99,10 +99,10 @@ AC_ARG_ENABLE([config_output],
[want_config_output="$enableval"], [want_config_output=yes])
AM_CONDITIONAL(BUILD_CONFIG_OUTPUT, test x$want_config_output = xyes)
AM_CONDITIONAL(BUILD_FOR_FOPENCOOKIE, test x$want_config_output = xyes)
if test x$want_config_output = xyes; then
AC_DEFINE(CONFIG_OUTPUT, 1, [Define if you want conky to output a default config (with -C)])
AC_CHECK_FUNCS(fopencookie)
AC_CHECK_FUNCS(funopen)
fi
dnl

View File

@ -29,19 +29,20 @@ bin_PROGRAMS = conky
if BUILD_CONFIG_OUTPUT
config_output = defconfig.h
if BUILD_FOR_FOPENCOOKIE
config_cookie = conf_cookie.c conf_cookie.h
if BUILD_X11
config_input = ../data/conky.conf
else
config_input = ../data/conky_no_x11.conf
endif
conky_DEPENDENCIES = $(config_output)
BUILT_SOURCES = $(config_output)
CLEANFILES = $(config_output)
if BUILD_X11
$(config_output): ../data/conky.conf
else
$(config_output): ../data/conky_no_x11.conf
endif
sh ../text2c.sh $< $@ defconfig
endif
$(config_output): ${config_input}
sh ../text2c.sh ${config_input} $@ defconfig
endif # BUILD_CONFIG_OUTPUT
if BUILD_AUDACIOUS
audacious = audacious.c audacious.h

View File

@ -1,12 +1,22 @@
#define _GNU_SOURCE
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include "defconfig.h"
ssize_t conf_read(void *cookie, char *buf, size_t size)
#if defined(HAVE_FOPENCOOKIE)
#define COOKIE_LEN_T size_t
#define COOKIE_RET_T ssize_t
#else
#define COOKIE_LEN_T int
#define COOKIE_RET_T int
#endif
static COOKIE_RET_T
conf_read(void *cookie, char *buf, COOKIE_LEN_T size)
{
static int col = 0, row = 0;
size_t i = 0;
COOKIE_LEN_T i = 0;
const char *conf[] = defconfig;
(void)cookie;
@ -24,11 +34,22 @@ ssize_t conf_read(void *cookie, char *buf, size_t size)
return i;
}
#if defined(__linux__) || defined(__FreeBSD_kernel__)
cookie_io_functions_t conf_cookie = {
#if defined(HAVE_FOPENCOOKIE)
static cookie_io_functions_t conf_cookie = {
.read = &conf_read,
.write = NULL,
.seek = NULL,
.close = NULL,
};
FILE *conf_cookie_open(void)
{
return fopencookie(NULL, "r", conf_cookie);
}
#elif defined(HAVE_FUNOPEN)
FILE *conf_cookie_open(void)
{
return funopen(NULL, &conf_read, NULL, NULL, NULL);
}
#else
FILE *conf_cookie_open(void) { return NULL; }
#endif

View File

@ -1,8 +1,6 @@
#ifndef _CONF_COOKIE_H
#define _CONF_COOKIE_H
#include <stdio.h>
extern cookie_io_functions_t conf_cookie;
FILE *conf_cookie_open(void);
#endif /* _CONF_COOKIE_H */

View File

@ -108,10 +108,8 @@ char *get_apm_battery_time(void);
#ifdef CONFIG_OUTPUT
#include "defconfig.h"
#ifdef HAVE_FOPENCOOKIE
#include "conf_cookie.h"
#endif
#endif
#ifndef S_ISSOCK
#define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK)
@ -7822,9 +7820,7 @@ static FILE *open_config_file(const char *f)
{
#ifdef CONFIG_OUTPUT
if (!strcmp(f, "==builtin==")) {
#ifdef HAVE_FOPENCOOKIE
return fopencookie(NULL, "r", conf_cookie);
#endif /* HAVE_FOPENCOOKIE */
return conf_cookie_open();
} else
#endif /* CONFIG_OUTPUT */
return fopen(f, "r");