Source code reorganization:
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 25 May 2008 18:03:06 +0000 (19:03 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 25 May 2008 18:03:06 +0000 (19:03 +0100)
  - 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

148 files changed:
.bzrignore
cgi/Makefile.am [new file with mode: 0644]
cgi/actions.c [moved from server/actions.c with 100% similarity]
cgi/cgimain.c [moved from server/cgimain.c with 100% similarity]
cgi/disorder-cgi.h [moved from server/disorder-cgi.h with 97% similarity]
cgi/login.c [moved from server/login.c with 100% similarity]
cgi/lookup.c [moved from server/lookup.c with 100% similarity]
cgi/macros-disorder.c [moved from server/macros-disorder.c with 100% similarity]
cgi/options.c [moved from server/options.c with 100% similarity]
clients/authorize.c
clients/disorder.c
clients/disorderfm.c
clients/filename-bytes.c
clients/playrtp-alsa.c
clients/playrtp-coreaudio.c
clients/playrtp-mem.c
clients/playrtp-oss.c
clients/playrtp.c
clients/test-eclient.c
configure.ac
disobedience/disobedience.h
doc/Makefile.am
driver/disorder.c
lib/Makefile.am
lib/addr.c
lib/addr.h
lib/alsabg.c
lib/asprintf.c
lib/authhash.c
lib/base64.c
lib/basen.c
lib/bits.c
lib/bits.h
lib/cache.c
lib/cgi.c
lib/charset.c
lib/charset.h
lib/client-common.c
lib/client-common.h
lib/client.c
lib/client.h
lib/common.h [moved from lib/types.h with 92% similarity]
lib/configuration.c
lib/configuration.h
lib/cookies.c
lib/cookies.h
lib/dateparse.c
lib/dateparse.h
lib/defs.c
lib/eclient.c
lib/event.c
lib/eventlog.c
lib/filepart.c
lib/fprintf.c
lib/hash.c
lib/heap.h
lib/hex.c
lib/hostname.c
lib/ifreq.c
lib/ifreq.h
lib/inputline.c
lib/kvp.c
lib/log.c
lib/logfd.c
lib/macros-builtin.c
lib/macros.c
lib/mem.c
lib/mime.c
lib/mixer-alsa.c
lib/mixer-oss.c
lib/mixer.c
lib/plugin.h [deleted file]
lib/printf.c
lib/printf.h
lib/queue-rights.c
lib/queue.c
lib/queue.h
lib/random.c
lib/regsub.c
lib/regsub.h
lib/rights.c
lib/selection.c
lib/selection.h
lib/sendmail.c
lib/signame.c
lib/sink.c
lib/sink.h
lib/snprintf.c
lib/speaker-protocol.c
lib/split.c
lib/syscalls.c
lib/syscalls.h
lib/table.c
lib/table.h
lib/timeval.h
lib/trackdb-int.h
lib/trackdb-stub.c
lib/trackdb.c
lib/trackname.c
lib/trackorder.c
lib/unicode.c
lib/unidata.c
lib/url.c
lib/user.c
lib/vector.c
lib/vector.h
lib/version.c
lib/wav.c
lib/wstat.c
libtests/test.h
plugins/notify.c
scripts/make-unidata
server/Makefile.am
server/api-client.c
server/api-server.c
server/api.c
server/choose.c
server/daemonize.c
server/daemonize.h [deleted file]
server/dbupgrade.c
server/deadlock.c
server/decode.c
server/disorder-server.h [new file with mode: 0644]
server/disorderd.c
server/dump.c
server/normalize.c
server/play.c
server/play.h [deleted file]
server/plugin.c [moved from lib/plugin.c with 96% similarity]
server/queue-ops.c [new file with mode: 0644]
server/rescan.c
server/schedule.c
server/schedule.h [deleted file]
server/server-queue.c
server/server-queue.h [deleted file]
server/server.c
server/server.h [deleted file]
server/speaker-alsa.c
server/speaker-command.c
server/speaker-coreaudio.c
server/speaker-network.c
server/speaker-oss.c
server/speaker.c
server/state.c
server/state.h [deleted file]
server/stats.c
server/trackname.c
tests/udplog.c

index 9a5ff0e..8824dd5 100644 (file)
@@ -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 (file)
index 0000000..2e126de
--- /dev/null
@@ -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
similarity index 100%
rename from server/actions.c
rename to cgi/actions.c
similarity index 100%
rename from server/cgimain.c
rename to cgi/cgimain.c
similarity index 97%
rename from server/disorder-cgi.h
rename to cgi/disorder-cgi.h
index beb8581..73a761d 100644 (file)
 #ifndef DISORDER_CGI_H
 #define DISORDER_CGI_H
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <stdarg.h>
-#include <string.h>
 #include <time.h>
 #include <errno.h>
 #include <ctype.h>
similarity index 100%
rename from server/login.c
rename to cgi/login.c
similarity index 100%
rename from server/lookup.c
rename to cgi/lookup.c
similarity index 100%
rename from server/options.c
rename to cgi/options.c
index 1a0717e..fe908bc 100644 (file)
@@ -18,8 +18,7 @@
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <pwd.h>
 #include <gcrypt.h>
@@ -27,7 +26,6 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <stdio.h>
 
 #include "client.h"
 #include "authorize.h"
index 1bac10b..be075f1 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <getopt.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <stdio.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <string.h>
 #include <locale.h>
 #include <time.h>
 #include <stddef.h>
 #include <unistd.h>
-#include <assert.h>
 #include <pcre.h>
 #include <ctype.h>
 
@@ -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"
index b834be6..b293301 100644 (file)
@@ -18,8 +18,7 @@
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <getopt.h>
 #include <unistd.h>
@@ -29,7 +28,6 @@
 #include <dirent.h>
 #include <sys/stat.h>
 #include <langinfo.h>
-#include <string.h>
 #include <fnmatch.h>
 
 #include "syscalls.h"
index 91c33c0..8bba942 100644 (file)
@@ -1,10 +1,9 @@
 /* Grotty program to print out the bytes making up filenames in some
  * directory */
 
-#include "config.h"
+#include "common.h"
 
 #include <dirent.h>
-#include <stdio.h>
 #include <ctype.h>
 
 int main(int attribute((unused)) argc, char **argv) {
index 3c9b67f..a3995e9 100644 (file)
  * wrapping OSS the whole of playrtp could probably be greatly simplified.
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_ALSA_ASOUNDLIB_H 
-#include "types.h"
 
 #include <poll.h>
 #include <alsa/asoundlib.h>
-#include <assert.h>
 #include <pthread.h>
 #include <arpa/inet.h>
 
index c0f1819..f490a0f 100644 (file)
  * @brief RTP player - Core Audio support
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_COREAUDIO_AUDIOHARDWARE_H
-#include "types.h"
-
-#include <assert.h>
 #include <pthread.h>
 #include <CoreAudio/AudioHardware.h>
 
index 7465707..2a868de 100644 (file)
  * @brief RTP player memory management
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <pthread.h>
-#include <assert.h>
-#include <string.h>
 
 #include "mem.h"
 #include "vector.h"
index 15f6b53..199487f 100644 (file)
  * @brief RTP player - OSS and empeg support
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
-#include "types.h"
 
 #include <poll.h>
 #include <sys/ioctl.h>
 #if !EMPEG_HOST
 #include <sys/soundcard.h>
 #endif
-#include <assert.h>
 #include <pthread.h>
-#include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
index 3f02e0c..cbc24ae 100644 (file)
  * - it is safe to read uint32_t values without a lock protecting them
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -62,8 +59,6 @@
 #include <pthread.h>
 #include <locale.h>
 #include <sys/uio.h>
-#include <string.h>
-#include <assert.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <sys/time.h>
index bae789a..b5742a3 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/select.h>
-#include <stdio.h>
-#include <assert.h>
 #include <errno.h>
-#include <stdlib.h>
 #include <time.h>
 
 #include "queue.h"
index beb2803..2d193ad 100644 (file)
@@ -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
index ccb9acc..db1e8e9 100644 (file)
 #ifndef DISOBEDIENCE_H
 #define DISOBEDIENCE_H
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <time.h>
-#include <string.h>
-#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <math.h>
index 4b01791..7ae24e4 100644 (file)
@@ -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
 
index fb05b59..d075a03 100644 (file)
  * disorder-normalize to convert to the confnigured target format.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
 #include <poll.h>
index 27ecb2c..7f25cdd 100644 (file)
@@ -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                                 \
index c0bc190..c7a1e74 100644 (file)
 /** @file lib/addr.c
  * @brief Socket address support */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <netdb.h>
 #include <arpa/inet.h>
 #include <sys/un.h>
 
 #include "log.h"
 #include "printf.h"
-#include "configuration.h"
 #include "addr.h"
 #include "mem.h"
 
index 8bd703f..4049b07 100644 (file)
@@ -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
 #ifndef ADDR_H
 #define ADDR_H
 
+#include <netdb.h>
+
+#include "configuration.h"
+
 struct addrinfo *get_address(const struct stringlist *a,
                             const struct addrinfo *pref,
                             char **namep);
index be589ce..336c2a3 100644 (file)
  * @brief Background-thread interface to ALSA
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_ALSA_ASOUNDLIB_H
-#include "types.h"
-
 #include <alsa/asoundlib.h>
 #include <pthread.h>
 
index f3bebd5..7d7bd31 100644 (file)
  */
 /** @file lib/asprintf.c @brief printf() workalikes */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <errno.h>
index 24c40f0..a083902 100644 (file)
  */
 /** @file lib/authhash.c @brief The authorization hash */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <stddef.h>
 #include <gcrypt.h>
-#include <assert.h>
 
 #include "hex.h"
 #include "log.h"
index 7909b4f..2975333 100644 (file)
  * @brief Support for MIME base64
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-
-#include <stdio.h>
+#include "common.h"
 
 #include "mem.h"
 #include "base64.h"
index 74cb836..a41a73b 100644 (file)
  * words.  The words themselves use the native byte order.
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
 
 #include "basen.h"
 
index 6b5273b..4ed2402 100644 (file)
@@ -22,8 +22,7 @@
  * @brief Bit operations
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <math.h>
 
index 0965cb6..e0f7c62 100644 (file)
@@ -25,8 +25,6 @@
 #ifndef BITS_H
 #define BITS_H
 
-#include <string.h>                     /* for fls() */
-
 #if HAVE_FLS
 static inline int leftmost_bit(uint32_t n) {
   return fls(n) - 1;
index 60c2600..f812dc6 100644 (file)
@@ -19,8 +19,7 @@
  */
 /** @file lib/cache.c @brief Object caching */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <time.h>
 
index c3a7680..8cb04bb 100644 (file)
--- a/lib/cgi.c
+++ b/lib/cgi.c
  * @brief CGI tools
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
 #include <unistd.h>
 #include <errno.h>
-#include <stdio.h>
 
 #include "cgi.h"
 #include "mem.h"
index 1dc4231..3c5f88b 100644 (file)
  */
 /** @file lib/charset.c @brief Character set conversion */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <iconv.h>
-#include <string.h>
 #include <errno.h>
 #include <langinfo.h>
 
index e4c72a9..db5e737 100644 (file)
@@ -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 */
index f5ace3e..53da8ac 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
-#include <string.h>
 #include <errno.h>
 #include <netdb.h>
 
index 271e28f..dc50ee9 100644 (file)
@@ -21,6 +21,9 @@
 #ifndef CLIENT_COMMON_H
 #define CLIENT_COMMON_H
 
+#include <sys/types.h>
+#include <sys/socket.h>
+
 socklen_t find_server(struct sockaddr **sap, char **namep);
 
 #endif /* CLIENT_COMMON_H */
index d357a8c..84eb77e 100644 (file)
  * implementation.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
-#include <string.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <netdb.h>
-#include <stdlib.h>
 #include <pcre.h>
 
 #include "log.h"
index abadef6..912fa32 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef CLIENT_H
 #define CLIENT_H
 
+#include <time.h>
+
 /** @brief Client data */
 typedef struct disorder_client disorder_client;
 
similarity index 92%
rename from lib/types.h
rename to lib/common.h
index 6b3dc37..77a2cd9 100644 (file)
  * 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 <config.h>
 
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
@@ -29,6 +34,9 @@
 
 /* had better be before atol/atoll redefinition */
 #include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
 
 #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:
index ca7d86e..c66f66b 100644 (file)
  * @brief Configuration file support
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
index bf3a493..51dc835 100644 (file)
 #ifndef CONFIGURATION_H
 #define CONFIGURATION_H
 
+#include <pcre.h>
+
 #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 */
 };
 
index c98db8f..40e3c3e 100644 (file)
  * @brief Cookie support
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
 #include <errno.h>
 #include <time.h>
 #include <gcrypt.h>
 #include <pcre.h>
 
-#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 */
index f02013d..ea6e412 100644 (file)
@@ -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);
index 45de40c..2a25292 100644 (file)
@@ -22,8 +22,7 @@
  * @brief Date parsing
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <time.h>
 
index 2f52dac..7b96fe9 100644 (file)
  * 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.h>
+
 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
index b5e1eff..084bf0a 100644 (file)
@@ -23,8 +23,7 @@
  * (see fix_path()), not so that the path can be ignored.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include "defs.h"
 #include "definitions.h"
index 941849c..a9805f7 100644 (file)
  * @brief Client code for event-driven programs
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
-#include <string.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <netdb.h>
-#include <stdlib.h>
-#include <assert.h>
 #include <inttypes.h>
 #include <stddef.h>
 #include <time.h>
index 4c3e9af..7c12b6f 100644 (file)
@@ -21,7 +21,7 @@
  * @brief DisOrder event loop
  */
 
-#include <config.h>
+#include "common.h"
 
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <assert.h>
 #include <signal.h>
 #include <errno.h>
-#include <string.h>
-#include <limits.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
-#include <stdio.h>
 #include "event.h"
 #include "mem.h"
 #include "log.h"
index d22a144..9c7f4fb 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
 
 #include "mem.h"
 #include "vector.h"
index 7af7de0..b772002 100644 (file)
  * @brief Filename parsing
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <assert.h>
-#include <stdio.h>
+#include "common.h"
 
 #include "filepart.h"
 #include "mem.h"
index 1e1b93c..741a31e 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
 #include <stdarg.h>
 #include <stddef.h>
 
index f38e1d9..f730a58 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
 
 #include "hash.h"
 #include "mem.h"
index 6f9bcab..c6504ef 100644 (file)
@@ -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
index 15860ad..e0542ce 100644 (file)
--- a/lib/hex.c
+++ b/lib/hex.c
  */
 /** @file lib/hex.c @brief Hexadecimal encoding and decoding */
 
-#include <config.h>
-#include "types.h"
-
-#include <stdio.h>
-#include <string.h>
+#include "common.h"
 
 #include "hex.h"
 #include "mem.h"
index 536bb8e..ee7ed49 100644 (file)
@@ -18,8 +18,7 @@
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/utsname.h>
 #include <errno.h>
index 7071a0e..3ec92b0 100644 (file)
  * @brief Network interface support
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <errno.h>
-#include <string.h>
 
 #include "ifreq.h"
 #include "mem.h"
index 7a65d80..3f2dd9d 100644 (file)
@@ -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);
 
