From: Andre Noll Date: Thu, 9 Jul 2009 14:14:19 +0000 (+0200) Subject: Merge commit 'meins/next' into next X-Git-Tag: v0.4.0~54 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=a37e903213215dd36b11bbde4ea98e1d4590a472;hp=e70a7e228472a5d00803ad6b2225dec877860a58 Merge commit 'meins/next' into next --- diff --git a/aac_afh.c b/aac_afh.c index 04461178..7de73706 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -10,6 +10,7 @@ /** \file aac_afh.c para_server's aac audio format handler */ +#include #include #include "para.h" diff --git a/aacdec_filter.c b/aacdec_filter.c index 1ceca1fc..59c49893 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -10,8 +10,9 @@ /** \file aacdec_filter.c paraslash's aac (m4a) decoder. */ -#include "para.h" +#include +#include "para.h" #include "list.h" #include "sched.h" #include "ggo.h" diff --git a/acl.c b/acl.c index ffcd1685..087ea0c8 100644 --- a/acl.c +++ b/acl.c @@ -6,6 +6,8 @@ /** \file acl.c Access control lists for paraslash senders. */ +#include + #include "para.h" #include "error.h" #include "string.h" diff --git a/afh.c b/afh.c index 894cd782..c0064493 100644 --- a/afh.c +++ b/afh.c @@ -6,6 +6,7 @@ /** \file afh.c Paraslash's standalone audio format handler tool. */ +#include #include #include diff --git a/afh_common.c b/afh_common.c index 74701460..bb04453f 100644 --- a/afh_common.c +++ b/afh_common.c @@ -10,6 +10,7 @@ #include /* gettimeofday */ #include #include +#include #include "para.h" #include "error.h" diff --git a/afs.c b/afs.c index b40fe8e0..8e3aa923 100644 --- a/afs.c +++ b/afs.c @@ -6,6 +6,7 @@ /** \file afs.c Paraslash's audio file selector. */ +#include #include #include #include diff --git a/aft.c b/aft.c index 6b74b0ae..220e019e 100644 --- a/aft.c +++ b/aft.c @@ -6,18 +6,18 @@ /** \file aft.c Audio file table functions. */ +#include #include /* readdir() */ #include - +#include +#include +#include #include + #include "para.h" #include "error.h" #include "crypt.h" #include "string.h" -#include -#include -#include - #include "afh.h" #include "afs.h" #include "net.h" diff --git a/alsa_write.c b/alsa_write.c index cf0f335b..3c7c03b4 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -12,6 +12,7 @@ * based on the vplay program by Michael Beck. */ +#include #include #include #include diff --git a/amp_filter.c b/amp_filter.c index a62344a1..63b1b9a6 100644 --- a/amp_filter.c +++ b/amp_filter.c @@ -6,6 +6,8 @@ /** \file amp_filter.c Paraslash's amplify filter. */ +#include + #include "para.h" #include "amp_filter.cmdline.h" #include "list.h" diff --git a/attribute.c b/attribute.c index 41a10058..b962661a 100644 --- a/attribute.c +++ b/attribute.c @@ -6,6 +6,7 @@ /** \file attribute.c Attribute handling functions. */ +#include #include #include diff --git a/audioc.c b/audioc.c index 5c081da5..81e5d1c5 100644 --- a/audioc.c +++ b/audioc.c @@ -6,6 +6,7 @@ /** \file audioc.c the client program used to connect to para_audiod */ +#include #include #include diff --git a/audiod.c b/audiod.c index 29a8aa30..32c83941 100644 --- a/audiod.c +++ b/audiod.c @@ -5,6 +5,7 @@ */ /** \file audiod.c the paraslash's audio daemon */ +#include #include #include #include diff --git a/audiod_command.c b/audiod_command.c index da5a2dc5..b3312940 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -6,6 +6,7 @@ /** \file audiod_command.c commands for para_audiod */ +#include #include #include @@ -17,7 +18,6 @@ #include "ggo.h" #include "filter.h" #include "grab_client.h" - #include "error.h" #include "audiod.h" #include "net.h" diff --git a/blob.c b/blob.c index 38e5cb54..6f10f0a2 100644 --- a/blob.c +++ b/blob.c @@ -6,6 +6,7 @@ /** \file blob.c Macros and functions for blob handling. */ +#include #include #include #include diff --git a/chunk_queue.c b/chunk_queue.c index fa317185..bb97c690 100644 --- a/chunk_queue.c +++ b/chunk_queue.c @@ -6,6 +6,8 @@ /** \file chunk_queue.c Queuing functions for paraslash senders. */ +#include + #include "para.h" #include "list.h" #include "afh.h" diff --git a/client.c b/client.c index fef6ba4a..b7c1644c 100644 --- a/client.c +++ b/client.c @@ -6,6 +6,7 @@ /** \file client.c the client program used to connect to para_server */ +#include #include #include "para.h" diff --git a/client_common.c b/client_common.c index dd951c15..eb053581 100644 --- a/client_common.c +++ b/client_common.c @@ -6,6 +6,7 @@ /** \file client_common.c Common functions of para_client and para_audiod. */ +#include #include #include #include diff --git a/close_on_fork.c b/close_on_fork.c index 378799c7..fb190646 100644 --- a/close_on_fork.c +++ b/close_on_fork.c @@ -5,6 +5,9 @@ */ /** \file close_on_fork.c Manage a list of fds that should be closed on fork. */ + +#include + #include "para.h" #include "list.h" #include "string.h" diff --git a/command.c b/command.c index a9eb03f1..8fdb839a 100644 --- a/command.c +++ b/command.c @@ -6,6 +6,7 @@ /** \file command.c Client authentication and server commands. */ +#include #include #include #include diff --git a/compress_filter.c b/compress_filter.c index 65bc8e51..2e263e87 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -10,6 +10,8 @@ * Uses ideas of AudioCompress, (C) 2002-2004 M. Hari Nezumi */ +#include + #include "para.h" #include "compress_filter.cmdline.h" #include "list.h" diff --git a/crypt.c b/crypt.c index a2642929..352c5b8d 100644 --- a/crypt.c +++ b/crypt.c @@ -6,6 +6,7 @@ /** \file crypt.c openssl-based RSA encryption/decryption routines */ +#include #include #include #include diff --git a/daemon.c b/daemon.c index cae63ea7..7f4aa6f5 100644 --- a/daemon.c +++ b/daemon.c @@ -5,12 +5,14 @@ */ /** \file daemon.c Some helpers for programs that detach from the console. */ -#include "para.h" -#include "daemon.h" + +#include #include #include /* getgrnam() */ #include +#include "para.h" +#include "daemon.h" #include "string.h" #include "color.h" diff --git a/dccp_recv.c b/dccp_recv.c index 93dea809..4d4ac86d 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -11,6 +11,7 @@ * (C) 2005 Ian McDonald */ +#include #include #include diff --git a/dccp_send.c b/dccp_send.c index 1e62d289..d2f81dd9 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -11,6 +11,7 @@ * (C) 2005 Ian McDonald */ +#include #include #include #include diff --git a/error.h b/error.h index f2e92c61..1cc40e7f 100644 --- a/error.h +++ b/error.h @@ -274,7 +274,8 @@ extern const char **para_errlist[]; PARA_ERROR(STRTOLL, "unknown strtoll error"), \ PARA_ERROR(ATOI_NO_DIGITS, "no digits found in string"), \ PARA_ERROR(ATOI_JUNK_AT_END, "further characters after number"), \ - PARA_ERROR(SIZE_PREFIX, "bad size prefix") \ + PARA_ERROR(SIZE_PREFIX, "bad size prefix"), \ + PARA_ERROR(REGEX, "regular expression error") \ #define EXEC_ERRORS \ diff --git a/exec.c b/exec.c index 7fc4ae06..b603809d 100644 --- a/exec.c +++ b/exec.c @@ -5,12 +5,15 @@ */ /** \file exec.c Helper functions for spawning new processes. */ + +#include #include + #include "para.h" #include "close_on_fork.h" #include "error.h" -#include "string.h" #include "fd.h" +#include "string.h" /** * Spawn a new process and redirect fd 0, 1, and 2. diff --git a/fade.c b/fade.c index 7f884473..0304f4c6 100644 --- a/fade.c +++ b/fade.c @@ -6,13 +6,9 @@ /** \file fade.c A volume fader and alarm clock for linux. */ +#include #include #include - -#include "fade.cmdline.h" -#include "para.h" -#include "fd.h" - #include #include #include /* EXIT_SUCCESS */ @@ -21,10 +17,13 @@ #include #include #include + +#include "fade.cmdline.h" +#include "para.h" +#include "fd.h" #include "string.h" #include "error.h" - INIT_FADE_ERRLISTS; struct fade_args_info conf; diff --git a/fd.c b/fd.c index 23b89b5d..3dc490cd 100644 --- a/fd.c +++ b/fd.c @@ -6,6 +6,7 @@ /** \file fd.c Helper functions for file descriptor handling. */ +#include #include #include #include @@ -15,6 +16,7 @@ #include "para.h" #include "error.h" #include "string.h" + /** * Write a buffer to a file descriptor, re-write on short writes. * diff --git a/fec.c b/fec.c index e4cdbaf3..d097b77d 100644 --- a/fec.c +++ b/fec.c @@ -33,6 +33,7 @@ * OF SUCH DAMAGE. */ +#include #include "para.h" #include "error.h" diff --git a/fecdec_filter.c b/fecdec_filter.c index a3cba9bb..7fe87437 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -6,6 +6,8 @@ /** \file fecdec_filter.c A filter fec-decodes an audio stream. */ +#include + #include #include "para.h" #include "error.h" diff --git a/file_write.c b/file_write.c index 1c534ae1..3286ea87 100644 --- a/file_write.c +++ b/file_write.c @@ -6,6 +6,7 @@ /** \file file_write.c simple output plugin for testing purposes */ +#include #include #include #include diff --git a/filter.c b/filter.c index b8a7c5c1..41136904 100644 --- a/filter.c +++ b/filter.c @@ -6,8 +6,9 @@ /** \file filter.c The stand-alone filter program. */ -#include "para.h" +#include +#include "para.h" #include "filter.cmdline.h" #include "list.h" #include "sched.h" diff --git a/filter_common.c b/filter_common.c index fbc5b66b..cfe08dd1 100644 --- a/filter_common.c +++ b/filter_common.c @@ -6,6 +6,7 @@ /** \file filter_common.c Common helper functions for filter input/output. */ +#include #include #include diff --git a/grab_client.c b/grab_client.c index df5b40a3..67db5057 100644 --- a/grab_client.c +++ b/grab_client.c @@ -11,6 +11,7 @@ * \sa filter_chain filter_chain_info filter. */ +#include #include #include diff --git a/gui.c b/gui.c index e734b10c..4866979a 100644 --- a/gui.c +++ b/gui.c @@ -6,14 +6,16 @@ /** \file gui.c Curses-based interface for paraslash. */ +#include #include #include #include +#include + #include "gui.cmdline.h" #include "para.h" #include "gui.h" #include "string.h" -#include #include "ringbuffer.h" #include "fd.h" #include "error.h" diff --git a/http_recv.c b/http_recv.c index 7f130341..f644233b 100644 --- a/http_recv.c +++ b/http_recv.c @@ -6,6 +6,7 @@ /** \file http_recv.c paraslash's http receiver */ +#include #include #include diff --git a/http_send.c b/http_send.c index feb1a842..3959cad4 100644 --- a/http_send.c +++ b/http_send.c @@ -6,6 +6,7 @@ /** \file http_send.c paraslash's http sender */ +#include #include #include #include diff --git a/mood.c b/mood.c index cb1534bc..f16d9c4c 100644 --- a/mood.c +++ b/mood.c @@ -6,8 +6,10 @@ /** \file mood.c Paraslash's mood handling functions. */ +#include #include #include + #include "para.h" #include "error.h" #include "string.h" @@ -63,11 +65,11 @@ typedef int mood_score_function(const char *path, const struct afs_info *afsi, * Some mood parsers pre-process the data given in the mood line to compute a * structure which depends of the particular mood_method and which is used * later in the mood_score_function of the mood_method. The mood_parser may - * store a pointer to its structure via the second argument. + * store a pointer to its structure via the void** pointer. * * \sa mood_open(), mood_cleanup_function, mood_score_function. */ -typedef int mood_parser(const char *, void **); +typedef int mood_parser(int, char **, void **); /** * Deallocate resources which were allocated by the mood_parser. @@ -165,11 +167,10 @@ static uint64_t int_sqrt(uint64_t x) return res; } -static int mm_no_attributes_set_parser(const char *arg, __a_unused void **ignored) +static int mm_no_attributes_set_parser(int argc, __a_unused char **argv, + __a_unused void **ignored) { - if (arg && *arg) - PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); - return 1; + return argc? -E_MOOD_SYNTAX : 1; } static int mm_no_attributes_set_score_function(__a_unused const char *path, @@ -198,11 +199,10 @@ static int mm_played_rarely_score_function(__a_unused const char *path, return -100; } -static int mm_played_rarely_parser(const char *arg, __a_unused void **ignored) +static int mm_played_rarely_parser(int argc, __a_unused char **argv, + __a_unused void **ignored) { - if (arg && *arg) - PARA_WARNING_LOG("ignored junk at eol: %s\n", arg); - return 1; + return argc? -E_MOOD_SYNTAX : 1; } static int mm_path_matches_score_function(const char *path, @@ -215,9 +215,11 @@ static int mm_path_matches_score_function(const char *path, return 100; } -static int mm_path_matches_parser(const char *arg, void **data) +static int mm_path_matches_parser(int argc, char **argv, void **data) { - *data = para_strdup(arg); + if (argc != 1) + return -E_MOOD_SYNTAX; + *data = para_strdup(argv[1]); return 1; } @@ -226,16 +228,20 @@ static void mm_path_matches_cleanup(void *data) free(data); } -static int mm_is_set_parser(const char *arg, void **bitnum) +static int mm_is_set_parser(int argc, char **argv, void **bitnum) { - unsigned char *c = para_malloc(1); - int ret = get_attribute_bitnum_by_name(arg, c); + int ret; + unsigned char c, *res; - if (ret >= 0) - *bitnum = c; - else - free(c); - return ret; + if (argc != 1) + return -E_MOOD_SYNTAX; + ret = get_attribute_bitnum_by_name(argv[1], &c); + if (ret < 0) + return ret; + res = para_malloc(1); + *res = c; + *bitnum = res; + return 1; } static int mm_is_set_score_function(__a_unused const char *path, @@ -476,8 +482,8 @@ check_for_if: ret = -E_MOOD_SYNTAX; if (!mood_methods[i].parser) goto out; - w++; - ret = mood_methods[i].parser(*w, &mi->parser_data); + ret = mood_methods[i].parser(num_words - 1 - (w - argv), w, + &mi->parser_data); if (ret < 0) goto out; mi->method = &mood_methods[i]; diff --git a/mp3_afh.c b/mp3_afh.c index ff133ca5..5eacf63b 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -16,7 +16,9 @@ * Johannes Overmann */ +#include #include + #include "para.h" #include "error.h" #include "afh.h" diff --git a/mp3dec_filter.c b/mp3dec_filter.c index 92da4a5c..aceee9ae 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -6,6 +6,9 @@ /** \file mp3dec_filter.c Paraslash's mp3 decoder. */ +#include +#include + #include "para.h" #include "mp3dec_filter.cmdline.h" #include "list.h" @@ -13,7 +16,6 @@ #include "ggo.h" #include "filter.h" #include "error.h" -#include #include "string.h" /** Convert a sample value from libmad to a signed short. */ diff --git a/net.c b/net.c index b3588f6d..61f50dd7 100644 --- a/net.c +++ b/net.c @@ -88,7 +88,8 @@ static bool is_v4_dot_quad(const char *address) bool result; regex_t r; - assert(!regcomp(&r, "^([0-9]+\\.){3}[0-9]+$", REG_EXTENDED|REG_NOSUB)); + assert(para_regcomp(&r, "^([0-9]+\\.){3}[0-9]+$", + REG_EXTENDED | REG_NOSUB) >= 0); result = regexec(&r, address, 0, NULL, 0) == 0; regfree(&r); return result; diff --git a/ogg_afh.c b/ogg_afh.c index f0c1e435..65573cfc 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -5,6 +5,7 @@ */ /** \file ogg_afh.c para_server's ogg vorbis audio format handler */ +#include #include #include #include diff --git a/oggdec_filter.c b/oggdec_filter.c index b158a5e1..02f04b48 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -6,8 +6,10 @@ /** \file oggdec_filter.c Paraslash's ogg vorbis decoder. */ -#include "para.h" +#include +#include +#include "para.h" #include "oggdec_filter.cmdline.h" #include "list.h" #include "sched.h" @@ -16,8 +18,6 @@ #include "error.h" #include "string.h" -#include - /** Determine byte sex. */ #ifdef WORDS_BIGENDIAN #define ENDIAN 1 diff --git a/oss_write.c b/oss_write.c index 552d5b97..103b14ea 100644 --- a/oss_write.c +++ b/oss_write.c @@ -6,6 +6,7 @@ /** \file oss_write.c Paraslash's oss output plugin. */ +#include #include #include #include diff --git a/playlist.c b/playlist.c index d1e16f8e..852ffd7a 100644 --- a/playlist.c +++ b/playlist.c @@ -4,7 +4,9 @@ * Licensed under the GPL v2. For licencing details see COPYING. */ +#include #include + #include "para.h" #include "error.h" #include "string.h" diff --git a/prebuffer_filter.c b/prebuffer_filter.c index 1ad5f446..f23e4e57 100644 --- a/prebuffer_filter.c +++ b/prebuffer_filter.c @@ -6,6 +6,8 @@ /** \file prebuffer_filter.c Paraslash's prebuffering filter. */ +#include + #include "para.h" #include "prebuffer_filter.cmdline.h" #include "list.h" diff --git a/recv.c b/recv.c index 5de9c6be..42fd335f 100644 --- a/recv.c +++ b/recv.c @@ -6,6 +6,7 @@ /** \file recv.c the stand-alone audio stream receiver */ +#include #include #include diff --git a/recv_common.c b/recv_common.c index c2ca29db..a5689390 100644 --- a/recv_common.c +++ b/recv_common.c @@ -6,8 +6,9 @@ /** \file recv_common.c common functions of para_recv and para_audiod */ -#include "para.h" +#include +#include "para.h" #include "list.h" #include "sched.h" #include "ggo.h" diff --git a/ringbuffer.c b/ringbuffer.c index b27fd8e8..eee2ca10 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -6,6 +6,8 @@ /** \file ringbuffer.c Simple ringbuffer implementation */ +#include + #include "para.h" #include "ringbuffer.h" #include "string.h" diff --git a/sched.c b/sched.c index 6f3f1faf..44e66c9b 100644 --- a/sched.c +++ b/sched.c @@ -6,6 +6,7 @@ /** \file sched.c Paraslash's scheduling functions. */ +#include #include /* readdir() */ #include #include diff --git a/score.c b/score.c index 3557b042..bc40668f 100644 --- a/score.c +++ b/score.c @@ -5,7 +5,9 @@ */ /** \file score.c Scoring functions to determine the audio file streaming order. */ +#include #include + #include "para.h" #include "error.h" #include "string.h" diff --git a/send_common.c b/send_common.c index a1757a51..388fde03 100644 --- a/send_common.c +++ b/send_common.c @@ -6,8 +6,10 @@ /** \file send_common.c Functions used by more than one paraslash sender. */ +#include #include #include + #include "para.h" #include "error.h" #include "string.h" diff --git a/server.c b/server.c index 24556263..be97516f 100644 --- a/server.c +++ b/server.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include "para.h" diff --git a/stat.c b/stat.c index 1062da36..03d00d77 100644 --- a/stat.c +++ b/stat.c @@ -9,7 +9,7 @@ * and para_audiod. */ - +#include #include #include diff --git a/stdin.c b/stdin.c index fea30dd9..8eb86dee 100644 --- a/stdin.c +++ b/stdin.c @@ -9,9 +9,7 @@ #include /* readdir() */ #include - #include "para.h" -#include "string.h" #include "list.h" #include "sched.h" #include "fd.h" diff --git a/stdout.c b/stdout.c index e178fe0e..d64586bc 100644 --- a/stdout.c +++ b/stdout.c @@ -10,7 +10,6 @@ #include #include "para.h" -#include "string.h" #include "list.h" #include "sched.h" #include "fd.h" diff --git a/string.c b/string.c index 5479e5b4..bb631201 100644 --- a/string.c +++ b/string.c @@ -6,14 +6,14 @@ /** \file string.c Memory allocation and string handling functions. */ -#include "para.h" -#include "string.h" - #include /* gettimeofday */ #include #include /* uname() */ #include +#include +#include "para.h" +#include "string.h" #include "error.h" /** @@ -735,3 +735,19 @@ err: free(argv); return ret; } + +int para_regcomp(regex_t *preg, const char *regex, int cflags) +{ + char *buf; + size_t size; + int ret = regcomp(preg, regex, cflags); + + if (ret == 0) + return 1; + size = regerror(ret, preg, NULL, 0); + buf = para_malloc(size); + regerror(ret, preg, buf, size); + PARA_ERROR_LOG("%s\n", buf); + free(buf); + return -E_REGEX; +} diff --git a/string.h b/string.h index b3b960ab..922ba696 100644 --- a/string.h +++ b/string.h @@ -81,3 +81,4 @@ int get_loglevel_by_name(const char *txt); int read_size_header(const char *buf); int create_argv(const char *buf, const char *delim, char ***result); void free_argv(char **argv); +int para_regcomp(regex_t *preg, const char *regex, int cflags); diff --git a/udp_recv.c b/udp_recv.c index ad8d51fe..7bbd4b0c 100644 --- a/udp_recv.c +++ b/udp_recv.c @@ -5,6 +5,7 @@ */ /** \file udp_recv.c Paraslash's udp receiver */ +#include #include #include #include diff --git a/udp_send.c b/udp_send.c index 499af66e..f8cce2b9 100644 --- a/udp_send.c +++ b/udp_send.c @@ -7,6 +7,7 @@ /** \file udp_send.c Para_server's udp sender. */ +#include #include #include #include diff --git a/user_list.c b/user_list.c index 1d3f21cf..3c0b4f85 100644 --- a/user_list.c +++ b/user_list.c @@ -6,6 +6,7 @@ /** \file user_list.c User handling for para_server. */ +#include #include #include #include diff --git a/vss.c b/vss.c index 57e531ea..21f4cb4d 100644 --- a/vss.c +++ b/vss.c @@ -11,6 +11,7 @@ * senders. */ +#include #include #include diff --git a/wav_filter.c b/wav_filter.c index 1c0da181..3c69311f 100644 --- a/wav_filter.c +++ b/wav_filter.c @@ -6,9 +6,10 @@ /** \file wav_filter.c A filter that inserts a wave header. */ +#include + #include "para.h" #include "error.h" - #include "list.h" #include "sched.h" #include "ggo.h" diff --git a/write.c b/write.c index c12736a6..34cea48c 100644 --- a/write.c +++ b/write.c @@ -6,6 +6,7 @@ /** \file write.c Paraslash's standalone wav/raw player. */ +#include #include #include diff --git a/write_common.c b/write_common.c index 476df8f0..5eb6b796 100644 --- a/write_common.c +++ b/write_common.c @@ -6,6 +6,8 @@ /** \file write_common.c common functions of para_audiod and para_write */ +#include + #include "para.h" #include "string.h" #include "list.h"