mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +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:
parent
c6a5a060cf
commit
912ed67d03
@ -99,10 +99,10 @@ AC_ARG_ENABLE([config_output],
|
|||||||
[want_config_output="$enableval"], [want_config_output=yes])
|
[want_config_output="$enableval"], [want_config_output=yes])
|
||||||
|
|
||||||
AM_CONDITIONAL(BUILD_CONFIG_OUTPUT, test x$want_config_output = xyes)
|
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
|
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_DEFINE(CONFIG_OUTPUT, 1, [Define if you want conky to output a default config (with -C)])
|
||||||
AC_CHECK_FUNCS(fopencookie)
|
AC_CHECK_FUNCS(fopencookie)
|
||||||
|
AC_CHECK_FUNCS(funopen)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
@ -29,19 +29,20 @@ bin_PROGRAMS = conky
|
|||||||
|
|
||||||
if BUILD_CONFIG_OUTPUT
|
if BUILD_CONFIG_OUTPUT
|
||||||
config_output = defconfig.h
|
config_output = defconfig.h
|
||||||
if BUILD_FOR_FOPENCOOKIE
|
|
||||||
config_cookie = conf_cookie.c conf_cookie.h
|
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
|
endif
|
||||||
|
|
||||||
conky_DEPENDENCIES = $(config_output)
|
conky_DEPENDENCIES = $(config_output)
|
||||||
BUILT_SOURCES = $(config_output)
|
BUILT_SOURCES = $(config_output)
|
||||||
CLEANFILES = $(config_output)
|
CLEANFILES = $(config_output)
|
||||||
if BUILD_X11
|
|
||||||
$(config_output): ../data/conky.conf
|
$(config_output): ${config_input}
|
||||||
else
|
sh ../text2c.sh ${config_input} $@ defconfig
|
||||||
$(config_output): ../data/conky_no_x11.conf
|
endif # BUILD_CONFIG_OUTPUT
|
||||||
endif
|
|
||||||
sh ../text2c.sh $< $@ defconfig
|
|
||||||
endif
|
|
||||||
|
|
||||||
if BUILD_AUDACIOUS
|
if BUILD_AUDACIOUS
|
||||||
audacious = audacious.c audacious.h
|
audacious = audacious.c audacious.h
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "defconfig.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;
|
static int col = 0, row = 0;
|
||||||
size_t i = 0;
|
COOKIE_LEN_T i = 0;
|
||||||
const char *conf[] = defconfig;
|
const char *conf[] = defconfig;
|
||||||
|
|
||||||
(void)cookie;
|
(void)cookie;
|
||||||
@ -24,11 +34,22 @@ ssize_t conf_read(void *cookie, char *buf, size_t size)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD_kernel__)
|
#if defined(HAVE_FOPENCOOKIE)
|
||||||
cookie_io_functions_t conf_cookie = {
|
static cookie_io_functions_t conf_cookie = {
|
||||||
.read = &conf_read,
|
.read = &conf_read,
|
||||||
.write = NULL,
|
.write = NULL,
|
||||||
.seek = NULL,
|
.seek = NULL,
|
||||||
.close = 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
|
#endif
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#ifndef _CONF_COOKIE_H
|
#ifndef _CONF_COOKIE_H
|
||||||
#define _CONF_COOKIE_H
|
#define _CONF_COOKIE_H
|
||||||
|
|
||||||
#include <stdio.h>
|
FILE *conf_cookie_open(void);
|
||||||
|
|
||||||
extern cookie_io_functions_t conf_cookie;
|
|
||||||
|
|
||||||
#endif /* _CONF_COOKIE_H */
|
#endif /* _CONF_COOKIE_H */
|
||||||
|
@ -108,10 +108,8 @@ char *get_apm_battery_time(void);
|
|||||||
|
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef CONFIG_OUTPUT
|
||||||
#include "defconfig.h"
|
#include "defconfig.h"
|
||||||
#ifdef HAVE_FOPENCOOKIE
|
|
||||||
#include "conf_cookie.h"
|
#include "conf_cookie.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef S_ISSOCK
|
#ifndef S_ISSOCK
|
||||||
#define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK)
|
#define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK)
|
||||||
@ -7822,9 +7820,7 @@ static FILE *open_config_file(const char *f)
|
|||||||
{
|
{
|
||||||
#ifdef CONFIG_OUTPUT
|
#ifdef CONFIG_OUTPUT
|
||||||
if (!strcmp(f, "==builtin==")) {
|
if (!strcmp(f, "==builtin==")) {
|
||||||
#ifdef HAVE_FOPENCOOKIE
|
return conf_cookie_open();
|
||||||
return fopencookie(NULL, "r", conf_cookie);
|
|
||||||
#endif /* HAVE_FOPENCOOKIE */
|
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_OUTPUT */
|
#endif /* CONFIG_OUTPUT */
|
||||||
return fopen(f, "r");
|
return fopen(f, "r");
|
||||||
|
Loading…
Reference in New Issue
Block a user