sad

simple audio daemon
git clone git://git.2f30.org/sad.git
Log | Files | Refs | LICENSE

commit 78040bbbf21b95beaad5e647b52011836eb4403d
parent 449264217b6dcedde28902c039a01f8b41d5f71d
Author: sin <sin@2f30.org>
Date:   Fri Jan  2 17:06:39 +0000

Remove cmdsearch()

The client can do the matching itself.

Diffstat:
PROTOCOL | 4----
cmd.c | 13-------------
playlist.c | 34----------------------------------
3 files changed, 0 insertions(+), 51 deletions(-)
diff --git a/PROTOCOL b/PROTOCOL @@ -43,10 +43,6 @@ playlist Dump the current playlist. The output has the following form: "%d: %s\n", id, filepath -search regex -Search for a song matching the given regex in the playlist. At the moment it -will only consider file names. - close Force the daemon to close the client connection. diff --git a/cmd.c b/cmd.c @@ -303,18 +303,6 @@ cmdping(int fd, char *arg) } static void -cmdsearch(int fd, char *arg) -{ - if (!arg[0]) { - dprintf(fd, "ERR expected search string\n"); - return; - } - if (searchplaylist(fd, arg) < 0) - dprintf(fd, "ERR failed to search through playlist\n"); - dprintf(fd, "OK\n"); -} - -static void cmdversion(int fd, char *arg) { if (arg[0]) { @@ -385,7 +373,6 @@ static Cmd cmds[] = { { "close", cmdclose }, { "kill", cmdkill }, { "ping", cmdping }, - { "search", cmdsearch }, { "version", cmdversion }, { "enable", cmdenable }, { "disable", cmddisable }, diff --git a/playlist.c b/playlist.c @@ -3,7 +3,6 @@ #include <err.h> #include <limits.h> -#include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -223,36 +222,3 @@ playlistmode(int mode) { playlist.mode = mode; } - -static int -wregcomp(int fd, regex_t *preg, const char *regex, int cflags) -{ - char errbuf[BUFSIZ] = ""; - int r; - - if ((r = regcomp(preg, regex, cflags)) == 0) - return r; - - regerror(r, preg, errbuf, sizeof(errbuf)); - dprintf(fd, "ERR invalid regex: %s\n", errbuf); - return r; -} - -int -searchplaylist(int fd, const char *search) -{ - Song *s; - int i; - regex_t re; - - if (wregcomp(fd, &re, search, REG_EXTENDED | REG_ICASE)) - return -1; /* invalid regex */ - - for (i = 0; i < playlist.nsongs; i++) { - s = playlist.songs[i]; - if (!regexec(&re, s->path, 0, NULL, REG_NOSUB)) - dprintf(fd, "%d: %s\n", s->id, s->path); - } - regfree(&re); - return 0; -}