chiark / gitweb /
Assume initial digits in a track name are a sort key even without the
[disorder] / clients / disorder.c
index f20dbbc663aab3fa67d5ba7cd5a96b2e60d3b528..be075f1a51050d696da24e370ff14c5b79cad948 100644 (file)
  * 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"
 #include "vector.h"
 #include "version.h"
+#include "dateparse.h"
 
 static disorder_client *client;
 
@@ -545,7 +540,7 @@ static void cf_schedule_del(char **argv) {
 
 static void cf_schedule_play(char **argv) {
   if(disorder_schedule_add(getclient(),
-                          atoll(argv[0]),
+                          dateparse(argv[0]),
                           argv[1],
                           "play",
                           argv[2]))
@@ -554,7 +549,7 @@ static void cf_schedule_play(char **argv) {
 
 static void cf_schedule_set_global(char **argv) {
   if(disorder_schedule_add(getclient(),
-                          atoll(argv[0]),
+                          dateparse(argv[0]),
                           argv[1],
                           "set-global",
                           argv[2],
@@ -564,7 +559,7 @@ static void cf_schedule_set_global(char **argv) {
 
 static void cf_schedule_unset_global(char **argv) {
   if(disorder_schedule_add(getclient(),
-                          atoll(argv[0]),
+                          dateparse(argv[0]),
                           argv[1],
                           "set-global",
                           argv[2],
@@ -726,6 +721,7 @@ int main(int argc, char **argv) {
   pcre_malloc = xmalloc;
   pcre_free = xfree;
   if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
+  if(!setlocale(LC_TIME, "")) fatal(errno, "error calling setlocale");
   while((n = getopt_long(argc, argv, "+hVc:dHlNu:p:", options, 0)) >= 0) {
     switch(n) {
     case 'h': help();
@@ -753,7 +749,7 @@ int main(int argc, char **argv) {
   optind = 1;                          /* for subsequent getopt calls */
   /* accumulate command args */
   while(n < argc) {
-    if((i = TABLE_FIND(commands, struct command, name, argv[n])) < 0)
+    if((i = TABLE_FIND(commands, name, argv[n])) < 0)
       fatal(0, "unknown command '%s'", argv[n]);
     if(n + commands[i].min >= argc)
       fatal(0, "missing arguments to '%s'", argv[n]);