chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs update
[disorder]
/
clients
/
disorder.c
diff --git
a/clients/disorder.c
b/clients/disorder.c
index 46e2c2d11db914b3f5efe83f4b22a8f4ef7c2a8b..5ccb625812b4b937ca43e97dca1015bfd5f45ce5 100644
(file)
--- a/
clients/disorder.c
+++ b/
clients/disorder.c
@@
-34,6
+34,8
@@
#include <stddef.h>
#include <unistd.h>
#include <assert.h>
#include <stddef.h>
#include <unistd.h>
#include <assert.h>
+#include <pcre.h>
+#include <ctype.h>
#include "configuration.h"
#include "syscalls.h"
#include "configuration.h"
#include "syscalls.h"
@@
-148,6
+150,8
@@
static void cf_shutdown(disorder_client *c,
static void cf_reconfigure(disorder_client *c,
char attribute((unused)) **argv) {
static void cf_reconfigure(disorder_client *c,
char attribute((unused)) **argv) {
+ /* Re-check configuration for server */
+ if(config_read(1)) fatal(0, "cannot read configuration");
if(disorder_reconfigure(c)) exit(EXIT_FAILURE);
}
if(disorder_reconfigure(c)) exit(EXIT_FAILURE);
}
@@
-375,6
+379,26
@@
static void cf_unset_global(disorder_client *c, char **argv) {
if(disorder_unset_global(c, argv[0])) exit(EXIT_FAILURE);
}
if(disorder_unset_global(c, argv[0])) exit(EXIT_FAILURE);
}
+static int isarg_integer(const char *s) {
+ if(!*s) return 0;
+ while(*s) {
+ if(!isdigit((unsigned char)*s))
+ return 0;
+ ++s;
+ }
+ return 1;
+}
+
+static void cf_new(disorder_client *c,
+ char **argv) {
+ char **vec;
+
+ if(disorder_new_tracks(c, &vec, 0, argv[0] ? atoi(argv[0]) : 0))
+ exit(EXIT_FAILURE);
+ while(*vec)
+ xprintf("%s\n", nullcheck(utf82mb(*vec++)));
+}
+
static const struct command {
const char *name;
int min, max;
static const struct command {
const char *name;
int min, max;
@@
-412,6
+436,8
@@
static const struct command {
"Copy event log to stdout" },
{ "move", 2, 2, cf_move, 0, "TRACK DELTA",
"Move a track in the queue" },
"Copy event log to stdout" },
{ "move", 2, 2, cf_move, 0, "TRACK DELTA",
"Move a track in the queue" },
+ { "new", 0, 1, cf_new, isarg_integer, "[MAX]",
+ "Get the most recently added MAX tracks" },
{ "part", 3, 3, cf_part, 0, "TRACK CONTEXT PART",
"Find a track name part" },
{ "pause", 0, 0, cf_pause, 0, "",
{ "part", 3, 3, cf_part, 0, "TRACK CONTEXT PART",
"Find a track name part" },
{ "pause", 0, 0, cf_pause, 0, "",
@@
-501,7
+527,10
@@
int main(int argc, char **argv) {
int status = 0;
struct vector args;
int status = 0;
struct vector args;
- mem_init(1);
+ mem_init();
+ /* garbage-collect PCRE's memory */
+ pcre_malloc = xmalloc;
+ pcre_free = xfree;
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
while((n = getopt_long(argc, argv, "hVc:dHL", options, 0)) >= 0) {
switch(n) {
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
while((n = getopt_long(argc, argv, "hVc:dHL", options, 0)) >= 0) {
switch(n) {
@@
-513,7
+542,7
@@
int main(int argc, char **argv) {
default: fatal(0, "invalid option");
}
}
default: fatal(0, "invalid option");
}
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(
0
)) fatal(0, "cannot read configuration");
if(!(c = disorder_new(1))) exit(EXIT_FAILURE);
s = config_get_file("socket");
if(disorder_connect(c)) exit(EXIT_FAILURE);
if(!(c = disorder_new(1))) exit(EXIT_FAILURE);
s = config_get_file("socket");
if(disorder_connect(c)) exit(EXIT_FAILURE);
@@
-551,4
+580,3
@@
c-basic-offset:2
comment-column:40
End:
*/
comment-column:40
End:
*/
-/* arch-tag:0ff200f4c42e9b04dd781fa89c6129f6 */