diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 8952dfe8..39c49ef9 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -91,11 +91,6 @@ if(BUILD_HTTP) set(conky_libs ${conky_libs} -lmicrohttpd) endif(BUILD_HTTP) -if(BUILD_BUILTIN_CONFIG) - check_function_exists(fopencookie HAVE_FOPENCOOKIE) - check_function_exists(funopen HAVE_FUNOPEN) -endif(BUILD_BUILTIN_CONFIG) - if(BUILD_NCURSES) check_include_file(ncurses.h NCURSES_H) find_library(NCURSES_LIB NAMES ncurses) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b94ee91..d462a442 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -180,10 +180,6 @@ if(BUILD_ICONV) set(optional_sources ${optional_sources} ${iconv}) endif(BUILD_ICONV) -if(BUILD_BUILTIN_CONFIG) - set(optional_sources ${optional_sources} conf_cookie.cc) -endif(BUILD_BUILTIN_CONFIG) - if(BUILD_NCURSES) set(optional_sources ${optional_sources} nc.cc) endif(BUILD_NCURSES) diff --git a/src/conf_cookie.cc b/src/conf_cookie.cc deleted file mode 100644 index 14e40cfe..00000000 --- a/src/conf_cookie.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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, 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 . - * - */ - -#include "config.h" -#include -#include -#include "defconfig.h" - -#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 - -#if defined(HAVE_FOPENCOOKIE) || defined(HAVE_FUNOPEN) -static COOKIE_RET_T -conf_read(void *cookie, char *buf, COOKIE_LEN_T size) -{ - static int col = 0, row = 0; - COOKIE_LEN_T i = 0; - const char *conf[] = defconfig; - - (void)cookie; - - while (i < size) { - if (!(conf[row])) /* end of rows */ - break; - if (!(conf[row][col])) { /* end of line */ - row++; - col = 0; - continue; - } - buf[i++] = conf[row][col++]; - } - return i; -} -#endif /* defined(HAVE_FOPENCOOKIE) || defined(HAVE_FUNOPEN) */ - -#if defined(HAVE_FOPENCOOKIE) -static cookie_io_functions_t conf_cookie; -FILE *conf_cookie_open(void) -{ - conf_cookie.read = &conf_read; - conf_cookie.write = NULL; - conf_cookie.seek = NULL; - conf_cookie.close = NULL; - 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 deleted file mode 100644 index 5458b465..00000000 --- a/src/conf_cookie.h +++ /dev/null @@ -1,8 +0,0 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ - -#ifndef _CONF_COOKIE_H -#define _CONF_COOKIE_H - -FILE *conf_cookie_open(void); - -#endif /* _CONF_COOKIE_H */ diff --git a/src/conky.cc b/src/conky.cc index c4056fca..c4a6a529 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -126,7 +126,8 @@ #ifdef BUILD_BUILTIN_CONFIG #include "defconfig.h" -#include "conf_cookie.h" + +namespace { const char builtin_config_magic[] = "==builtin=="; } #endif #ifndef S_ISSOCK @@ -2687,11 +2688,6 @@ static void X11_create_window(void) static FILE *open_config_file(const char *f) { -#ifdef BUILD_BUILTIN_CONFIG - if (!strcmp(f, "==builtin==")) { - return conf_cookie_open(); - } else -#endif /* BUILD_BUILTIN_CONFIG */ return fopen(f, "r"); } @@ -2956,7 +2952,7 @@ void set_current_config() { if (current_config.empty()) { #define NOCFGFILEFOUND "no personal or system-wide config file found" #ifdef BUILD_BUILTIN_CONFIG - current_config = "==builtin=="; + current_config = builtin_config_magic; NORM_ERR(NOCFGFILEFOUND ", using builtin default"); #else CRIT_ERR(NULL, NULL, NOCFGFILEFOUND); @@ -3214,7 +3210,7 @@ int main(int argc, char **argv) return 0; #ifdef BUILD_BUILTIN_CONFIG case 'C': - print_defconfig(); + std::cout << defconfig; return 0; #endif #ifdef BUILD_X11 @@ -3235,7 +3231,10 @@ int main(int argc, char **argv) //////////// XXX //////////////////////////////// lua::state &l = *state; try { - l.loadfile(argv[1]); + if(current_config == builtin_config_magic) + l.loadstring(defconfig); + else + l.loadfile(current_config.c_str()); l.call(0, 0); conky::set_config_settings(l); std::cout << "config.alignment = " << text_alignment.get(l) << std::endl; diff --git a/text2c.sh b/text2c.sh index 1fd9afeb..54d83929 100755 --- a/text2c.sh +++ b/text2c.sh @@ -35,16 +35,6 @@ outupper="`basename "$2" | tr '[a-z-.]' '[A-Z__]'`" ( - printf "#ifndef __%s\n" "$outupper" - printf "#define __%s\n" "$outupper" - printf "\n#define %s { \\" $3 - printf "\n" - sed -e 's/"/\\"/g' -e 's/^/"/' -e 's/$/\\n", \\/' $1 - printf "NULL }\n" - printf "\n#define print_%s() { \\" $3 - printf "\n\tconst char **__sp, *__s[] = %s; \\" $3 - printf "\n\tfor (__sp = __s; *__sp; __sp++) \\" - printf "\n\t\tprintf(\"%s\", *__sp); \\" "%s" - printf "\n}\n\n" - printf "#endif /* __%s */\n" "$outupper" + printf "const char %s[] = \n" $3 + sed -e 's/["\]/\\&/g' -e 's/^/\t"/' -e 's/$/\\n"/' -e '$s/$/;/' $1 ) > $2