From cca89d7ce589d10a226c6dfa212e36cbcad25fd2 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 17 Nov 2013 10:36:38 +0000 Subject: [PATCH] Cope with various header files being missing. Organization: Straylight/Edgeware From: Richard Kettlewell Not a complete sweep - only things that will work on Windows have been updated. --- clients/disorder.c | 30 ++++++++--- configure.ac | 3 +- lib/addr.c | 22 ++++++-- lib/addr.h | 6 ++- lib/authhash.c | 19 +++++-- lib/byte-order.h | 6 ++- lib/charset.c | 10 ++-- lib/client-common.c | 18 +++++-- lib/client-common.h | 6 ++- lib/client.c | 26 +++++++--- lib/common.h | 6 ++- lib/configuration.c | 43 ++++++++++++++-- lib/configuration.h | 13 ++++- lib/log.c | 21 ++++++-- lib/log.h | 7 ++- lib/speaker-protocol.h | 4 +- lib/strptime.c | 111 ++++++++++++++++++++++++++++++++++++++++- lib/syscalls.c | 14 ++++-- lib/syscalls.h | 4 +- 19 files changed, 310 insertions(+), 59 deletions(-) diff --git a/clients/disorder.c b/clients/disorder.c index 7966dbc..36af9f5 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -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 @@ -23,17 +23,29 @@ #include #include -#include -#include +#if HAVE_SYS_SOCKET_H +# include +#endif +#if HAVE_SYS_UN_H +# include +#endif #include #include #include #include -#include -#include +#if HAVE_UNISTD_H +# include +#endif +#if HAVE_PCRE_H +# include +#endif #include -#include -#include +#if HAVE_GCRYPT_H +# include +#endif +#if HAVE_LANGINFO_H +# include +#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) diff --git a/configure.ac b/configure.ac index 11085e0..f0f8a83 100644 --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/lib/addr.c b/lib/addr.c index 052466c..f23da74 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -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,10 +21,18 @@ #include "common.h" #include -#include -#include -#include -#include +#if HAVE_SYS_SOCKET_H +# include +#endif +#if HAVE_NETINET_IN_H +# include +#endif +#if HAVE_ARPA_INET_H +# include +#endif +#if HAVE_SYS_UN_H +# include +#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; } diff --git a/lib/addr.h b/lib/addr.h index 90c165e..6b3991f 100644 --- a/lib/addr.h +++ b/lib/addr.h @@ -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 +#if HAVE_NETDB_H +# include +#endif struct stringlist; diff --git a/lib/authhash.c b/lib/authhash.c index c06c233..78352da 100644 --- a/lib/authhash.c +++ b/lib/authhash.c @@ -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 @@ -20,7 +20,11 @@ #include "common.h" #include -#include +#if HAVE_GCRYPT_H +# include +#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; } diff --git a/lib/byte-order.h b/lib/byte-order.h index e80e51f..b89222f 100644 --- a/lib/byte-order.h +++ b/lib/byte-order.h @@ -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 +#if HAVE_CONFIG_H +# include +#endif #define ENDIAN_BIG 1 #define ENDIAN_LITTLE 2 diff --git a/lib/charset.c b/lib/charset.c index fdc6d61..feb4469 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -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 @@ -19,9 +19,13 @@ #include "common.h" -#include +#if HAVE_ICONV_H +# include +#endif #include -#include +#if HAVE_LANGINFO_H +# include +#endif #include "mem.h" #include "log.h" diff --git a/lib/client-common.c b/lib/client-common.c index f88008f..fb70817 100644 --- a/lib/client-common.c +++ b/lib/client-common.c @@ -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 @@ -21,11 +21,19 @@ #include "common.h" -#include -#include +#if HAVE_NETINET_IN_H +# include +#endif +#if HAVE_SYS_UN_H +# include +#endif #include -#include -#include +#if HAVE_NETDB_H +# include +#endif +#if HAVE_UNISTD_H +# include +#endif #include "log.h" #include "configuration.h" diff --git a/lib/client-common.h b/lib/client-common.h index 26db715..dd53a1d 100644 --- a/lib/client-common.h +++ b/lib/client-common.h @@ -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 -#include +#if HAVE_SYS_SOCKET_H +# include +#endif socklen_t find_server(struct config *c, struct sockaddr **sap, char **namep); diff --git a/lib/client.c b/lib/client.c index 09e5426..08d70e7 100644 --- a/lib/client.c +++ b/lib/client.c @@ -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 @@ -25,13 +25,25 @@ #include "common.h" #include -#include -#include -#include -#include +#if HAVE_SYS_SOCKET_H +# include +#endif +#if HAVE_NETINET_IN_H +# include +#endif +#if HAVE_SYS_UN_H +# include +#endif +#if HAVE_UNISTD_H +# include +#endif #include -#include -#include +#if HAVE_NETDB_H +# include +#endif +#if HAVE_PCRE_H +# include +#endif #include "log.h" #include "mem.h" diff --git a/lib/common.h b/lib/common.h index 2ca41a6..154338e 100644 --- a/lib/common.h +++ b/lib/common.h @@ -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 +#if HAVE_CONFIG_H +# include +#endif #if HAVE_INTTYPES_H # include diff --git a/lib/configuration.c b/lib/configuration.c index 71c6a1f..c2c9a9f 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -25,12 +25,20 @@ #include #include #include -#include +#if HAVE_UNISTD_H +# include +#endif #include #include -#include -#include -#include +#if HAVE_PWD_H +# include +#endif +#if HAVE_LANGINFO_H +# include +#endif +#if HAVE_PCRE_H +# include +#endif #include #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 = ""; 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 diff --git a/lib/configuration.h b/lib/configuration.h index 08304be..bb90242 100644 --- a/lib/configuration.h +++ b/lib/configuration.h @@ -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 +#if HAVE_PCRE_H +# include +#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; diff --git a/lib/log.c b/lib/log.c index 82ba377..988a845 100644 --- 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 @@ -37,8 +37,19 @@ #include "common.h" #include -#include -#include +#include +#if HAVE_SYSLOG_H +# include +#endif +#if HAVE_SYS_TIME_H +# include +#endif +#if HAVE_SYS_SOCKET_H +# include +#endif +#if HAVE_NETDB_H +# include +#endif #include #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) { diff --git a/lib/log.h b/lib/log.h index f1f55d2..bacccb3 100644 --- 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; diff --git a/lib/speaker-protocol.h b/lib/speaker-protocol.h index cd6a192..4a8d3aa 100644 --- a/lib/speaker-protocol.h +++ b/lib/speaker-protocol.h @@ -26,7 +26,9 @@ #define SPEAKER_PROTOCOL_H #include "byte-order.h" -#include +#if HAVE_NETINET_IN_H +# include +#endif /** @brief A message from the main server to the speaker, or vica versa */ struct speaker_message { diff --git a/lib/strptime.c b/lib/strptime.c index 46761b0..84a95e3 100644 --- a/lib/strptime.c +++ b/lib/strptime.c @@ -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 @@ -34,12 +34,119 @@ * some missing bits. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include -#include +#if HAVE_LANGINFO_H +# include +#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 */ diff --git a/lib/syscalls.c b/lib/syscalls.c index b894ca3..0fb0377 100644 --- a/lib/syscalls.c +++ b/lib/syscalls.c @@ -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 @@ -20,12 +20,18 @@ */ #include "common.h" -#include +#if HAVE_UNISTD_H +# include +#endif #include #include #include -#include -#include +#if HAVE_SYS_SOCKET_H +# include +#endif +#if HAVE_SYS_TIME_H +# include +#endif #include #include diff --git a/lib/syscalls.h b/lib/syscalls.h index af60335..ea6dbaf 100644 --- a/lib/syscalls.h +++ b/lib/syscalls.h @@ -27,7 +27,9 @@ struct sockaddr; struct sigaction; struct timezone; -#include +#if HAVE_SYS_SOCKET_H +# include +#endif #include pid_t xfork(void); -- [mdw]