index 5af46f9..8882f57 100644 (file)
  * @brief Line input
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <errno.h>
-#include <string.h>
 
 #include "log.h"
 #include "mem.h"
index 4aa31a1..9cd0554 100644 (file)
--- a/lib/kvp.c
+++ b/lib/kvp.c
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <stdio.h>
+#include "common.h"
 
 #include "mem.h"
 #include "kvp.h"
index cae84a7..24f9427 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
 #define NO_MEMORY_ALLOCATION
 /* because the memory allocation functions report errors */
 
-#include <config.h>
+#include "common.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #include <syslog.h>
 #include <sys/time.h>
index a0a608f..1baaff2 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <unistd.h>
-#include <string.h>
 #include <errno.h>
 
 #include "syscalls.h"
index 04ea490..8123f2b 100644 (file)
  * generated from the comments at the head of each function.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
 #include <errno.h>
-#include <assert.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
index 4d3b9a0..7b77144 100644 (file)
  * @brief Macro expansion
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
 #include <ctype.h>
-#include <assert.h>
-#include <stdio.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
index 6d531cc..10fffe3 100644 (file)
--- a/lib/mem.c
+++ b/lib/mem.c
  * @brief Memory management
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #if GC
 #include <gc.h>
 #endif
 #include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
 
 #include "mem.h"
 #include "log.h"
