From b71d1e5ef301b21c2bb33c1a205c971b0a51b769 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 20 Jan 2007 19:11:36 +0100 Subject: [PATCH] make the playlist selector use command_util.sh Also, add random_selector.cmd which should have been includes already in the previous patch. --- Makefile.in | 11 +++++++++++ configure.ac | 3 ++- playlist_selector.c | 35 +++++------------------------------ playlist_selector.cmd | 13 +++++++++++++ random_selector.cmd | 5 +++++ 5 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 playlist_selector.cmd create mode 100644 random_selector.cmd diff --git a/Makefile.in b/Makefile.in index 87569955..e416d53e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -181,6 +181,17 @@ random_selector_command_list.h: random_selector.cmd echo 'extern struct server_command random_selector_cmds[];' > $@ ./command_util.sh proto < $< >> $@ +playlist_selector_command_list.c: playlist_selector.cmd playlist_selector_command_list.h + echo '#include "server.h"' > $@ + echo '#include "user_list.h"' >> $@ + echo '#include "playlist_selector_command_list.h"' >> $@ + echo 'struct server_command playlist_selector_cmds[] = {' >>$@ + ./command_util.sh array < $< >>$@ + echo '{.name = NULL}};' >> $@ +playlist_selector_command_list.h: playlist_selector.cmd + echo 'extern struct server_command playlist_selector_cmds[];' > $@ + ./command_util.sh proto < $< >> $@ + ortp_recv.o: ortp_recv.c $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ortp_cppflags@ $< diff --git a/configure.ac b/configure.ac index c6797cbf..1ab497a8 100644 --- a/configure.ac +++ b/configure.ac @@ -80,7 +80,8 @@ audiod_errlist_objs="audiod signal string daemon stat net audiod_ldflags="" audiod_audio_formats="" -server_cmdline_objs="server.cmdline server_command_list random_selector_command_list" +server_cmdline_objs="server.cmdline server_command_list random_selector_command_list + playlist_selector_command_list" server_errlist_objs="server mp3_afh vss command net string signal random_selector time daemon stat crypt http_send db close_on_fork playlist_selector ipc dccp dccp_send fd user_list" diff --git a/playlist_selector.c b/playlist_selector.c index 010c9d21..c40976d4 100644 --- a/playlist_selector.c +++ b/playlist_selector.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Andre Noll + * Copyright (C) 2006-2007 Andre Noll * * 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 @@ -25,6 +25,7 @@ #include "string.h" #include "ipc.h" #include "user_list.h" +#include "playlist_selector_command_list.h" /** * structure used for transmission of the playlist @@ -62,34 +63,8 @@ static unsigned playlist_len, playlist_size, current_playlist_entry; static char **playlist; static struct audio_file_selector *self; -static int com_ppl(int, int, char **); -static int com_lpl(int, int, char **); extern struct misc_meta_data *mmd; -/* array of supported commands */ -static struct server_command cmds[] = { -{ -.name = "ppl", -.handler = com_ppl, -.perms = DB_READ, -.description = "print playlist", -.synopsis = "ppl", -.help = -"Print out the current playlist" -}, { -.name = "lpl", -.handler = com_lpl, -.perms = DB_WRITE, -.description = "load playlist", -.synopsis = "lpl", -.help = -"Read a new playlist from stdin. Example:\n" -"\tfind /audio -name '*.mp3' | para_client lpl" -}, { -.name = NULL, -} -}; - static void playlist_add(char *path) { if (playlist_len >= playlist_size) { @@ -143,7 +118,7 @@ out: return ret; } -static int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[]) +int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[]) { unsigned loaded = 0; size_t bufsize = 4096; /* guess that's enough */ @@ -174,7 +149,7 @@ out: return ret; } -static int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[]) +int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[]) { unsigned i; @@ -316,7 +291,7 @@ int playlist_selector_init(struct audio_file_selector *db) void *shm = NULL; self = db; - db->cmd_list = cmds; + db->cmd_list = playlist_selector_cmds; db->get_audio_file_list = pls_get_audio_file_list; db->shutdown = pls_shutdown; db->post_select = pls_post_select; diff --git a/playlist_selector.cmd b/playlist_selector.cmd new file mode 100644 index 00000000..9f073a51 --- /dev/null +++ b/playlist_selector.cmd @@ -0,0 +1,13 @@ +N: ppl +P: DB_READ +D: print playlist +S: ppl +H: Print out the current playlist +--- +N: lpl +P: DB_WRITE +D: load playlist +S: lpl +H: Read a new playlist from stdin. Example: +H: find /audio -name '*.mp3' | para_client lpl +--- diff --git a/random_selector.cmd b/random_selector.cmd new file mode 100644 index 00000000..929c7eea --- /dev/null +++ b/random_selector.cmd @@ -0,0 +1,5 @@ +N: random_info +P: 0 +D: about the random audio file selector +S: random_info +H: The random selector chooses files randomly out of the given directory. -- 2.30.2