diff --git a/CHANGELOG b/CHANGELOG index c487b729a4216e456f4ef50903b78a601d2bbf0e..c7ec8185eba5b2590ae97723f11755d77ea99665 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,21 @@ +# Next + +- Add the download and build dependencies script, whith its option in the + configure script +- Bug fix: broken stop and clear +- Bug fix: broken insert +- More separation between modules and lektord's source code + +# v2.0 + +- Change build toolchain to autotools +- Asserts are enabled manually at runtime +- Enable static modules and debug builds at compile time +- Add a CI +- Update documentation +- Some refactor done +- Some bug fixes… + # v1.8-2 - Add plt list to list all available playlists diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..f89aa7f0836a309b50ae3f7ca38ba7a09f77e733 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing to Lektor + +Clone the [git repository](https://git.iiens.net/martin2018/lektor). Create a +branch from master with the `git checkout -b dev-${pseudal}` command. + +Please, rebase regularly your branch on `master`. + +Please, add your name in the CONTRIBUTORS file. The format is `First name +'Pseudal' FAMILY NAME`. The licence is a modified version of the ISC licence +to include this file (in short, a kind of MIT licence). + +## Building + +It is recommended to use the `../configure` method to build while in +developpement. Also, prefere useing the `--with-depends` with the +configuration, to use the fixed version. + +## Style style and the code + +Prefer using `__${name}` names for static variables and functions. Prefix the +name of the file or folder in function names, e.g. `database_` or `command_`. + +For formating, use the `./scripts/astyle.bash` from the root of the project. +You'll need [astyle](http://astyle.sourceforge.net/) for that. Note that the +astyle step is a part of the CI/CD. + +You are encouraged to use the `./scripts/tags.bash` script to build the `ctags` +and `cscope` database files to explore more easelly the project. diff --git a/CONTRIBUTING b/CONTRIBUTORS similarity index 100% rename from CONTRIBUTING rename to CONTRIBUTORS diff --git a/LICENSE b/LICENSE index bc67651debd1e0fef3081a674d0cbd9655d6a7c5..061d50b1ac0baea26c48f423da8fadea7f7eed45 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,8 @@ -Copyright 2020 to Lektor contributors +Copyright 2020 to Lektor contributors, refer to the CONTRIBUTORS file. Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. +with or without fee is hereby granted, provided that the above copyright notice, +the CONTRIBUTORS file and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND diff --git a/Makefile.in b/Makefile.in index 115bcd2e3f2cb1e0252d248a6ae6ba5fd9b84b0f..2df476de4bcda37f884ec8bb9510686b42924fba 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -362,6 +362,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -672,10 +673,6 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) -dist-zstd: distdir - tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst - $(am__post_remove_distdir) - dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @@ -718,8 +715,6 @@ distcheck: dist eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ - *.tar.zst*) \ - zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) @@ -900,19 +895,19 @@ uninstall-am: uninstall-binSCRIPTS am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip dist-zstd distcheck distclean \ - distclean-generic distclean-hdr distclean-libtool \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-binSCRIPTS install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am \ - installcheck-binSCRIPTS installdirs installdirs-am \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-binSCRIPTS + dist-xz dist-zip distcheck distclean distclean-generic \ + distclean-hdr distclean-libtool distclean-tags distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-binSCRIPTS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installcheck-binSCRIPTS installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am tags tags-am uninstall uninstall-am \ + uninstall-binSCRIPTS .PRECIOUS: Makefile diff --git a/README.md b/README.md index dfbf6dbdf791d476ba0bea59125f7576b83bbe90..a46b0ed9b94c24b75971d8e530a502dfb8512ae1 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,16 @@ configuration file: archlinux, seems to be distributed in its own package on debian: [xxd](https://packages.debian.org/sid/xxd) +If you use the configure with the `--with-depends` option (needed on debian +10), you will need the following dependencies: + +- the [curl](https://curl.haxx.se/) command line utility +- the [wget](https://www.gnu.org/software/wget/) command line utility +- the [git](https://git-scm.com/) command line utility + +Note that because of the use of `curl` and `get`, building behind a proxy may +be challenging. + The manual way of installing and setting up lektor: ```sh @@ -50,12 +60,13 @@ make sudo make install # Config and run -lkt adm conf > ~/.config/lektor/lektor.ini lektord ``` -The sqlite database will be created automatically if needed (i.e. on the first -time you run lektord, you may need to restart lektord). +The sqlite database and the config file will be created automatically if +needed, i.e. on the first run. If you are upgrading lektor, the config might +not be correct. You can delete the config file or use the `lkt admin config` to +generate the config file again. If you are using special modules or are compiling lektor without static modules, you may set their **absolute path** inside the lektor's config file. diff --git a/aclocal.m4 b/aclocal.m4 index 23061948d1b0e57350bdcbdbfd5fd40bdff892c5..44474660648a21cbc65d69de06b3e937c4a0314c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.2 -*- Autoconf -*- +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.2], [], +m4_if([$1], [1.16.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.2])dnl +[AM_AUTOMAKE_VERSION([1.16.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -# Copyright (C) 2011-2020 Free Software Foundation, Inc. +# Copyright (C) 2011-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -118,7 +118,7 @@ AC_SUBST([AR])dnl # Figure out how to run the assembler. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -138,7 +138,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -190,7 +190,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -221,7 +221,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -412,7 +412,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -451,9 +451,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. If GNU make was not used, consider - re-running the configure script with MAKE="gmake" (or whatever is - necessary). You can also try re-running configure with the + for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi @@ -480,7 +478,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -677,7 +675,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -698,7 +696,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2020 Free Software Foundation, Inc. +# Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -719,7 +717,7 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -762,7 +760,7 @@ AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -801,7 +799,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -830,7 +828,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -877,7 +875,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -896,7 +894,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -977,7 +975,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1037,7 +1035,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1065,7 +1063,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1084,7 +1082,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2020 Free Software Foundation, Inc. +# Copyright (C) 2004-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/configure b/configure index ca7d3351e34d7450c5fd52df31e9866bd8a453f9..a31103804bc3304d15bfc717383d613578c8111e 100755 --- a/configure +++ b/configure @@ -634,6 +634,8 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +LKT_DEPENDS_ENABLE_FALSE +LKT_DEPENDS_ENABLE_TRUE LKT_ENDIANES_BIG LKT_ENDIANES_LITTLE LKT_BUILD_STRING @@ -744,6 +746,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -779,6 +782,7 @@ with_sysroot enable_libtool_lock enable_debug enable_static_module +with_depends ' ac_precious_vars='build_alias host_alias @@ -830,6 +834,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1082,6 +1087,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1219,7 +1233,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1372,6 +1386,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1435,6 +1450,7 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). + --with-depends Download and build dependencies needed for lektor Some influential environment variables: CC C compiler command @@ -13594,14 +13610,14 @@ LKT_ENDIANES_LITTLE="$(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6) if test "$LKT_ENDIANES_LITTLE" = "1" ; then cat >>confdefs.h <<_ACEOF -#define LKT_ENDIANES_LITTLE /**/ +#define LKT_ENDIANES_LITTLE 1 _ACEOF else cat >>confdefs.h <<_ACEOF -#define LKT_ENDIANES_BIG /**/ +#define LKT_ENDIANES_BIG 1 _ACEOF @@ -13611,13 +13627,70 @@ fi # CFLAGS # ########## -BASEFLAGS="-Werror -Wall" -if test "x${LKT_DEBUG_ENABLED}" = "xyes" ; then - BASEFLAGS+=" -g" +BASEFLAGS=`test "x${LKT_DEBUG_ENABLED}" = 'xyes' && echo "-g" || echo "-O3"` +CFLAGS="-Werror -Wall -Wextra ${BASEFLAGS} -std=c11" + +################################# +# BUILD WITH THE DEPENDS SCRIPT # +################################# + + +# Check whether --with-depends was given. +if test "${with_depends+set}" = set; then : + withval=$with_depends; LKT_BUILD_DEPENDS=yes +else + LKT_BUILD_DEPENDS=no +fi + + if test "x${LKT_BUILD_DEPENDS}" = "xyes"; then + LKT_DEPENDS_ENABLE_TRUE= + LKT_DEPENDS_ENABLE_FALSE='#' +else + LKT_DEPENDS_ENABLE_TRUE='#' + LKT_DEPENDS_ENABLE_FALSE= +fi + +if test "x$LKT_BUILD_DEPENDS" = "xyes" ; then + LKT_LIB_DIR="$PWD/depends_install/lib" + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac else - BASEFLAGS+=" -O3" + enable_shared=no +fi + + + + + + + CFLAGS="${CFLAGS} -I$PWD/depends_install/include" + LDFLAGS="${LDFLAGS} -L$PWD/depends_install/lib" + + # Download and build dependencies + cd $LKT_PATH_SOURCE + ./scripts/depends.bash $LKT_PATH_BUILD + if test $? -ne 0 ; then + as_fn_error 1 "\"Failed to download and build dependencies\"" "$LINENO" 5 + fi + cd $LKT_PATH_BUILD fi -CFLAGS="${BASEFLAGS} -std=c11" ########## # OUTPUT # @@ -13768,6 +13841,10 @@ if test -z "${LKT_STATIC_MODULE_TRUE}" && test -z "${LKT_STATIC_MODULE_FALSE}"; as_fn_error $? "conditional \"LKT_STATIC_MODULE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${LKT_DEPENDS_ENABLE_TRUE}" && test -z "${LKT_DEPENDS_ENABLE_FALSE}"; then + as_fn_error $? "conditional \"LKT_DEPENDS_ENABLE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -15328,9 +15405,7 @@ $as_echo X/"$am_mf" | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. If GNU make was not used, consider - re-running the configure script with MAKE=\"gmake\" (or whatever is - necessary). You can also try re-running configure with the + for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } @@ -15930,18 +16005,23 @@ fi # CONF RESULTS # ################ +AFF_BRANCH=$(git rev-parse --abbrev-ref HEAD) +AFF_VERSION=$(git -C $LKT_PATH_SOURCE rev-list --count HEAD).$(git -C $LKT_PATH_SOURCE rev-parse --short HEAD) LKT_CONFIG_RESULT=" ########## Lektor configuration ########### # # Configure run on..... $(date) # Compiler C........... $(basename $CC) -# Version.............. mk7.$(git -C $LKT_PATH_SOURCE rev-list --count HEAD).$(git -C $LKT_PATH_SOURCE rev-parse --short HEAD) +# Version.............. mk7.$AFF_VERSION +# Branch............... $AFF_BRANCH # ### Build options # # Modules.............. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static) # C Flags.............. $CFLAGS +# LD Flags............. $LDFLAGS # To link against...... -Wl,-rpath -Wl,$prefix/lib +# Builtin depends...... $LKT_BUILD_DEPENDS # ### Other informations # diff --git a/configure.ac b/configure.ac index cfa8891779f1e5f89dc1cc73b3dbcb567d90fdbb..613902d099d7d865ed60a981f2571e74951d65c3 100644 --- a/configure.ac +++ b/configure.ac @@ -113,10 +113,10 @@ AC_SUBST([LKT_BUILD_STRING]) LKT_ENDIANES_LITTLE="$(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6)" if test "$LKT_ENDIANES_LITTLE" = "1" ; then - AC_DEFINE_UNQUOTED([LKT_ENDIANES_LITTLE], [], [Little endian]) + AC_DEFINE_UNQUOTED([LKT_ENDIANES_LITTLE], [1], [Little endian]) AC_SUBST([LKT_ENDIANES_LITTLE]) else - AC_DEFINE_UNQUOTED([LKT_ENDIANES_BIG], [], [Big endian]) + AC_DEFINE_UNQUOTED([LKT_ENDIANES_BIG], [1], [Big endian]) AC_SUBST([LKT_ENDIANES_BIG]) fi @@ -124,13 +124,33 @@ fi # CFLAGS # ########## -BASEFLAGS="-Werror -Wall" -if test "x${LKT_DEBUG_ENABLED}" = "xyes" ; then - BASEFLAGS+=" -g" -else - BASEFLAGS+=" -O3" +BASEFLAGS=`test "x${LKT_DEBUG_ENABLED}" = 'xyes' && echo "-g" || echo "-O3"` +CFLAGS="-Werror -Wall -Wextra ${BASEFLAGS} -std=c11" + +################################# +# BUILD WITH THE DEPENDS SCRIPT # +################################# + +AC_ARG_WITH([depends], + [AS_HELP_STRING([--with-depends], + [Download and build dependencies needed for lektor])], + [LKT_BUILD_DEPENDS=yes], + [LKT_BUILD_DEPENDS=no]) +AM_CONDITIONAL([LKT_DEPENDS_ENABLE], [test "x${LKT_BUILD_DEPENDS}" = "xyes"]) +if test "x$LKT_BUILD_DEPENDS" = "xyes" ; then + LKT_LIB_DIR="$PWD/depends_install/lib" + AC_DISABLE_SHARED + CFLAGS="${CFLAGS} -I$PWD/depends_install/include" + LDFLAGS="${LDFLAGS} -L$PWD/depends_install/lib" + + # Download and build dependencies + cd $LKT_PATH_SOURCE + ./scripts/depends.bash $LKT_PATH_BUILD + if test $? -ne 0 ; then + AC_MSG_ERROR("Failed to download and build dependencies", [1]) + fi + cd $LKT_PATH_BUILD fi -CFLAGS="${BASEFLAGS} -std=c11" ########## # OUTPUT # @@ -149,18 +169,23 @@ AC_OUTPUT([ # CONF RESULTS # ################ +AFF_BRANCH=$(git rev-parse --abbrev-ref HEAD) +AFF_VERSION=$(git -C $LKT_PATH_SOURCE rev-list --count HEAD).$(git -C $LKT_PATH_SOURCE rev-parse --short HEAD) LKT_CONFIG_RESULT=" ########## Lektor configuration ########### # # Configure run on..... $(date) # Compiler C........... $(basename $CC) -# Version.............. mk7.$(git -C $LKT_PATH_SOURCE rev-list --count HEAD).$(git -C $LKT_PATH_SOURCE rev-parse --short HEAD) +# Version.............. mk7.$AFF_VERSION +# Branch............... $AFF_BRANCH # ### Build options # # Modules.............. $(test $LKT_STATIC_MODULE = 'yes' && echo static || echo not static) # C Flags.............. $CFLAGS +# LD Flags............. $LDFLAGS # To link against...... -Wl,-rpath -Wl,$prefix/lib +# Builtin depends...... $LKT_BUILD_DEPENDS # ### Other informations # diff --git a/depends/depends.txt b/depends/depends.txt new file mode 100644 index 0000000000000000000000000000000000000000..1919fe6de4d16df196faf955d0dea9508b26d6e9 --- /dev/null +++ b/depends/depends.txt @@ -0,0 +1,6 @@ +curl sqlite3 https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release sqlite3.tar.gz +wget sdl2 https://www.libsdl.org/release/SDL2-2.0.12.tar.gz sdl2.tar.gz +wget libcurl https://curl.haxx.se/download/curl-7.72.0.tar.gz libcurl.tar.gz +wget zlib https://zlib.net/zlib-1.2.11.tar.gz zlib.tar.gz +wget iconv https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz iconv.tar.gz +git openssl git://git.openssl.org/openssl.git openssl -b OpenSSL_1_1_1-stable diff --git a/depends/rules.txt b/depends/rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..b5be0f653af591c303fdd3064eb031b550327d75 --- /dev/null +++ b/depends/rules.txt @@ -0,0 +1,6 @@ +zlib zconfigure --static --64 +iconv configure --disable-shared +openssl sslconfigure no-shared -fPIC no-hw +sqlite3 configure --disable-shared --disable-tcl CFLAGS=-fPIC --enable-update-limit +sdl2 configure --disable-shared --enable-fcitx --enable-input-tslib=no CFLAGS=-fPIC +libcurl configure --disable-shared --without-zlib --enable-optimize --disable-rt --disable-pop3 --disable-imap --disable-rtsp --disable-smtp --disable-smb --disable-smbs --disable-dict --disable-tftp --enable-https --enable-http --enable-mime --disable-threaded-resolver --without-zsh-functions-dir --without-fish-functions-dir --with-ssl=__BUILD_DIR__ --with-zlib=__BUILD_DIR__ diff --git a/inc/Makefile.am b/inc/Makefile.am index 05db39c4310193702ca810f17495b18996c2b293..afce1bebac2c09336e06f9c33c9fe37b09963a22 100644 --- a/inc/Makefile.am +++ b/inc/Makefile.am @@ -1,3 +1,3 @@ nobase_include_HEADERS = lektor/cmd.h lektor/commands.h lektor/config.h lektor/database.h -nobase_include_HEADERS += lektor/mkv.h lektor/net.h lektor/reg.h lektor/thread.h lektor/uri.h -nobase_include_HEADERS += lektor/bufferfd.h lektor/common.h lektor/queue.h lektor/stack.h +nobase_include_HEADERS += lektor/mkv.h lektor/net.h lektor/reg.h lektor/uri.h lektor/common.h +nobase_include_HEADERS += lektor/bufferfd.h lektor/queue.h diff --git a/inc/Makefile.in b/inc/Makefile.in index 593219d58d87af72d2559d54e4a57865d6d39d4d..d5666c2876542f6ad4f674631431253cbae47b64 100644 --- a/inc/Makefile.in +++ b/inc/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -293,6 +293,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -303,8 +304,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ nobase_include_HEADERS = lektor/cmd.h lektor/commands.h \ lektor/config.h lektor/database.h lektor/mkv.h lektor/net.h \ - lektor/reg.h lektor/thread.h lektor/uri.h lektor/bufferfd.h \ - lektor/common.h lektor/queue.h lektor/stack.h + lektor/reg.h lektor/uri.h lektor/common.h lektor/bufferfd.h \ + lektor/queue.h all: all-am .SUFFIXES: diff --git a/inc/lektor/common.h b/inc/lektor/common.h index c65f732a5fc441a5d90858350852c337ef4af2ad..fc797c50e74e5b0a31340008c0b720973df55be9 100644 --- a/inc/lektor/common.h +++ b/inc/lektor/common.h @@ -51,13 +51,14 @@ extern void (*__lkt_assert)(const char *file, int line, const char *func, const #endif /* Custom log functions. */ -extern int log_level; enum log_level { ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4, + __LAST_UNUSED_LOG_LEVEL, /* Usefull to enable all by default */ }; +extern enum log_level __log_level; void __lkt_log(enum log_level, const char *section, const char *func, const char *format, ...); #define LOG_INFO( section, ...) __lkt_log(INFO, section, __func__, __VA_ARGS__) #define LOG_WARN( section, ...) __lkt_log(WARN, section, __func__, __VA_ARGS__) diff --git a/inc/lektor/lktconfig.h.in~ b/inc/lektor/lktconfig.h.in~ index 833b96d19dd348b08db54231b44b31647d5db6d9..80c0bb02b6a4d88abf2a97933ef08b79bbe9e9aa 100644 --- a/inc/lektor/lktconfig.h.in~ +++ b/inc/lektor/lktconfig.h.in~ @@ -1,8 +1,5 @@ /* inc/lektor/lktconfig.h.in. Generated from configure.ac by autoheader. */ -/* Define to 1 if you have the <assert.h> header file. */ -#undef HAVE_ASSERT_H - /* Define to 1 if you have the <ctypes.h> header file. */ #undef HAVE_CTYPES_H @@ -84,6 +81,9 @@ /* Little endian */ #undef LKT_ENDIANES_LITTLE +/* Depends lib dir */ +#undef LKT_LIB_DIR + /* Path to the man executable */ #undef LKT_MAN_BINARY diff --git a/inc/lektor/lktmodule.h b/inc/lektor/lktmodule.h new file mode 100644 index 0000000000000000000000000000000000000000..3ec608e87f7e17b35db82317a8e5fd7bcc0f4ef5 --- /dev/null +++ b/inc/lektor/lktmodule.h @@ -0,0 +1,24 @@ +#if ! defined(__LKT_LKTMODULE_H__) +#define __LKT_LKTMODULE_H__ + +/* The single header modules can use from lektor */ + +/* Include header */ + +#include <lektor/lktconfig.h> +#include <lektor/common.h> +#include <lektor/queue.h> +#include <lektor/database.h> +#include <lektor/net.h> +#include <lektor/reg.h> +#include <lektor/stack.h> + +/* Include source files, only do it once per module ! */ +#if defined(__LKT_MODULE_MAIN_SOURCE__) && ! defined(LKT_STATIC_MODULE) +#include "../../src/base/common.c" +#include "../../src/base/stack.c" +#include "../../src/database/queue.c" +#include "../../src/module/thread.c" +#endif /* __LKT_MODULE_MAIN_SOURCE__ && ! LKT_STATIC_MODULE*/ + +#endif /* __LKT_LKTMODULE_H__ */ diff --git a/inc/lektor/net.h b/inc/lektor/net.h index d74fa7c6b2fdaf9e0a10e99cc89bf3c4b771b959..4ec9c4f89fe62677cf233083548846d8714c7af2 100644 --- a/inc/lektor/net.h +++ b/inc/lektor/net.h @@ -5,7 +5,6 @@ #include <lektor/queue.h> #include <lektor/mkv.h> #include <lektor/config.h> -#include <lektor/thread.h> #include <lektor/reg.h> #include <lektor/uri.h> diff --git a/inc/lektor/queue.h b/inc/lektor/queue.h index f62bad11b520f91ee329bf484e84a631c4a6faa7..1332a2e6bdf5d65fd1a155703a383a11ef0d888c 100644 --- a/inc/lektor/queue.h +++ b/inc/lektor/queue.h @@ -1,7 +1,16 @@ #if ! defined(__LKT_QUEUE_H__) #define __LKT_QUEUE_H__ +#define _POSIX_C_SOURCE 200809L + +/* Everything in this file is implemented in the header, so that modules don't + have to compile the lib with another .c file. */ #include <pthread.h> +#include <errno.h> +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <stdio.h> #include <lektor/common.h> enum { @@ -59,12 +68,93 @@ struct queue { volatile int available; }; -int lkt_queue_new(struct queue *); -void lkt_queue_free(struct queue *); +static inline int +lkt_queue_new(struct queue *ret) +{ + if (!ret) + return 1; + + pthread_mutex_t mxt = PTHREAD_MUTEX_INITIALIZER; + struct queue _ret = { + .contents = malloc(LKT_DEFAULT_LIST_SIZE * sizeof(lkt_event)), + .size = LKT_DEFAULT_LIST_SIZE, + .last = 0, + .available = 0, + .lock = mxt, + }; + + if (_ret.contents == NULL) + return 1; + + *ret = _ret; + return 0; +} + +static inline void +lkt_queue_free(struct queue *queue) +{ + pthread_mutex_lock(&queue->lock); + if (queue && queue->contents) + free((void *) queue->contents); + pthread_mutex_unlock(&queue->lock); +} + +static inline void +lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr) +{ + pthread_mutex_lock(&queue->lock); + GOTO_UNLESS(queue, "Invalid argument", end) + + volatile lkt_event *new; + if (queue->size == queue->last) { + new = realloc((void *) queue->contents, queue->size * 2 * sizeof(lkt_event)); + + if (NULL == new) + goto end; + + queue->contents = new; + queue->size *= 2; + } + + lkt_event evt = { + .type = _type, + .attr = _attr, + }; + queue->contents[(queue->last)++] = evt; + + if (! (_type & queue->available)) + LOG_WARN("QUEUE", "The event %d is not available, push it anyway", _type); +end: + pthread_mutex_unlock(&queue->lock); +} + +static inline lkt_event +lkt_queue_handle(struct queue *queue) +{ + pthread_mutex_lock(&queue->lock); + lkt_event ret = {0}; + if (!queue || !queue->last) + goto end; + if (! (queue->contents[0].type & queue->available) && + queue->contents[0].type) { + LOG_WARN("QUEUE", "Event %d is not available", queue->contents[0].type); + goto end; + } -void lkt_queue_send(struct queue *, enum lkt_event_type, void *attr); -lkt_event lkt_queue_handle(struct queue *); + ret = queue->contents[0]; + memmove((void *) queue->contents, (void *) (queue->contents + 1), + --(queue->last)); +end: + pthread_mutex_unlock(&queue->lock); + return ret; +} -void lkt_queue_make_available(struct queue *, enum lkt_event_type); +static inline void +lkt_queue_make_available(struct queue *queue, enum lkt_event_type type) +{ + pthread_mutex_lock(&queue->lock); + queue->available |= type; + pthread_mutex_unlock(&queue->lock); +} #endif /* __LKT_QUEUE_H__ */ diff --git a/man/Makefile.in b/man/Makefile.in index 38997f6e53f19d9ccc90b13ad04c547a0ba422f2..a1b42e965faca9892119f6f571e47255a271f87f 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -275,6 +275,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/man/lkt.template b/man/lkt.template index 20d33de3eb62f0a5b669659685ac4c1b6c353e55..3ae343ed531cb4e09e830ab6283cb351a623ce87 100644 --- a/man/lkt.template +++ b/man/lkt.template @@ -253,8 +253,8 @@ Here are some examples of queries: \fBtype OP\fP Select karas that are openings .TP -\fBauthor k%\fP -Select karas where the author begin with the character "k" +\fBauthor kubat\fP +Select karas where the author is "kubat" .PP .SH "EXAMPLES" diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 22137a8afef1283575adbaa3c312bd74c8fa0513..5df33ea4b98945103ad38f1627e704dc48600dd1 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -246,6 +246,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/scripts/cscope.bash b/scripts/cscope.bash deleted file mode 100755 index d3dc11d66d13a9af999a6ddb87f8efab4af40b05..0000000000000000000000000000000000000000 --- a/scripts/cscope.bash +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -find . -iname '*.c' -o -iname '*.h' > cscope.files -cscope -b -i cscope.files -f cscope.out -ctags -R . diff --git a/scripts/depends.bash b/scripts/depends.bash new file mode 100755 index 0000000000000000000000000000000000000000..28edb7b1a829f5e4401ea83cfdad3a82b24fd1ff --- /dev/null +++ b/scripts/depends.bash @@ -0,0 +1,183 @@ +#!/bin/bash + +DEPENDS_FILE=depends/depends.txt +RULES_FILE=depends/rules.txt +BUILD_DIR="$1" +ROOT_DIR="$PWD" +NPROC=`getconf _NPROCESSORS_ONLN` +ABS_BUILD_DIR=`realpath $BUILD_DIR` + +function die () +{ + echo "ERROR: $*" + exit 1 +} + +function curl () +{ + $CURL $1 --output $2 2>/dev/null >/dev/null + [ $? -ne 0 ] && die "Failed to download $1 and save it to $2" +} + +function wget () +{ + $WGET $1 -O $2 2>/dev/null >/dev/null + [ $? -ne 0 ] && die "Failed to download $1" +} + +function git () +{ + local URL=$1 + local DEST=$2 + shift 2 + $GIT clone $URL $DEST $* + [ $? -ne 0 ] && die "Failed to clone $URL into folder $DEST with options $OPT" +} + +function get () +{ + local NUM=$1 + shift + echo $* | cut -d' ' -f$NUM - +} + +function get_from () +{ + local NUM=$1 + shift + echo $* | cut -d' ' -f$NUM- - +} + +function untar () +{ + local OLD=`tar tf depends/$1 | cut -d'/' -f1 - | uniq` + (cd depends && $TAR xzf $1 --transform="s!^$OLD!$2!") +} + +[ "x${BUILD_DIR}" = "x" ] && die "You must specify the lektor's build folder as the first argument" +echo "Lektor's build file is $BUILD_DIR" + +CURL=`which curl 2>/dev/null` +[ $? -ne 0 ] && die "Failed to find the curl binary" +WGET=`which wget 2>/dev/null` +[ $? -ne 0 ] && die "Failed to find the wget binary" +TAR=`which tar 2>/dev/null` +[ $? -ne 0 ] && die "Failed to find the tar binary" +GIT=`which git 2>/dev/null` +[ $? -ne 0 ] && die "Failed to find the git binary" + +! [ -f $DEPENDS_FILE ] && die "You must run this script from the root of the project" +! [ -f $PWD/scripts/depends.bash ] && die "You must run thus script from the root of the project" +! [ -d $BUILD_DIR/depends_install ] && mkdir $BUILD_DIR/depends_install +! [ -d $BUILD_DIR/depends_install ] && die "Failed to create depends install folder" + +######################### +# Download dependencies # +######################### + +! [ -d depends ] && mkdir depends + +while read LINE +do + FUNC=`get 1 $LINE` + FOLD=`get 2 $LINE` + URL=`get 3 $LINE` + DEST=`get 4 $LINE` + OPT=`get_from 5 $LINE` + + if [ -f depends/$DEST ] || [ -d depends/$DEST ] + then + echo "Dependency $FOLD is already downloaded," \ + "remove depends/$DEST and depends/$DEST to re-download it" + continue + fi + + echo "Downloading $FOLD from $URL to depends/$DEST" + case $FUNC in + wget) + wget $URL depends/$DEST + ;; + curl) + curl $URL depends/$DEST + ;; + git) + git $URL depends/$DEST $OPT + ;; + esac +done < $DEPENDS_FILE + +################################## +# Extract dependencies and build # +################################## + +while read LINE +do + FOLD=`get 2 $LINE` + FILE=`get 4 $LINE` + if [ -d depends/$FOLD ] + then + echo "Skip already extracted folder depends/$FOLD" + continue + fi + echo "Extract file depends/$FILE to depends/$FOLD" + untar $FILE $FOLD +done < $DEPENDS_FILE + +while read LINE +do + FOLD=`get 1 $LINE` + TYPE=`get 2 $LINE` + OPT=`get_from 3 $LINE` + + # Replace __VARIABLES__ from the OPT variable + OPT=`echo "$OPT" | sed -e "s+__BUILD_DIR__+$BUILD_DIR/depends_install/+g"` + + ! [ -d $BUILD_DIR/depends/$FOLD ] && mkdir -p $BUILD_DIR/depends/$FOLD + ! [ -d $BUILD_DIR/depends/$FOLD ] && die "Failed to create the build folder" \ + "for $FOLD" + + if [ -f $BUILD_DIR/depends/$FOLD/.lektor ] + then + echo "Skip already built folder $FOLD, if you want to rebuild it," \ + "remove file $BUILD_DIR/depends/$FOLD/.lektor" + continue + fi + + # Go to right folder + cd $BUILD_DIR/depends/$FOLD + + # Types of builds + case "$TYPE" in + configure) + $ROOT_DIR/depends/$FOLD/configure --prefix=$ABS_BUILD_DIR/depends_install CC=$CC CXX=$CXX $OPT + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + zconfigure) + # The CC= and CXX= doesn't work for zlib + # TODO pour le Kubat du futur: trouver un moyen uniforme de passer le '-fPIC' + CC=$CC CXX=$CXX CFLAGS="-fPIC" $ROOT_DIR/depends/$FOLD/configure --prefix=$ABS_BUILD_DIR/depends_install $OPT + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + sslconfigure) + # Yes, we need to call Configure and not configure here... + # TODO pour le Kubat du futur: trouver un moyen de pas ardcoder le linux-x86_64 (build FreeBSD, OSX et autres) + CC=$CC CXX=$CXX $ROOT_DIR/depends/$FOLD/Configure --prefix=$ABS_BUILD_DIR/depends_install $OPT linux-x86_64 + [ $? -ne 0 ] && die "Failed to configure $FOLD" + ;; + esac + + # Common part + make -j$NPROC + [ $? -ne 0 ] && die "Failed to make $FOLD, build folder is $BUILD_DIR/depends/$FOLD" + make install + [ $? -ne 0 ] && die "Failed to install $FOLD, build folder is " \ + "$BUILD_DIR/depends/$FOLD, install folder " \ + "is $ROOT_DIR/depends_install" + + # Exit folder and mark it as compiled + touch .lektor + cd $ROOT_DIR + echo "Finished to build $FOLD, result is in $BUILD_DIR/depends/$FOLD" +done < $RULES_FILE + +# vim:syntax=sh ts=4 sw=4 expandtab diff --git a/scripts/tags.bash b/scripts/tags.bash new file mode 100755 index 0000000000000000000000000000000000000000..29b137c2f7947cebf87e174226c64826ad45542b --- /dev/null +++ b/scripts/tags.bash @@ -0,0 +1,5 @@ +#!/bin/sh + +find . -iname '*.c' -o -iname '*.h' | egrep -v '^\.\/depends' > cscope.files +cscope -b -i cscope.files -f cscope.out +ctags -R ./inc ./src diff --git a/src/Makefile.am b/src/Makefile.am index 11f477f72c84f4f46682a41a059b51a851aca77f..81cf2669fae29d72843a349e228e52fa6de4b4e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,7 +14,7 @@ endif ## REPO module liblktmodrepo_la_SOURCES = module/module_repo.c module/worker.c liblktmodrepo_la_CFLAGS = -fPIC -liblktmodrepo_la_LDFLAGS = -avoid-version -pthread +liblktmodrepo_la_LDFLAGS = -avoid-version -pthread -ljson-c -lcurl if LKT_STATIC_MODULE liblktmodrepo_la_LDFLAGS += -static else @@ -35,8 +35,7 @@ endif ## Lib lektor # Base sources liblektor_la_SOURCES = base/bufferfd.c base/cmd.c base/common.c base/config.c -liblektor_la_SOURCES += base/queue.c base/reg.c base/stack.c base/uri.c -liblektor_la_SOURCES += base/thread.c base/commands.c +liblektor_la_SOURCES += base/reg.c base/uri.c base/commands.c base/stack.c # Database sources liblektor_la_SOURCES += database/disk.c database/memory.c @@ -52,12 +51,17 @@ liblektor_la_SOURCES += net/command.c net/listen.c net/message.c # Liblektor configuration liblektor_la_CFLAGS = -fPIC -liblektor_la_LDFLAGS = -avoid-version -shared -pthread -ljson-c -lsqlite3 -lcurl +liblektor_la_LDFLAGS = -avoid-version -shared -pthread -lsqlite3 if LKT_STATIC_MODULE liblektor_la_LDFLAGS += -lSDL2 -lmpv liblektor_la_LIBADD = liblktmodsdl.la liblktmodrepo.la endif +# TODO pour le Kubat du futur: c'est pas beau, trouver un truc pour que ça se fasse tout seul +if LKT_STATIC_MODULE +liblektor_la_SOURCES += module/thread.c +endif + # Generated with `xxd` database/disk.c: database/disk.sql @echo '__attribute__((unused)) unsigned char ___src_database_disk_sql[] = { ' > $@ diff --git a/src/Makefile.in b/src/Makefile.in index 94c2556c46e9ca77494e2019fa517ec21ff7d15a..31e9041c838020004e10a9d999f585c0e0c00d68 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -94,6 +94,9 @@ host_triplet = @host@ @LKT_STATIC_MODULE_TRUE@am__append_3 = -static @LKT_STATIC_MODULE_FALSE@am__append_4 = -shared @LKT_STATIC_MODULE_TRUE@am__append_5 = -lSDL2 -lmpv + +# TODO pour le Kubat du futur: c'est pas beau, trouver un truc pour que ça se fasse tout seul +@LKT_STATIC_MODULE_TRUE@am__append_6 = module/thread.c bin_PROGRAMS = lektord$(EXEEXT) lkt$(EXEEXT) subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -142,13 +145,21 @@ am__uninstall_files_from_dir = { \ LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) @LKT_STATIC_MODULE_TRUE@liblektor_la_DEPENDENCIES = liblktmodsdl.la \ @LKT_STATIC_MODULE_TRUE@ liblktmodrepo.la +am__liblektor_la_SOURCES_DIST = base/bufferfd.c base/cmd.c \ + base/common.c base/config.c base/reg.c base/uri.c \ + base/commands.c base/stack.c database/disk.c database/memory.c \ + database/open.c database/playlist.c database/queue.c \ + database/stickers.c database/update.c database/user.c \ + database/config.c database/find.c mkv/mkv.c mkv/utils.c \ + mkv/write.c net/command.c net/listen.c net/message.c \ + module/thread.c am__dirstamp = $(am__leading_dot)dirstamp +@LKT_STATIC_MODULE_TRUE@am__objects_1 = module/liblektor_la-thread.lo am_liblektor_la_OBJECTS = base/liblektor_la-bufferfd.lo \ base/liblektor_la-cmd.lo base/liblektor_la-common.lo \ - base/liblektor_la-config.lo base/liblektor_la-queue.lo \ - base/liblektor_la-reg.lo base/liblektor_la-stack.lo \ - base/liblektor_la-uri.lo base/liblektor_la-thread.lo \ - base/liblektor_la-commands.lo database/liblektor_la-disk.lo \ + base/liblektor_la-config.lo base/liblektor_la-reg.lo \ + base/liblektor_la-uri.lo base/liblektor_la-commands.lo \ + base/liblektor_la-stack.lo database/liblektor_la-disk.lo \ database/liblektor_la-memory.lo database/liblektor_la-open.lo \ database/liblektor_la-playlist.lo \ database/liblektor_la-queue.lo \ @@ -157,7 +168,8 @@ am_liblektor_la_OBJECTS = base/liblektor_la-bufferfd.lo \ database/liblektor_la-config.lo database/liblektor_la-find.lo \ mkv/liblektor_la-mkv.lo mkv/liblektor_la-utils.lo \ mkv/liblektor_la-write.lo net/liblektor_la-command.lo \ - net/liblektor_la-listen.lo net/liblektor_la-message.lo + net/liblektor_la-listen.lo net/liblektor_la-message.lo \ + $(am__objects_1) liblektor_la_OBJECTS = $(am_liblektor_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -216,10 +228,8 @@ am__depfiles_remade = base/$(DEPDIR)/cmd.Po base/$(DEPDIR)/common.Po \ base/$(DEPDIR)/liblektor_la-commands.Plo \ base/$(DEPDIR)/liblektor_la-common.Plo \ base/$(DEPDIR)/liblektor_la-config.Plo \ - base/$(DEPDIR)/liblektor_la-queue.Plo \ base/$(DEPDIR)/liblektor_la-reg.Plo \ base/$(DEPDIR)/liblektor_la-stack.Plo \ - base/$(DEPDIR)/liblektor_la-thread.Plo \ base/$(DEPDIR)/liblektor_la-uri.Plo \ database/$(DEPDIR)/liblektor_la-config.Plo \ database/$(DEPDIR)/liblektor_la-disk.Plo \ @@ -234,6 +244,7 @@ am__depfiles_remade = base/$(DEPDIR)/cmd.Po base/$(DEPDIR)/common.Po \ main/$(DEPDIR)/server.Po mkv/$(DEPDIR)/liblektor_la-mkv.Plo \ mkv/$(DEPDIR)/liblektor_la-utils.Plo \ mkv/$(DEPDIR)/liblektor_la-write.Plo \ + module/$(DEPDIR)/liblektor_la-thread.Plo \ module/$(DEPDIR)/liblktmodrepo_la-module_repo.Plo \ module/$(DEPDIR)/liblktmodrepo_la-worker.Plo \ module/$(DEPDIR)/liblktmodsdl_la-module_sdl2.Plo \ @@ -262,8 +273,9 @@ am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(liblektor_la_SOURCES) $(liblktmodrepo_la_SOURCES) \ $(liblktmodsdl_la_SOURCES) $(lektord_SOURCES) $(lkt_SOURCES) -DIST_SOURCES = $(liblektor_la_SOURCES) $(liblktmodrepo_la_SOURCES) \ - $(liblktmodsdl_la_SOURCES) $(lektord_SOURCES) $(lkt_SOURCES) +DIST_SOURCES = $(am__liblektor_la_SOURCES_DIST) \ + $(liblktmodrepo_la_SOURCES) $(liblktmodsdl_la_SOURCES) \ + $(lektord_SOURCES) $(lkt_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -410,6 +422,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -427,8 +440,8 @@ AM_CPPFLAGS = -I$(abs_top_srcdir)/inc/ -I$(abs_top_builddir)/inc/ @LKT_STATIC_MODULE_TRUE@lib_LTLIBRARIES = liblektor.la liblktmodrepo_la_SOURCES = module/module_repo.c module/worker.c liblktmodrepo_la_CFLAGS = -fPIC -liblktmodrepo_la_LDFLAGS = -avoid-version -pthread $(am__append_1) \ - $(am__append_2) +liblktmodrepo_la_LDFLAGS = -avoid-version -pthread -ljson-c -lcurl \ + $(am__append_1) $(am__append_2) liblktmodsdl_la_SOURCES = module/module_sdl2.c module/mpv.c liblktmodsdl_la_CFLAGS = -fPIC `sdl2-config --cflags` liblktmodsdl_la_LDFLAGS = -avoid-version -pthread -lmpv \ @@ -443,18 +456,17 @@ liblktmodsdl_la_LIBADD = -lSDL2 -lmpv # Net sources liblektor_la_SOURCES = base/bufferfd.c base/cmd.c base/common.c \ - base/config.c base/queue.c base/reg.c base/stack.c base/uri.c \ - base/thread.c base/commands.c database/disk.c \ - database/memory.c database/open.c database/playlist.c \ - database/queue.c database/stickers.c database/update.c \ - database/user.c database/config.c database/find.c mkv/mkv.c \ - mkv/utils.c mkv/write.c net/command.c net/listen.c \ - net/message.c + base/config.c base/reg.c base/uri.c base/commands.c \ + base/stack.c database/disk.c database/memory.c database/open.c \ + database/playlist.c database/queue.c database/stickers.c \ + database/update.c database/user.c database/config.c \ + database/find.c mkv/mkv.c mkv/utils.c mkv/write.c \ + net/command.c net/listen.c net/message.c $(am__append_6) # Liblektor configuration liblektor_la_CFLAGS = -fPIC -liblektor_la_LDFLAGS = -avoid-version -shared -pthread -ljson-c \ - -lsqlite3 -lcurl $(am__append_5) +liblektor_la_LDFLAGS = -avoid-version -shared -pthread -lsqlite3 \ + $(am__append_5) @LKT_STATIC_MODULE_TRUE@liblektor_la_LIBADD = liblktmodsdl.la liblktmodrepo.la CLEANFILES = database/disk.c database/memory.c EXTRA_DIST = database/disk.sql database/memory.sql @@ -619,18 +631,14 @@ base/liblektor_la-common.lo: base/$(am__dirstamp) \ base/$(DEPDIR)/$(am__dirstamp) base/liblektor_la-config.lo: base/$(am__dirstamp) \ base/$(DEPDIR)/$(am__dirstamp) -base/liblektor_la-queue.lo: base/$(am__dirstamp) \ - base/$(DEPDIR)/$(am__dirstamp) base/liblektor_la-reg.lo: base/$(am__dirstamp) \ base/$(DEPDIR)/$(am__dirstamp) -base/liblektor_la-stack.lo: base/$(am__dirstamp) \ - base/$(DEPDIR)/$(am__dirstamp) base/liblektor_la-uri.lo: base/$(am__dirstamp) \ base/$(DEPDIR)/$(am__dirstamp) -base/liblektor_la-thread.lo: base/$(am__dirstamp) \ - base/$(DEPDIR)/$(am__dirstamp) base/liblektor_la-commands.lo: base/$(am__dirstamp) \ base/$(DEPDIR)/$(am__dirstamp) +base/liblektor_la-stack.lo: base/$(am__dirstamp) \ + base/$(DEPDIR)/$(am__dirstamp) database/$(am__dirstamp): @$(MKDIR_P) database @: > database/$(am__dirstamp) @@ -681,15 +689,17 @@ net/liblektor_la-listen.lo: net/$(am__dirstamp) \ net/$(DEPDIR)/$(am__dirstamp) net/liblektor_la-message.lo: net/$(am__dirstamp) \ net/$(DEPDIR)/$(am__dirstamp) - -liblektor.la: $(liblektor_la_OBJECTS) $(liblektor_la_DEPENDENCIES) $(EXTRA_liblektor_la_DEPENDENCIES) - $(AM_V_CCLD)$(liblektor_la_LINK) $(am_liblektor_la_rpath) $(liblektor_la_OBJECTS) $(liblektor_la_LIBADD) $(LIBS) module/$(am__dirstamp): @$(MKDIR_P) module @: > module/$(am__dirstamp) module/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) module/$(DEPDIR) @: > module/$(DEPDIR)/$(am__dirstamp) +module/liblektor_la-thread.lo: module/$(am__dirstamp) \ + module/$(DEPDIR)/$(am__dirstamp) + +liblektor.la: $(liblektor_la_OBJECTS) $(liblektor_la_DEPENDENCIES) $(EXTRA_liblektor_la_DEPENDENCIES) + $(AM_V_CCLD)$(liblektor_la_LINK) $(am_liblektor_la_rpath) $(liblektor_la_OBJECTS) $(liblektor_la_LIBADD) $(LIBS) module/liblktmodrepo_la-module_repo.lo: module/$(am__dirstamp) \ module/$(DEPDIR)/$(am__dirstamp) module/liblktmodrepo_la-worker.lo: module/$(am__dirstamp) \ @@ -751,10 +761,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-commands.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-common.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-config.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-queue.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-reg.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-stack.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-thread.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@base/$(DEPDIR)/liblektor_la-uri.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@database/$(DEPDIR)/liblektor_la-config.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@database/$(DEPDIR)/liblektor_la-disk.Plo@am__quote@ # am--include-marker @@ -771,6 +779,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@mkv/$(DEPDIR)/liblektor_la-mkv.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@mkv/$(DEPDIR)/liblektor_la-utils.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@mkv/$(DEPDIR)/liblektor_la-write.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@module/$(DEPDIR)/liblektor_la-thread.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@module/$(DEPDIR)/liblktmodrepo_la-module_repo.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@module/$(DEPDIR)/liblktmodrepo_la-worker.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@module/$(DEPDIR)/liblktmodsdl_la-module_sdl2.Plo@am__quote@ # am--include-marker @@ -837,13 +846,6 @@ base/liblektor_la-config.lo: base/config.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-config.lo `test -f 'base/config.c' || echo '$(srcdir)/'`base/config.c -base/liblektor_la-queue.lo: base/queue.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-queue.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-queue.Tpo -c -o base/liblektor_la-queue.lo `test -f 'base/queue.c' || echo '$(srcdir)/'`base/queue.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-queue.Tpo base/$(DEPDIR)/liblektor_la-queue.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='base/queue.c' object='base/liblektor_la-queue.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-queue.lo `test -f 'base/queue.c' || echo '$(srcdir)/'`base/queue.c - base/liblektor_la-reg.lo: base/reg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-reg.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-reg.Tpo -c -o base/liblektor_la-reg.lo `test -f 'base/reg.c' || echo '$(srcdir)/'`base/reg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-reg.Tpo base/$(DEPDIR)/liblektor_la-reg.Plo @@ -851,13 +853,6 @@ base/liblektor_la-reg.lo: base/reg.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-reg.lo `test -f 'base/reg.c' || echo '$(srcdir)/'`base/reg.c -base/liblektor_la-stack.lo: base/stack.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-stack.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-stack.Tpo -c -o base/liblektor_la-stack.lo `test -f 'base/stack.c' || echo '$(srcdir)/'`base/stack.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-stack.Tpo base/$(DEPDIR)/liblektor_la-stack.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='base/stack.c' object='base/liblektor_la-stack.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-stack.lo `test -f 'base/stack.c' || echo '$(srcdir)/'`base/stack.c - base/liblektor_la-uri.lo: base/uri.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-uri.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-uri.Tpo -c -o base/liblektor_la-uri.lo `test -f 'base/uri.c' || echo '$(srcdir)/'`base/uri.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-uri.Tpo base/$(DEPDIR)/liblektor_la-uri.Plo @@ -865,13 +860,6 @@ base/liblektor_la-uri.lo: base/uri.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-uri.lo `test -f 'base/uri.c' || echo '$(srcdir)/'`base/uri.c -base/liblektor_la-thread.lo: base/thread.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-thread.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-thread.Tpo -c -o base/liblektor_la-thread.lo `test -f 'base/thread.c' || echo '$(srcdir)/'`base/thread.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-thread.Tpo base/$(DEPDIR)/liblektor_la-thread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='base/thread.c' object='base/liblektor_la-thread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-thread.lo `test -f 'base/thread.c' || echo '$(srcdir)/'`base/thread.c - base/liblektor_la-commands.lo: base/commands.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-commands.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-commands.Tpo -c -o base/liblektor_la-commands.lo `test -f 'base/commands.c' || echo '$(srcdir)/'`base/commands.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-commands.Tpo base/$(DEPDIR)/liblektor_la-commands.Plo @@ -879,6 +867,13 @@ base/liblektor_la-commands.lo: base/commands.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-commands.lo `test -f 'base/commands.c' || echo '$(srcdir)/'`base/commands.c +base/liblektor_la-stack.lo: base/stack.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT base/liblektor_la-stack.lo -MD -MP -MF base/$(DEPDIR)/liblektor_la-stack.Tpo -c -o base/liblektor_la-stack.lo `test -f 'base/stack.c' || echo '$(srcdir)/'`base/stack.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) base/$(DEPDIR)/liblektor_la-stack.Tpo base/$(DEPDIR)/liblektor_la-stack.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='base/stack.c' object='base/liblektor_la-stack.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o base/liblektor_la-stack.lo `test -f 'base/stack.c' || echo '$(srcdir)/'`base/stack.c + database/liblektor_la-disk.lo: database/disk.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT database/liblektor_la-disk.lo -MD -MP -MF database/$(DEPDIR)/liblektor_la-disk.Tpo -c -o database/liblektor_la-disk.lo `test -f 'database/disk.c' || echo '$(srcdir)/'`database/disk.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) database/$(DEPDIR)/liblektor_la-disk.Tpo database/$(DEPDIR)/liblektor_la-disk.Plo @@ -991,6 +986,13 @@ net/liblektor_la-message.lo: net/message.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o net/liblektor_la-message.lo `test -f 'net/message.c' || echo '$(srcdir)/'`net/message.c +module/liblektor_la-thread.lo: module/thread.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -MT module/liblektor_la-thread.lo -MD -MP -MF module/$(DEPDIR)/liblektor_la-thread.Tpo -c -o module/liblektor_la-thread.lo `test -f 'module/thread.c' || echo '$(srcdir)/'`module/thread.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) module/$(DEPDIR)/liblektor_la-thread.Tpo module/$(DEPDIR)/liblektor_la-thread.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='module/thread.c' object='module/liblektor_la-thread.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblektor_la_CFLAGS) $(CFLAGS) -c -o module/liblektor_la-thread.lo `test -f 'module/thread.c' || echo '$(srcdir)/'`module/thread.c + module/liblktmodrepo_la-module_repo.lo: module/module_repo.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblktmodrepo_la_CFLAGS) $(CFLAGS) -MT module/liblktmodrepo_la-module_repo.lo -MD -MP -MF module/$(DEPDIR)/liblktmodrepo_la-module_repo.Tpo -c -o module/liblktmodrepo_la-module_repo.lo `test -f 'module/module_repo.c' || echo '$(srcdir)/'`module/module_repo.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) module/$(DEPDIR)/liblktmodrepo_la-module_repo.Tpo module/$(DEPDIR)/liblktmodrepo_la-module_repo.Plo @@ -1180,10 +1182,8 @@ distclean: distclean-am -rm -f base/$(DEPDIR)/liblektor_la-commands.Plo -rm -f base/$(DEPDIR)/liblektor_la-common.Plo -rm -f base/$(DEPDIR)/liblektor_la-config.Plo - -rm -f base/$(DEPDIR)/liblektor_la-queue.Plo -rm -f base/$(DEPDIR)/liblektor_la-reg.Plo -rm -f base/$(DEPDIR)/liblektor_la-stack.Plo - -rm -f base/$(DEPDIR)/liblektor_la-thread.Plo -rm -f base/$(DEPDIR)/liblektor_la-uri.Plo -rm -f database/$(DEPDIR)/liblektor_la-config.Plo -rm -f database/$(DEPDIR)/liblektor_la-disk.Plo @@ -1200,6 +1200,7 @@ distclean: distclean-am -rm -f mkv/$(DEPDIR)/liblektor_la-mkv.Plo -rm -f mkv/$(DEPDIR)/liblektor_la-utils.Plo -rm -f mkv/$(DEPDIR)/liblektor_la-write.Plo + -rm -f module/$(DEPDIR)/liblektor_la-thread.Plo -rm -f module/$(DEPDIR)/liblktmodrepo_la-module_repo.Plo -rm -f module/$(DEPDIR)/liblktmodrepo_la-worker.Plo -rm -f module/$(DEPDIR)/liblktmodsdl_la-module_sdl2.Plo @@ -1259,10 +1260,8 @@ maintainer-clean: maintainer-clean-am -rm -f base/$(DEPDIR)/liblektor_la-commands.Plo -rm -f base/$(DEPDIR)/liblektor_la-common.Plo -rm -f base/$(DEPDIR)/liblektor_la-config.Plo - -rm -f base/$(DEPDIR)/liblektor_la-queue.Plo -rm -f base/$(DEPDIR)/liblektor_la-reg.Plo -rm -f base/$(DEPDIR)/liblektor_la-stack.Plo - -rm -f base/$(DEPDIR)/liblektor_la-thread.Plo -rm -f base/$(DEPDIR)/liblektor_la-uri.Plo -rm -f database/$(DEPDIR)/liblektor_la-config.Plo -rm -f database/$(DEPDIR)/liblektor_la-disk.Plo @@ -1279,6 +1278,7 @@ maintainer-clean: maintainer-clean-am -rm -f mkv/$(DEPDIR)/liblektor_la-mkv.Plo -rm -f mkv/$(DEPDIR)/liblektor_la-utils.Plo -rm -f mkv/$(DEPDIR)/liblektor_la-write.Plo + -rm -f module/$(DEPDIR)/liblektor_la-thread.Plo -rm -f module/$(DEPDIR)/liblktmodrepo_la-module_repo.Plo -rm -f module/$(DEPDIR)/liblktmodrepo_la-worker.Plo -rm -f module/$(DEPDIR)/liblktmodsdl_la-module_sdl2.Plo diff --git a/src/base/commands.c b/src/base/commands.c index cb0808dd0b67d09af388c956ef0ac8244835875b..65db132a891a3a924f74915d26fca1bdeaf91ee9 100644 --- a/src/base/commands.c +++ b/src/base/commands.c @@ -62,7 +62,8 @@ command_update(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX] } bool -command_rescan(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX], int forced) +command_rescan(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX], + int __attribute__((unused)) forced) { UNUSED(argv); RETURN_UNLESS(lkt_client_auth(srv, c, false), "Failed to authentificate user", false); diff --git a/src/base/common.c b/src/base/common.c index 093e5ff3fe816a7b1bba9e9a04a02031d2fec86a..647b06aaccdba814a0de94c26dbc7032c85542a0 100644 --- a/src/base/common.c +++ b/src/base/common.c @@ -36,7 +36,7 @@ __set_assert(void) /* Log functions */ -int log_level = 0; /* None by default */ +enum log_level __log_level = __LAST_UNUSED_LOG_LEVEL; /* All by default */ void __lkt_log(enum log_level level, const char *section, const char *func, const char *format, ...) @@ -44,7 +44,7 @@ __lkt_log(enum log_level level, const char *section, const char *func, const cha char line[LKT_MESSAGE_MAX]; va_list ap; - if (level <= log_level) { + if (level <= __log_level) { safe_snprintf(line, LKT_MESSAGE_MAX, " %c [%s] %s: %s\n", level == ERROR ? '!' : level == WARN ? '*' : level == INFO ? '.' : ' ', section, func, format); diff --git a/src/base/config.c b/src/base/config.c index 6ec549ae16bb368977914111c8c8d268922a5179..c417c7d0ca8d0f9e7d3a0dabd616dfc9d09175ad 100644 --- a/src/base/config.c +++ b/src/base/config.c @@ -62,17 +62,17 @@ __set_log_level(const char *name, const char *level) } if (STR_MATCH(level, "error")) - log_level = ERROR; + __log_level = ERROR; else if (STR_MATCH(level, "warn") || STR_MATCH(level, "warning")) - log_level = WARN; + __log_level = WARN; else if (STR_MATCH(level, "info")) - log_level = INFO; + __log_level = INFO; else if (STR_MATCH(level, "debug")) - log_level = DEBUG; + __log_level = DEBUG; else - log_level = strtol(level, NULL, 0); + __log_level = strtol(level, NULL, 0); - LOG_INFO("CONFIG", "Log level set to %d", log_level); + LOG_INFO("CONFIG", "Log level set to %d", __log_level); } static inline int @@ -172,12 +172,15 @@ config_default_file(char *dest, size_t len) memset(dest, 0, len * sizeof(char)); char *home = getenv("XDG_CONFIG_HOME"); if (NULL == home || strlen(home) >= len) { + LOG_DEBUG("CONFIG", "No env variable XDG_CONFIG_HOME"); home = getenv("HOME"); if (NULL == home) { LOG_ERROR("FATAL", "Failed to get home folder for user, will now exit"); exit(EXIT_FAILURE); } + safe_strncpy(dest, home, len); strncat(dest, "/.config/lektor/lektor.ini", len - 1); + LOG_DEBUG("CONFIG", "Use '%s' insted of XDG_CONFIG_HOME", home); } else { strncat(dest, "/lektor/lektor.ini", len - 1); } diff --git a/src/base/queue.c b/src/base/queue.c deleted file mode 100644 index ae9be02a664b89d4c48a7de579fc804ba453c60d..0000000000000000000000000000000000000000 --- a/src/base/queue.c +++ /dev/null @@ -1,99 +0,0 @@ -#define _POSIX_C_SOURCE 200809L - -#include <errno.h> -#include <stdlib.h> -#include <stddef.h> -#include <string.h> -#include <stdio.h> -#include <lektor/common.h> -#include <lektor/queue.h> -#include <pthread.h> - -int -lkt_queue_new(struct queue *ret) -{ - if (!ret) - return 1; - - pthread_mutex_t mxt = PTHREAD_MUTEX_INITIALIZER; - struct queue _ret = { - .contents = malloc(LKT_DEFAULT_LIST_SIZE * sizeof(lkt_event)), - .size = LKT_DEFAULT_LIST_SIZE, - .last = 0, - .available = 0, - .lock = mxt, - }; - - if (_ret.contents == NULL) - return 1; - - *ret = _ret; - return 0; -} - -void -lkt_queue_free(struct queue *queue) -{ - pthread_mutex_lock(&queue->lock); - if (queue && queue->contents) - free((void *) queue->contents); - pthread_mutex_unlock(&queue->lock); -} - -void -lkt_queue_send(struct queue *queue, enum lkt_event_type _type, void *_attr) -{ - pthread_mutex_lock(&queue->lock); - GOTO_UNLESS(queue, "Invalid argument", end) - - volatile lkt_event *new; - if (queue->size == queue->last) { - new = realloc((void *) queue->contents, queue->size * 2 * sizeof(lkt_event)); - - if (NULL == new) - goto end; - - queue->contents = new; - queue->size *= 2; - } - - lkt_event evt = { - .type = _type, - .attr = _attr, - }; - queue->contents[(queue->last)++] = evt; - - if (! (_type & queue->available)) - LOG_WARN("QUEUE", "The event %d is not available, push it anyway", _type); -end: - pthread_mutex_unlock(&queue->lock); -} - -lkt_event -lkt_queue_handle(struct queue *queue) -{ - pthread_mutex_lock(&queue->lock); - lkt_event ret = {0}; - if (!queue || !queue->last) - goto end; - if (! (queue->contents[0].type & queue->available) && - queue->contents[0].type) { - LOG_WARN("QUEUE", "Event %d is not available", queue->contents[0].type); - goto end; - } - - ret = queue->contents[0]; - memmove((void *) queue->contents, (void *) (queue->contents + 1), - --(queue->last)); -end: - pthread_mutex_unlock(&queue->lock); - return ret; -} - -void -lkt_queue_make_available(struct queue *queue, enum lkt_event_type type) -{ - pthread_mutex_lock(&queue->lock); - queue->available |= type; - pthread_mutex_unlock(&queue->lock); -} diff --git a/src/database/disk.sql b/src/database/disk.sql index 691a028ac17d7ee836c196089c249f5c8f711484..d1e356f6bb2ac14244e3931dcbd3e0510d65aed9 100644 --- a/src/database/disk.sql +++ b/src/database/disk.sql @@ -77,13 +77,6 @@ CREATE TABLE IF NOT EXISTS queue , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6) ); --- Temporary queue table used when reordering the queue (for inserts) -CREATE TABLE IF NOT EXISTS queue_tmp - ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0) - , kara_id INTEGER - , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6) - ); - -- The user table -- Used for the [password {passwd}] MPD command. The documentation can be found diff --git a/src/database/macro.h b/src/database/macro.h index 76f449021bf6966c1d7e31f0f3e39e311f7cf9f2..da23e82ca954a90e253ddd7b47f914dbdb417ccd 100644 --- a/src/database/macro.h +++ b/src/database/macro.h @@ -3,21 +3,21 @@ #define SQLITE_PREPARE(db, stmt, SQL, goto_label) \ if (sqlite3_prepare_v2((sqlite3 *) db, SQL, -1, &(stmt), 0) != SQLITE_OK) { \ - LOG_ERROR("DB", "Failed to prepare statement: %s", \ + LOG_DEBUG("DB", "Failed to prepare statement: %s", \ sqlite3_errmsg((sqlite3 *) db)); \ goto goto_label; \ } #define SQLITE_EXEC(db, SQL, goto_label) \ if (sqlite3_exec((sqlite3 *) db, SQL, NULL, NULL, NULL) != SQLITE_OK) { \ - LOG_ERROR("DB", "Failed to exec statement: %s", \ + LOG_DEBUG("DB", "Failed to exec statement: %s", \ sqlite3_errmsg((sqlite3 *) db)); \ goto goto_label; \ } #define SQLITE_BIND_TEXT(db, stmt, pos, text, error) { \ if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) { \ - LOG_ERROR("DB", "Failed to bind text %s at pos %d: %s", \ + LOG_DEBUG("DB", "Failed to bind text %s at pos %d: %s", \ (const char *) text, pos, \ sqlite3_errmsg((sqlite3 *) db)); \ goto error; \ @@ -25,14 +25,14 @@ #define SQLITE_BIND_INT(db, stmt, pos, integer, error) { \ if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) { \ - LOG_ERROR("DB", "Failed to bind int %d at pos %d: %s", \ + LOG_DEBUG("DB", "Failed to bind int %d at pos %d: %s", \ integer, pos, sqlite3_errmsg((sqlite3 *) db)); \ goto error; \ }} #define SQLITE_STEP(db, stmt, code, error) \ if (sqlite3_step(stmt) != code) { \ - LOG_ERROR("DB", "Failed to step: %s", \ + LOG_DEBUG("DB", "Failed to step: %s", \ sqlite3_errmsg((sqlite3 *) db)); \ goto error; \ } diff --git a/src/database/memory.sql b/src/database/memory.sql index 5a36f3a9b1392b00d3ad6fe26525b5281602f96d..cdfb70a0f5a26982b8157910d7d9f72c0fa9f5a7 100644 --- a/src/database/memory.sql +++ b/src/database/memory.sql @@ -26,6 +26,14 @@ CREATE TABLE IF NOT EXISTS queue_state INSERT INTO queue_state (id) VALUES (42); +-- Temporary queue table used when reordering the queue (for inserts) +CREATE TABLE IF NOT EXISTS queue_tmp + ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0) + , kara_id INTEGER + , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6) + ); + + -- Used to store the content of the ini configuration file. CREATE TABLE IF NOT EXISTS config diff --git a/src/database/queue.c b/src/database/queue.c index ac5d1181731da4fc42923e8e85aceec6648b0c7d..1b8a8720e3f8c8e3ddbe77342065caa9da1602e1 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -26,7 +26,7 @@ sqlite_just_exec(database_queue_stop, "UPDATE queue_state SET current sqlite_just_exec(database_queue_clear, "DELETE FROM queue;" "DELETE FROM queue_tmp;" "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" - "DELETE FROM sqlite_sequence WHERE name = 'queue';" + "DELETE FROM " LKT_PROTECTED_DATABASE ".sqlite_sequence WHERE name = 'queue';" "UPDATE queue_state SET current = NULL;") sqlite_just_exec(database_config_queue_default, "UPDATE queue_state SET volume = 100, paused = 1," " random = 0, repeat = 0, single = 0, consume = 0," @@ -142,16 +142,21 @@ __queue_reorder(volatile sqlite3 *db) "(SELECT CASE WHEN (SELECT current FROM queue_state) IS NULL THEN 0" \ " ELSE (SELECT current FROM queue_state) END AS val LIMIT 1)" static const char *SQL_REORDER = + /* Clear the TMP */ + "DELETE FROM queue_tmp;" + "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" /* Separate karas that are after the current one */ "INSERT INTO queue_tmp (kara_id, priority)" " SELECT kara_id, priority FROM queue WHERE position > " CURRENT_POS_OR_0 " ORDER BY priority DESC, position ASC;" "DELETE FROM queue WHERE position > " CURRENT_POS_OR_0 ";" + /* Update the sqlite_sequence table */ + "UPDATE sqlite_sequence SET seq = " CURRENT_POS_OR_0 " WHERE name = 'queue';" /* Insert back */ "INSERT INTO queue (position, kara_id, priority)" " SELECT position + " CURRENT_POS_OR_0 ", kara_id, priority" " FROM queue_tmp;" - /* Drop temporary tables */ + /* Clear the TMP */ "DELETE FROM queue_tmp;" "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"; #undef CURRENT_POS_OR_0 @@ -253,12 +258,13 @@ database_queue_add_id(volatile sqlite3 *db, int id, int priority) sqlite3_finalize(stmt); /* Do the move shit only if the priority > 1 */ - reorder(db, priority, error); + reorder(db, priority, error_no_stmt); SQLITE_EXEC(db, "COMMIT;", error); return true; error: sqlite3_finalize(stmt); +error_no_stmt: SQLITE_DO_ROLLBACK(db); return false; } @@ -293,8 +299,9 @@ database_queue_del_id(volatile sqlite3 *db, int id) { static const char *SQL_TEMPLATE = "BEGIN TRANSACTION;" - "CREATE TEMPORARY TABLE IF NOT EXISTS queue_tmp (position INTEGER, kara_id INTEGER, priority INTEGER);" + /* Clear the TMP */ "DELETE FROM queue_tmp;" + "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" /* Move the current 'pointer' */ "UPDATE queue_state SET current = (SELECT NULLIF(COUNT(position), 0) FROM queue JOIN queue_state ON position <= current AND kara_id != %d);" "DELETE FROM queue WHERE kara_id = %d;" /* Delete any kara with the specified id */ @@ -302,6 +309,9 @@ database_queue_del_id(volatile sqlite3 *db, int id) "DELETE FROM queue;" "INSERT INTO queue(priority, position, kara_id) SELECT priority, ROW_NUMBER() OVER(ORDER BY position ASC), kara_id FROM queue_tmp;" "UPDATE sqlite_sequence SET seq = (SELECT COUNT(*) FROM queue) WHERE name = 'queue';" /* Update the sqlite_sequence */ + /* Clear the TMP */ + "DELETE FROM queue_tmp;" + "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" "COMMIT;"; char SQL[LKT_MAX_SQLITE_STATEMENT]; safe_snprintf(SQL, LKT_MAX_SQLITE_STATEMENT, SQL_TEMPLATE, id, id); @@ -570,13 +580,8 @@ database_queue_shuffle(volatile sqlite3 *db) const char *SQL = "BEGIN TRANSACTION;" /* Create temporary queue */ - "CREATE TEMPORARY TABLE IF NOT EXISTS queue_tmp" - " ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)" - " , kara_id INTEGER" - " , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)" - " );" - "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" "DELETE FROM queue_tmp;" + "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" /* When current is NULL, that thing is also NULL, so no insertion is done */ "INSERT INTO queue_tmp (kara_id, priority)" " SELECT kara_id, 5" @@ -603,6 +608,9 @@ database_queue_shuffle(volatile sqlite3 *db) " SET current = CASE" " WHEN current NOT NULL THEN 1" " ELSE NULL END;" + /* Clear the TMP */ + "DELETE FROM queue_tmp;" + "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';" "COMMIT;"; SQLITE_EXEC(db, SQL, error); return true; diff --git a/src/main/lkt.c b/src/main/lkt.c index 042d346729fd039594a4a981a13398d0fc70082a..079a34e1a1f200fc9f8ffd114fe46e15ea8d7581 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -1101,7 +1101,7 @@ parse_args(args_t *args, int argc, const char **argv) int main(int argc, const char **argv) { - log_level = ERROR; + __log_level = ERROR; executable_name = "lkt"; assert(NULL != setlocale(LC_ALL, "en_US.UTF-8")); /* BECAUSE! */ if (signal(SIGPIPE, sigpipe__)) { diff --git a/src/main/server.c b/src/main/server.c index 12515efe639f8f5b5462eaadf6b2423ec12fdb35..cb2e7c2036a4f4d4e3f7aa656d4bdb582185c490 100644 --- a/src/main/server.c +++ b/src/main/server.c @@ -111,7 +111,8 @@ retry_config: __mkdir(conf_file); /* Create the folder for the file. */ FILE *file_desc = fopen(conf_file, "w+"); if (NULL == file_desc) { - LOG_ERROR("FATAL", "Failed to open default config fiel for initializing it"); + LOG_ERROR("FATAL", "Failed to open default config file '%s' to initialize it", + conf_file); exit(EXIT_FAILURE); } config_default(file_desc); diff --git a/src/module/module_repo.c b/src/module/module_repo.c index e11cc7101f547009fa5244e8ebb4a2bf982e7b5c..fffc8ff6ba8f76607876c20354b76f23beb7021c 100644 --- a/src/module/module_repo.c +++ b/src/module/module_repo.c @@ -1,11 +1,7 @@ #define _POSIX_C_SOURCE 200809L -#include <lektor/lktconfig.h> -#include <lektor/common.h> -#include <lektor/queue.h> -#include <lektor/database.h> -#include <lektor/net.h> -#include <lektor/reg.h> +#define __LKT_MODULE_MAIN_SOURCE__ +#include <lektor/lktmodule.h> #include "worker.h" @@ -115,8 +111,7 @@ __safe_json_get_string(struct json_object *jobj, const char *key, { const char *got; struct json_object *field; - RETURN_UNLESS(json_object_object_get_ex(jobj, key, &field), - "Key not found in json", 1); + RETURN_UNLESS(json_object_object_get_ex(jobj, key, &field), "Key not found in json", 1); got = json_object_get_string(field); RETURN_UNLESS(got, "Got a NULL for the key, may be an error", 1); strncpy(content, got, len - 1); @@ -141,13 +136,19 @@ __json_sync(struct module_repo_internal *repo, struct json_object **json) RETURN_UNLESS(json, "Invalid argument", 1); CURL *curl_handle; CURLcode res; + struct curl_slist *headers = NULL; int ret = 1; struct __memory file = { .mem = NULL, .size = 0. }; + /* Only accept json file */ + headers = curl_slist_append(headers, "Accept: application/json"); + headers = curl_slist_append(headers, "Content-Type: application/json"); + curl_handle = curl_easy_init(); + curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle, CURLOPT_URL, repo->get_all_json); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, __write_mem); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &file); @@ -155,7 +156,14 @@ __json_sync(struct module_repo_internal *repo, struct json_object **json) res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { - LOG_ERROR("CURL", "curl_easy_perform failed: %s", curl_easy_strerror(res)); + LOG_ERROR("CURL", "curl_easy_perform failed on url %s: %s", repo->get_all_json, + curl_easy_strerror(res)); + goto err; + } + + /* Check if recieved json is not empty */ + if (file.size == 0) { + LOG_ERROR("CURL", "Gottent file is empty"); goto err; } @@ -164,6 +172,7 @@ __json_sync(struct module_repo_internal *repo, struct json_object **json) err: __clean_memory(&file); curl_easy_cleanup(curl_handle); + curl_slist_free_all(headers); return ret; } diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index 490a0feda7841041ec8152dbdef648e1bac4e08b..8825ee294c37f988e19ed897809e69ca7bfe34e9 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -1,13 +1,10 @@ #define _POSIX_C_SOURCE 200809L -#include <lektor/lktconfig.h> -#include <lektor/common.h> -#include <lektor/queue.h> -#include <lektor/thread.h> -#include <lektor/reg.h> -#include <lektor/net.h> +#define __LKT_MODULE_MAIN_SOURCE__ +#include <lektor/lktmodule.h> #include "mpv.h" +#include "thread.h" #include <sqlite3.h> #include <sched.h> diff --git a/src/module/mpv.c b/src/module/mpv.c index 4d92ecc08dab27b3c8d56010765f829f5c399006..7186bd20ce1f932f41921d748ce97d5c3646cb3e 100644 --- a/src/module/mpv.c +++ b/src/module/mpv.c @@ -3,7 +3,6 @@ #include "mpv.h" #include <lektor/common.h> -#include <lektor/commands.h> #include <lektor/database.h> #include <strings.h> #include <stdio.h> diff --git a/src/base/thread.c b/src/module/thread.c similarity index 99% rename from src/base/thread.c rename to src/module/thread.c index 0ef3bca850c6bb6dcd19f4ddc03d69b1194b1597..fb4a20c11a3eea77f1d6d03928e52143d9031a11 100644 --- a/src/base/thread.c +++ b/src/module/thread.c @@ -1,7 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include <lektor/common.h> -#include <lektor/thread.h> #include <pthread.h> #include <sys/types.h> #include <stdlib.h> @@ -9,6 +8,7 @@ #include <stdio.h> #include <unistd.h> #include <string.h> +#include "thread.h" struct __args { void *(*start)(struct poller_thread_arg *); diff --git a/inc/lektor/thread.h b/src/module/thread.h similarity index 95% rename from inc/lektor/thread.h rename to src/module/thread.h index da681f162cf125a56e18c593bcd6c9f332de27bb..9f41398b31f02033d10538ef9535f63d99d6836c 100644 --- a/inc/lektor/thread.h +++ b/src/module/thread.h @@ -1,8 +1,7 @@ #if ! defined(__LKT_THREAD_H__) #define __LKT_THREAD_H__ -#include <lektor/common.h> -#include <lektor/stack.h> +#include <lektor/lktmodule.h> #include <pthread.h> #include <sys/types.h>