index 5db7585..b7975f2 100644 (file)
  * @brief Support for MIME and allied protocols
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
 #include <ctype.h>
 
-#include <stdio.h>
-
 #include "mem.h"
 #include "mime.h"
 #include "vector.h"
index 40103e0..4ba684f 100644 (file)
  * (as I don't one).
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_ALSA_ASOUNDLIB_H
 
-#include "types.h"
-
-#include <stdio.h>
-#include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <stddef.h>
 #include <ctype.h>
index e1c8b19..158b6f6 100644 (file)
  * nonetheless).
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_SYS_SOUNDCARD_H
 
-#include "types.h"
-
-#include <stdio.h>
-#include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <stddef.h>
 #include <sys/ioctl.h>
index ee88fbb..36acd73 100644 (file)
@@ -21,8 +21,7 @@
  * @brief Mixer support
  */
 
-#include <config.h>
-#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 (file)
index 1283555..0000000
+++ /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:
-*/
index c5b9ebd..ed6af66 100644 (file)
 #define NO_MEMORY_ALLOCATION
 /* because byte_snprintf used from log.c */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <stdarg.h>
-#include <string.h>
 #include <errno.h>
-#include <stdlib.h>
 #include <stddef.h>
 
 #include "printf.h"
index 3b3b7c1..fd052b0 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef PRINTF_H
 #define PRINTF_H
 
