Recently Written · git

sad

sad (2f30.org simple audio daemon) with a Cygwin/OSS port on branch cygwin

git clone https://github.com/equwal/sad

Log | Files | Refs


commit 78040bbbf21b95beaad5e647b52011836eb4403d
sin <sin@2f30.org>
2015-01-02 17:06:39 +0000

Remove cmdsearch()

The client can do the matching itself.

 PROTOCOL   |  4 ----
 cmd.c      | 13 -------------
 playlist.c | 34 ----------------------------------
 3 files changed, 51 deletions(-)
diff --git a/PROTOCOL b/PROTOCOL
index 20a65ac..f595f6c 100644
--- 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
index 97f412f..657cf79 100644
--- a/cmd.c
+++ b/cmd.c
@@ -302,18 +302,6 @@ cmdping(int fd, char *arg)
 	dprintf(fd, "pong\nOK\n");
 }
 
-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)
 {
@@ -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
index a29392b..38cb4aa 100644
--- 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;
-}