chiark / gitweb /
Cope with various header files being missing.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:36:38 +0000 (10:36 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:36:38 +0000 (10:36 +0000)
Not a complete sweep - only things that will work on Windows have been
updated.

19 files changed:
clients/disorder.c
configure.ac
lib/addr.c
lib/addr.h
lib/authhash.c
lib/byte-order.h
lib/charset.c
lib/client-common.c
lib/client-common.h
lib/client.c
lib/common.h
lib/configuration.c
lib/configuration.h
lib/log.c
lib/log.h
lib/speaker-protocol.h
lib/strptime.c
lib/syscalls.c
lib/syscalls.h

index 7966dbc7eda6a18fd2073397e7d391b01026c8bf..36af9f5eed5cbf44c019e7962a74ad6cbc5203bf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004-2012 Richard Kettlewell
+ * Copyright (C) 2004-2013 Richard Kettlewell
  *
  * 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
 
 #include <getopt.h>
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
 #include <errno.h>
 #include <locale.h>
 #include <time.h>
 #include <stddef.h>
-#include <unistd.h>
-#include <pcre.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#if HAVE_PCRE_H
+# include <pcre.h>
+#endif
 #include <ctype.h>
-#include <gcrypt.h>
-#include <langinfo.h>
+#if HAVE_GCRYPT_H
+# include <gcrypt.h>
+#endif
+#if HAVE_LANGINFO_H
+# include <langinfo.h>
+#endif
 
 #include "configuration.h"
 #include "syscalls.h"
@@ -849,9 +861,11 @@ int main(int argc, char **argv) {
   const char *user = 0, *password = 0;
 
   mem_init();
+#if HAVE_PCRE_H
   /* garbage-collect PCRE's memory */
   pcre_malloc = xmalloc;
   pcre_free = xfree;
+#endif
   if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale");
   if(!setlocale(LC_TIME, "")) disorder_fatal(errno, "error calling setlocale");
   while((n = getopt_long(argc, argv, "+hVc:dHlNu:p:", options, 0)) >= 0) {
@@ -882,11 +896,13 @@ int main(int argc, char **argv) {
     config->connect.af = -1;
   n = optind;
   optind = 1;                          /* for subsequent getopt calls */
+#if HAVE_GCRYPT_H
   /* gcrypt initialization */
   if(!gcry_check_version(NULL))
     disorder_fatal(0, "gcry_check_version failed");
   gcry_control(GCRYCTL_INIT_SECMEM, 0);
   gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+#endif
   /* accumulate command args */
   while(n < argc) {
     if((i = TABLE_FIND(commands, name, argv[n])) < 0)
index 11085e0e9bbef47523947b3b4f3c74294ed8ebca..f0f8a83b98e97e1e04ea299362b767e7786f7381 100644 (file)
@@ -526,7 +526,8 @@ fi
 if test $want_coreaudio = yes; then
   AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
 fi
-AC_CHECK_HEADERS([inttypes.h])
+AC_CHECK_HEADERS([inttypes.h sys/time.h sys/socket.h netinet/in.h \
+                  arpa/inet.h sys/un.h netdb.h pcre.h pwd.h langinfo.h])
 # We don't bother checking very standard stuff
 # Compilation will fail if any of these headers are missing, so we
 # check for them here and fail early.
index 052466c649ff50ba866917f8b5565b2e89407088..f23da74b1646e07796de7beabe650a8937d09426 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2007, 2008, 2013 Richard Kettlewell
  *
  * 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
 #include "common.h"
 
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/un.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
 
 #include "log.h"
 #include "printf.h"
@@ -185,10 +193,12 @@ static inline char *format_sockaddr6(const struct sockaddr_in6 *sin6) {
   return r;
 }
 
+#if HAVE_SYS_UN_H
 /** @brief Format a UNIX socket address */
 static inline char *format_sockaddrun(const struct sockaddr_un *sun) {
   return xstrdup(sun->sun_path);
 }
+#endif
     
 /** @brief Construct a text description a sockaddr
  * @param sa Socket address
@@ -200,8 +210,10 @@ char *format_sockaddr(const struct sockaddr *sa) {
     return format_sockaddr4((const struct sockaddr_in *)sa);
   case AF_INET6:
     return format_sockaddr6((const struct sockaddr_in6 *)sa);
+#if HAVE_SYS_UN_H
   case AF_UNIX:
     return format_sockaddrun((const struct sockaddr_un *)sa);
+#endif
   default:
     return 0;
   }
index 90c165eadf242c46223db49a14ed8fa646d3f5e0..6b3991f123ae5ac42070ee9e2052550db62d8f13 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2007, 2008, 2013 Richard Kettlewell
  *
  * 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
@@ -21,7 +21,9 @@
 #ifndef ADDR_H
 #define ADDR_H
 
-#include <netdb.h>
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
 
 struct stringlist;
 
index c06c233ed26642833a92517ce9ae425a93ba758e..78352da3729dcd066ce2c957cad24bfaf3ffdde1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2004, 2006, 2007, 2009 Richard Kettlewell
+ * Copyright (C) 2004, 2006, 2007, 2009, 2013 Richard Kettlewell
  *
  * 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
 #include "common.h"
 
 #include <stddef.h>
-#include <gcrypt.h>
+#if HAVE_GCRYPT_H
+# include <gcrypt.h>
+#else
+# error No crypto API available
+#endif
 
 #include "hex.h"
 #include "log.h"
@@ -31,8 +35,11 @@ struct algorithm {
   /** @brief DisOrder algorithm name */
   const char *name;
 
+#if HAVE_GCRYPT_H
   /** @brief gcrypt algorithm ID */
   int id;
+#endif
+
 };
 
 /** @brief Algorithm lookup table
@@ -41,6 +48,7 @@ struct algorithm {
  * the disorder protocol.
  */
 static const struct algorithm algorithms[] = {
+#if HAVE_GCRYPT_H
   { "SHA1", GCRY_MD_SHA1 },
   { "sha1", GCRY_MD_SHA1 },
   { "SHA256", GCRY_MD_SHA256 },
@@ -49,6 +57,7 @@ static const struct algorithm algorithms[] = {
   { "sha384", GCRY_MD_SHA384 },
   { "SHA512", GCRY_MD_SHA512 },
   { "sha512", GCRY_MD_SHA512 },
+#endif
 };
 
 /** @brief Number of supported algorithms */
@@ -66,10 +75,12 @@ static const struct algorithm algorithms[] = {
  */
 char *authhash(const void *challenge, size_t nchallenge,
                const char *password, const char *algo) {
+#if HAVE_GCRYPT_H
   gcrypt_hash_handle h;
+  int id;
+#endif
   char *res;
   size_t n;
-  int id;
 
   assert(challenge != 0);
   assert(password != 0);
@@ -79,6 +90,7 @@ char *authhash(const void *challenge, size_t nchallenge,
       break;
   if(n >= NALGORITHMS)
     return NULL;
+#if HAVE_GCRYPT_H
   id = algorithms[n].id;
 #if HAVE_GCRY_ERROR_T
   {
@@ -96,6 +108,7 @@ char *authhash(const void *challenge, size_t nchallenge,
   gcry_md_write(h, challenge, nchallenge);
   res = hex(gcry_md_read(h, id), gcry_md_get_algo_dlen(id));
   gcry_md_close(h);
+#endif
   return res;
 }
 
index e80e51f1b56f1777fab8283eb753de6c19f5a1ee..b89222f5ba946370b35c3168abac243664db47bd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2009 Richard Kettlewell
+ * Copyright (C) 2009, 2013 Richard Kettlewell
  *
  * 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
@@ -22,7 +22,9 @@
 #ifndef BYTE_ORDER_H
 #define BYTE_ORDER_H
 
-#include <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 #define ENDIAN_BIG 1
 #define ENDIAN_LITTLE 2
index fdc6d619e25731755fcbeafa556b4819bbd0c88d..feb4469e5950d0c7de9837ee3fa49d80e22ecff2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
  *
  * 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
 
 #include "common.h"
 
-#include <iconv.h>
+#if HAVE_ICONV_H
+# include <iconv.h>
+#endif
 #include <errno.h>
-#include <langinfo.h>
+#if HAVE_LANGINFO_H
+# include <langinfo.h>
+#endif
 
 #include "mem.h"
 #include "log.h"
index f88008ffe2e4b8a11e693d281f670d65585f1457..fb708175190d851f0493ac55322dd3859bba2ded 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2004, 2005, 2006, 2007, 2009 Richard Kettlewell
+ * Copyright (C) 2004-7, 2009, 2011-13 Richard Kettlewell
  *
  * 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
 
 #include "common.h"
 
-#include <netinet/in.h>
-#include <sys/un.h>
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
 #include <errno.h>
-#include <netdb.h>
-#include <unistd.h>
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 
 #include "log.h"
 #include "configuration.h"
index 26db71564faf091e7011694698bc83570d7b11ad..dd53a1d655e3d982f46b8bb70cac93c39dca5bff 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2004-2007 Richard Kettlewell
+ * Copyright (C) 2004-8, 2011, 2013 Richard Kettlewell
  *
  * 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
@@ -23,7 +23,9 @@
 #define CLIENT_COMMON_H
 
 #include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
 
 socklen_t find_server(struct config *c, struct sockaddr **sap, char **namep);
 
index 09e542693b9e5fb7376106138d3f504c197eedf3..08d70e762c1c37a87c2bf2c54638f354e8da1342 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004-2010 Richard Kettlewell
+ * Copyright (C) 2004-13 Richard Kettlewell
  *
  * 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
 #include "common.h"
 
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/un.h>
-#include <unistd.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 #include <errno.h>
-#include <netdb.h>
-#include <pcre.h>
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
+#if HAVE_PCRE_H
+# include <pcre.h>
+#endif
 
 #include "log.h"
 #include "mem.h"
index 2ca41a69b88852f3572200e0ccea36a2acd20495..154338e85d1e561e2faebaec2256422ca2f513c3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
  *
  * 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
@@ -22,7 +22,9 @@
 #ifndef COMMON_H
 #define COMMON_H
 
-#include <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
index 71c6a1fa4b49160cda04b5d2785492a4fb125f4a..c2c9a9f69b4d7ed8a83ae5e2df6b2a04b22a4388 100644 (file)
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 #include <ctype.h>
 #include <stddef.h>
-#include <pwd.h>
-#include <langinfo.h>
-#include <pcre.h>
+#if HAVE_PWD_H
+# include <pwd.h>
+#endif
+#if HAVE_LANGINFO_H
+# include <langinfo.h>
+#endif
+#if HAVE_PCRE_H
+# include <pcre.h>
+#endif
 #include <signal.h>
 
 #include "rights.h"
@@ -44,7 +52,9 @@
 #include "charset.h"
 #include "defs.h"
 #include "printf.h"
-#include "regsub.h"
+#if HAVE_PCRE_H
+# include "regsub.h"
+#endif
 #include "signame.h"
 #include "authhash.h"
 #include "vector.h"
@@ -200,8 +210,13 @@ static int set_collections(const struct config_state *cs,
   /* Defaults */
   if(!module)
     module = "fs";
+#if HAVE_LANGINFO_H
   if(!encoding)
     encoding = nl_langinfo(CODESET);
+#else
+  if(!encoding)
+    encoding = "ascii";
+#endif
   cl = ADDRESS(cs->config, struct collectionlist);
   ++cl->n;
   cl->s = xrealloc(cl->s, cl->n * sizeof (struct collection));
@@ -395,6 +410,7 @@ static int set_sample_format(const struct config_state *cs,
                             nvec, vec);
 }
 
+#if HAVE_PCRE_H
 static int set_namepart(const struct config_state *cs,
                        const struct conf *whoami,
                        int nvec, char **vec) {
@@ -480,6 +496,7 @@ static int set_transform(const struct config_state *cs,
   ++tl->n;
   return 0;
 }
+#endif
 
 static int set_rights(const struct config_state *cs,
                      const struct conf *whoami,
@@ -561,6 +578,7 @@ static void free_collectionlist(struct config *c,
   xfree(cll->s);
 }
 
+#if HAVE_PCRE_H
 static void free_namepartlist(struct config *c,
                              const struct conf *whoami) {
   struct namepartlist *npl = ADDRESS(c, struct namepartlist);
@@ -593,6 +611,7 @@ static void free_transformlist(struct config *c,
   }
   xfree(tl->t);
 }
+#endif
 
 static void free_netaddress(struct config *c,
                            const struct conf *whoami) {
@@ -1033,7 +1052,9 @@ static const struct conf conf[] = {
   { C(mount_rescan),     &type_boolean,          validate_any },
   { C(multicast_loop),   &type_boolean,          validate_any },
   { C(multicast_ttl),    &type_integer,          validate_non_negative },
+#if HAVE_PCRE_H
   { C(namepart),         &type_namepart,         validate_any },
+#endif
   { C(new_bias),         &type_integer,          validate_positive },
   { C(new_bias_age),     &type_integer,          validate_positive },
   { C(new_max),          &type_integer,          validate_positive },
@@ -1069,7 +1090,9 @@ static const struct conf conf[] = {
   { C(stopword),         &type_string_accum,     validate_any },
   { C(templates),        &type_string_accum,     validate_isdir },
   { C(tracklength),      &type_stringlist_accum, validate_tracklength },
+#if HAVE_PCRE_H
   { C(transform),        &type_transform,        validate_any },
+#endif
   { C(url),              &type_string,           validate_url },
   { C(user),             &type_string,           validate_isauser },
   { C(username),         &type_string,           validate_any },
@@ -1391,9 +1414,12 @@ void config_free(struct config *c) {
 static void config_postdefaults(struct config *c,
                                int server) {
   struct config_state cs;
+#if HAVE_PCRE_H
   const struct conf *whoami;
   int n;
+#endif
 
+#if HAVE_PCRE_H
   static const char *namepart[][4] = {
     { "title",  "/([0-9]+ *[-:]? *)?([^/]+)\\.[a-zA-Z0-9]+$", "$2", "display" },
     { "title",  "/([^/]+)\\.[a-zA-Z0-9]+$",           "$1", "sort" },
@@ -1411,10 +1437,12 @@ static void config_postdefaults(struct config *c,
     { "dir",   "[[:punct:]]",                           "", "sort", "g", }
   };
 #define NTRANSFORM (int)(sizeof transform / sizeof *transform)
+#endif
 
   cs.path = "<internal>";
   cs.line = 0;
   cs.config = c;
+#if HAVE_PCRE_H
   if(!c->namepart.n) {
     whoami = find("namepart");
     for(n = 0; n < NNAMEPART; ++n)
@@ -1425,6 +1453,7 @@ static void config_postdefaults(struct config *c,
     for(n = 0; n < NTRANSFORM; ++n)
       set_transform(&cs, whoami, 5, (char **)transform[n]);
   }
+#endif
   if(!c->api) {
     if(c->speaker_command)
       c->api = xstrdup("command");
@@ -1533,10 +1562,12 @@ int config_read(int server,
       disorder_error(0, "'nice_server' cannot be changed without a restart");
       /* ...but we accept the new config anyway */
     }
+#if HAVE_PCRE_H
     if(namepartlist_compare(&c->namepart, &oldconfig->namepart)) {
       disorder_error(0, "'namepart' settings cannot be changed without a restart");
       failed = 1;
     }
+#endif
     if(stringlist_compare(&c->stopword, &oldconfig->stopword)) {
       disorder_error(0, "'stopword' settings cannot be changed without a restart");
       failed = 1;
@@ -1614,6 +1645,7 @@ static int stringlist_compare(const struct stringlist *a,
     return 0;
 }
 
+#if HAVE_PCRE_H
 /** @brief Order two namepart definitions
  * @param a First namepart definition
  * @param b Second namepart definition
@@ -1659,6 +1691,7 @@ static int namepartlist_compare(const struct namepartlist *a,
   else
     return 0;
 }
+#endif
 
 /** @brief Verify configuration table.
  * @return The number of problems found
index 08304bedbc7ff82cd4101734e5fa7917e0d52f55..bb9024212fefe2c39dfab67c4daea82573532f64 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004-2010 Richard Kettlewell
+ * Copyright (C) 2004-2011, 2013 Richard Kettlewell
  *
  * 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
@@ -22,7 +22,9 @@
 #ifndef CONFIGURATION_H
 #define CONFIGURATION_H
 
-#include <pcre.h>
+#if HAVE_PCRE_H
+# include <pcre.h>
+#endif
 
 #include "speaker-protocol.h"
 #include "rights.h"
@@ -68,6 +70,7 @@ struct collectionlist {
   struct collection *s;
 };
 
+#if HAVE_PCRE_H
 /** @brief A track name part */
 struct namepart {
   char *part;                          /* part */
@@ -98,6 +101,7 @@ struct transformlist {
   int n;
   struct transform *t;
 };
+#endif
 
 /** @brief System configuration */
 struct config {
@@ -214,14 +218,19 @@ struct config {
   /** @brief Minimum time between a track being played again */
   long replay_min;
   
+#if HAVE_PCRE_H
   struct namepartlist namepart;                /* transformations */
+#endif
 
   /** @brief Termination signal for subprocesses */
   int signal;
 
   /** @brief ALSA output device */
   const char *device;
+
+#if HAVE_PCRE_H
   struct transformlist transform;      /* path name transformations */
+#endif
 
   /** @brief Address to send audio data to */
   struct netaddress broadcast;
index 82ba3772066e4ca6bfd437b89cfd114c658e4278..988a8452bcd9ecaa3bae3737feb6de93eed99d32 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004-2008 Richard Kettlewell
+ * Copyright (C) 2004-9, 2013 Richard Kettlewell
  *
  * 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
 #include "common.h"
 
 #include <errno.h>
-#include <syslog.h>
-#include <sys/time.h>
+#include <sys/types.h>
+#if HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
 #include <time.h>
 
 #include "log.h"
@@ -156,6 +167,7 @@ static void logfp(int pri, const char *msg, void *user) {
   fputc('\n', fp);
 }
 
+#if HAVE_SYSLOG_H
 /** @brief Log to syslog */
 static void logsyslog(int pri, const char *msg,
                      void attribute((unused)) *user) {
@@ -164,12 +176,15 @@ static void logsyslog(int pri, const char *msg,
   else
     syslog(pri, "%s:%d: %s", debug_filename, debug_lineno, msg);
 }
+#endif
 
 /** @brief Log output that writes to @c stderr */
 struct log_output log_stderr = { logfp, 0 };
 
+#if HAVE_SYSLOG_H
 /** @brief Log output that sends to syslog */
 struct log_output log_syslog = { logsyslog, 0 };
+#endif
 
 /** @brief Format and log a message */
 static void vlogger(int pri, const char *fmt, va_list ap) {
index f1f55d2cce3dcb5c43dabcfe267ae93db0ff524b..bacccb386292909daf92b6f73832f728f2f0ac84 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007-9, 2013 Richard Kettlewell
  *
  * 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
@@ -50,7 +50,10 @@ extern void (*exitfn)(int) attribute((noreturn));
 extern const char *progname;
 /* program name */
 
-extern struct log_output log_stderr, log_syslog, *log_default;
+extern struct log_output log_stderr, *log_default;
+#if HAVE_SYSLOG_H
+extern struct log_output log_syslog;
+#endif
 /* some typical outputs */
 
 extern const char *debug_filename;
index cd6a192bed9098165176be6d17e28811fe94d218..4a8d3aa643c1ecbc6b9864173d4b3c35af5a7b85 100644 (file)
@@ -26,7 +26,9 @@
 #define SPEAKER_PROTOCOL_H
 
 #include "byte-order.h"
-#include <netinet/in.h>
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
 
 /** @brief A message from the main server to the speaker, or vica versa */
 struct speaker_message {
index 46761b065490d496138eb4a8af587bb60c4d91e3..84a95e37bc104bd92db9f549fbbd1128917f5be5 100644 (file)
@@ -1,6 +1,6 @@
 /* strptime.c - partial strptime() reimplementation
  *
- * Copyright (c) 2008, 2011 Richard Kettlewell.
+ * Copyright (c) 2008, 2011, 2013 Richard Kettlewell.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * some missing bits.
  */
 
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <ctype.h>
 #include <limits.h>
 #include <string.h>
-#include <langinfo.h>
+#if HAVE_LANGINFO_H
+# include <langinfo.h>
+#endif
 #include "strptime.h"
 
+#if !HAVE_LANGINFO_H
+/* Fake plastic langinfo.  Primarily for Windows.
+ * TODO WIN32 can we get these values out of the win32 api instead? */
+typedef enum {
+  DAY_1,
+  DAY_2,
+  DAY_3,
+  DAY_4,
+  DAY_5,
+  DAY_6,
+  DAY_7,
+  ABDAY_1,
+  ABDAY_2,
+  ABDAY_3,
+  ABDAY_4,
+  ABDAY_5,
+  ABDAY_6,
+  ABDAY_7,
+  MON_1,
+  MON_2,
+  MON_3,
+  MON_4,
+  MON_5,
+  MON_6,
+  MON_7,
+  MON_8,
+  MON_9,
+  MON_10,
+  MON_11,
+  MON_12,
+  ABMON_1,
+  ABMON_2,
+  ABMON_3,
+  ABMON_4,
+  ABMON_5,
+  ABMON_6,
+  ABMON_7,
+  ABMON_8,
+  ABMON_9,
+  ABMON_10,
+  ABMON_11,
+  ABMON_12,
+  D_FMT,
+  T_FMT,
+  D_T_FMT,
+  ERA_D_FMT,
+  ERA_T_FMT,
+  ERA_D_T_FMT,
+} nl_item;
+
+const char *nl_langinfo(nl_item item) {
+  switch(item) {
+  case DAY_1: return "Sunday";
+  case DAY_2: return "Monday";
+  case DAY_3: return "Tuesday";
+  case DAY_4: return "Wednesday";
+  case DAY_5: return "Thursday";
+  case DAY_6: return "Friday";
+  case DAY_7: return "Saturday";
+  case ABDAY_1: return "Sun";
+  case ABDAY_2: return "Mon";
+  case ABDAY_3: return "Tue";
+  case ABDAY_4: return "Wed";
+  case ABDAY_5: return "Thu";
+  case ABDAY_6: return "Fri";
+  case ABDAY_7: return "Sat";
+  case MON_1: return "January";
+  case MON_2: return "February";
+  case MON_3: return "March";
+  case MON_4: return "April";
+  case MON_5: return "May";
+  case MON_6: return "June";
+  case MON_7: return "July";
+  case MON_8: return "August";
+  case MON_9: return "September";
+  case MON_10: return "October";
+  case MON_11: return "November";
+  case MON_12: return "December";
+  case ABMON_1: return "Jan";
+  case ABMON_2: return "Feb";
+  case ABMON_3: return "Mar";
+  case ABMON_4: return "Apr";
+  case ABMON_5: return "May";
+  case ABMON_6: return "Jun";
+  case ABMON_7: return "Jul";
+  case ABMON_8: return "Aug";
+  case ABMON_9: return "Sep";
+  case ABMON_10: return "Oct";
+  case ABMON_11: return "Nov";
+  case ABMON_12: return "Dec";
+  case D_FMT: return "%d/%m/%y";
+  case T_FMT: return "%H:%M:%S";
+  case D_T_FMT: return "%a %d %b %Y %H:%M:%S %Z";
+  case ERA_D_FMT: return "";
+  case ERA_T_FMT: return "";
+  case ERA_D_T_FMT: return "";
+  default: return 0;
+  }
+}
+#endif
+
 /** @brief Lookup table entry for locale-specific strings */
 struct locale_item_match {
   /** @brief Locale key to try */
index b894ca39bfb80885917dc6bd903c9d47f9c1ae63..0fb03773ae7de1cd59057340d85bf3395c07c7a4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007-9, 2013 Richard Kettlewell
  *
  * 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
  */
 #include "common.h"
 
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
 #include <signal.h>
 #include <time.h>
 
index af60335d83796810b9ab3fd4a9c873b509bbdc17..ea6dbafb87cec0b60ba3ee0fde0215844c3e866e 100644 (file)
@@ -27,7 +27,9 @@ struct sockaddr;
 struct sigaction;
 struct timezone;
 
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
 #include <signal.h>
 
 pid_t xfork(void);