+#include <stdarg.h>
+
 struct sink;
 
 int byte_vsinkprintf(struct sink *output,
index 523a4ad..4205d26 100644 (file)
  * @brief Various rights-checking operations
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
 
 #include "queue.h"
 #include "rights.h"
index a98bec1..0849070 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
-#include <stdio.h>
 #include <errno.h>
 #include <stddef.h>
 
@@ -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 *),
index 6bcbeed..e466c95 100644 (file)
@@ -21,6 +21,9 @@
 #ifndef QUEUE_H
 #define QUEUE_H
 
+#include <time.h>
+
+
 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);
index 69e1409..ce87abd 100644 (file)
  *
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-#include <string.h>
 
 #include "random.h"
 #include "log.h"
index 6345725..bb90f43 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
 #include <pcre.h>
 
 #include "regsub.h"
index e85a597..2e13930 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef REGSUB_H
 #define REGSUB_H
 
+#include <pcre.h>
+
 #define REGSUB_GLOBAL          0x0001  /* global replace */
 #define REGSUB_MUST_MATCH      0x0002  /* return 0 if no match */
 #define REGSUB_CASE_INDEPENDENT        0x0004  /* case independent */
index f0dc892..416c6a7 100644 (file)
  * @brief User rights
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
 
 #include "mem.h"
 #include "log.h"
