server/disorder-dump
server/disorder-rescan
server/disorder-speaker
-server/disorder.cgi
+cgi/disorder.cgi
server/disorderd
server/trackname
sounds/Makefile
libtests/t-event
libtests/t-dateparse
libtests/Makefile
+cgi/Makefile
--- /dev/null
+#
+# 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
#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>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <pwd.h>
#include <gcrypt.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <stdio.h>
#include "client.h"
#include "authorize.h"
* 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>
#include "kvp.h"
#include "split.h"
#include "sink.h"
-#include "plugin.h"
#include "mem.h"
#include "defs.h"
#include "authorize.h"
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <getopt.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <langinfo.h>
-#include <string.h>
#include <fnmatch.h>
#include "syscalls.h"
/* 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) {
* 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>
* @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>
* @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"
* @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>
* - 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>
#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>
* 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"
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"
scripts/Makefile
lib/Makefile
server/Makefile
+ cgi/Makefile
clients/Makefile
disobedience/Makefile
doc/Makefile
#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>
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
* 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>
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 \
/** @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"
/*
* 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);
* @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>
*/
/** @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>
*/
/** @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"
* @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"
* words. The words themselves use the native byte order.
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
#include "basen.h"
* @brief Bit operations
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <math.h>
#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;
*/
/** @file lib/cache.c @brief Object caching */
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <time.h>
* @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"
*/
/** @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>
+
/*
* This file is part of DisOrder.
* Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
#ifndef CHARSET_H
#define CHARSET_H
+#include "log.h"
+
struct dynstr;
/* Character encoding conversion routines */
* 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>
#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 */
* 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"
#ifndef CLIENT_H
#define CLIENT_H
+#include <time.h>
+
/** @brief Client data */
typedef struct disorder_client disorder_client;
* 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>
/* 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;
# endif
#endif
-#endif /* TYPES_H */
+#endif /* COMMENT_H */
/*
Local Variables:
* @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>
#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.
*/
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 */
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 */
};
* @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"
#include "base64.h"
#include "configuration.h"
#include "kvp.h"
-#include "rights.h"
#include "trackdb.h"
/** @brief Hash function used in signing HMAC */
#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);
* @brief Date parsing
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <time.h>
* 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,
struct tm *tp,
const char *const *template);
+#endif /* DATEPARSE_H */
+
/*
Local Variables:
c-basic-offset:2
* (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"
* @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>
* @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"
* 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"
* @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"
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <stdio.h>
-#include <string.h>
#include <stdarg.h>
#include <stddef.h>
* USA
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
#include "hash.h"
#include "mem.h"
#ifndef HEAP_H
#define HEAP_H
+#include "vector.h"
+
/** @brief Binary heap template.
* @param NAME name of type to define
* @param ETYPE element type
*/
/** @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"
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <sys/utsname.h>
#include <errno.h>
* @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"
#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);
* @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"
* USA
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <stdio.h>
+#include "common.h"
#include "mem.h"
#include "kvp.h"
#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>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <unistd.h>
-#include <string.h>
#include <errno.h>
#include "syscalls.h"
* 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>
* @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>
* @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"
* @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"
* (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>
* 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>
* @brief Mixer support
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include "configuration.h"
#include "mixer.h"
+++ /dev/null
-/*
- * 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:
-*/
#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"
#ifndef PRINTF_H
#define PRINTF_H
+#include <stdarg.h>
+
struct sink;
int byte_vsinkprintf(struct sink *output,
* @brief Various rights-checking operations
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
+#include "common.h"
#include "queue.h"
#include "rights.h"
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <string.h>
-#include <stdio.h>
#include <errno.h>
#include <stddef.h>
#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 *),
#ifndef QUEUE_H
#define QUEUE_H
+#include <time.h>
+
+
enum playing_state {
playing_failed, /* failed to play */
playing_isscratch, /* this is a scratch track */
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);
*
*/
-#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"
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <string.h>
#include <pcre.h>
#include "regsub.h"
#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 */
* @brief User rights
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <string.h>
#include "mem.h"
#include "log.h"
* @brief Select management for Disobedience
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include "mem.h"
#include "hash.h"
#ifndef SELECTION_H
#define SELECTION_H
+#include "hash.h"
+
/* Represent a selection using a hash */
hash *selection_new(void);
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/socket.h>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <signal.h>
#include <stddef.h>
* @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"
#ifndef SINK_H
#define SINK_H
+#include <stdarg.h>
+
struct dynstr;
/** @brief Sink type
#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>
* @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>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <ctype.h>
-#include <string.h>
#include <errno.h>
#include "mem.h"
* USA
*/
-#include <config.h>
+#include "common.h"
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
#include "syscalls.h"
#include "log.h"
#include <sys/socket.h>
#include <signal.h>
-#include <stdio.h>
-
-#include "types.h"
pid_t xfork(void);
void xclose_guts(const char *, int, int);
* USA
*/
-#include <config.h>
-
-#include <string.h>
+#include "common.h"
#include "table.h"
#ifndef TABLE_H
#define TABLE_H
+#include <stddef.h>
+
#define TABLE_FIND(TABLE, FIELD, NAME) \
table_find((void *)TABLE, \
offsetof(typeof((TABLE)[0]), FIELD), \
#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;
#ifndef TRACKDB_INT_H
#define TRACKDB_INT_H
+#include <db.h>
+
#include "kvp.h"
struct vector; /* forward declaration */
* Stubs for non-server builds
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <pcre.h>
* 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>
* 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"
* 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"
* - @ref utf8
*/
-#include <config.h>
-#include "types.h"
-
-#include <string.h>
-#include <stdio.h> /* TODO */
+#include "common.h"
#include "mem.h"
#include "vector.h"
/* 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
* @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"
* @brief Jukebox user management
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <sys/types.h>
#include <sys/stat.h>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <stddef.h>
-#include <string.h>
#include "mem.h"
#include "log.h"
#ifndef VECTOR_H
#define VECTOR_H
+#include "mem.h"
+
/** @brief Dynamic array template
* @param NAME type name
* @param ETYPE element type
* USA
*/
-#include <config.h>
-#include "types.h"
-
-#include <stdio.h>
-#include <stdlib.h>
+#include "common.h"
#include "syscalls.h"
#include "version.h"
* 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"
* @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"
#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>
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
#include <time.h>
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
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)
$(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
$(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
cmp decoded.raw oggdec.raw
rm -f scratch.wav config decoded.raw oggdec.raw
-cgi.o: ../lib/definitions.h
-
EXTRA_DIST=README.dbversions
* 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>
* 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);
* 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"
* 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
* @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
+++ /dev/null
-/*
- * 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:
-*/
* 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;
* 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();
/* 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);
* 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' },
* @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 {
--- /dev/null
+/*
+ * 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:
+*/
* 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;
* 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' },
* 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' },
* 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"
+++ /dev/null
-/*
- * 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:
-*/
* 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 *****************************************************/
--- /dev/null
+/*
+ * 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:
+*/
* 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;
*
* 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,
+++ /dev/null
-/*
- * 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:
-*/
* 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 };
* 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;
&& (!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);
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;
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
+++ /dev/null
-/*
- * 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:
-*/
* 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
+++ /dev/null
-/*
- * 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:
-*/
/** @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>
/** @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>
* @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>
/** @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>
#include <gcrypt.h>
#include <sys/socket.h>
#include <sys/uio.h>
-#include <assert.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <errno.h>
/** @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>
* 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>
* 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;
+++ /dev/null
-/*
- * 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:
-*/
* 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' },
* 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' },
* USA
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
#include <getopt.h>
#include <sys/types.h>