From 05b75f8d50b83e943af3be4071449304d82dbdcd Mon Sep 17 00:00:00 2001 Message-Id: <05b75f8d50b83e943af3be4071449304d82dbdcd.1713883584.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 25 May 2008 19:03:06 +0100 Subject: [PATCH] Source code reorganization: - almost all headers now include common.h, which includes a number of universally necessary headers and declarations - the server programs now have a single disorder-server.h header - the cgi is now in its own directory - plugin exports are limited to those programs that actually need them Organization: Straylight/Edgeware From: Richard Kettlewell --- .bzrignore | 3 +- cgi/Makefile.am | 33 +++ {server => cgi}/actions.c | 0 {server => cgi}/cgimain.c | 0 {server => cgi}/disorder-cgi.h | 5 +- {server => cgi}/login.c | 0 {server => cgi}/lookup.c | 0 {server => cgi}/macros-disorder.c | 0 {server => cgi}/options.c | 0 clients/authorize.c | 4 +- clients/disorder.c | 8 +- clients/disorderfm.c | 4 +- clients/filename-bytes.c | 3 +- clients/playrtp-alsa.c | 4 +- clients/playrtp-coreaudio.c | 5 +- clients/playrtp-mem.c | 5 +- clients/playrtp-oss.c | 5 +- clients/playrtp.c | 7 +- clients/test-eclient.c | 6 +- configure.ac | 3 +- disobedience/disobedience.h | 6 +- doc/Makefile.am | 8 +- driver/disorder.c | 5 +- lib/Makefile.am | 1 - lib/addr.c | 7 +- lib/addr.h | 6 +- lib/alsabg.c | 4 +- lib/asprintf.c | 5 +- lib/authhash.c | 4 +- lib/base64.c | 7 +- lib/basen.c | 5 +- lib/bits.c | 3 +- lib/bits.h | 2 - lib/cache.c | 3 +- lib/cgi.c | 7 +- lib/charset.c | 4 +- lib/charset.h | 3 + lib/client-common.c | 6 +- lib/client-common.h | 3 + lib/client.c | 6 +- lib/client.h | 2 + lib/{types.h => common.h} | 14 +- lib/configuration.c | 6 +- lib/configuration.h | 8 +- lib/cookies.c | 8 +- lib/cookies.h | 2 + lib/dateparse.c | 3 +- lib/dateparse.h | 8 +- lib/defs.c | 3 +- lib/eclient.c | 7 +- lib/event.c | 6 +- lib/eventlog.c | 5 +- lib/filepart.c | 7 +- lib/fprintf.c | 5 +- lib/hash.c | 5 +- lib/heap.h | 2 + lib/hex.c | 6 +- lib/hostname.c | 3 +- lib/ifreq.c | 4 +- lib/ifreq.h | 2 - lib/inputline.c | 5 +- lib/kvp.c | 6 +- lib/log.c | 5 +- lib/logfd.c | 4 +- lib/macros-builtin.c | 6 +- lib/macros.c | 6 +- lib/mem.c | 7 +- lib/mime.c | 6 +- lib/mixer-alsa.c | 7 +- lib/mixer-oss.c | 7 +- lib/mixer.c | 3 +- lib/plugin.h | 127 ------------ lib/printf.c | 6 +- lib/printf.h | 2 + lib/queue-rights.c | 5 +- lib/queue.c | 19 +- lib/queue.h | 6 + lib/random.c | 4 +- lib/regsub.c | 4 +- lib/regsub.h | 2 + lib/rights.c | 4 +- lib/selection.c | 3 +- lib/selection.h | 2 + lib/sendmail.c | 4 +- lib/signame.c | 3 +- lib/sink.c | 5 +- lib/sink.h | 2 + lib/snprintf.c | 5 +- lib/speaker-protocol.c | 4 +- lib/split.c | 4 +- lib/syscalls.c | 4 +- lib/syscalls.h | 3 - lib/table.c | 4 +- lib/table.h | 2 + lib/timeval.h | 2 + lib/trackdb-int.h | 2 + lib/trackdb-stub.c | 3 +- lib/trackdb.c | 6 +- lib/trackname.c | 5 +- lib/trackorder.c | 5 +- lib/unicode.c | 6 +- lib/unidata.c | 3 +- lib/url.c | 6 +- lib/user.c | 3 +- lib/vector.c | 4 +- lib/vector.h | 2 + lib/version.c | 6 +- lib/wav.c | 4 +- lib/wstat.c | 4 +- libtests/test.h | 7 +- plugins/notify.c | 4 +- scripts/make-unidata | 3 +- server/Makefile.am | 36 +--- server/api-client.c | 5 +- server/api-server.c | 18 +- server/api.c | 13 +- server/choose.c | 32 +-- server/daemonize.c | 13 +- server/daemonize.h | 41 ---- server/dbupgrade.c | 41 +--- server/deadlock.c | 26 +-- server/decode.c | 18 +- server/disorder-server.h | 332 ++++++++++++++++++++++++++++++ server/disorderd.c | 42 +--- server/dump.c | 30 +-- server/normalize.c | 19 +- server/play.c | 38 +--- server/play.h | 89 -------- {lib => server}/plugin.c | 14 +- server/queue-ops.c | 190 +++++++++++++++++ server/rescan.c | 36 +--- server/schedule.c | 23 +-- server/schedule.h | 40 ---- server/server-queue.c | 202 +----------------- server/server-queue.h | 82 -------- server/server.c | 55 +---- server/server.h | 49 ----- server/speaker-alsa.c | 4 +- server/speaker-command.c | 3 +- server/speaker-coreaudio.c | 4 +- server/speaker-network.c | 4 +- server/speaker-oss.c | 5 +- server/speaker.c | 7 +- server/state.c | 30 +-- server/state.h | 37 ---- server/stats.c | 20 +- server/trackname.c | 17 +- tests/udplog.c | 3 +- 148 files changed, 761 insertions(+), 1514 deletions(-) create mode 100644 cgi/Makefile.am rename {server => cgi}/actions.c (100%) rename {server => cgi}/cgimain.c (100%) rename {server => cgi}/disorder-cgi.h (97%) rename {server => cgi}/login.c (100%) rename {server => cgi}/lookup.c (100%) rename {server => cgi}/macros-disorder.c (100%) rename {server => cgi}/options.c (100%) rename lib/{types.h => common.h} (92%) delete mode 100644 lib/plugin.h delete mode 100644 server/daemonize.h create mode 100644 server/disorder-server.h delete mode 100644 server/play.h rename {lib => server}/plugin.c (96%) create mode 100644 server/queue-ops.c delete mode 100644 server/schedule.h delete mode 100644 server/server-queue.h delete mode 100644 server/server.h delete mode 100644 server/state.h diff --git a/.bzrignore b/.bzrignore index 9a5ff0e..8824dd5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -77,7 +77,7 @@ server/disorder-deadlock server/disorder-dump server/disorder-rescan server/disorder-speaker -server/disorder.cgi +cgi/disorder.cgi server/disorderd server/trackname sounds/Makefile @@ -192,3 +192,4 @@ libtests/t-charset libtests/t-event libtests/t-dateparse libtests/Makefile +cgi/Makefile diff --git a/cgi/Makefile.am b/cgi/Makefile.am new file mode 100644 index 0000000..2e126de --- /dev/null +++ b/cgi/Makefile.am @@ -0,0 +1,33 @@ +# +# This file is part of DisOrder. +# Copyright (C) 2004-2008 Richard Kettlewell +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# + +noinst_PROGRAMS=disorder.cgi + +AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib + +disorder_cgi_SOURCES=macros-disorder.c macros-disorder.h lookup.c \ + lookup.h options.c options.h actions.c actions.h login.c \ + login.h cgimain.c +disorder_cgi_LDADD=../lib/libdisorder.a \ + $(LIBPCRE) $(LIBGCRYPT) $(LIBDL) $(LIBDB) +disorder_cgi_LDFLAGS=-export-dynamic +disorder_cgi_DEPENDENCIES=../lib/libdisorder.a + +cgi.o: ../lib/definitions.h diff --git a/server/actions.c b/cgi/actions.c similarity index 100% rename from server/actions.c rename to cgi/actions.c diff --git a/server/cgimain.c b/cgi/cgimain.c similarity index 100% rename from server/cgimain.c rename to cgi/cgimain.c diff --git a/server/disorder-cgi.h b/cgi/disorder-cgi.h similarity index 97% rename from server/disorder-cgi.h rename to cgi/disorder-cgi.h index beb8581..73a761d 100644 --- a/server/disorder-cgi.h +++ b/cgi/disorder-cgi.h @@ -24,12 +24,9 @@ #ifndef DISORDER_CGI_H #define DISORDER_CGI_H -#include -#include "types.h" +#include "common.h" -#include #include -#include #include #include #include diff --git a/server/login.c b/cgi/login.c similarity index 100% rename from server/login.c rename to cgi/login.c diff --git a/server/lookup.c b/cgi/lookup.c similarity index 100% rename from server/lookup.c rename to cgi/lookup.c diff --git a/server/macros-disorder.c b/cgi/macros-disorder.c similarity index 100% rename from server/macros-disorder.c rename to cgi/macros-disorder.c diff --git a/server/options.c b/cgi/options.c similarity index 100% rename from server/options.c rename to cgi/options.c diff --git a/clients/authorize.c b/clients/authorize.c index 1a0717e..fe908bc 100644 --- a/clients/authorize.c +++ b/clients/authorize.c @@ -18,8 +18,7 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include @@ -27,7 +26,6 @@ #include #include #include -#include #include "client.h" #include "authorize.h" diff --git a/clients/disorder.c b/clients/disorder.c index 1bac10b..be075f1 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -18,22 +18,17 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include #include #include -#include #include -#include -#include #include #include #include #include -#include #include #include @@ -48,7 +43,6 @@ #include "kvp.h" #include "split.h" #include "sink.h" -#include "plugin.h" #include "mem.h" #include "defs.h" #include "authorize.h" diff --git a/clients/disorderfm.c b/clients/disorderfm.c index b834be6..b293301 100644 --- a/clients/disorderfm.c +++ b/clients/disorderfm.c @@ -18,8 +18,7 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include #include "syscalls.h" diff --git a/clients/filename-bytes.c b/clients/filename-bytes.c index 91c33c0..8bba942 100644 --- a/clients/filename-bytes.c +++ b/clients/filename-bytes.c @@ -1,10 +1,9 @@ /* Grotty program to print out the bytes making up filenames in some * directory */ -#include "config.h" +#include "common.h" #include -#include #include int main(int attribute((unused)) argc, char **argv) { diff --git a/clients/playrtp-alsa.c b/clients/playrtp-alsa.c index 3c9b67f..a3995e9 100644 --- a/clients/playrtp-alsa.c +++ b/clients/playrtp-alsa.c @@ -25,14 +25,12 @@ * wrapping OSS the whole of playrtp could probably be greatly simplified. */ -#include +#include "common.h" #if HAVE_ALSA_ASOUNDLIB_H -#include "types.h" #include #include -#include #include #include diff --git a/clients/playrtp-coreaudio.c b/clients/playrtp-coreaudio.c index c0f1819..f490a0f 100644 --- a/clients/playrtp-coreaudio.c +++ b/clients/playrtp-coreaudio.c @@ -21,12 +21,9 @@ * @brief RTP player - Core Audio support */ -#include +#include "common.h" #if HAVE_COREAUDIO_AUDIOHARDWARE_H -#include "types.h" - -#include #include #include diff --git a/clients/playrtp-mem.c b/clients/playrtp-mem.c index 7465707..2a868de 100644 --- a/clients/playrtp-mem.c +++ b/clients/playrtp-mem.c @@ -21,12 +21,9 @@ * @brief RTP player memory management */ -#include -#include "types.h" +#include "common.h" #include -#include -#include #include "mem.h" #include "vector.h" diff --git a/clients/playrtp-oss.c b/clients/playrtp-oss.c index 15f6b53..199487f 100644 --- a/clients/playrtp-oss.c +++ b/clients/playrtp-oss.c @@ -22,19 +22,16 @@ * @brief RTP player - OSS and empeg support */ -#include +#include "common.h" #if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST -#include "types.h" #include #include #if !EMPEG_HOST #include #endif -#include #include -#include #include #include #include diff --git a/clients/playrtp.c b/clients/playrtp.c index 3f02e0c..cbc24ae 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -49,12 +49,9 @@ * - it is safe to read uint32_t values without a lock protecting them */ -#include -#include "types.h" +#include "common.h" #include -#include -#include #include #include #include @@ -62,8 +59,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/clients/test-eclient.c b/clients/test-eclient.c index bae789a..b5742a3 100644 --- a/clients/test-eclient.c +++ b/clients/test-eclient.c @@ -18,14 +18,10 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include -#include #include -#include #include #include "queue.h" diff --git a/configure.ac b/configure.ac index beb2803..2d193ad 100644 --- a/configure.ac +++ b/configure.ac @@ -178,7 +178,7 @@ fi subdirs="${subdirs} clients doc examples debian" if test $want_server = yes; then - subdirs="${subdirs} server plugins driver templates sounds images" + subdirs="${subdirs} server cgi plugins driver templates sounds images" fi if test $want_gtk = yes; then subdirs="${subdirs} disobedience" @@ -589,6 +589,7 @@ AC_CONFIG_FILES([Makefile scripts/Makefile lib/Makefile server/Makefile + cgi/Makefile clients/Makefile disobedience/Makefile doc/Makefile diff --git a/disobedience/disobedience.h b/disobedience/disobedience.h index ccb9acc..db1e8e9 100644 --- a/disobedience/disobedience.h +++ b/disobedience/disobedience.h @@ -24,13 +24,9 @@ #ifndef DISOBEDIENCE_H #define DISOBEDIENCE_H -#include -#include "types.h" +#include "common.h" -#include #include -#include -#include #include #include #include diff --git a/doc/Makefile.am b/doc/Makefile.am index 4b01791..7ae24e4 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -53,24 +53,24 @@ $(TMPLMAN) : %.tmpl : % $(top_srcdir)/scripts/htmlman disorder_templates.5.in: disorder_templates.5.head disorder_templates.5.tail \ $(top_srcdir)/lib/macros-builtin.c \ - $(top_srcdir)/server/macros-disorder.c \ + $(top_srcdir)/cgi/macros-disorder.c \ $(top_srcdir)/scripts/macro-docs rm -f disorder_templates.5.new cat ${srcdir}/disorder_templates.5.head >> disorder_templates.5.new $(top_srcdir)/scripts/macro-docs >> disorder_templates.5.new \ $(top_srcdir)/lib/macros-builtin.c \ - $(top_srcdir)/server/macros-disorder.c + $(top_srcdir)/cgi/macros-disorder.c cat ${srcdir}/disorder_templates.5.tail >> disorder_templates.5.new mv disorder_templates.5.new disorder_templates.5.in disorder_actions.5.in: disorder_actions.5.head disorder_actions.5.tail \ $(top_srcdir)/lib/macros-builtin.c \ - $(top_srcdir)/server/actions.c \ + $(top_srcdir)/cgi/actions.c \ $(top_srcdir)/scripts/macro-docs rm -f disorder_actions.5.new cat ${srcdir}/disorder_actions.5.head >> disorder_actions.5.new $(top_srcdir)/scripts/macro-docs >> disorder_actions.5.new \ - $(top_srcdir)/server/actions.c + $(top_srcdir)/cgi/actions.c cat ${srcdir}/disorder_actions.5.tail >> disorder_actions.5.new mv disorder_actions.5.new disorder_actions.5.in diff --git a/driver/disorder.c b/driver/disorder.c index fb05b59..d075a03 100644 --- a/driver/disorder.c +++ b/driver/disorder.c @@ -24,11 +24,8 @@ * disorder-normalize to convert to the confnigured target format. */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include #include diff --git a/lib/Makefile.am b/lib/Makefile.am index 27ecb2c..7f25cdd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -60,7 +60,6 @@ libdisorder_a_SOURCES=charset.c charset.h \ mem.c mem.h mem-impl.h \ mime.h mime.c \ mixer.c mixer.h mixer-oss.c mixer-alsa.c \ - plugin.c plugin.h \ printf.c printf.h \ asprintf.c fprintf.c snprintf.c \ queue.c queue.h \ diff --git a/lib/addr.c b/lib/addr.c index c0bc190..c7a1e74 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -20,21 +20,16 @@ /** @file lib/addr.c * @brief Socket address support */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include #include -#include #include #include #include "log.h" #include "printf.h" -#include "configuration.h" #include "addr.h" #include "mem.h" diff --git a/lib/addr.h b/lib/addr.h index 8bd703f..4049b07 100644 --- a/lib/addr.h +++ b/lib/addr.h @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2007 Richard Kettlewell + * Copyright (C) 2004, 2007, 2008 Richard Kettlewell * * 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 @@ -23,6 +23,10 @@ #ifndef ADDR_H #define ADDR_H +#include + +#include "configuration.h" + struct addrinfo *get_address(const struct stringlist *a, const struct addrinfo *pref, char **namep); diff --git a/lib/alsabg.c b/lib/alsabg.c index be589ce..336c2a3 100644 --- a/lib/alsabg.c +++ b/lib/alsabg.c @@ -21,11 +21,9 @@ * @brief Background-thread interface to ALSA */ -#include +#include "common.h" #if HAVE_ALSA_ASOUNDLIB_H -#include "types.h" - #include #include diff --git a/lib/asprintf.c b/lib/asprintf.c index f3bebd5..7d7bd31 100644 --- a/lib/asprintf.c +++ b/lib/asprintf.c @@ -19,11 +19,8 @@ */ /** @file lib/asprintf.c @brief printf() workalikes */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include #include diff --git a/lib/authhash.c b/lib/authhash.c index 24c40f0..a083902 100644 --- a/lib/authhash.c +++ b/lib/authhash.c @@ -19,12 +19,10 @@ */ /** @file lib/authhash.c @brief The authorization hash */ -#include -#include "types.h" +#include "common.h" #include #include -#include #include "hex.h" #include "log.h" diff --git a/lib/base64.c b/lib/base64.c index 7909b4f..2975333 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -21,12 +21,7 @@ * @brief Support for MIME base64 */ -#include -#include "types.h" - -#include - -#include +#include "common.h" #include "mem.h" #include "base64.h" diff --git a/lib/basen.c b/lib/basen.c index 74cb836..a41a73b 100644 --- a/lib/basen.c +++ b/lib/basen.c @@ -24,10 +24,7 @@ * words. The words themselves use the native byte order. */ -#include -#include "types.h" - -#include +#include "common.h" #include "basen.h" diff --git a/lib/bits.c b/lib/bits.c index 6b5273b..4ed2402 100644 --- a/lib/bits.c +++ b/lib/bits.c @@ -22,8 +22,7 @@ * @brief Bit operations */ -#include -#include "types.h" +#include "common.h" #include diff --git a/lib/bits.h b/lib/bits.h index 0965cb6..e0f7c62 100644 --- a/lib/bits.h +++ b/lib/bits.h @@ -25,8 +25,6 @@ #ifndef BITS_H #define BITS_H -#include /* for fls() */ - #if HAVE_FLS static inline int leftmost_bit(uint32_t n) { return fls(n) - 1; diff --git a/lib/cache.c b/lib/cache.c index 60c2600..f812dc6 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -19,8 +19,7 @@ */ /** @file lib/cache.c @brief Object caching */ -#include -#include "types.h" +#include "common.h" #include diff --git a/lib/cgi.c b/lib/cgi.c index c3a7680..8cb04bb 100644 --- a/lib/cgi.c +++ b/lib/cgi.c @@ -21,15 +21,10 @@ * @brief CGI tools */ -#include -#include "types.h" +#include "common.h" -#include -#include -#include #include #include -#include #include "cgi.h" #include "mem.h" diff --git a/lib/charset.c b/lib/charset.c index 1dc4231..3c5f88b 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -19,11 +19,9 @@ */ /** @file lib/charset.c @brief Character set conversion */ -#include -#include "types.h" +#include "common.h" #include -#include #include #include diff --git a/lib/charset.h b/lib/charset.h index e4c72a9..db5e737 100644 --- a/lib/charset.h +++ b/lib/charset.h @@ -1,3 +1,4 @@ + /* * This file is part of DisOrder. * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell @@ -20,6 +21,8 @@ #ifndef CHARSET_H #define CHARSET_H +#include "log.h" + struct dynstr; /* Character encoding conversion routines */ diff --git a/lib/client-common.c b/lib/client-common.c index f5ace3e..53da8ac 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -18,14 +18,10 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include -#include #include #include diff --git a/lib/client-common.h b/lib/client-common.h index 271e28f..dc50ee9 100644 --- a/lib/client-common.h +++ b/lib/client-common.h @@ -21,6 +21,9 @@ #ifndef CLIENT_COMMON_H #define CLIENT_COMMON_H +#include +#include + socklen_t find_server(struct sockaddr **sap, char **namep); #endif /* CLIENT_COMMON_H */ diff --git a/lib/client.c b/lib/client.c index d357a8c..84eb77e 100644 --- a/lib/client.c +++ b/lib/client.c @@ -24,19 +24,15 @@ * implementation. */ -#include -#include "types.h" +#include "common.h" #include #include #include #include -#include -#include #include #include #include -#include #include #include "log.h" diff --git a/lib/client.h b/lib/client.h index abadef6..912fa32 100644 --- a/lib/client.h +++ b/lib/client.h @@ -27,6 +27,8 @@ #ifndef CLIENT_H #define CLIENT_H +#include + /** @brief Client data */ typedef struct disorder_client disorder_client; diff --git a/lib/types.h b/lib/common.h similarity index 92% rename from lib/types.h rename to lib/common.h index 6b3dc37..77a2cd9 100644 --- a/lib/types.h +++ b/lib/common.h @@ -17,9 +17,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ +/** @file lib/common.h + * @brief Common includes and definitions + */ + +#ifndef COMMON_H +#define COMMON_H -#ifndef TYPES_H -#define TYPES_H +#include #if HAVE_INTTYPES_H # include @@ -29,6 +34,9 @@ /* had better be before atol/atoll redefinition */ #include +#include +#include +#include #if HAVE_LONG_LONG typedef long long long_long; @@ -104,7 +112,7 @@ typedef unsigned char uint32_t; # endif #endif -#endif /* TYPES_H */ +#endif /* COMMENT_H */ /* Local Variables: diff --git a/lib/configuration.c b/lib/configuration.c index ca7d86e..c66f66b 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -22,12 +22,8 @@ * @brief Configuration file support */ -#include -#include "types.h" +#include "common.h" -#include -#include -#include #include #include #include diff --git a/lib/configuration.h b/lib/configuration.h index bf3a493..51dc835 100644 --- a/lib/configuration.h +++ b/lib/configuration.h @@ -25,11 +25,11 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H +#include + #include "speaker-protocol.h" #include "rights.h" -struct real_pcre; - /* Configuration is kept in a @struct config@; the live configuration * is always pointed to by @config@. Values in @config@ are UTF-8 encoded. */ @@ -70,7 +70,7 @@ struct collectionlist { struct namepart { char *part; /* part */ - struct real_pcre *re; /* regexp */ + pcre *re; /* regexp */ char *replace; /* replacement string */ char *context; /* context glob */ unsigned reflags; /* regexp flags */ @@ -85,7 +85,7 @@ struct transform { char *type; /* track or dir */ char *context; /* sort or choose */ char *replace; /* substitution string */ - struct real_pcre *re; /* compiled re */ + pcre *re; /* compiled re */ unsigned flags; /* regexp flags */ }; diff --git a/lib/cookies.c b/lib/cookies.c index c98db8f..40e3c3e 100644 --- a/lib/cookies.c +++ b/lib/cookies.c @@ -21,18 +21,13 @@ * @brief Cookie support */ -#include -#include "types.h" +#include "common.h" -#include -#include -#include #include #include #include #include -#include "rights.h" #include "cookies.h" #include "hash.h" #include "mem.h" @@ -41,7 +36,6 @@ #include "base64.h" #include "configuration.h" #include "kvp.h" -#include "rights.h" #include "trackdb.h" /** @brief Hash function used in signing HMAC */ diff --git a/lib/cookies.h b/lib/cookies.h index f02013d..ea6e412 100644 --- a/lib/cookies.h +++ b/lib/cookies.h @@ -24,6 +24,8 @@ #ifndef COOKIES_H #define COOKIES_H +#include "rights.h" + char *make_cookie(const char *user); char *verify_cookie(const char *cookie, rights_type *rights); void revoke_cookie(const char *cookie); diff --git a/lib/dateparse.c b/lib/dateparse.c index 45de40c..2a25292 100644 --- a/lib/dateparse.c +++ b/lib/dateparse.c @@ -22,8 +22,7 @@ * @brief Date parsing */ -#include -#include "types.h" +#include "common.h" #include diff --git a/lib/dateparse.h b/lib/dateparse.h index 2f52dac..7b96fe9 100644 --- a/lib/dateparse.h +++ b/lib/dateparse.h @@ -17,11 +17,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ - /** @file lib/dateparse.h * @brief Date parsing */ +#ifndef DATEPARSE_H +#define DATEPARSE_H + +#include + time_t dateparse(const char *s); #if 0 struct tm *xgetdate(const char *string, @@ -31,6 +35,8 @@ int xgetdate_r(const char *string, struct tm *tp, const char *const *template); +#endif /* DATEPARSE_H */ + /* Local Variables: c-basic-offset:2 diff --git a/lib/defs.c b/lib/defs.c index b5e1eff..084bf0a 100644 --- a/lib/defs.c +++ b/lib/defs.c @@ -23,8 +23,7 @@ * (see fix_path()), not so that the path can be ignored. */ -#include -#include "types.h" +#include "common.h" #include "defs.h" #include "definitions.h" diff --git a/lib/eclient.c b/lib/eclient.c index 941849c..a9805f7 100644 --- a/lib/eclient.c +++ b/lib/eclient.c @@ -21,20 +21,15 @@ * @brief Client code for event-driven programs */ -#include -#include "types.h" +#include "common.h" #include #include #include #include -#include -#include #include #include #include -#include -#include #include #include #include diff --git a/lib/event.c b/lib/event.c index 4c3e9af..7c12b6f 100644 --- a/lib/event.c +++ b/lib/event.c @@ -21,7 +21,7 @@ * @brief DisOrder event loop */ -#include +#include "common.h" #include #include @@ -31,15 +31,11 @@ #include #include #include -#include #include #include -#include -#include #include #include #include -#include #include "event.h" #include "mem.h" #include "log.h" diff --git a/lib/eventlog.c b/lib/eventlog.c index d22a144..9c7f4fb 100644 --- a/lib/eventlog.c +++ b/lib/eventlog.c @@ -18,12 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include -#include #include "mem.h" #include "vector.h" diff --git a/lib/filepart.c b/lib/filepart.c index 7af7de0..b772002 100644 --- a/lib/filepart.c +++ b/lib/filepart.c @@ -21,12 +21,7 @@ * @brief Filename parsing */ -#include -#include "types.h" - -#include -#include -#include +#include "common.h" #include "filepart.h" #include "mem.h" diff --git a/lib/fprintf.c b/lib/fprintf.c index 1e1b93c..741a31e 100644 --- a/lib/fprintf.c +++ b/lib/fprintf.c @@ -18,11 +18,8 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include diff --git a/lib/hash.c b/lib/hash.c index f38e1d9..f730a58 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -18,10 +18,7 @@ * USA */ -#include -#include "types.h" - -#include +#include "common.h" #include "hash.h" #include "mem.h" diff --git a/lib/heap.h b/lib/heap.h index 6f9bcab..c6504ef 100644 --- a/lib/heap.h +++ b/lib/heap.h @@ -22,6 +22,8 @@ #ifndef HEAP_H #define HEAP_H +#include "vector.h" + /** @brief Binary heap template. * @param NAME name of type to define * @param ETYPE element type diff --git a/lib/hex.c b/lib/hex.c index 15860ad..e0542ce 100644 --- a/lib/hex.c +++ b/lib/hex.c @@ -19,11 +19,7 @@ */ /** @file lib/hex.c @brief Hexadecimal encoding and decoding */ -#include -#include "types.h" - -#include -#include +#include "common.h" #include "hex.h" #include "mem.h" diff --git a/lib/hostname.c b/lib/hostname.c index 536bb8e..ee7ed49 100644 --- a/lib/hostname.c +++ b/lib/hostname.c @@ -18,8 +18,7 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include diff --git a/lib/ifreq.c b/lib/ifreq.c index 7071a0e..3ec92b0 100644 --- a/lib/ifreq.c +++ b/lib/ifreq.c @@ -21,15 +21,13 @@ * @brief Network interface support */ -#include -#include "types.h" +#include "common.h" #include #include #include #include #include -#include #include "ifreq.h" #include "mem.h" diff --git a/lib/ifreq.h b/lib/ifreq.h index 7a65d80..3f2dd9d 100644 --- a/lib/ifreq.h +++ b/lib/ifreq.h @@ -23,8 +23,6 @@ #ifndef IFREQ_H #define IFREQ_H -struct ifreq; - /** @brief Return true if two socket addresses match */ int sockaddr_equal(const struct sockaddr *a, const struct sockaddr *b); diff --git a/lib/inputline.c b/lib/inputline.c index 5af46f9..8882f57 100644 --- a/lib/inputline.c +++ b/lib/inputline.c @@ -21,12 +21,9 @@ * @brief Line input */ -#include -#include "types.h" +#include "common.h" -#include #include -#include #include "log.h" #include "mem.h" diff --git a/lib/kvp.c b/lib/kvp.c index 4aa31a1..9cd0554 100644 --- a/lib/kvp.c +++ b/lib/kvp.c @@ -18,11 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include +#include "common.h" #include "mem.h" #include "kvp.h" diff --git a/lib/log.c b/lib/log.c index cae84a7..24f9427 100644 --- a/lib/log.c +++ b/lib/log.c @@ -35,11 +35,8 @@ #define NO_MEMORY_ALLOCATION /* because the memory allocation functions report errors */ -#include +#include "common.h" -#include -#include -#include #include #include #include diff --git a/lib/logfd.c b/lib/logfd.c index a0a608f..1baaff2 100644 --- a/lib/logfd.c +++ b/lib/logfd.c @@ -18,11 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include #include #include "syscalls.h" diff --git a/lib/macros-builtin.c b/lib/macros-builtin.c index 04ea490..8123f2b 100644 --- a/lib/macros-builtin.c +++ b/lib/macros-builtin.c @@ -25,13 +25,9 @@ * generated from the comments at the head of each function. */ -#include -#include "types.h" +#include "common.h" -#include -#include #include -#include #include #include #include diff --git a/lib/macros.c b/lib/macros.c index 4d3b9a0..7b77144 100644 --- a/lib/macros.c +++ b/lib/macros.c @@ -22,13 +22,9 @@ * @brief Macro expansion */ -#include -#include "types.h" +#include "common.h" -#include #include -#include -#include #include #include #include diff --git a/lib/mem.c b/lib/mem.c index 6d531cc..10fffe3 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -21,17 +21,12 @@ * @brief Memory management */ -#include -#include "types.h" +#include "common.h" #if GC #include #endif #include -#include -#include -#include -#include #include "mem.h" #include "log.h" diff --git a/lib/mime.c b/lib/mime.c index 5db7585..b7975f2 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -21,14 +21,10 @@ * @brief Support for MIME and allied protocols */ -#include -#include "types.h" +#include "common.h" -#include #include -#include - #include "mem.h" #include "mime.h" #include "vector.h" diff --git a/lib/mixer-alsa.c b/lib/mixer-alsa.c index 40103e0..4ba684f 100644 --- a/lib/mixer-alsa.c +++ b/lib/mixer-alsa.c @@ -29,17 +29,12 @@ * (as I don't one). */ -#include +#include "common.h" #if HAVE_ALSA_ASOUNDLIB_H -#include "types.h" - -#include -#include #include #include -#include #include #include #include diff --git a/lib/mixer-oss.c b/lib/mixer-oss.c index e1c8b19..158b6f6 100644 --- a/lib/mixer-oss.c +++ b/lib/mixer-oss.c @@ -24,17 +24,12 @@ * nonetheless). */ -#include +#include "common.h" #if HAVE_SYS_SOUNDCARD_H -#include "types.h" - -#include -#include #include #include -#include #include #include #include diff --git a/lib/mixer.c b/lib/mixer.c index ee88fbb..36acd73 100644 --- a/lib/mixer.c +++ b/lib/mixer.c @@ -21,8 +21,7 @@ * @brief Mixer support */ -#include -#include "types.h" +#include "common.h" #include "configuration.h" #include "mixer.h" diff --git a/lib/plugin.h b/lib/plugin.h deleted file mode 100644 index 1283555..0000000 --- a/lib/plugin.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004-2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef PLUGIN_H -#define PLUGIN_H - -/* general ********************************************************************/ - -struct plugin; - -typedef void *plugin_handle; -typedef void function_t(void); - -const struct plugin *open_plugin(const char *name, - unsigned flags); -#define PLUGIN_FATAL 0x0001 /* fatal() on error */ -/* Open a plugin. Returns a null pointer on error or a handle to it - * on success. */ - -function_t *get_plugin_function(const struct plugin *handle, - const char *symbol); -const void *get_plugin_object(const struct plugin *handle, - const char *symbol); -/* Look up a function or an object in a plugin */ - -/* track length computation ***************************************************/ - -long tracklength(const char *plugin, const char *track, const char *path); - -/* collection interface *******************************************************/ - -void scan(const char *module, const char *root); -/* write a list of path names below @root@ to standard output. */ - -int check(const char *module, const char *root, const char *path); -/* Recheck a track, given its root and path name. Return 1 if it - * exists, 0 if it does not exist and -1 if an error occurred. */ - -/* notification interface *****************************************************/ - -void notify_play(const char *track, - const char *submitter); -/* we're going to play @track@. It was submitted by @submitter@ - * (might be a null pointer) */ - -void notify_scratch(const char *track, - const char *submitter, - const char *scratcher, - int seconds); -/* @scratcher@ scratched @track@ after @seconds@. It was submitted by - * @submitter@ (might be a null pointer) */ - -void notify_not_scratched(const char *track, - const char *submitter); -/* @track@ (submitted by @submitter@, which might be a null pointer) - * was not scratched. */ - -void notify_queue(const char *track, - const char *submitter); -/* @track@ was queued by @submitter@ */ - -void notify_queue_remove(const char *track, - const char *remover); -/* @track@ removed from the queue by @remover@ (never a null pointer) */ - -void notify_queue_move(const char *track, - const char *mover); -/* @track@ moved in the queue by @mover@ (never a null pointer) */ - -void notify_pause(const char *track, - const char *pauser); -/* TRACK was paused by PAUSER (might be a null pointer) */ - -void notify_resume(const char *track, - const char *resumer); -/* TRACK was resumed by PAUSER (might be a null pointer) */ - -/* track playing **************************************************************/ - -unsigned long play_get_type(const struct plugin *pl); -/* Get the type word for this plugin */ - -void *play_prefork(const struct plugin *pl, - const char *track); -/* Call the prefork function for PL and return the user data */ - -void play_track(const struct plugin *pl, - const char *const *parameters, - int nparameters, - const char *path, - const char *track); -/* play a track. Called inside a fork. */ - -void play_cleanup(const struct plugin *pl, void *data); -/* Call the cleanup function for PL if necessary */ - -int play_pause(const struct plugin *pl, long *playedp, void *data); -/* Pause track. */ - -void play_resume(const struct plugin *pl, void *data); -/* Resume track. */ - -#endif /* PLUGIN_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/lib/printf.c b/lib/printf.c index c5b9ebd..ed6af66 100644 --- a/lib/printf.c +++ b/lib/printf.c @@ -21,14 +21,10 @@ #define NO_MEMORY_ALLOCATION /* because byte_snprintf used from log.c */ -#include -#include "types.h" +#include "common.h" -#include #include -#include #include -#include #include #include "printf.h" diff --git a/lib/printf.h b/lib/printf.h index 3b3b7c1..fd052b0 100644 --- a/lib/printf.h +++ b/lib/printf.h @@ -20,6 +20,8 @@ #ifndef PRINTF_H #define PRINTF_H +#include + struct sink; int byte_vsinkprintf(struct sink *output, diff --git a/lib/queue-rights.c b/lib/queue-rights.c index 523a4ad..4205d26 100644 --- a/lib/queue-rights.c +++ b/lib/queue-rights.c @@ -21,10 +21,7 @@ * @brief Various rights-checking operations */ -#include -#include "types.h" - -#include +#include "common.h" #include "queue.h" #include "rights.h" diff --git a/lib/queue.c b/lib/queue.c index a98bec1..0849070 100644 --- a/lib/queue.c +++ b/lib/queue.c @@ -18,11 +18,8 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include @@ -49,6 +46,20 @@ const char *playing_states[] = { #define VALUE(q, offset, type) *(type *)((char *)q + offset) +/* add new entry @n@ to a doubly linked list just after @b@ */ +void queue_insert_entry(struct queue_entry *b, struct queue_entry *n) { + n->prev = b; + n->next = b->next; + n->next->prev = n; + n->prev->next = n; +} + +/* remove an entry from a doubly-linked list */ +void queue_delete_entry(struct queue_entry *node) { + node->next->prev = node->prev; + node->prev->next = node->next; +} + static int unmarshall_long(char *data, struct queue_entry *q, size_t offset, void (*error_handler)(const char *, void *), diff --git a/lib/queue.h b/lib/queue.h index 6bcbeed..e466c95 100644 --- a/lib/queue.h +++ b/lib/queue.h @@ -21,6 +21,9 @@ #ifndef QUEUE_H #define QUEUE_H +#include + + enum playing_state { playing_failed, /* failed to play */ playing_isscratch, /* this is a scratch track */ @@ -62,6 +65,9 @@ struct queue_entry { struct queuelike *ql; /* owning queue */ }; +void queue_insert_entry(struct queue_entry *b, struct queue_entry *n); +void queue_delete_entry(struct queue_entry *node); + int queue_unmarshall(struct queue_entry *q, const char *s, void (*error_handler)(const char *, void *), void *u); diff --git a/lib/random.c b/lib/random.c index 69e1409..ce87abd 100644 --- a/lib/random.c +++ b/lib/random.c @@ -23,13 +23,11 @@ * */ -#include -#include "types.h" +#include "common.h" #include #include #include -#include #include "random.h" #include "log.h" diff --git a/lib/regsub.c b/lib/regsub.c index 6345725..bb90f43 100644 --- a/lib/regsub.c +++ b/lib/regsub.c @@ -18,10 +18,8 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include #include #include "regsub.h" diff --git a/lib/regsub.h b/lib/regsub.h index e85a597..2e13930 100644 --- a/lib/regsub.h +++ b/lib/regsub.h @@ -21,6 +21,8 @@ #ifndef REGSUB_H #define REGSUB_H +#include + #define REGSUB_GLOBAL 0x0001 /* global replace */ #define REGSUB_MUST_MATCH 0x0002 /* return 0 if no match */ #define REGSUB_CASE_INDEPENDENT 0x0004 /* case independent */ diff --git a/lib/rights.c b/lib/rights.c index f0dc892..416c6a7 100644 --- a/lib/rights.c +++ b/lib/rights.c @@ -21,10 +21,8 @@ * @brief User rights */ -#include -#include "types.h" +#include "common.h" -#include #include "mem.h" #include "log.h" diff --git a/lib/selection.c b/lib/selection.c index 58ff5d1..6d0a588 100644 --- a/lib/selection.c +++ b/lib/selection.c @@ -21,8 +21,7 @@ * @brief Select management for Disobedience */ -#include -#include "types.h" +#include "common.h" #include "mem.h" #include "hash.h" diff --git a/lib/selection.h b/lib/selection.h index 6618b17..0999501 100644 --- a/lib/selection.h +++ b/lib/selection.h @@ -24,6 +24,8 @@ #ifndef SELECTION_H #define SELECTION_H +#include "hash.h" + /* Represent a selection using a hash */ hash *selection_new(void); diff --git a/lib/sendmail.c b/lib/sendmail.c index 2e0df8f..8f75343 100644 --- a/lib/sendmail.c +++ b/lib/sendmail.c @@ -18,10 +18,8 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include #include #include #include diff --git a/lib/signame.c b/lib/signame.c index cc1b339..047e625 100644 --- a/lib/signame.c +++ b/lib/signame.c @@ -18,8 +18,7 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include diff --git a/lib/sink.c b/lib/sink.c index 2c1279b..925bb01 100644 --- a/lib/sink.c +++ b/lib/sink.c @@ -21,12 +21,9 @@ * @brief Abstract output sink type */ -#include -#include "types.h" +#include "common.h" -#include #include -#include #include #include "mem.h" diff --git a/lib/sink.h b/lib/sink.h index 13ea7d4..aab645b 100644 --- a/lib/sink.h +++ b/lib/sink.h @@ -24,6 +24,8 @@ #ifndef SINK_H #define SINK_H +#include + struct dynstr; /** @brief Sink type diff --git a/lib/snprintf.c b/lib/snprintf.c index 3b41af7..f738bed 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -21,11 +21,8 @@ #define NO_MEMORY_ALLOCATION /* because used from log.c */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include diff --git a/lib/speaker-protocol.c b/lib/speaker-protocol.c index ab8b4ee..ef66ed6 100644 --- a/lib/speaker-protocol.c +++ b/lib/speaker-protocol.c @@ -21,11 +21,9 @@ * @brief Speaker/server protocol support */ -#include -#include "types.h" +#include "common.h" #include -#include #include #include #include diff --git a/lib/split.c b/lib/split.c index 610fb3e..90036d4 100644 --- a/lib/split.c +++ b/lib/split.c @@ -18,11 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include #include #include "mem.h" diff --git a/lib/syscalls.c b/lib/syscalls.c index c398c93..2d0245d 100644 --- a/lib/syscalls.c +++ b/lib/syscalls.c @@ -18,7 +18,7 @@ * USA */ -#include +#include "common.h" #include #include @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include "syscalls.h" #include "log.h" diff --git a/lib/syscalls.h b/lib/syscalls.h index 8e9d9b8..f1f3383 100644 --- a/lib/syscalls.h +++ b/lib/syscalls.h @@ -29,9 +29,6 @@ struct timezone; #include #include -#include - -#include "types.h" pid_t xfork(void); void xclose_guts(const char *, int, int); diff --git a/lib/table.c b/lib/table.c index f2835cb..d37ffe3 100644 --- a/lib/table.c +++ b/lib/table.c @@ -18,9 +18,7 @@ * USA */ -#include - -#include +#include "common.h" #include "table.h" diff --git a/lib/table.h b/lib/table.h index 8cdfcfd..a301db7 100644 --- a/lib/table.h +++ b/lib/table.h @@ -21,6 +21,8 @@ #ifndef TABLE_H #define TABLE_H +#include + #define TABLE_FIND(TABLE, FIELD, NAME) \ table_find((void *)TABLE, \ offsetof(typeof((TABLE)[0]), FIELD), \ diff --git a/lib/timeval.h b/lib/timeval.h index c2cd106..10b02ea 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -21,6 +21,8 @@ #ifndef TIMEVAL_H #define TIMEVAL_H +#include + static inline struct timeval tvsub(const struct timeval a, const struct timeval b) { struct timeval r; diff --git a/lib/trackdb-int.h b/lib/trackdb-int.h index 1cfadbc..32a6ca4 100644 --- a/lib/trackdb-int.h +++ b/lib/trackdb-int.h @@ -21,6 +21,8 @@ #ifndef TRACKDB_INT_H #define TRACKDB_INT_H +#include + #include "kvp.h" struct vector; /* forward declaration */ diff --git a/lib/trackdb-stub.c b/lib/trackdb-stub.c index 3b92c97..6ddb6af 100644 --- a/lib/trackdb-stub.c +++ b/lib/trackdb-stub.c @@ -23,8 +23,7 @@ * Stubs for non-server builds */ -#include -#include "types.h" +#include "common.h" #include diff --git a/lib/trackdb.c b/lib/trackdb.c index e1a0c80..689af09 100644 --- a/lib/trackdb.c +++ b/lib/trackdb.c @@ -23,15 +23,11 @@ * This file is getting in desparate need of splitting up... */ -#include -#include "types.h" +#include "common.h" -#include -#include #include #include #include -#include #include #include #include diff --git a/lib/trackname.c b/lib/trackname.c index 0aef934..14de985 100644 --- a/lib/trackname.c +++ b/lib/trackname.c @@ -18,13 +18,10 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include -#include -#include #include "trackname.h" #include "configuration.h" diff --git a/lib/trackorder.c b/lib/trackorder.c index a61b89c..80c5b92 100644 --- a/lib/trackorder.c +++ b/lib/trackorder.c @@ -18,13 +18,10 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include -#include -#include #include "trackname.h" #include "log.h" diff --git a/lib/unicode.c b/lib/unicode.c index 5803926..417ae07 100644 --- a/lib/unicode.c +++ b/lib/unicode.c @@ -39,11 +39,7 @@ * - @ref utf8 */ -#include -#include "types.h" - -#include -#include /* TODO */ +#include "common.h" #include "mem.h" #include "vector.h" diff --git a/lib/unidata.c b/lib/unidata.c index d7bed16..db4334d 100644 --- a/lib/unidata.c +++ b/lib/unidata.c @@ -1,6 +1,5 @@ /* Automatically generated file, see scripts/make-unidata */ -#include -#include "types.h" +#include "common.h" #include "unidata.h" #define Cc unicode_General_Category_Cc #define Cf unicode_General_Category_Cf diff --git a/lib/url.c b/lib/url.c index 16f3257..b777282 100644 --- a/lib/url.c +++ b/lib/url.c @@ -21,13 +21,9 @@ * @brief URL support functions */ -#include -#include "types.h" +#include "common.h" -#include -#include #include -#include #include "mem.h" #include "log.h" diff --git a/lib/user.c b/lib/user.c index ec01a33..512aaa1 100644 --- a/lib/user.c +++ b/lib/user.c @@ -21,8 +21,7 @@ * @brief Jukebox user management */ -#include -#include "types.h" +#include "common.h" #include #include diff --git a/lib/vector.c b/lib/vector.c index 6f397ce..d9fd18b 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -18,11 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include #include "mem.h" #include "log.h" diff --git a/lib/vector.h b/lib/vector.h index 33f3d35..d89376c 100644 --- a/lib/vector.h +++ b/lib/vector.h @@ -22,6 +22,8 @@ #ifndef VECTOR_H #define VECTOR_H +#include "mem.h" + /** @brief Dynamic array template * @param NAME type name * @param ETYPE element type diff --git a/lib/version.c b/lib/version.c index f92e0c7..a8e2ad1 100644 --- a/lib/version.c +++ b/lib/version.c @@ -18,11 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include +#include "common.h" #include "syscalls.h" #include "version.h" diff --git a/lib/wav.c b/lib/wav.c index c7d4b93..d0f3acf 100644 --- a/lib/wav.c +++ b/lib/wav.c @@ -103,13 +103,11 @@ * orderings of different channels. */ -#include -#include "types.h" +#include "common.h" #include #include #include -#include #include "log.h" #include "wav.h" diff --git a/lib/wstat.c b/lib/wstat.c index 67de318..0e33d1f 100644 --- a/lib/wstat.c +++ b/lib/wstat.c @@ -21,11 +21,9 @@ * @brief Convert wait status to text */ -#include +#include "common.h" #include -#include -#include #include #include "mem.h" diff --git a/libtests/test.h b/libtests/test.h index 7a0ef5d..cb26b62 100644 --- a/libtests/test.h +++ b/libtests/test.h @@ -22,15 +22,10 @@ #ifndef TEST_H #define TEST_H -#include -#include "types.h" +#include "common.h" -#include -#include -#include #include #include -#include #include #include #include diff --git a/plugins/notify.c b/plugins/notify.c index 4f80cc2..15ef47c 100644 --- a/plugins/notify.c +++ b/plugins/notify.c @@ -18,11 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include -#include #include #include diff --git a/scripts/make-unidata b/scripts/make-unidata index 1230aa7..5611b0d 100755 --- a/scripts/make-unidata +++ b/scripts/make-unidata @@ -439,8 +439,7 @@ print STDERR "Generating unidata.c...\n"; open(STDOUT, ">unidata.c") or die "unidata.c: $!\n"; out("/* Automatically generated file, see scripts/make-unidata */\n", - "#include \n", - "#include \"types.h\"\n", + "#include \"common.h\"\n", "#include \"unidata.h\"\n"); # Short aliases to keep .c file small diff --git a/server/Makefile.am b/server/Makefile.am index a2b5acf..3557158 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -21,20 +21,13 @@ sbin_PROGRAMS=disorderd disorder-deadlock disorder-rescan disorder-dump \ disorder-speaker disorder-decode disorder-normalize \ disorder-stats disorder-dbupgrade disorder-choose -noinst_PROGRAMS=disorder.cgi trackname +noinst_PROGRAMS=trackname AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib -disorderd_SOURCES=disorderd.c \ - api.c api-server.c \ - daemonize.c daemonize.h \ - play.c play.h \ - server.c server.h \ - server-queue.c server-queue.h \ - state.c state.h \ - schedule.c \ - exports.c \ - ../lib/memgc.c +disorderd_SOURCES=disorderd.c api.c api-server.c daemonize.c play.c \ + server.c server-queue.c queue-ops.c state.c plugin.c \ + schedule.c exports.c ../lib/memgc.c disorderd_LDADD=$(LIBOBJS) ../lib/libdisorder.a \ $(LIBPCRE) $(LIBDB) $(LIBAO) $(LIBGC) $(LIBGCRYPT) $(LIBICONV) \ $(LIBASOUND) $(COREAUDIO) @@ -66,20 +59,14 @@ disorder_normalize_LDADD=$(LIBOBJS) ../lib/libdisorder.a \ $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) disorder_normalize_DEPENDENCIES=../lib/libdisorder.a -disorder_rescan_SOURCES=rescan.c \ - api.c api-server.c \ - exports.c \ +disorder_rescan_SOURCES=rescan.c plugin.c api.c api-server.c exports.c \ ../lib/memgc.c disorder_rescan_LDADD=$(LIBOBJS) ../lib/libdisorder.a \ $(LIBDB) $(LIBGC) $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) disorder_rescan_LDFLAGS=-export-dynamic disorder_rescan_DEPENDENCIES=../lib/libdisorder.a -disorder_choose_SOURCES=choose.c \ - server-queue.c server-queue.h \ - api.c api-server.c \ - exports.c \ - ../lib/memgc.c +disorder_choose_SOURCES=choose.c server-queue.c ../lib/memgc.c disorder_choose_LDADD=$(LIBOBJS) ../lib/libdisorder.a \ $(LIBDB) $(LIBGC) $(LIBPCRE) $(LIBGCRYPT) disorder_choose_LDFLAGS=-export-dynamic @@ -101,15 +88,6 @@ disorder_dbupgrade_LDADD=$(LIBOBJS) ../lib/libdisorder.a \ $(LIBDB) $(LIBGC) $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) disorder_dbupgrade_DEPENDENCIES=../lib/libdisorder.a -disorder_cgi_SOURCES=macros-disorder.c macros-disorder.h lookup.c \ - lookup.h options.c options.h actions.c actions.h login.c \ - login.h api.c \ - api-client.c api-client.h cgimain.c exports.c -disorder_cgi_LDADD=../lib/libdisorder.a \ - $(LIBPCRE) $(LIBGCRYPT) $(LIBDL) $(LIBDB) -disorder_cgi_LDFLAGS=-export-dynamic -disorder_cgi_DEPENDENCIES=../lib/libdisorder.a - trackname_SOURCES=trackname.c trackname_LDADD=../lib/libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGCRYPT) trackname_DEPENDENCIES=../lib/libdisorder.a @@ -157,6 +135,4 @@ check-decode: disorder-decode disorder-normalize cmp decoded.raw oggdec.raw rm -f scratch.wav config decoded.raw oggdec.raw -cgi.o: ../lib/definitions.h - EXTRA_DIST=README.dbversions diff --git a/server/api-client.c b/server/api-client.c index 2f6a01f..174ed88 100644 --- a/server/api-client.c +++ b/server/api-client.c @@ -18,12 +18,9 @@ * USA */ -#include -#include "types.h" +#include "common.h" -#include #include -#include #include #include #include diff --git a/server/api-server.c b/server/api-server.c index bc8144e..173c82e 100644 --- a/server/api-server.c +++ b/server/api-server.c @@ -18,23 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "log.h" -#include "mem.h" -#include "disorder.h" -#include "event.h" -#include "rights.h" -#include "trackdb.h" +#include "disorder-server.h" int disorder_track_exists(const char *track) { return trackdb_exists(track); diff --git a/server/api.c b/server/api.c index 5366468..11564f8 100644 --- a/server/api.c +++ b/server/api.c @@ -18,18 +18,7 @@ * USA */ -#include - -#include -#include -#include -#include -#include - -#include "log.h" -#include "mem.h" -#include "disorder.h" -#include "printf.h" +#include "disorder-server.h" /* shared implementation of vararg functions */ #include "log-impl.h" diff --git a/server/choose.c b/server/choose.c index c39e27b..f1d06b8 100644 --- a/server/choose.c +++ b/server/choose.c @@ -26,37 +26,7 @@ * deadlock - it just exits and expects the server to try again. */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configuration.h" -#include "log.h" -#include "defs.h" -#include "mem.h" -#include "kvp.h" -#include "syscalls.h" -#include "printf.h" -#include "trackdb.h" -#include "trackdb-int.h" -#include "version.h" -#include "trackname.h" -#include "queue.h" -#include "server-queue.h" -#include "random.h" +#include "disorder-server.h" #define BASE_WEIGHT 90000 diff --git a/server/daemonize.c b/server/daemonize.c index 7dea700..5f6e226 100644 --- a/server/daemonize.c +++ b/server/daemonize.c @@ -21,18 +21,7 @@ * @brief Go into background */ -#include - -#include -#include -#include -#include -#include -#include - -#include "daemonize.h" -#include "syscalls.h" -#include "log.h" +#include "disorder-server.h" /** @brief Go into background * @param tag Message tag, or NULL diff --git a/server/daemonize.h b/server/daemonize.h deleted file mode 100644 index 23d88a6..0000000 --- a/server/daemonize.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -/** @file server/daemonize.h - * @brief Go into background - */ - -#ifndef DAEMONIZE_H -#define DAEMONIZE_H - -void daemonize(const char *tag, int fac, const char *pidfile); -/* Go into background. Send stdout/stderr to syslog. - * If @pri@ is non-null, it should be "facility.level" - * If @tag@ is non-null, it is used as a tag to each message - * If @pidfile@ is non-null, the PID is written to that file. - */ - -#endif /* DAEMONIZE_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/server/dbupgrade.c b/server/dbupgrade.c index f972b59..74354b7 100644 --- a/server/dbupgrade.c +++ b/server/dbupgrade.c @@ -17,30 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ - -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "syscalls.h" -#include "log.h" -#include "defs.h" -#include "kvp.h" -#include "rights.h" -#include "trackdb.h" -#include "trackdb-int.h" -#include "mem.h" -#include "configuration.h" -#include "unicode.h" -#include "version.h" +#include "disorder-server.h" static DB_TXN *global_tid; @@ -138,9 +115,9 @@ static int scan_core(const char *name, DB *db, * Everything happens inside the @p global_tid tranasction. @p callback * should return 0 or DB_LOCK_DEADLOCK. */ -static void scan(const char *name, DB *db, - int (*callback)(const char *name, DB *db, DBC *c, - DBT *k, DBT *d)) { +static void scandb(const char *name, DB *db, + int (*callback)(const char *name, DB *db, DBC *c, + DBT *k, DBT *d)) { info("scanning %s", name); for(;;) { global_tid = trackdb_begin_transaction(); @@ -312,16 +289,16 @@ static void upgrade(void) { /* Normalize keys and values as required. We will also remove aliases as * they will be regenerated when we re-noticed the tracks. */ info("renormalizing keys"); - scan("tracks.db", trackdb_tracksdb, remove_aliases_normalize_keys); - scan("prefs.db", trackdb_prefsdb, normalize_keys); - scan("global.db", trackdb_globaldb, normalize_keys); - scan("noticed.db", trackdb_noticeddb, normalize_values); + scandb("tracks.db", trackdb_tracksdb, remove_aliases_normalize_keys); + scandb("prefs.db", trackdb_prefsdb, normalize_keys); + scandb("global.db", trackdb_globaldb, normalize_keys); + scandb("noticed.db", trackdb_noticeddb, normalize_values); /* search.db and tags.db we will rebuild */ info("regenerating search database and aliases"); truncate_database("search.db", trackdb_searchdb); truncate_database("tags.db", trackdb_tagsdb); /* Regenerate the search database and aliases */ - scan("tracks.db", trackdb_tracksdb, renotice); + scandb("tracks.db", trackdb_tracksdb, renotice); /* Finally update the database version */ snprintf(buf, sizeof buf, "%ld", config->dbversion); trackdb_set_global("_dbversion", buf, 0); diff --git a/server/deadlock.c b/server/deadlock.c index dba28d3..1a47301 100644 --- a/server/deadlock.c +++ b/server/deadlock.c @@ -18,31 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configuration.h" -#include "syscalls.h" -#include "log.h" -#include "defs.h" -#include "mem.h" -#include "kvp.h" -#include "rights.h" -#include "trackdb.h" -#include "trackdb-int.h" -#include "version.h" +#include "disorder-server.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, diff --git a/server/decode.c b/server/decode.c index c693c75..3a1e1a9 100644 --- a/server/decode.c +++ b/server/decode.c @@ -21,20 +21,10 @@ * @brief General-purpose decoder for use by speaker process */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include +#include "disorder-server.h" + #include #include -#include /* libFLAC has had an API change and stupidly taken away the old API */ #if HAVE_FLAC_FILE_DECODER_H @@ -45,12 +35,8 @@ #define FLAC__FileDecoderState FLAC__StreamDecoderState #endif -#include "log.h" -#include "syscalls.h" -#include "defs.h" #include "wav.h" #include "speaker-protocol.h" -#include "version.h" /** @brief Encoding lookup table type */ struct decoder { diff --git a/server/disorder-server.h b/server/disorder-server.h new file mode 100644 index 0000000..361bd4f --- /dev/null +++ b/server/disorder-server.h @@ -0,0 +1,332 @@ +/* + * This file is part of DisOrder + * Copyright (C) 2008 Richard Kettlewell + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#ifndef DISORDER_SERVER_H +#define DISORDER_SERVER_H + +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "addr.h" +#include "authhash.h" +#include "base64.h" +#include "cache.h" +#include "charset.h" +#include "configuration.h" +#include "cookies.h" +#include "defs.h" +#include "disorder.h" +#include "event.h" +#include "eventlog.h" +#include "eventlog.h" +#include "hash.h" +#include "hex.h" +#include "inputline.h" +#include "kvp.h" +#include "log.h" +#include "logfd.h" +#include "mem.h" +#include "mime.h" +#include "mixer.h" +#include "printf.h" +#include "queue.h" +#include "random.h" +#include "rights.h" +#include "sendmail.h" +#include "sink.h" +#include "speaker-protocol.h" +#include "split.h" +#include "syscalls.h" +#include "table.h" +#include "trackdb-int.h" +#include "trackdb.h" +#include "trackname.h" +#include "unicode.h" +#include "user.h" +#include "vector.h" +#include "version.h" +#include "wstat.h" + +void daemonize(const char *tag, int fac, const char *pidfile); +/* Go into background. Send stdout/stderr to syslog. + * If @pri@ is non-null, it should be "facility.level" + * If @tag@ is non-null, it is used as a tag to each message + * If @pidfile@ is non-null, the PID is written to that file. + */ + +void quit(ev_source *ev) attribute((noreturn)); +/* terminate the daemon */ + +int reconfigure(ev_source *ev, int reload); +/* reconfigure. If @reload@ is nonzero, update the configuration. */ + +extern struct queue_entry qhead; +/* queue of things yet to be played. the head will be played + * soonest. */ + +extern struct queue_entry phead; +/* things that have been played in the past. the head is the oldest. */ + +extern long pcount; + +void queue_read(void); +/* read the queue in. Calls @fatal@ on error. */ + +void queue_write(void); +/* write the queue out. Calls @fatal@ on error. */ + +void recent_read(void); +/* read the recently played list in. Calls @fatal@ on error. */ + +void recent_write(void); +/* write the recently played list out. Calls @fatal@ on error. */ + +struct queue_entry *queue_add(const char *track, const char *submitter, + int where); +#define WHERE_START 0 /* Add to head of queue */ +#define WHERE_END 1 /* Add to end of queue */ +#define WHERE_BEFORE_RANDOM 2 /* End, or before random track */ +/* add an entry to the queue. Return a pointer to the new entry. */ + +void queue_remove(struct queue_entry *q, const char *who); +/* remove an from the queue */ + +struct queue_entry *queue_find(const char *key); +/* find a track in the queue by name or ID */ + +void queue_played(struct queue_entry *q); +/* add @q@ to the played list */ + +int queue_move(struct queue_entry *q, int delta, const char *who); +/* move element @q@ in the queue towards the front (@delta@ > 0) or towards the + * back (@delta@ < 0). The return value is the leftover delta once we've hit + * the end in whichever direction we were going. */ + +void queue_moveafter(struct queue_entry *target, + int nqs, struct queue_entry **qs, const char *who); +/* Move all the elements QS to just after TARGET, or to the head if + * TARGET=0. */ + +void queue_fix_sofar(struct queue_entry *q); +/* Fix up the sofar field for standalone players */ + +void schedule_init(ev_source *ev); +const char *schedule_add(ev_source *ev, + struct kvp *actiondata); +int schedule_del(const char *id); +struct kvp *schedule_get(const char *id); +char **schedule_list(int *neventsp); + +extern struct queue_entry *playing; /* playing track or 0 */ +extern int paused; /* non-0 if paused */ + +void play(ev_source *ev); +/* try to play something, if playing is enabled and nothing is playing + * already */ + +int playing_is_enabled(void); +/* return true iff playing is enabled */ + +void enable_playing(const char *who, ev_source *ev); +/* enable playing */ + +void disable_playing(const char *who); +/* disable playing. */ + +int random_is_enabled(void); +/* return true iff random play is enabled */ + +void enable_random(const char *who, ev_source *ev); +/* enable random play */ + +void disable_random(const char *who); +/* disable random play */ + +void scratch(const char *who, const char *id); +/* scratch the playing track. @who@ identifies the scratcher. @id@ is + * the ID or a null pointer. */ + +void quitting(ev_source *ev); +/* called to terminate current track and shut down speaker process + * when quitting */ + +void speaker_setup(ev_source *ev); +/* set up the speaker subprocess */ + +void speaker_reload(void); +/* Tell the speaker process to reload its configuration. */ + +int pause_playing(const char *who); +/* Pause the current track. Return 0 on success, -1 on error. WHO + * can be 0. */ + +void resume_playing(const char *who); +/* Resume after a pause. WHO can be 0. */ + +int prepare(ev_source *ev, + struct queue_entry *q); +/* Prepare to play Q */ + +void abandon(ev_source *ev, + struct queue_entry *q); +/* Abandon a possibly-prepared track. */ + +void add_random_track(ev_source *ev); +/* If random play is enabled then try to add a track to the queue. */ + +int server_start(ev_source *ev, int pf, + size_t socklen, const struct sockaddr *sa, + const char *name); +/* start listening. Return the fd. */ + +int server_stop(ev_source *ev, int fd); +/* Stop listening on @fd@ */ + +extern int volume_left, volume_right; /* last known volume */ + +extern int wideopen; /* blindly accept all logins */ + +/* plugins */ + +struct plugin; + +typedef void *plugin_handle; +typedef void function_t(void); + +const struct plugin *open_plugin(const char *name, + unsigned flags); +#define PLUGIN_FATAL 0x0001 /* fatal() on error */ +/* Open a plugin. Returns a null pointer on error or a handle to it + * on success. */ + +function_t *get_plugin_function(const struct plugin *handle, + const char *symbol); +const void *get_plugin_object(const struct plugin *handle, + const char *symbol); +/* Look up a function or an object in a plugin */ + +/* track length computation ***************************************************/ + +long tracklength(const char *plugin, const char *track, const char *path); + +/* collection interface *******************************************************/ + +void scan(const char *module, const char *root); +/* write a list of path names below @root@ to standard output. */ + +int check(const char *module, const char *root, const char *path); +/* Recheck a track, given its root and path name. Return 1 if it + * exists, 0 if it does not exist and -1 if an error occurred. */ + +/* notification interface *****************************************************/ + +void notify_play(const char *track, + const char *submitter); +/* we're going to play @track@. It was submitted by @submitter@ + * (might be a null pointer) */ + +void notify_scratch(const char *track, + const char *submitter, + const char *scratcher, + int seconds); +/* @scratcher@ scratched @track@ after @seconds@. It was submitted by + * @submitter@ (might be a null pointer) */ + +void notify_not_scratched(const char *track, + const char *submitter); +/* @track@ (submitted by @submitter@, which might be a null pointer) + * was not scratched. */ + +void notify_queue(const char *track, + const char *submitter); +/* @track@ was queued by @submitter@ */ + +void notify_queue_remove(const char *track, + const char *remover); +/* @track@ removed from the queue by @remover@ (never a null pointer) */ + +void notify_queue_move(const char *track, + const char *mover); +/* @track@ moved in the queue by @mover@ (never a null pointer) */ + +void notify_pause(const char *track, + const char *pauser); +/* TRACK was paused by PAUSER (might be a null pointer) */ + +void notify_resume(const char *track, + const char *resumer); +/* TRACK was resumed by PAUSER (might be a null pointer) */ + +/* track playing **************************************************************/ + +unsigned long play_get_type(const struct plugin *pl); +/* Get the type word for this plugin */ + +void *play_prefork(const struct plugin *pl, + const char *track); +/* Call the prefork function for PL and return the user data */ + +void play_track(const struct plugin *pl, + const char *const *parameters, + int nparameters, + const char *path, + const char *track); +/* play a track. Called inside a fork. */ + +void play_cleanup(const struct plugin *pl, void *data); +/* Call the cleanup function for PL if necessary */ + +int play_pause(const struct plugin *pl, long *playedp, void *data); +/* Pause track. */ + +void play_resume(const struct plugin *pl, void *data); +/* Resume track. */ + +#endif /* DISORDER_SERVER_H */ + +/* +Local Variables: +c-basic-offset:2 +comment-column:40 +fill-column:79 +indent-tabs-mode:nil +End: +*/ diff --git a/server/disorderd.c b/server/disorderd.c index 9f444b6..e78c28f 100644 --- a/server/disorderd.c +++ b/server/disorderd.c @@ -17,47 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ - -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "daemonize.h" -#include "event.h" -#include "log.h" -#include "configuration.h" -#include "rights.h" -#include "trackdb.h" -#include "queue.h" -#include "mem.h" -#include "play.h" -#include "server.h" -#include "state.h" -#include "syscalls.h" -#include "defs.h" -#include "user.h" -#include "mixer.h" -#include "eventlog.h" -#include "printf.h" -#include "version.h" +#include "disorder-server.h" static ev_source *ev; diff --git a/server/dump.c b/server/dump.c index 7b4b3a4..aec1804 100644 --- a/server/dump.c +++ b/server/dump.c @@ -18,35 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configuration.h" -#include "syscalls.h" -#include "log.h" -#include "client.h" -#include "sink.h" -#include "mem.h" -#include "defs.h" -#include "printf.h" -#include "kvp.h" -#include "vector.h" -#include "inputline.h" -#include "rights.h" -#include "trackdb.h" -#include "trackdb-int.h" -#include "charset.h" -#include "version.h" +#include "disorder-server.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, diff --git a/server/normalize.c b/server/normalize.c index 6d8823e..956eb6b 100644 --- a/server/normalize.c +++ b/server/normalize.c @@ -25,24 +25,7 @@ * and eliminate the dependency on sox. */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "syscalls.h" -#include "log.h" -#include "configuration.h" -#include "speaker-protocol.h" -#include "defs.h" -#include "version.h" +#include "disorder-server.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, diff --git a/server/play.c b/server/play.c index df9158b..756031d 100644 --- a/server/play.c +++ b/server/play.c @@ -18,44 +18,8 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "disorder-server.h" #include -#include -#include - -#include "event.h" -#include "log.h" -#include "mem.h" -#include "configuration.h" -#include "queue.h" -#include "server-queue.h" -#include "rights.h" -#include "trackdb.h" -#include "play.h" -#include "plugin.h" -#include "wstat.h" -#include "eventlog.h" -#include "logfd.h" -#include "syscalls.h" -#include "speaker-protocol.h" -#include "disorder.h" -#include "signame.h" -#include "hash.h" #define SPEAKER "disorder-speaker" diff --git a/server/play.h b/server/play.h deleted file mode 100644 index aff474c..0000000 --- a/server/play.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004-2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef PLAY_H -#define PLAY_H - -extern struct queue_entry *playing; /* playing track or 0 */ -extern int paused; /* non-0 if paused */ - -void play(ev_source *ev); -/* try to play something, if playing is enabled and nothing is playing - * already */ - -int playing_is_enabled(void); -/* return true iff playing is enabled */ - -void enable_playing(const char *who, ev_source *ev); -/* enable playing */ - -void disable_playing(const char *who); -/* disable playing. */ - -int random_is_enabled(void); -/* return true iff random play is enabled */ - -void enable_random(const char *who, ev_source *ev); -/* enable random play */ - -void disable_random(const char *who); -/* disable random play */ - -void scratch(const char *who, const char *id); -/* scratch the playing track. @who@ identifies the scratcher. @id@ is - * the ID or a null pointer. */ - -void quitting(ev_source *ev); -/* called to terminate current track and shut down speaker process - * when quitting */ - -void speaker_setup(ev_source *ev); -/* set up the speaker subprocess */ - -void speaker_reload(void); -/* Tell the speaker process to reload its configuration. */ - -int pause_playing(const char *who); -/* Pause the current track. Return 0 on success, -1 on error. WHO - * can be 0. */ - -void resume_playing(const char *who); -/* Resume after a pause. WHO can be 0. */ - -int prepare(ev_source *ev, - struct queue_entry *q); -/* Prepare to play Q */ - -void abandon(ev_source *ev, - struct queue_entry *q); -/* Abandon a possibly-prepared track. */ - -void add_random_track(ev_source *ev); -/* If random play is enabled then try to add a track to the queue. */ - -#endif /* PLAY_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -fill-column:79 -End: -*/ diff --git a/lib/plugin.c b/server/plugin.c similarity index 96% rename from lib/plugin.c rename to server/plugin.c index c23865d..a0c7d35 100644 --- a/lib/plugin.c +++ b/server/plugin.c @@ -18,21 +18,9 @@ * USA */ -#include -#include "types.h" +#include "disorder-server.h" #include -#include -#include -#include - -#include "plugin.h" -#include "configuration.h" -#include "log.h" -#include "mem.h" -#include "defs.h" -#include "disorder.h" -#include "printf.h" /* generic plugin support *****************************************************/ diff --git a/server/queue-ops.c b/server/queue-ops.c new file mode 100644 index 0000000..952cb71 --- /dev/null +++ b/server/queue-ops.c @@ -0,0 +1,190 @@ +/* + * This file is part of DisOrder. + * Copyright (C) 2004-2008 Richard Kettlewell + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ +#include "disorder-server.h" + +static int find_in_list(struct queue_entry *needle, + int nqs, struct queue_entry **qs) { + int n; + + for(n = 0; n < nqs; ++n) + if(qs[n] == needle) + return 1; + return 0; +} + +static int id_in_use(const char *id) { + struct queue_entry *q; + + for(q = qhead.next; q != &qhead; q = q->next) + if(!strcmp(id, q->id)) + return 1; + return 0; +} + +static void queue_id(struct queue_entry *q) { + const char *id; + + id = random_id(); + while(id_in_use(id)) + id = random_id(); + q->id = id; +} + +struct queue_entry *queue_add(const char *track, const char *submitter, + int where) { + struct queue_entry *q, *beforeme; + + q = xmalloc(sizeof *q); + q->track = xstrdup(track); + q->submitter = submitter ? xstrdup(submitter) : 0; + q->state = playing_unplayed; + queue_id(q); + time(&q->when); + switch(where) { + case WHERE_START: + queue_insert_entry(&qhead, q); + break; + case WHERE_END: + queue_insert_entry(qhead.prev, q); + break; + case WHERE_BEFORE_RANDOM: + /* We want to find the point in the queue before the block of random tracks + * at the end. */ + beforeme = &qhead; + while(beforeme->prev != &qhead + && beforeme->prev->state == playing_random) + beforeme = beforeme->prev; + queue_insert_entry(beforeme->prev, q); + break; + } + /* submitter will be a null pointer for a scratch */ + if(submitter) + notify_queue(track, submitter); + eventlog_raw("queue", queue_marshall(q), (const char *)0); + return q; +} + +int queue_move(struct queue_entry *q, int delta, const char *who) { + int moved = 0; + char buffer[20]; + + /* not the most efficient approach but hopefuly relatively comprehensible: + * the idea is that for each step we determine which nodes are affected, and + * fill in all the links starting at the 'prev' end and moving towards the + * 'next' end. */ + + while(delta > 0 && q->prev != &qhead) { + struct queue_entry *n, *p, *pp; + + n = q->next; + p = q->prev; + pp = p->prev; + pp->next = q; + q->prev = pp; + q->next = p; + p->prev = q; + p->next = n; + n->prev = p; + --delta; + ++moved; + } + + while(delta < 0 && q->next != &qhead) { + struct queue_entry *n, *p, *nn; + + p = q->prev; + n = q->next; + nn = n->next; + p->next = n; + n->prev = p; + n->next = q; + q->prev = n; + q->next = nn; + nn->prev = q; + ++delta; + --moved; + } + + if(moved) { + info("user %s moved %s", who, q->id); + notify_queue_move(q->track, who); + sprintf(buffer, "%d", moved); + eventlog("moved", who, (char *)0); + } + + return delta; +} + +void queue_moveafter(struct queue_entry *target, + int nqs, struct queue_entry **qs, + const char *who) { + struct queue_entry *q; + int n; + + /* Normalize */ + if(!target) + target = &qhead; + else + while(find_in_list(target, nqs, qs)) + target = target->prev; + /* Do the move */ + for(n = 0; n < nqs; ++n) { + q = qs[n]; + queue_delete_entry(q); + queue_insert_entry(target, q); + target = q; + /* Log the individual tracks */ + info("user %s moved %s", who, q->id); + notify_queue_move(q->track, who); + } + /* Report that the queue changed to the event log */ + eventlog("moved", who, (char *)0); +} + +void queue_remove(struct queue_entry *which, const char *who) { + if(who) { + info("user %s removed %s", who, which->id); + notify_queue_move(which->track, who); + } + eventlog("removed", which->id, who, (const char *)0); + queue_delete_entry(which); +} + +void queue_played(struct queue_entry *q) { + while(pcount && pcount >= config->history) { + eventlog("recent_removed", phead.next->id, (char *)0); + queue_delete_entry(phead.next); + pcount--; + } + if(config->history) { + eventlog_raw("recent_added", queue_marshall(q), (char *)0); + queue_insert_entry(phead.prev, q); + ++pcount; + } +} + +/* +Local Variables: +c-basic-offset:2 +comment-column:40 +fill-column:79 +indent-tabs-mode:nil +End: +*/ diff --git a/server/rescan.c b/server/rescan.c index 2d390f8..04ffba4 100644 --- a/server/rescan.c +++ b/server/rescan.c @@ -18,41 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configuration.h" -#include "syscalls.h" -#include "log.h" -#include "defs.h" -#include "mem.h" -#include "plugin.h" -#include "inputline.h" -#include "charset.h" -#include "wstat.h" -#include "kvp.h" -#include "printf.h" -#include "rights.h" -#include "trackdb.h" -#include "trackdb-int.h" -#include "trackname.h" -#include "unicode.h" -#include "version.h" +#include "disorder-server.h" static DB_TXN *global_tid; diff --git a/server/schedule.c b/server/schedule.c index 4f0b34e..6092fb5 100644 --- a/server/schedule.c +++ b/server/schedule.c @@ -81,28 +81,7 @@ * * TODO: add disorder-dump support */ - -#include -#include "types.h" - -#include -#include -#include -#include - -#include "trackdb.h" -#include "trackdb-int.h" -#include "schedule.h" -#include "table.h" -#include "kvp.h" -#include "log.h" -#include "queue.h" -#include "server-queue.h" -#include "state.h" -#include "play.h" -#include "mem.h" -#include "random.h" -#include "vector.h" +#include "disorder-server.h" static int schedule_trigger(ev_source *ev, const struct timeval *now, diff --git a/server/schedule.h b/server/schedule.h deleted file mode 100644 index 0c7efa1..0000000 --- a/server/schedule.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of DisOrder - * Copyright (C) 2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef SCHEDULE_H -#define SCHEDULE_H - -void schedule_init(ev_source *ev); -const char *schedule_add(ev_source *ev, - struct kvp *actiondata); -int schedule_del(const char *id); -struct kvp *schedule_get(const char *id); -char **schedule_list(int *neventsp); - -#endif /* SCHEDULE_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -fill-column:79 -indent-tabs-mode:nil -End: -*/ diff --git a/server/server-queue.c b/server/server-queue.c index b71d677..a83ee56 100644 --- a/server/server-queue.c +++ b/server/server-queue.c @@ -17,28 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ - -#include -#include "types.h" - -#include -#include -#include -#include -#include - -#include "mem.h" -#include "log.h" -#include "split.h" -#include "printf.h" -#include "queue.h" -#include "server-queue.h" -#include "eventlog.h" -#include "plugin.h" -#include "random.h" -#include "configuration.h" -#include "inputline.h" -#include "disorder.h" +#include "disorder-server.h" /* the head of the queue is played next, so normally we add to the tail */ struct queue_entry qhead = { &qhead, &qhead, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -47,21 +26,7 @@ struct queue_entry qhead = { &qhead, &qhead, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, * played */ struct queue_entry phead = { &phead, &phead, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static long pcount; - -/* add new entry @n@ to a doubly linked list just after @b@ */ -static void l_add(struct queue_entry *b, struct queue_entry *n) { - n->prev = b; - n->next = b->next; - n->next->prev = n; - n->prev->next = n; -} - -/* remove an entry from a doubly-linked list */ -static void l_remove(struct queue_entry *node) { - node->next->prev = node->prev; - node->prev->next = node->next; -} +long pcount; void queue_fix_sofar(struct queue_entry *q) { long sofar; @@ -110,7 +75,7 @@ static void queue_do_read(struct queue_entry *head, const char *path) { && (!q->track || !q->when)) fatal(0, "incomplete queue entry in %s", path); - l_add(head->prev, q); + queue_insert_entry(head->prev, q); } if(ferror(fp)) fatal(errno, "error reading %s", path); fclose(fp); @@ -155,154 +120,6 @@ void recent_write(void) { queue_do_write(&phead, config_get_file("recent")); } -static int id_in_use(const char *id) { - struct queue_entry *q; - - for(q = qhead.next; q != &qhead; q = q->next) - if(!strcmp(id, q->id)) - return 1; - return 0; -} - -static void queue_id(struct queue_entry *q) { - const char *id; - - id = random_id(); - while(id_in_use(id)) - id = random_id(); - q->id = id; -} - -struct queue_entry *queue_add(const char *track, const char *submitter, - int where) { - struct queue_entry *q, *beforeme; - - q = xmalloc(sizeof *q); - q->track = xstrdup(track); - q->submitter = submitter ? xstrdup(submitter) : 0; - q->state = playing_unplayed; - queue_id(q); - time(&q->when); - switch(where) { - case WHERE_START: - l_add(&qhead, q); - break; - case WHERE_END: - l_add(qhead.prev, q); - break; - case WHERE_BEFORE_RANDOM: - /* We want to find the point in the queue before the block of random tracks - * at the end. */ - beforeme = &qhead; - while(beforeme->prev != &qhead - && beforeme->prev->state == playing_random) - beforeme = beforeme->prev; - l_add(beforeme->prev, q); - break; - } - /* submitter will be a null pointer for a scratch */ - if(submitter) - notify_queue(track, submitter); - eventlog_raw("queue", queue_marshall(q), (const char *)0); - return q; -} - -int queue_move(struct queue_entry *q, int delta, const char *who) { - int moved = 0; - char buffer[20]; - - /* not the most efficient approach but hopefuly relatively comprehensible: - * the idea is that for each step we determine which nodes are affected, and - * fill in all the links starting at the 'prev' end and moving towards the - * 'next' end. */ - - while(delta > 0 && q->prev != &qhead) { - struct queue_entry *n, *p, *pp; - - n = q->next; - p = q->prev; - pp = p->prev; - pp->next = q; - q->prev = pp; - q->next = p; - p->prev = q; - p->next = n; - n->prev = p; - --delta; - ++moved; - } - - while(delta < 0 && q->next != &qhead) { - struct queue_entry *n, *p, *nn; - - p = q->prev; - n = q->next; - nn = n->next; - p->next = n; - n->prev = p; - n->next = q; - q->prev = n; - q->next = nn; - nn->prev = q; - ++delta; - --moved; - } - - if(moved) { - info("user %s moved %s", who, q->id); - notify_queue_move(q->track, who); - sprintf(buffer, "%d", moved); - eventlog("moved", who, (char *)0); - } - - return delta; -} - -static int find_in_list(struct queue_entry *needle, - int nqs, struct queue_entry **qs) { - int n; - - for(n = 0; n < nqs; ++n) - if(qs[n] == needle) - return 1; - return 0; -} - -void queue_moveafter(struct queue_entry *target, - int nqs, struct queue_entry **qs, - const char *who) { - struct queue_entry *q; - int n; - - /* Normalize */ - if(!target) - target = &qhead; - else - while(find_in_list(target, nqs, qs)) - target = target->prev; - /* Do the move */ - for(n = 0; n < nqs; ++n) { - q = qs[n]; - l_remove(q); - l_add(target, q); - target = q; - /* Log the individual tracks */ - info("user %s moved %s", who, q->id); - notify_queue_move(q->track, who); - } - /* Report that the queue changed to the event log */ - eventlog("moved", who, (char *)0); -} - -void queue_remove(struct queue_entry *which, const char *who) { - if(who) { - info("user %s removed %s", who, which->id); - notify_queue_move(which->track, who); - } - eventlog("removed", which->id, who, (const char *)0); - l_remove(which); -} - struct queue_entry *queue_find(const char *key) { struct queue_entry *q; @@ -313,19 +130,6 @@ struct queue_entry *queue_find(const char *key) { return q != &qhead ? q : 0; } -void queue_played(struct queue_entry *q) { - while(pcount && pcount >= config->history) { - eventlog("recent_removed", phead.next->id, (char *)0); - l_remove(phead.next); - pcount--; - } - if(config->history) { - eventlog_raw("recent_added", queue_marshall(q), (char *)0); - l_add(phead.prev, q); - ++pcount; - } -} - /* Local Variables: c-basic-offset:2 diff --git a/server/server-queue.h b/server/server-queue.h deleted file mode 100644 index 624f203..0000000 --- a/server/server-queue.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef SERVER_QUEUE_H -#define SERVER_QUEUE_H - -extern struct queue_entry qhead; -/* queue of things yet to be played. the head will be played - * soonest. */ - -extern struct queue_entry phead; -/* things that have been played in the past. the head is the oldest. */ - -void queue_read(void); -/* read the queue in. Calls @fatal@ on error. */ - -void queue_write(void); -/* write the queue out. Calls @fatal@ on error. */ - -void recent_read(void); -/* read the recently played list in. Calls @fatal@ on error. */ - -void recent_write(void); -/* write the recently played list out. Calls @fatal@ on error. */ - -struct queue_entry *queue_add(const char *track, const char *submitter, - int where); -#define WHERE_START 0 /* Add to head of queue */ -#define WHERE_END 1 /* Add to end of queue */ -#define WHERE_BEFORE_RANDOM 2 /* End, or before random track */ -/* add an entry to the queue. Return a pointer to the new entry. */ - -void queue_remove(struct queue_entry *q, const char *who); -/* remove an from the queue */ - -struct queue_entry *queue_find(const char *key); -/* find a track in the queue by name or ID */ - -void queue_played(struct queue_entry *q); -/* add @q@ to the played list */ - -int queue_move(struct queue_entry *q, int delta, const char *who); -/* move element @q@ in the queue towards the front (@delta@ > 0) or towards the - * back (@delta@ < 0). The return value is the leftover delta once we've hit - * the end in whichever direction we were going. */ - -void queue_moveafter(struct queue_entry *target, - int nqs, struct queue_entry **qs, const char *who); -/* Move all the elements QS to just after TARGET, or to the head if - * TARGET=0. */ - -void queue_fix_sofar(struct queue_entry *q); -/* Fix up the sofar field for standalone players */ - -#endif /* SERVER_QUEUE_H */ - - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -fill-column:79 -indent-tabs-mode:nil -End: -*/ diff --git a/server/server.c b/server/server.c index 527255e..0ddfd53 100644 --- a/server/server.c +++ b/server/server.c @@ -18,60 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "event.h" -#include "server.h" -#include "syscalls.h" -#include "queue.h" -#include "server-queue.h" -#include "play.h" -#include "log.h" -#include "mem.h" -#include "state.h" -#include "charset.h" -#include "split.h" -#include "configuration.h" -#include "hex.h" -#include "rights.h" -#include "trackdb.h" -#include "table.h" -#include "kvp.h" -#include "mixer.h" -#include "sink.h" -#include "authhash.h" -#include "plugin.h" -#include "printf.h" -#include "trackname.h" -#include "eventlog.h" -#include "defs.h" -#include "cache.h" -#include "unicode.h" -#include "cookies.h" -#include "base64.h" -#include "hash.h" -#include "mime.h" -#include "sendmail.h" -#include "wstat.h" -#include "schedule.h" +#include "disorder-server.h" #ifndef NONCE_SIZE # define NONCE_SIZE 16 diff --git a/server/server.h b/server/server.h deleted file mode 100644 index 0d34d1e..0000000 --- a/server/server.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2006-2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef SERVER_H -#define SERVER_H - -/* The command-response server. - * - * See disorder_protocol(5) for sometimes up-to-date protocol documentation. - */ - -int server_start(ev_source *ev, int pf, - size_t socklen, const struct sockaddr *sa, - const char *name); -/* start listening. Return the fd. */ - -int server_stop(ev_source *ev, int fd); -/* Stop listening on @fd@ */ - -extern int volume_left, volume_right; /* last known volume */ - -extern int wideopen; /* blindly accept all logins */ - -#endif /* SERVER_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -fill-column:79 -End: -*/ diff --git a/server/speaker-alsa.c b/server/speaker-alsa.c index 8ed01a8..41e53b2 100644 --- a/server/speaker-alsa.c +++ b/server/speaker-alsa.c @@ -20,12 +20,10 @@ /** @file server/speaker-alsa.c * @brief Support for @ref BACKEND_ALSA */ -#include +#include "common.h" #if HAVE_ALSA_ASOUNDLIB_H -#include "types.h" - #include #include #include diff --git a/server/speaker-command.c b/server/speaker-command.c index 27b2664..7e19e2b 100644 --- a/server/speaker-command.c +++ b/server/speaker-command.c @@ -21,8 +21,7 @@ /** @file server/speaker-command.c * @brief Support for @ref BACKEND_COMMAND */ -#include -#include "types.h" +#include "common.h" #include #include diff --git a/server/speaker-coreaudio.c b/server/speaker-coreaudio.c index 4f46891..df2759b 100644 --- a/server/speaker-coreaudio.c +++ b/server/speaker-coreaudio.c @@ -32,12 +32,10 @@ * @todo support @ref config::device */ -#include +#include "common.h" #if HAVE_COREAUDIO_AUDIOHARDWARE_H -#include "types.h" - #include #include #include diff --git a/server/speaker-network.c b/server/speaker-network.c index b77334c..2d8d2cb 100644 --- a/server/speaker-network.c +++ b/server/speaker-network.c @@ -20,8 +20,7 @@ /** @file server/speaker-network.c * @brief Support for @ref BACKEND_NETWORK */ -#include -#include "types.h" +#include "common.h" #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/server/speaker-oss.c b/server/speaker-oss.c index 36ef4a8..95dcfe3 100644 --- a/server/speaker-oss.c +++ b/server/speaker-oss.c @@ -21,15 +21,12 @@ /** @file server/speaker-oss.c * @brief Support for @ref BACKEND_OSS */ -#include +#include "common.h" #if HAVE_SYS_SOUNDCARD_H -#include "types.h" - #include #include -#include #include #include #include diff --git a/server/speaker.c b/server/speaker.c index bcc44cc..3021652 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -50,19 +50,14 @@ * 2-byte samples. */ -#include -#include "types.h" +#include "common.h" #include -#include -#include #include #include #include #include #include -#include -#include #include #include #include diff --git a/server/state.c b/server/state.c index ad90425..2be2edd 100644 --- a/server/state.c +++ b/server/state.c @@ -18,35 +18,7 @@ * USA */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "event.h" -#include "play.h" -#include "rights.h" -#include "trackdb.h" -#include "state.h" -#include "configuration.h" -#include "log.h" -#include "queue.h" -#include "server-queue.h" -#include "server.h" -#include "printf.h" -#include "addr.h" -#include "schedule.h" +#include "disorder-server.h" static const char *current_unix; static int current_unix_fd; diff --git a/server/state.h b/server/state.h deleted file mode 100644 index 21f6a1a..0000000 --- a/server/state.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 Richard Kettlewell - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef STATE_H -#define STATE_H - -void quit(ev_source *ev) attribute((noreturn)); -/* terminate the daemon */ - -int reconfigure(ev_source *ev, int reload); -/* reconfigure. If @reload@ is nonzero, update the configuration. */ - -#endif /* QUIT_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/server/stats.c b/server/stats.c index 5648ca0..2725fd5 100644 --- a/server/stats.c +++ b/server/stats.c @@ -18,25 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "defs.h" -#include "mem.h" -#include "log.h" -#include "syscalls.h" -#include "configuration.h" -#include "rights.h" -#include "trackdb.h" -#include "version.h" +#include "disorder-server.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, diff --git a/server/trackname.c b/server/trackname.c index 3d7de6d..3639c52 100644 --- a/server/trackname.c +++ b/server/trackname.c @@ -18,22 +18,7 @@ * USA */ -#include -#include "types.h" - -#include -#include -#include -#include - -#include "configuration.h" -#include "syscalls.h" -#include "log.h" -#include "trackname.h" -#include "mem.h" -#include "charset.h" -#include "defs.h" -#include "version.h" +#include "disorder-server.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, diff --git a/tests/udplog.c b/tests/udplog.c index 7e580f2..f8839c8 100644 --- a/tests/udplog.c +++ b/tests/udplog.c @@ -18,8 +18,7 @@ * USA */ -#include -#include "types.h" +#include "common.h" #include #include -- [mdw]