index 58ff5d1..6d0a588 100644 (file)
@@ -21,8 +21,7 @@
  * @brief Select management for Disobedience
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include "mem.h"
 #include "hash.h"
index 6618b17..0999501 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef SELECTION_H
 #define SELECTION_H
 
+#include "hash.h"
+
 /* Represent a selection using a hash */
 
 hash *selection_new(void);
index 2e0df8f..8f75343 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <sys/socket.h>
index cc1b339..047e625 100644 (file)
@@ -18,8 +18,7 @@
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <signal.h>
 #include <stddef.h>
index 2c1279b..925bb01 100644 (file)
  * @brief Abstract output sink type
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <stdarg.h>
-#include <string.h>
 #include <errno.h>
 
 #include "mem.h"
index 13ea7d4..aab645b 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef SINK_H
 #define SINK_H
 
+#include <stdarg.h>
+
 struct dynstr;
 
 /** @brief Sink type
index 3b41af7..f738bed 100644 (file)
 #define NO_MEMORY_ALLOCATION
 /* because used from log.c */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
 #include <stdarg.h>
 #include <stddef.h>
 
index ab8b4ee..ef66ed6 100644 (file)
  * @brief Speaker/server protocol support
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/socket.h>
-#include <string.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stddef.h>
index 610fb3e..90036d4 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <ctype.h>
-#include <string.h>
 #include <errno.h>
 
 #include "mem.h"
