From: Richard Kettlewell Date: Sun, 22 Feb 2009 14:09:22 +0000 (+0000) Subject: Merge Core Audio fixes X-Git-Tag: 5.0~187 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/e3002eb9f618d7498f21933a2e8552d42ffcc7fc?hp=f5fd9a6b25366f98a20468ca9bda64c4313db09e Merge Core Audio fixes --- diff --git a/lib/Makefile.am b/lib/Makefile.am index b270e82..9df1dfd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -55,10 +55,10 @@ libdisorder_a_SOURCES=charset.c charset.h \ ifreq.c ifreq.h \ inputline.c inputline.h \ kvp.c kvp.h \ - log.c log.h log-impl.h \ + log.c log.h \ logfd.c logfd.h \ macros.c macros-builtin.c macros.h \ - mem.c mem.h mem-impl.h \ + mem.c mem.h \ mime.h mime.c \ mixer.c mixer.h mixer-oss.c mixer-alsa.c \ printf.c printf.h \ diff --git a/lib/log-impl.h b/lib/log-impl.h deleted file mode 100644 index de47cf2..0000000 --- a/lib/log-impl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2007, 2008 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 - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -/** @file lib/log-impl.h @brief Errors and logging */ - -/** @brief Log an error and quit - * - * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process - * is aborted, so you can get a backtrace. - */ -void disorder_fatal(int errno_value, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_CRIT, errno_value, msg, ap); - va_end(ap); - if(getenv("DISORDER_FATAL_ABORT")) abort(); - exitfn(EXIT_FAILURE); -} - -/** @brief Log an error */ -void disorder_error(int errno_value, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_ERR, errno_value, msg, ap); - va_end(ap); -} - -/** @brief Log an informational message */ -void disorder_info(const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_INFO, 0, msg, ap); - va_end(ap); -} - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/lib/log.c b/lib/log.c index f885e88..3f57073 100644 --- a/lib/log.c +++ b/lib/log.c @@ -194,15 +194,41 @@ void elog(int pri, int errno_value, const char *fmt, va_list ap) { } } -#define disorder_fatal fatal -#define disorder_error error -#define disorder_info info +/** @brief Log an error and quit + * + * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process + * is aborted, so you can get a backtrace. + */ +void disorder_fatal(int errno_value, const char *msg, ...) { + va_list ap; + + va_start(ap, msg); + elog(LOG_CRIT, errno_value, msg, ap); + va_end(ap); + if(getenv("DISORDER_FATAL_ABORT")) abort(); + exitfn(EXIT_FAILURE); +} + +/** @brief Log an error */ +void disorder_error(int errno_value, const char *msg, ...) { + va_list ap; -/* shared implementation of vararg functions */ -#include "log-impl.h" + va_start(ap, msg); + elog(LOG_ERR, errno_value, msg, ap); + va_end(ap); +} + +/** @brief Log an informational message */ +void disorder_info(const char *msg, ...) { + va_list ap; + + va_start(ap, msg); + elog(LOG_INFO, 0, msg, ap); + va_end(ap); +} /** @brief Log a debug message */ -void debug(const char *msg, ...) { +void disorder_debug(const char *msg, ...) { va_list ap; va_start(ap, msg); diff --git a/lib/log.h b/lib/log.h index e7f6e43..4d91008 100644 --- a/lib/log.h +++ b/lib/log.h @@ -30,17 +30,29 @@ void set_progname(char **argv); void elog(int pri, int errno_value, const char *fmt, va_list ap); -void fatal(int errno_value, const char *msg, ...) attribute((noreturn)) +void disorder_fatal(int errno_value, const char *msg, ...) attribute((noreturn)) attribute((format (printf, 2, 3))); -void error(int errno_value, const char *msg, ...) +void disorder_error(int errno_value, const char *msg, ...) attribute((format (printf, 2, 3))); -void info(const char *msg, ...) +void disorder_info(const char *msg, ...) attribute((format (printf, 1, 2))); -void debug(const char *msg, ...) +void disorder_debug(const char *msg, ...) attribute((format (printf, 1, 2))); /* report a message of the given class. @errno_value@ if present an * non-zero is included. @fatal@ terminates the process. */ +/** @brief Backward-compatibility alias for disorder_fatal() */ +#define fatal disorder_fatal + +/** @brief Backward-compatibility alias for disorder_error() */ +#define error disorder_error + +/** @brief Backward-compatibility alias for disorder_info() */ +#define info disorder_info + +/** @brief Backward-compatibility alias for disorder_debug() */ +#define debug disorder_debug + extern int debugging; /* set when debugging enabled */ diff --git a/lib/mem-impl.h b/lib/mem-impl.h deleted file mode 100644 index b3a16bb..0000000 --- a/lib/mem-impl.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 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 - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -int disorder_asprintf(char **rp, const char *fmt, ...) { - va_list ap; - int n; - - va_start(ap, fmt); - n = byte_vasprintf(rp, fmt, ap); - va_end(ap); - return n; -} - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/server/api-client.c b/server/api-client.c deleted file mode 100644 index 9321770..0000000 --- a/server/api-client.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 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 - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "common.h" - -#include -#include -#include -#include - -#include "client.h" -#include "mem.h" -#include "log.h" -#include "configuration.h" -#include "disorder.h" -#include "api-client.h" - -static disorder_client *c; - -disorder_client *disorder_get_client(void) { - if(!c) - if(!(c = disorder_new(0))) exit(EXIT_FAILURE); - return c; -} - -int disorder_track_exists(const char *track) { - int result; - - return disorder_exists(c, track, &result) ? 0 : result; -} - -const char *disorder_track_get_data(const char *track, const char *key) { - char *value; - - if(disorder_get(c, track, key, &value)) return 0; - return value; -} - -int disorder_track_set_data(const char *track, - const char *key, - const char *value) { - if(value) - return disorder_set(c, track, key, value); - else - return disorder_unset(c, track, key); -} - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/server/api-client.h b/server/api-client.h deleted file mode 100644 index 99a9410..0000000 --- a/server/api-client.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 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 - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef API_CLIENT_H -#define API_CLIENT_H - -disorder_client *disorder_get_client(void); - -#endif /* API_CLIENT_H */ - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/server/api.c b/server/api.c index fe9686c..e973fbe 100644 --- a/server/api.c +++ b/server/api.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2007, 2008 Richard Kettlewell + * Copyright (C) 2004, 2007, 2008, 2009 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,10 +22,6 @@ */ #include "disorder-server.h" -/* shared implementation of vararg functions */ -#include "log-impl.h" -#include "mem-impl.h" - void *disorder_malloc(size_t n) { return xmalloc(n); } @@ -60,6 +56,16 @@ int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...) { return n; } +int disorder_asprintf(char **rp, const char *fmt, ...) { + va_list ap; + int n; + + va_start(ap, fmt); + n = byte_vasprintf(rp, fmt, ap); + va_end(ap); + return n; +} + /* Local Variables: c-basic-offset:2