diff --git a/configure.ac.in b/configure.ac.in index db802197..e0fd07c6 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 53bcfd54..d77b5108 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/conf_cookie.c b/src/conf_cookie.c index 7af85870..91905a60 100644 --- a/src/conf_cookie.c +++ b/src/conf_cookie.c @@ -1,12 +1,22 @@ #define _GNU_SOURCE +#include "config.h" #include #include #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 diff --git a/src/conf_cookie.h b/src/conf_cookie.h index a5a8fea2..4ffada0a 100644 --- a/src/conf_cookie.h +++ b/src/conf_cookie.h @@ -1,8 +1,6 @@ #ifndef _CONF_COOKIE_H #define _CONF_COOKIE_H -#include - -extern cookie_io_functions_t conf_cookie; +FILE *conf_cookie_open(void); #endif /* _CONF_COOKIE_H */ diff --git a/src/conky.c b/src/conky.c index 614a039c..8717b7c4 100644 --- a/src/conky.c +++ b/src/conky.c @@ -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");