index c398c93..2d0245d 100644 (file)
@@ -18,7 +18,7 @@
  * USA
  */
 
-#include <config.h>
+#include "common.h"
 
 #include <unistd.h>
 #include <errno.h>
@@ -27,8 +27,6 @@
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
 
 #include "syscalls.h"
 #include "log.h"
index 8e9d9b8..f1f3383 100644 (file)
@@ -29,9 +29,6 @@ struct timezone;
 
 #include <sys/socket.h>
 #include <signal.h>
-#include <stdio.h>
-
-#include "types.h"
 
 pid_t xfork(void);
 void xclose_guts(const char *, int, int);
index f2835cb..d37ffe3 100644 (file)
@@ -18,9 +18,7 @@
  * USA
  */
 
-#include <config.h>
-
-#include <string.h>
+#include "common.h"
 
 #include "table.h"
 
index 8cdfcfd..a301db7 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef TABLE_H
 #define TABLE_H
 
+#include <stddef.h>
+
 #define TABLE_FIND(TABLE, FIELD, NAME)                 \
   table_find((void *)TABLE,                            \
             offsetof(typeof((TABLE)[0]), FIELD),       \
index c2cd106..10b02ea 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef TIMEVAL_H
 #define TIMEVAL_H
 
+#include <time.h>
+
 static inline struct timeval tvsub(const struct timeval a,
                                    const struct timeval b) {
   struct timeval r;
index 1cfadbc..32a6ca4 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef TRACKDB_INT_H
 #define TRACKDB_INT_H
 
+#include <db.h>
+
 #include "kvp.h"
 
 struct vector;                          /* forward declaration */
index 3b92c97..6ddb6af 100644 (file)
@@ -23,8 +23,7 @@
  * Stubs for non-server builds
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <pcre.h>
 
index e1a0c80..689af09 100644 (file)
  * This file is getting in desparate need of splitting up...
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <string.h>
-#include <stdio.h>
 #include <db.h>
 #include <sys/socket.h>
 #include <pcre.h>
-#include <assert.h>
 #include <unistd.h>
 #include <errno.h>
 #include <stddef.h>
index 0aef934..14de985 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <pcre.h>
 #include <fnmatch.h>
-#include <string.h>
-#include <assert.h>
 
 #include "trackname.h"
 #include "configuration.h"
index a61b89c..80c5b92 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <pcre.h>
 #include <fnmatch.h>
-#include <string.h>
-#include <assert.h>
 
 #include "trackname.h"
 #include "log.h"
index 5803926..417ae07 100644 (file)
  * - @ref utf8
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <stdio.h>             /* TODO */
+#include "common.h"
 
 #include "mem.h"
 #include "vector.h"
index d7bed16..db4334d 100644 (file)
@@ -1,6 +1,5 @@
 /* Automatically generated file, see scripts/make-unidata */
-#include <config.h>
-#include "types.h"
+#include "common.h"
 #include "unidata.h"
 #define Cc unicode_General_Category_Cc
 #define Cf unicode_General_Category_Cf
index 16f3257..b777282 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
  * @brief URL support functions
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <errno.h>
-#include <string.h>
 
 #include "mem.h"
 #include "log.h"
index ec01a33..512aaa1 100644 (file)
@@ -21,8 +21,7 @@
  * @brief Jukebox user management
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
index 6f397ce..d9fd18b 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <stddef.h>
-#include <string.h>
 
 #include "mem.h"
 #include "log.h"
index 33f3d35..d89376c 100644 (file)
@@ -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
index f92e0c7..a8e2ad1 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <stdio.h>
-#include <stdlib.h>
+#include "common.h"
 
 #include "syscalls.h"
 #include "version.h"
index c7d4b93..d0f3acf 100644 (file)
--- a/lib/wav.c
+++ b/lib/wav.c
  * orderings of different channels.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <string.h>
 
 #include "log.h"
 #include "wav.h"
index 67de318..0e33d1f 100644 (file)
  * @brief Convert wait status to text
  */
 
-#include <config.h>
+#include "common.h"
 
 #include <sys/wait.h>
-#include <stdio.h>
-#include <string.h>
 #include <signal.h>
 
 #include "mem.h"
index 7a0ef5d..cb26b62 100644 (file)
 #ifndef TEST_H
 #define TEST_H
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
-#include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
index 4f80cc2..15ef47c 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <stddef.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 
index 1230aa7..5611b0d 100755 (executable)
@@ -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 <config.h>\n",
-    "#include \"types.h\"\n",
+    "#include \"common.h\"\n",
     "#include \"unidata.h\"\n");
 
 # Short aliases to keep .c file small
index a2b5acf..3557158 100644 (file)
 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
index 2f6a01f..174ed88 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
 #include <errno.h>
-#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <locale.h>
index bc8144e..173c82e 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <pcre.h>
-
-#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);
index 5366468..11564f8 100644 (file)
  * USA
  */
 
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <syslog.h>
-
-#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"
index c39e27b..f1d06b8 100644 (file)
  * deadlock - it just exits and expects the server to try again.
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <db.h>
-#include <locale.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pcre.h>
-#include <string.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <time.h>
-
-#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
 
index 7dea700..5f6e226 100644 (file)
  * @brief Go into background
  */
 
-#include <config.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <syslog.h>
-
-#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 (file)
index 23d88a6..0000000
+++ /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:
-*/
index f972b59..74354b7 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <getopt.h>
-#include <db.h>
-#include <locale.h>
-#include <errno.h>
-#include <syslog.h>
-#include <pcre.h>
-#include <unistd.h>
-
-#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);
index dba28d3..1a47301 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <db.h>
-#include <locale.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pcre.h>
-#include <string.h>
-#include <syslog.h>
-
-#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' },
index c693c75..3a1e1a9 100644 (file)
  * @brief General-purpose decoder for use by speaker process
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <locale.h>
-#include <assert.h>
-#include <fnmatch.h>
+#include "disorder-server.h"
+
 #include <mad.h>
 #include <vorbis/vorbisfile.h>
-#include <string.h>
 
 /* libFLAC has had an API change and stupidly taken away the old API */
 #if HAVE_FLAC_FILE_DECODER_H
 #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 (file)
index 0000000..361bd4f
--- /dev/null
@@ -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 <db.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <fnmatch.h>
+#include <gcrypt.h>
+#include <getopt.h>
+#include <grp.h>
+#include <locale.h>
+#include <netinet/in.h>
+#include <pcre.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <syslog.h>
+#include <time.h>
+#include <unistd.h>
+
+#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:
+*/
index 9f444b6..e78c28f 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
-#include <config.h>
-#include "types.h"
-
-#include <stdio.h>
-#include <getopt.h>
-#include <pwd.h>
-#include <grp.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <time.h>
-#include <locale.h>
-#include <syslog.h>
-#include <sys/time.h>
-#include <pcre.h>
-#include <fcntl.h>
-#include <gcrypt.h>
-
-#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;
 
index 7b4b3a4..aec1804 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <pcre.h>
-#include <unistd.h>
-#include <db.h>
-#include <fcntl.h>
-
-#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' },
index 6d8823e..956eb6b 100644 (file)
  * and eliminate the dependency on sox.
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <locale.h>
-#include <errno.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#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' },
index df9158b..756031d 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fnmatch.h>
-#include <time.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <pcre.h>
+#include "disorder-server.h"
 #include <ao/ao.h>
-#include <sys/wait.h>
-#include <sys/un.h>
-
-#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 (file)
index aff474c..0000000
+++ /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:
-*/
similarity index 96%
rename from lib/plugin.c
rename to server/plugin.c
index c23865d..a0c7d35 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "disorder-server.h"
 
 #include <dlfcn.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#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 (file)
index 0000000..952cb71
--- /dev/null
@@ -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:
+*/
index 2d390f8..04ffba4 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <db.h>
-#include <locale.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pcre.h>
-#include <fnmatch.h>
-#include <sys/wait.h>
-#include <string.h>
-#include <syslog.h>
-#include <time.h>
-
-#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;
 
index 4f0b34e..6092fb5 100644 (file)
  *
  * TODO: add disorder-dump support
  */
-
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <db.h>
-#include <time.h>
-#include <stddef.h>
-
-#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 (file)
index 0c7efa1..0000000
+++ /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:
-*/
index b71d677..a83ee56 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  */
-
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
-
-#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 (file)
index 624f203..0000000
+++ /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:
-*/
index 527255e..0ddfd53 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <gcrypt.h>
-#include <stddef.h>
-#include <time.h>
-#include <limits.h>
-#include <pcre.h>
-#include <netdb.h>
-#include <netinet/in.h>
-
-#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 (file)
index 0d34d1e..0000000
+++ /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:
-*/
index 8ed01a8..41e53b2 100644 (file)
 /** @file server/speaker-alsa.c
  * @brief Support for @ref BACKEND_ALSA */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_ALSA_ASOUNDLIB_H
 
-#include "types.h"
-
 #include <unistd.h>
 #include <poll.h>
 #include <alsa/asoundlib.h>
index 27b2664..7e19e2b 100644 (file)
@@ -21,8 +21,7 @@
 /** @file server/speaker-command.c
  * @brief Support for @ref BACKEND_COMMAND */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <unistd.h>
 #include <poll.h>
index 4f46891..df2759b 100644 (file)
  * @todo support @ref config::device
  */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_COREAUDIO_AUDIOHARDWARE_H
 
-#include "types.h"
-
 #include <poll.h>
 #include <sys/socket.h>
 #include <unistd.h>
index b77334c..2d8d2cb 100644 (file)
@@ -20,8 +20,7 @@
 /** @file server/speaker-network.c
  * @brief Support for @ref BACKEND_NETWORK */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <unistd.h>
 #include <poll.h>
@@ -29,7 +28,6 @@
 #include <gcrypt.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
-#include <assert.h>
 #include <net/if.h>
 #include <ifaddrs.h>
 #include <errno.h>
index 36ef4a8..95dcfe3 100644 (file)
 /** @file server/speaker-oss.c
  * @brief Support for @ref BACKEND_OSS */
 
-#include <config.h>
+#include "common.h"
 
 #if HAVE_SYS_SOUNDCARD_H
 
-#include "types.h"
-
 #include <unistd.h>
 #include <poll.h>
-#include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
index bcc44cc..3021652 100644 (file)
  * 2-byte samples.
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <locale.h>
 #include <syslog.h>
 #include <unistd.h>
 #include <errno.h>
 #include <ao/ao.h>
-#include <string.h>
-#include <assert.h>
 #include <sys/select.h>
 #include <sys/wait.h>
 #include <time.h>
index ad90425..2be2edd 100644 (file)
  * USA
  */
 
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <locale.h>
-#include <stdio.h>
-#include <pcre.h>
-#include <netdb.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-
-#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 (file)
index 21f6a1a..0000000
+++ /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:
-*/
index 5648ca0..2725fd5 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <locale.h>
-#include <stdio.h>
-#include <errno.h>
-#include <pcre.h>
-#include <getopt.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#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' },
index 3d7de6d..3639c52 100644 (file)
  * USA
  */
 
-#include <config.h>
-#include "types.h"
-
-#include <getopt.h>
-#include <locale.h>
-#include <errno.h>
-#include <string.h>
-
-#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' },
index 7e580f2..f8839c8 100644 (file)
@@ -18,8 +18,7 @@
  * USA
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
 #include <getopt.h>
 #include <sys/types.h>