chiark / gitweb /
Switch to GPL v3
[disorder] / clients / disorder.c
index f20dbbc663aab3fa67d5ba7cd5a96b2e60d3b528..b07ffa1f2b66edc655d1cf4413ce98b34a7bec71 100644 (file)
@@ -2,38 +2,31 @@
  * This file is part of DisOrder.
  * Copyright (C) 2004-2008 Richard Kettlewell
  *
- * This program is free software; you can redistribute it and/or modify
+ * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#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 +538,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 +547,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 +557,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 +719,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 +747,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]);